babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The dirty prepass flag value
  862. */
  863. static readonly MATERIAL_PrePassDirtyFlag: number;
  864. /**
  865. * The all dirty flag value
  866. */
  867. static readonly MATERIAL_AllDirtyFlag: number;
  868. /**
  869. * Returns the triangle fill mode
  870. */
  871. static readonly MATERIAL_TriangleFillMode: number;
  872. /**
  873. * Returns the wireframe mode
  874. */
  875. static readonly MATERIAL_WireFrameFillMode: number;
  876. /**
  877. * Returns the point fill mode
  878. */
  879. static readonly MATERIAL_PointFillMode: number;
  880. /**
  881. * Returns the point list draw mode
  882. */
  883. static readonly MATERIAL_PointListDrawMode: number;
  884. /**
  885. * Returns the line list draw mode
  886. */
  887. static readonly MATERIAL_LineListDrawMode: number;
  888. /**
  889. * Returns the line loop draw mode
  890. */
  891. static readonly MATERIAL_LineLoopDrawMode: number;
  892. /**
  893. * Returns the line strip draw mode
  894. */
  895. static readonly MATERIAL_LineStripDrawMode: number;
  896. /**
  897. * Returns the triangle strip draw mode
  898. */
  899. static readonly MATERIAL_TriangleStripDrawMode: number;
  900. /**
  901. * Returns the triangle fan draw mode
  902. */
  903. static readonly MATERIAL_TriangleFanDrawMode: number;
  904. /**
  905. * Stores the clock-wise side orientation
  906. */
  907. static readonly MATERIAL_ClockWiseSideOrientation: number;
  908. /**
  909. * Stores the counter clock-wise side orientation
  910. */
  911. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  912. /**
  913. * Nothing
  914. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  915. */
  916. static readonly ACTION_NothingTrigger: number;
  917. /**
  918. * On pick
  919. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  920. */
  921. static readonly ACTION_OnPickTrigger: number;
  922. /**
  923. * On left pick
  924. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  925. */
  926. static readonly ACTION_OnLeftPickTrigger: number;
  927. /**
  928. * On right pick
  929. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  930. */
  931. static readonly ACTION_OnRightPickTrigger: number;
  932. /**
  933. * On center pick
  934. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnCenterPickTrigger: number;
  937. /**
  938. * On pick down
  939. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickDownTrigger: number;
  942. /**
  943. * On double pick
  944. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnDoublePickTrigger: number;
  947. /**
  948. * On pick up
  949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPickUpTrigger: number;
  952. /**
  953. * On pick out.
  954. * This trigger will only be raised if you also declared a OnPickDown
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickOutTrigger: number;
  958. /**
  959. * On long press
  960. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  961. */
  962. static readonly ACTION_OnLongPressTrigger: number;
  963. /**
  964. * On pointer over
  965. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  966. */
  967. static readonly ACTION_OnPointerOverTrigger: number;
  968. /**
  969. * On pointer out
  970. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  971. */
  972. static readonly ACTION_OnPointerOutTrigger: number;
  973. /**
  974. * On every frame
  975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  976. */
  977. static readonly ACTION_OnEveryFrameTrigger: number;
  978. /**
  979. * On intersection enter
  980. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  981. */
  982. static readonly ACTION_OnIntersectionEnterTrigger: number;
  983. /**
  984. * On intersection exit
  985. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  986. */
  987. static readonly ACTION_OnIntersectionExitTrigger: number;
  988. /**
  989. * On key down
  990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  991. */
  992. static readonly ACTION_OnKeyDownTrigger: number;
  993. /**
  994. * On key up
  995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  996. */
  997. static readonly ACTION_OnKeyUpTrigger: number;
  998. /**
  999. * Billboard mode will only apply to Y axis
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1002. /**
  1003. * Billboard mode will apply to all axes
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1006. /**
  1007. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1008. */
  1009. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1010. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1011. * Test order :
  1012. * Is the bounding sphere outside the frustum ?
  1013. * If not, are the bounding box vertices outside the frustum ?
  1014. * It not, then the cullable object is in the frustum.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1017. /** Culling strategy : Bounding Sphere Only.
  1018. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1019. * It's also less accurate than the standard because some not visible objects can still be selected.
  1020. * Test : is the bounding sphere outside the frustum ?
  1021. * If not, then the cullable object is in the frustum.
  1022. */
  1023. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1024. /** Culling strategy : Optimistic Inclusion.
  1025. * This in an inclusion test first, then the standard exclusion test.
  1026. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1027. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1028. * Anyway, it's as accurate as the standard strategy.
  1029. * Test :
  1030. * Is the cullable object bounding sphere center in the frustum ?
  1031. * If not, apply the default culling strategy.
  1032. */
  1033. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1034. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1035. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1036. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1037. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1038. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1039. * Test :
  1040. * Is the cullable object bounding sphere center in the frustum ?
  1041. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1042. */
  1043. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1044. /**
  1045. * No logging while loading
  1046. */
  1047. static readonly SCENELOADER_NO_LOGGING: number;
  1048. /**
  1049. * Minimal logging while loading
  1050. */
  1051. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1052. /**
  1053. * Summary logging while loading
  1054. */
  1055. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1056. /**
  1057. * Detailled logging while loading
  1058. */
  1059. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1060. /**
  1061. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1062. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1063. */
  1064. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1065. /**
  1066. * Constant used to retrieve the position texture index in the textures array in the prepass
  1067. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1068. */
  1069. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1070. /**
  1071. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1072. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1073. */
  1074. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1075. /**
  1076. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1077. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1078. */
  1079. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1080. /**
  1081. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1082. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1083. */
  1084. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1085. /**
  1086. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1087. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1088. */
  1089. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1090. /**
  1091. * Constant used to retrieve albedo index in the textures array in the prepass
  1092. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1093. */
  1094. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1095. }
  1096. }
  1097. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1098. import { Nullable } from "babylonjs/types";
  1099. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. */
  1123. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1124. /**
  1125. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1126. * @param data contains the texture data
  1127. * @param texture defines the BabylonJS internal texture
  1128. * @param callback defines the method to call once ready to upload
  1129. */
  1130. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1131. }
  1132. }
  1133. declare module "babylonjs/Engines/IPipelineContext" {
  1134. /**
  1135. * Class used to store and describe the pipeline context associated with an effect
  1136. */
  1137. export interface IPipelineContext {
  1138. /**
  1139. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1140. */
  1141. isAsync: boolean;
  1142. /**
  1143. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1144. */
  1145. isReady: boolean;
  1146. /** @hidden */
  1147. _getVertexShaderCode(): string | null;
  1148. /** @hidden */
  1149. _getFragmentShaderCode(): string | null;
  1150. /** @hidden */
  1151. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1152. }
  1153. }
  1154. declare module "babylonjs/Meshes/dataBuffer" {
  1155. /**
  1156. * Class used to store gfx data (like WebGLBuffer)
  1157. */
  1158. export class DataBuffer {
  1159. /**
  1160. * Gets or sets the number of objects referencing this buffer
  1161. */
  1162. references: number;
  1163. /** Gets or sets the size of the underlying buffer */
  1164. capacity: number;
  1165. /**
  1166. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1167. */
  1168. is32Bits: boolean;
  1169. /**
  1170. * Gets the underlying buffer
  1171. */
  1172. get underlyingResource(): any;
  1173. }
  1174. }
  1175. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1176. /** @hidden */
  1177. export interface IShaderProcessor {
  1178. attributeProcessor?: (attribute: string) => string;
  1179. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1180. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1181. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1182. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1183. lineProcessor?: (line: string, isFragment: boolean) => string;
  1184. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1185. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1186. }
  1187. }
  1188. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1189. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1190. /** @hidden */
  1191. export interface ProcessingOptions {
  1192. defines: string[];
  1193. indexParameters: any;
  1194. isFragment: boolean;
  1195. shouldUseHighPrecisionShader: boolean;
  1196. supportsUniformBuffers: boolean;
  1197. shadersRepository: string;
  1198. includesShadersStore: {
  1199. [key: string]: string;
  1200. };
  1201. processor?: IShaderProcessor;
  1202. version: string;
  1203. platformName: string;
  1204. lookForClosingBracketForUniformBuffer?: boolean;
  1205. }
  1206. }
  1207. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1208. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1234. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1235. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1236. /** @hidden */
  1237. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1238. process(preprocessors: {
  1239. [key: string]: string;
  1240. }, options: ProcessingOptions): string;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1244. /** @hidden */
  1245. export class ShaderDefineExpression {
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. private static _OperatorPriority;
  1250. private static _Stack;
  1251. static postfixToInfix(postfix: string[]): string;
  1252. static infixToPostfix(infix: string): string[];
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1256. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1257. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1258. /** @hidden */
  1259. export class ShaderCodeTestNode extends ShaderCodeNode {
  1260. testExpression: ShaderDefineExpression;
  1261. isValid(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1270. define: string;
  1271. not: boolean;
  1272. constructor(define: string, not?: boolean);
  1273. isTrue(preprocessors: {
  1274. [key: string]: string;
  1275. }): boolean;
  1276. }
  1277. }
  1278. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1279. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1280. /** @hidden */
  1281. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1282. leftOperand: ShaderDefineExpression;
  1283. rightOperand: ShaderDefineExpression;
  1284. isTrue(preprocessors: {
  1285. [key: string]: string;
  1286. }): boolean;
  1287. }
  1288. }
  1289. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1290. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1291. /** @hidden */
  1292. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1293. leftOperand: ShaderDefineExpression;
  1294. rightOperand: ShaderDefineExpression;
  1295. isTrue(preprocessors: {
  1296. [key: string]: string;
  1297. }): boolean;
  1298. }
  1299. }
  1300. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1301. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1302. /** @hidden */
  1303. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1304. define: string;
  1305. operand: string;
  1306. testValue: string;
  1307. constructor(define: string, operand: string, testValue: string);
  1308. isTrue(preprocessors: {
  1309. [key: string]: string;
  1310. }): boolean;
  1311. }
  1312. }
  1313. declare module "babylonjs/Offline/IOfflineProvider" {
  1314. /**
  1315. * Class used to enable access to offline support
  1316. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1317. */
  1318. export interface IOfflineProvider {
  1319. /**
  1320. * Gets a boolean indicating if scene must be saved in the database
  1321. */
  1322. enableSceneOffline: boolean;
  1323. /**
  1324. * Gets a boolean indicating if textures must be saved in the database
  1325. */
  1326. enableTexturesOffline: boolean;
  1327. /**
  1328. * Open the offline support and make it available
  1329. * @param successCallback defines the callback to call on success
  1330. * @param errorCallback defines the callback to call on error
  1331. */
  1332. open(successCallback: () => void, errorCallback: () => void): void;
  1333. /**
  1334. * Loads an image from the offline support
  1335. * @param url defines the url to load from
  1336. * @param image defines the target DOM image
  1337. */
  1338. loadImage(url: string, image: HTMLImageElement): void;
  1339. /**
  1340. * Loads a file from offline support
  1341. * @param url defines the URL to load from
  1342. * @param sceneLoaded defines a callback to call on success
  1343. * @param progressCallBack defines a callback to call when progress changed
  1344. * @param errorCallback defines a callback to call on error
  1345. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1346. */
  1347. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1348. }
  1349. }
  1350. declare module "babylonjs/Misc/filesInputStore" {
  1351. /**
  1352. * Class used to help managing file picking and drag'n'drop
  1353. * File Storage
  1354. */
  1355. export class FilesInputStore {
  1356. /**
  1357. * List of files ready to be loaded
  1358. */
  1359. static FilesToLoad: {
  1360. [key: string]: File;
  1361. };
  1362. }
  1363. }
  1364. declare module "babylonjs/Misc/retryStrategy" {
  1365. import { WebRequest } from "babylonjs/Misc/webRequest";
  1366. /**
  1367. * Class used to define a retry strategy when error happens while loading assets
  1368. */
  1369. export class RetryStrategy {
  1370. /**
  1371. * Function used to defines an exponential back off strategy
  1372. * @param maxRetries defines the maximum number of retries (3 by default)
  1373. * @param baseInterval defines the interval between retries
  1374. * @returns the strategy function to use
  1375. */
  1376. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1377. }
  1378. }
  1379. declare module "babylonjs/Misc/baseError" {
  1380. /**
  1381. * @ignore
  1382. * Application error to support additional information when loading a file
  1383. */
  1384. export abstract class BaseError extends Error {
  1385. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1386. }
  1387. }
  1388. declare module "babylonjs/Misc/fileTools" {
  1389. import { WebRequest } from "babylonjs/Misc/webRequest";
  1390. import { Nullable } from "babylonjs/types";
  1391. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1392. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1393. import { BaseError } from "babylonjs/Misc/baseError";
  1394. /** @ignore */
  1395. export class LoadFileError extends BaseError {
  1396. request?: WebRequest;
  1397. file?: File;
  1398. /**
  1399. * Creates a new LoadFileError
  1400. * @param message defines the message of the error
  1401. * @param request defines the optional web request
  1402. * @param file defines the optional file
  1403. */
  1404. constructor(message: string, object?: WebRequest | File);
  1405. }
  1406. /** @ignore */
  1407. export class RequestFileError extends BaseError {
  1408. request: WebRequest;
  1409. /**
  1410. * Creates a new LoadFileError
  1411. * @param message defines the message of the error
  1412. * @param request defines the optional web request
  1413. */
  1414. constructor(message: string, request: WebRequest);
  1415. }
  1416. /** @ignore */
  1417. export class ReadFileError extends BaseError {
  1418. file: File;
  1419. /**
  1420. * Creates a new ReadFileError
  1421. * @param message defines the message of the error
  1422. * @param file defines the optional file
  1423. */
  1424. constructor(message: string, file: File);
  1425. }
  1426. /**
  1427. * @hidden
  1428. */
  1429. export class FileTools {
  1430. /**
  1431. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1432. */
  1433. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1434. /**
  1435. * Gets or sets the base URL to use to load assets
  1436. */
  1437. static BaseUrl: string;
  1438. /**
  1439. * Default behaviour for cors in the application.
  1440. * It can be a string if the expected behavior is identical in the entire app.
  1441. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1442. */
  1443. static CorsBehavior: string | ((url: string | string[]) => string);
  1444. /**
  1445. * Gets or sets a function used to pre-process url before using them to load assets
  1446. */
  1447. static PreprocessUrl: (url: string) => string;
  1448. /**
  1449. * Removes unwanted characters from an url
  1450. * @param url defines the url to clean
  1451. * @returns the cleaned url
  1452. */
  1453. private static _CleanUrl;
  1454. /**
  1455. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1456. * @param url define the url we are trying
  1457. * @param element define the dom element where to configure the cors policy
  1458. */
  1459. static SetCorsBehavior(url: string | string[], element: {
  1460. crossOrigin: string | null;
  1461. }): void;
  1462. /**
  1463. * Loads an image as an HTMLImageElement.
  1464. * @param input url string, ArrayBuffer, or Blob to load
  1465. * @param onLoad callback called when the image successfully loads
  1466. * @param onError callback called when the image fails to load
  1467. * @param offlineProvider offline provider for caching
  1468. * @param mimeType optional mime type
  1469. * @returns the HTMLImageElement of the loaded image
  1470. */
  1471. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1472. /**
  1473. * Reads a file from a File object
  1474. * @param file defines the file to load
  1475. * @param onSuccess defines the callback to call when data is loaded
  1476. * @param onProgress defines the callback to call during loading process
  1477. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1478. * @param onError defines the callback to call when an error occurs
  1479. * @returns a file request object
  1480. */
  1481. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1482. /**
  1483. * Loads a file from a url
  1484. * @param url url to load
  1485. * @param onSuccess callback called when the file successfully loads
  1486. * @param onProgress callback called while file is loading (if the server supports this mode)
  1487. * @param offlineProvider defines the offline provider for caching
  1488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1489. * @param onError callback called when the file fails to load
  1490. * @returns a file request object
  1491. */
  1492. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1493. /**
  1494. * Loads a file
  1495. * @param url url to load
  1496. * @param onSuccess callback called when the file successfully loads
  1497. * @param onProgress callback called while file is loading (if the server supports this mode)
  1498. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1499. * @param onError callback called when the file fails to load
  1500. * @param onOpened callback called when the web request is opened
  1501. * @returns a file request object
  1502. */
  1503. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1504. /**
  1505. * Checks if the loaded document was accessed via `file:`-Protocol.
  1506. * @returns boolean
  1507. */
  1508. static IsFileURL(): boolean;
  1509. }
  1510. }
  1511. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1512. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1513. import { WebRequest } from "babylonjs/Misc/webRequest";
  1514. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1515. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1516. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1517. /** @hidden */
  1518. export class ShaderProcessor {
  1519. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1520. private static _ProcessPrecision;
  1521. private static _ExtractOperation;
  1522. private static _BuildSubExpression;
  1523. private static _BuildExpression;
  1524. private static _MoveCursorWithinIf;
  1525. private static _MoveCursor;
  1526. private static _EvaluatePreProcessors;
  1527. private static _PreparePreProcessors;
  1528. private static _ProcessShaderConversion;
  1529. private static _ProcessIncludes;
  1530. /**
  1531. * Loads a file from a url
  1532. * @param url url to load
  1533. * @param onSuccess callback called when the file successfully loads
  1534. * @param onProgress callback called while file is loading (if the server supports this mode)
  1535. * @param offlineProvider defines the offline provider for caching
  1536. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1537. * @param onError callback called when the file fails to load
  1538. * @returns a file request object
  1539. * @hidden
  1540. */
  1541. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1542. }
  1543. }
  1544. declare module "babylonjs/Maths/math.like" {
  1545. import { float, int, DeepImmutable } from "babylonjs/types";
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IColor4Like {
  1550. r: float;
  1551. g: float;
  1552. b: float;
  1553. a: float;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IColor3Like {
  1559. r: float;
  1560. g: float;
  1561. b: float;
  1562. }
  1563. /**
  1564. * @hidden
  1565. */
  1566. export interface IVector4Like {
  1567. x: float;
  1568. y: float;
  1569. z: float;
  1570. w: float;
  1571. }
  1572. /**
  1573. * @hidden
  1574. */
  1575. export interface IVector3Like {
  1576. x: float;
  1577. y: float;
  1578. z: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IVector2Like {
  1584. x: float;
  1585. y: float;
  1586. }
  1587. /**
  1588. * @hidden
  1589. */
  1590. export interface IMatrixLike {
  1591. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1592. updateFlag: int;
  1593. }
  1594. /**
  1595. * @hidden
  1596. */
  1597. export interface IViewportLike {
  1598. x: float;
  1599. y: float;
  1600. width: float;
  1601. height: float;
  1602. }
  1603. /**
  1604. * @hidden
  1605. */
  1606. export interface IPlaneLike {
  1607. normal: IVector3Like;
  1608. d: float;
  1609. normalize(): void;
  1610. }
  1611. }
  1612. declare module "babylonjs/Materials/iEffectFallbacks" {
  1613. import { Effect } from "babylonjs/Materials/effect";
  1614. /**
  1615. * Interface used to define common properties for effect fallbacks
  1616. */
  1617. export interface IEffectFallbacks {
  1618. /**
  1619. * Removes the defines that should be removed when falling back.
  1620. * @param currentDefines defines the current define statements for the shader.
  1621. * @param effect defines the current effect we try to compile
  1622. * @returns The resulting defines with defines of the current rank removed.
  1623. */
  1624. reduce(currentDefines: string, effect: Effect): string;
  1625. /**
  1626. * Removes the fallback from the bound mesh.
  1627. */
  1628. unBindMesh(): void;
  1629. /**
  1630. * Checks to see if more fallbacks are still availible.
  1631. */
  1632. hasMoreFallbacks: boolean;
  1633. }
  1634. }
  1635. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1636. /**
  1637. * Class used to evalaute queries containing `and` and `or` operators
  1638. */
  1639. export class AndOrNotEvaluator {
  1640. /**
  1641. * Evaluate a query
  1642. * @param query defines the query to evaluate
  1643. * @param evaluateCallback defines the callback used to filter result
  1644. * @returns true if the query matches
  1645. */
  1646. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1647. private static _HandleParenthesisContent;
  1648. private static _SimplifyNegation;
  1649. }
  1650. }
  1651. declare module "babylonjs/Misc/tags" {
  1652. /**
  1653. * Class used to store custom tags
  1654. */
  1655. export class Tags {
  1656. /**
  1657. * Adds support for tags on the given object
  1658. * @param obj defines the object to use
  1659. */
  1660. static EnableFor(obj: any): void;
  1661. /**
  1662. * Removes tags support
  1663. * @param obj defines the object to use
  1664. */
  1665. static DisableFor(obj: any): void;
  1666. /**
  1667. * Gets a boolean indicating if the given object has tags
  1668. * @param obj defines the object to use
  1669. * @returns a boolean
  1670. */
  1671. static HasTags(obj: any): boolean;
  1672. /**
  1673. * Gets the tags available on a given object
  1674. * @param obj defines the object to use
  1675. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1676. * @returns the tags
  1677. */
  1678. static GetTags(obj: any, asString?: boolean): any;
  1679. /**
  1680. * Adds tags to an object
  1681. * @param obj defines the object to use
  1682. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1683. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1684. */
  1685. static AddTagsTo(obj: any, tagsString: string): void;
  1686. /**
  1687. * @hidden
  1688. */
  1689. static _AddTagTo(obj: any, tag: string): void;
  1690. /**
  1691. * Removes specific tags from a specific object
  1692. * @param obj defines the object to use
  1693. * @param tagsString defines the tags to remove
  1694. */
  1695. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1696. /**
  1697. * @hidden
  1698. */
  1699. static _RemoveTagFrom(obj: any, tag: string): void;
  1700. /**
  1701. * Defines if tags hosted on an object match a given query
  1702. * @param obj defines the object to use
  1703. * @param tagsQuery defines the tag query
  1704. * @returns a boolean
  1705. */
  1706. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1707. }
  1708. }
  1709. declare module "babylonjs/Maths/math.scalar" {
  1710. /**
  1711. * Scalar computation library
  1712. */
  1713. export class Scalar {
  1714. /**
  1715. * Two pi constants convenient for computation.
  1716. */
  1717. static TwoPi: number;
  1718. /**
  1719. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1720. * @param a number
  1721. * @param b number
  1722. * @param epsilon (default = 1.401298E-45)
  1723. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1724. */
  1725. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1726. /**
  1727. * Returns a string : the upper case translation of the number i to hexadecimal.
  1728. * @param i number
  1729. * @returns the upper case translation of the number i to hexadecimal.
  1730. */
  1731. static ToHex(i: number): string;
  1732. /**
  1733. * Returns -1 if value is negative and +1 is value is positive.
  1734. * @param value the value
  1735. * @returns the value itself if it's equal to zero.
  1736. */
  1737. static Sign(value: number): number;
  1738. /**
  1739. * Returns the value itself if it's between min and max.
  1740. * Returns min if the value is lower than min.
  1741. * Returns max if the value is greater than max.
  1742. * @param value the value to clmap
  1743. * @param min the min value to clamp to (default: 0)
  1744. * @param max the max value to clamp to (default: 1)
  1745. * @returns the clamped value
  1746. */
  1747. static Clamp(value: number, min?: number, max?: number): number;
  1748. /**
  1749. * the log2 of value.
  1750. * @param value the value to compute log2 of
  1751. * @returns the log2 of value.
  1752. */
  1753. static Log2(value: number): number;
  1754. /**
  1755. * Loops the value, so that it is never larger than length and never smaller than 0.
  1756. *
  1757. * This is similar to the modulo operator but it works with floating point numbers.
  1758. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1759. * With t = 5 and length = 2.5, the result would be 0.0.
  1760. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1761. * @param value the value
  1762. * @param length the length
  1763. * @returns the looped value
  1764. */
  1765. static Repeat(value: number, length: number): number;
  1766. /**
  1767. * Normalize the value between 0.0 and 1.0 using min and max values
  1768. * @param value value to normalize
  1769. * @param min max to normalize between
  1770. * @param max min to normalize between
  1771. * @returns the normalized value
  1772. */
  1773. static Normalize(value: number, min: number, max: number): number;
  1774. /**
  1775. * Denormalize the value from 0.0 and 1.0 using min and max values
  1776. * @param normalized value to denormalize
  1777. * @param min max to denormalize between
  1778. * @param max min to denormalize between
  1779. * @returns the denormalized value
  1780. */
  1781. static Denormalize(normalized: number, min: number, max: number): number;
  1782. /**
  1783. * Calculates the shortest difference between two given angles given in degrees.
  1784. * @param current current angle in degrees
  1785. * @param target target angle in degrees
  1786. * @returns the delta
  1787. */
  1788. static DeltaAngle(current: number, target: number): number;
  1789. /**
  1790. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1791. * @param tx value
  1792. * @param length length
  1793. * @returns The returned value will move back and forth between 0 and length
  1794. */
  1795. static PingPong(tx: number, length: number): number;
  1796. /**
  1797. * Interpolates between min and max with smoothing at the limits.
  1798. *
  1799. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1800. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1801. * @param from from
  1802. * @param to to
  1803. * @param tx value
  1804. * @returns the smooth stepped value
  1805. */
  1806. static SmoothStep(from: number, to: number, tx: number): number;
  1807. /**
  1808. * Moves a value current towards target.
  1809. *
  1810. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1811. * Negative values of maxDelta pushes the value away from target.
  1812. * @param current current value
  1813. * @param target target value
  1814. * @param maxDelta max distance to move
  1815. * @returns resulting value
  1816. */
  1817. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1818. /**
  1819. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1820. *
  1821. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1822. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1823. * @param current current value
  1824. * @param target target value
  1825. * @param maxDelta max distance to move
  1826. * @returns resulting angle
  1827. */
  1828. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1829. /**
  1830. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1831. * @param start start value
  1832. * @param end target value
  1833. * @param amount amount to lerp between
  1834. * @returns the lerped value
  1835. */
  1836. static Lerp(start: number, end: number, amount: number): number;
  1837. /**
  1838. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1839. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1840. * @param start start value
  1841. * @param end target value
  1842. * @param amount amount to lerp between
  1843. * @returns the lerped value
  1844. */
  1845. static LerpAngle(start: number, end: number, amount: number): number;
  1846. /**
  1847. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1848. * @param a start value
  1849. * @param b target value
  1850. * @param value value between a and b
  1851. * @returns the inverseLerp value
  1852. */
  1853. static InverseLerp(a: number, b: number, value: number): number;
  1854. /**
  1855. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1856. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1857. * @param value1 spline value
  1858. * @param tangent1 spline value
  1859. * @param value2 spline value
  1860. * @param tangent2 spline value
  1861. * @param amount input value
  1862. * @returns hermite result
  1863. */
  1864. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1865. /**
  1866. * Returns a random float number between and min and max values
  1867. * @param min min value of random
  1868. * @param max max value of random
  1869. * @returns random value
  1870. */
  1871. static RandomRange(min: number, max: number): number;
  1872. /**
  1873. * This function returns percentage of a number in a given range.
  1874. *
  1875. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1876. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1877. * @param number to convert to percentage
  1878. * @param min min range
  1879. * @param max max range
  1880. * @returns the percentage
  1881. */
  1882. static RangeToPercent(number: number, min: number, max: number): number;
  1883. /**
  1884. * This function returns number that corresponds to the percentage in a given range.
  1885. *
  1886. * PercentToRange(0.34,0,100) will return 34.
  1887. * @param percent to convert to number
  1888. * @param min min range
  1889. * @param max max range
  1890. * @returns the number
  1891. */
  1892. static PercentToRange(percent: number, min: number, max: number): number;
  1893. /**
  1894. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1895. * @param angle The angle to normalize in radian.
  1896. * @return The converted angle.
  1897. */
  1898. static NormalizeRadians(angle: number): number;
  1899. }
  1900. }
  1901. declare module "babylonjs/Maths/math.constants" {
  1902. /**
  1903. * Constant used to convert a value to gamma space
  1904. * @ignorenaming
  1905. */
  1906. export const ToGammaSpace: number;
  1907. /**
  1908. * Constant used to convert a value to linear space
  1909. * @ignorenaming
  1910. */
  1911. export const ToLinearSpace = 2.2;
  1912. /**
  1913. * Constant used to define the minimal number value in Babylon.js
  1914. * @ignorenaming
  1915. */
  1916. let Epsilon: number;
  1917. export { Epsilon };
  1918. }
  1919. declare module "babylonjs/Maths/math.viewport" {
  1920. /**
  1921. * Class used to represent a viewport on screen
  1922. */
  1923. export class Viewport {
  1924. /** viewport left coordinate */
  1925. x: number;
  1926. /** viewport top coordinate */
  1927. y: number;
  1928. /**viewport width */
  1929. width: number;
  1930. /** viewport height */
  1931. height: number;
  1932. /**
  1933. * Creates a Viewport object located at (x, y) and sized (width, height)
  1934. * @param x defines viewport left coordinate
  1935. * @param y defines viewport top coordinate
  1936. * @param width defines the viewport width
  1937. * @param height defines the viewport height
  1938. */
  1939. constructor(
  1940. /** viewport left coordinate */
  1941. x: number,
  1942. /** viewport top coordinate */
  1943. y: number,
  1944. /**viewport width */
  1945. width: number,
  1946. /** viewport height */
  1947. height: number);
  1948. /**
  1949. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1950. * @param renderWidth defines the rendering width
  1951. * @param renderHeight defines the rendering height
  1952. * @returns a new Viewport
  1953. */
  1954. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1955. /**
  1956. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1957. * @param renderWidth defines the rendering width
  1958. * @param renderHeight defines the rendering height
  1959. * @param ref defines the target viewport
  1960. * @returns the current viewport
  1961. */
  1962. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1963. /**
  1964. * Returns a new Viewport copied from the current one
  1965. * @returns a new Viewport
  1966. */
  1967. clone(): Viewport;
  1968. }
  1969. }
  1970. declare module "babylonjs/Misc/arrayTools" {
  1971. /**
  1972. * Class containing a set of static utilities functions for arrays.
  1973. */
  1974. export class ArrayTools {
  1975. /**
  1976. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1977. * @param size the number of element to construct and put in the array
  1978. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1979. * @returns a new array filled with new objects
  1980. */
  1981. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1982. }
  1983. }
  1984. declare module "babylonjs/Maths/math.plane" {
  1985. import { DeepImmutable } from "babylonjs/types";
  1986. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1987. /**
  1988. * Represents a plane by the equation ax + by + cz + d = 0
  1989. */
  1990. export class Plane {
  1991. private static _TmpMatrix;
  1992. /**
  1993. * Normal of the plane (a,b,c)
  1994. */
  1995. normal: Vector3;
  1996. /**
  1997. * d component of the plane
  1998. */
  1999. d: number;
  2000. /**
  2001. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2002. * @param a a component of the plane
  2003. * @param b b component of the plane
  2004. * @param c c component of the plane
  2005. * @param d d component of the plane
  2006. */
  2007. constructor(a: number, b: number, c: number, d: number);
  2008. /**
  2009. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2010. */
  2011. asArray(): number[];
  2012. /**
  2013. * @returns a new plane copied from the current Plane.
  2014. */
  2015. clone(): Plane;
  2016. /**
  2017. * @returns the string "Plane".
  2018. */
  2019. getClassName(): string;
  2020. /**
  2021. * @returns the Plane hash code.
  2022. */
  2023. getHashCode(): number;
  2024. /**
  2025. * Normalize the current Plane in place.
  2026. * @returns the updated Plane.
  2027. */
  2028. normalize(): Plane;
  2029. /**
  2030. * Applies a transformation the plane and returns the result
  2031. * @param transformation the transformation matrix to be applied to the plane
  2032. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2033. */
  2034. transform(transformation: DeepImmutable<Matrix>): Plane;
  2035. /**
  2036. * Compute the dot product between the point and the plane normal
  2037. * @param point point to calculate the dot product with
  2038. * @returns the dot product (float) of the point coordinates and the plane normal.
  2039. */
  2040. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2041. /**
  2042. * Updates the current Plane from the plane defined by the three given points.
  2043. * @param point1 one of the points used to contruct the plane
  2044. * @param point2 one of the points used to contruct the plane
  2045. * @param point3 one of the points used to contruct the plane
  2046. * @returns the updated Plane.
  2047. */
  2048. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2049. /**
  2050. * Checks if the plane is facing a given direction
  2051. * @param direction the direction to check if the plane is facing
  2052. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2053. * @returns True is the vector "direction" is the same side than the plane normal.
  2054. */
  2055. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2056. /**
  2057. * Calculates the distance to a point
  2058. * @param point point to calculate distance to
  2059. * @returns the signed distance (float) from the given point to the Plane.
  2060. */
  2061. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2062. /**
  2063. * Creates a plane from an array
  2064. * @param array the array to create a plane from
  2065. * @returns a new Plane from the given array.
  2066. */
  2067. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2068. /**
  2069. * Creates a plane from three points
  2070. * @param point1 point used to create the plane
  2071. * @param point2 point used to create the plane
  2072. * @param point3 point used to create the plane
  2073. * @returns a new Plane defined by the three given points.
  2074. */
  2075. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2076. /**
  2077. * Creates a plane from an origin point and a normal
  2078. * @param origin origin of the plane to be constructed
  2079. * @param normal normal of the plane to be constructed
  2080. * @returns a new Plane the normal vector to this plane at the given origin point.
  2081. * Note : the vector "normal" is updated because normalized.
  2082. */
  2083. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2084. /**
  2085. * Calculates the distance from a plane and a point
  2086. * @param origin origin of the plane to be constructed
  2087. * @param normal normal of the plane to be constructed
  2088. * @param point point to calculate distance to
  2089. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2090. */
  2091. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2092. }
  2093. }
  2094. declare module "babylonjs/Engines/performanceConfigurator" {
  2095. /** @hidden */
  2096. export class PerformanceConfigurator {
  2097. /** @hidden */
  2098. static MatrixUse64Bits: boolean;
  2099. /** @hidden */
  2100. static MatrixTrackPrecisionChange: boolean;
  2101. /** @hidden */
  2102. static MatrixCurrentType: any;
  2103. /** @hidden */
  2104. static MatrixTrackedMatrices: Array<any> | null;
  2105. /** @hidden */
  2106. static SetMatrixPrecision(use64bits: boolean): void;
  2107. }
  2108. }
  2109. declare module "babylonjs/Maths/math.vector" {
  2110. import { Viewport } from "babylonjs/Maths/math.viewport";
  2111. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2112. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2113. import { Plane } from "babylonjs/Maths/math.plane";
  2114. /**
  2115. * Class representing a vector containing 2 coordinates
  2116. */
  2117. export class Vector2 {
  2118. /** defines the first coordinate */
  2119. x: number;
  2120. /** defines the second coordinate */
  2121. y: number;
  2122. /**
  2123. * Creates a new Vector2 from the given x and y coordinates
  2124. * @param x defines the first coordinate
  2125. * @param y defines the second coordinate
  2126. */
  2127. constructor(
  2128. /** defines the first coordinate */
  2129. x?: number,
  2130. /** defines the second coordinate */
  2131. y?: number);
  2132. /**
  2133. * Gets a string with the Vector2 coordinates
  2134. * @returns a string with the Vector2 coordinates
  2135. */
  2136. toString(): string;
  2137. /**
  2138. * Gets class name
  2139. * @returns the string "Vector2"
  2140. */
  2141. getClassName(): string;
  2142. /**
  2143. * Gets current vector hash code
  2144. * @returns the Vector2 hash code as a number
  2145. */
  2146. getHashCode(): number;
  2147. /**
  2148. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2149. * @param array defines the source array
  2150. * @param index defines the offset in source array
  2151. * @returns the current Vector2
  2152. */
  2153. toArray(array: FloatArray, index?: number): Vector2;
  2154. /**
  2155. * Update the current vector from an array
  2156. * @param array defines the destination array
  2157. * @param index defines the offset in the destination array
  2158. * @returns the current Vector3
  2159. */
  2160. fromArray(array: FloatArray, index?: number): Vector2;
  2161. /**
  2162. * Copy the current vector to an array
  2163. * @returns a new array with 2 elements: the Vector2 coordinates.
  2164. */
  2165. asArray(): number[];
  2166. /**
  2167. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2168. * @param source defines the source Vector2
  2169. * @returns the current updated Vector2
  2170. */
  2171. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2172. /**
  2173. * Sets the Vector2 coordinates with the given floats
  2174. * @param x defines the first coordinate
  2175. * @param y defines the second coordinate
  2176. * @returns the current updated Vector2
  2177. */
  2178. copyFromFloats(x: number, y: number): Vector2;
  2179. /**
  2180. * Sets the Vector2 coordinates with the given floats
  2181. * @param x defines the first coordinate
  2182. * @param y defines the second coordinate
  2183. * @returns the current updated Vector2
  2184. */
  2185. set(x: number, y: number): Vector2;
  2186. /**
  2187. * Add another vector with the current one
  2188. * @param otherVector defines the other vector
  2189. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2190. */
  2191. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2192. /**
  2193. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2194. * @param otherVector defines the other vector
  2195. * @param result defines the target vector
  2196. * @returns the unmodified current Vector2
  2197. */
  2198. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2199. /**
  2200. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2201. * @param otherVector defines the other vector
  2202. * @returns the current updated Vector2
  2203. */
  2204. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2207. * @param otherVector defines the other vector
  2208. * @returns a new Vector2
  2209. */
  2210. addVector3(otherVector: Vector3): Vector2;
  2211. /**
  2212. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2213. * @param otherVector defines the other vector
  2214. * @returns a new Vector2
  2215. */
  2216. subtract(otherVector: Vector2): Vector2;
  2217. /**
  2218. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2219. * @param otherVector defines the other vector
  2220. * @param result defines the target vector
  2221. * @returns the unmodified current Vector2
  2222. */
  2223. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2224. /**
  2225. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2226. * @param otherVector defines the other vector
  2227. * @returns the current updated Vector2
  2228. */
  2229. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Multiplies in place the current Vector2 coordinates by the given ones
  2232. * @param otherVector defines the other vector
  2233. * @returns the current updated Vector2
  2234. */
  2235. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2236. /**
  2237. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2238. * @param otherVector defines the other vector
  2239. * @returns a new Vector2
  2240. */
  2241. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2242. /**
  2243. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2244. * @param otherVector defines the other vector
  2245. * @param result defines the target vector
  2246. * @returns the unmodified current Vector2
  2247. */
  2248. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2249. /**
  2250. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2251. * @param x defines the first coordinate
  2252. * @param y defines the second coordinate
  2253. * @returns a new Vector2
  2254. */
  2255. multiplyByFloats(x: number, y: number): Vector2;
  2256. /**
  2257. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2258. * @param otherVector defines the other vector
  2259. * @returns a new Vector2
  2260. */
  2261. divide(otherVector: Vector2): Vector2;
  2262. /**
  2263. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2264. * @param otherVector defines the other vector
  2265. * @param result defines the target vector
  2266. * @returns the unmodified current Vector2
  2267. */
  2268. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2269. /**
  2270. * Divides the current Vector2 coordinates by the given ones
  2271. * @param otherVector defines the other vector
  2272. * @returns the current updated Vector2
  2273. */
  2274. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2275. /**
  2276. * Gets a new Vector2 with current Vector2 negated coordinates
  2277. * @returns a new Vector2
  2278. */
  2279. negate(): Vector2;
  2280. /**
  2281. * Negate this vector in place
  2282. * @returns this
  2283. */
  2284. negateInPlace(): Vector2;
  2285. /**
  2286. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2287. * @param result defines the Vector3 object where to store the result
  2288. * @returns the current Vector2
  2289. */
  2290. negateToRef(result: Vector2): Vector2;
  2291. /**
  2292. * Multiply the Vector2 coordinates by scale
  2293. * @param scale defines the scaling factor
  2294. * @returns the current updated Vector2
  2295. */
  2296. scaleInPlace(scale: number): Vector2;
  2297. /**
  2298. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2299. * @param scale defines the scaling factor
  2300. * @returns a new Vector2
  2301. */
  2302. scale(scale: number): Vector2;
  2303. /**
  2304. * Scale the current Vector2 values by a factor to a given Vector2
  2305. * @param scale defines the scale factor
  2306. * @param result defines the Vector2 object where to store the result
  2307. * @returns the unmodified current Vector2
  2308. */
  2309. scaleToRef(scale: number, result: Vector2): Vector2;
  2310. /**
  2311. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2312. * @param scale defines the scale factor
  2313. * @param result defines the Vector2 object where to store the result
  2314. * @returns the unmodified current Vector2
  2315. */
  2316. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2317. /**
  2318. * Gets a boolean if two vectors are equals
  2319. * @param otherVector defines the other vector
  2320. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2321. */
  2322. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2323. /**
  2324. * Gets a boolean if two vectors are equals (using an epsilon value)
  2325. * @param otherVector defines the other vector
  2326. * @param epsilon defines the minimal distance to consider equality
  2327. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2328. */
  2329. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2330. /**
  2331. * Gets a new Vector2 from current Vector2 floored values
  2332. * @returns a new Vector2
  2333. */
  2334. floor(): Vector2;
  2335. /**
  2336. * Gets a new Vector2 from current Vector2 floored values
  2337. * @returns a new Vector2
  2338. */
  2339. fract(): Vector2;
  2340. /**
  2341. * Gets the length of the vector
  2342. * @returns the vector length (float)
  2343. */
  2344. length(): number;
  2345. /**
  2346. * Gets the vector squared length
  2347. * @returns the vector squared length (float)
  2348. */
  2349. lengthSquared(): number;
  2350. /**
  2351. * Normalize the vector
  2352. * @returns the current updated Vector2
  2353. */
  2354. normalize(): Vector2;
  2355. /**
  2356. * Gets a new Vector2 copied from the Vector2
  2357. * @returns a new Vector2
  2358. */
  2359. clone(): Vector2;
  2360. /**
  2361. * Gets a new Vector2(0, 0)
  2362. * @returns a new Vector2
  2363. */
  2364. static Zero(): Vector2;
  2365. /**
  2366. * Gets a new Vector2(1, 1)
  2367. * @returns a new Vector2
  2368. */
  2369. static One(): Vector2;
  2370. /**
  2371. * Gets a new Vector2 set from the given index element of the given array
  2372. * @param array defines the data source
  2373. * @param offset defines the offset in the data source
  2374. * @returns a new Vector2
  2375. */
  2376. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2377. /**
  2378. * Sets "result" from the given index element of the given array
  2379. * @param array defines the data source
  2380. * @param offset defines the offset in the data source
  2381. * @param result defines the target vector
  2382. */
  2383. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2384. /**
  2385. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2386. * @param value1 defines 1st point of control
  2387. * @param value2 defines 2nd point of control
  2388. * @param value3 defines 3rd point of control
  2389. * @param value4 defines 4th point of control
  2390. * @param amount defines the interpolation factor
  2391. * @returns a new Vector2
  2392. */
  2393. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2394. /**
  2395. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2396. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2397. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2398. * @param value defines the value to clamp
  2399. * @param min defines the lower limit
  2400. * @param max defines the upper limit
  2401. * @returns a new Vector2
  2402. */
  2403. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2404. /**
  2405. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2406. * @param value1 defines the 1st control point
  2407. * @param tangent1 defines the outgoing tangent
  2408. * @param value2 defines the 2nd control point
  2409. * @param tangent2 defines the incoming tangent
  2410. * @param amount defines the interpolation factor
  2411. * @returns a new Vector2
  2412. */
  2413. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2414. /**
  2415. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2416. * @param start defines the start vector
  2417. * @param end defines the end vector
  2418. * @param amount defines the interpolation factor
  2419. * @returns a new Vector2
  2420. */
  2421. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2422. /**
  2423. * Gets the dot product of the vector "left" and the vector "right"
  2424. * @param left defines first vector
  2425. * @param right defines second vector
  2426. * @returns the dot product (float)
  2427. */
  2428. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2429. /**
  2430. * Returns a new Vector2 equal to the normalized given vector
  2431. * @param vector defines the vector to normalize
  2432. * @returns a new Vector2
  2433. */
  2434. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2435. /**
  2436. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2437. * @param left defines 1st vector
  2438. * @param right defines 2nd vector
  2439. * @returns a new Vector2
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2442. /**
  2443. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2444. * @param left defines 1st vector
  2445. * @param right defines 2nd vector
  2446. * @returns a new Vector2
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2449. /**
  2450. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2451. * @param vector defines the vector to transform
  2452. * @param transformation defines the matrix to apply
  2453. * @returns a new Vector2
  2454. */
  2455. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2456. /**
  2457. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2458. * @param vector defines the vector to transform
  2459. * @param transformation defines the matrix to apply
  2460. * @param result defines the target vector
  2461. */
  2462. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2463. /**
  2464. * Determines if a given vector is included in a triangle
  2465. * @param p defines the vector to test
  2466. * @param p0 defines 1st triangle point
  2467. * @param p1 defines 2nd triangle point
  2468. * @param p2 defines 3rd triangle point
  2469. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2470. */
  2471. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2472. /**
  2473. * Gets the distance between the vectors "value1" and "value2"
  2474. * @param value1 defines first vector
  2475. * @param value2 defines second vector
  2476. * @returns the distance between vectors
  2477. */
  2478. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2479. /**
  2480. * Returns the squared distance between the vectors "value1" and "value2"
  2481. * @param value1 defines first vector
  2482. * @param value2 defines second vector
  2483. * @returns the squared distance between vectors
  2484. */
  2485. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2486. /**
  2487. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2488. * @param value1 defines first vector
  2489. * @param value2 defines second vector
  2490. * @returns a new Vector2
  2491. */
  2492. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2493. /**
  2494. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2495. * @param p defines the middle point
  2496. * @param segA defines one point of the segment
  2497. * @param segB defines the other point of the segment
  2498. * @returns the shortest distance
  2499. */
  2500. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2501. }
  2502. /**
  2503. * Class used to store (x,y,z) vector representation
  2504. * A Vector3 is the main object used in 3D geometry
  2505. * It can represent etiher the coordinates of a point the space, either a direction
  2506. * Reminder: js uses a left handed forward facing system
  2507. */
  2508. export class Vector3 {
  2509. private static _UpReadOnly;
  2510. private static _ZeroReadOnly;
  2511. /** @hidden */
  2512. _x: number;
  2513. /** @hidden */
  2514. _y: number;
  2515. /** @hidden */
  2516. _z: number;
  2517. /** @hidden */
  2518. _isDirty: boolean;
  2519. /** Gets or sets the x coordinate */
  2520. get x(): number;
  2521. set x(value: number);
  2522. /** Gets or sets the y coordinate */
  2523. get y(): number;
  2524. set y(value: number);
  2525. /** Gets or sets the z coordinate */
  2526. get z(): number;
  2527. set z(value: number);
  2528. /**
  2529. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2530. * @param x defines the first coordinates (on X axis)
  2531. * @param y defines the second coordinates (on Y axis)
  2532. * @param z defines the third coordinates (on Z axis)
  2533. */
  2534. constructor(x?: number, y?: number, z?: number);
  2535. /**
  2536. * Creates a string representation of the Vector3
  2537. * @returns a string with the Vector3 coordinates.
  2538. */
  2539. toString(): string;
  2540. /**
  2541. * Gets the class name
  2542. * @returns the string "Vector3"
  2543. */
  2544. getClassName(): string;
  2545. /**
  2546. * Creates the Vector3 hash code
  2547. * @returns a number which tends to be unique between Vector3 instances
  2548. */
  2549. getHashCode(): number;
  2550. /**
  2551. * Creates an array containing three elements : the coordinates of the Vector3
  2552. * @returns a new array of numbers
  2553. */
  2554. asArray(): number[];
  2555. /**
  2556. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2557. * @param array defines the destination array
  2558. * @param index defines the offset in the destination array
  2559. * @returns the current Vector3
  2560. */
  2561. toArray(array: FloatArray, index?: number): Vector3;
  2562. /**
  2563. * Update the current vector from an array
  2564. * @param array defines the destination array
  2565. * @param index defines the offset in the destination array
  2566. * @returns the current Vector3
  2567. */
  2568. fromArray(array: FloatArray, index?: number): Vector3;
  2569. /**
  2570. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2571. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2572. */
  2573. toQuaternion(): Quaternion;
  2574. /**
  2575. * Adds the given vector to the current Vector3
  2576. * @param otherVector defines the second operand
  2577. * @returns the current updated Vector3
  2578. */
  2579. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2580. /**
  2581. * Adds the given coordinates to the current Vector3
  2582. * @param x defines the x coordinate of the operand
  2583. * @param y defines the y coordinate of the operand
  2584. * @param z defines the z coordinate of the operand
  2585. * @returns the current updated Vector3
  2586. */
  2587. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2588. /**
  2589. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2590. * @param otherVector defines the second operand
  2591. * @returns the resulting Vector3
  2592. */
  2593. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2594. /**
  2595. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2596. * @param otherVector defines the second operand
  2597. * @param result defines the Vector3 object where to store the result
  2598. * @returns the current Vector3
  2599. */
  2600. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2601. /**
  2602. * Subtract the given vector from the current Vector3
  2603. * @param otherVector defines the second operand
  2604. * @returns the current updated Vector3
  2605. */
  2606. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2607. /**
  2608. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2609. * @param otherVector defines the second operand
  2610. * @returns the resulting Vector3
  2611. */
  2612. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2613. /**
  2614. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2615. * @param otherVector defines the second operand
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the current Vector3
  2618. */
  2619. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2620. /**
  2621. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2622. * @param x defines the x coordinate of the operand
  2623. * @param y defines the y coordinate of the operand
  2624. * @param z defines the z coordinate of the operand
  2625. * @returns the resulting Vector3
  2626. */
  2627. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2628. /**
  2629. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2630. * @param x defines the x coordinate of the operand
  2631. * @param y defines the y coordinate of the operand
  2632. * @param z defines the z coordinate of the operand
  2633. * @param result defines the Vector3 object where to store the result
  2634. * @returns the current Vector3
  2635. */
  2636. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2637. /**
  2638. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2639. * @returns a new Vector3
  2640. */
  2641. negate(): Vector3;
  2642. /**
  2643. * Negate this vector in place
  2644. * @returns this
  2645. */
  2646. negateInPlace(): Vector3;
  2647. /**
  2648. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2649. * @param result defines the Vector3 object where to store the result
  2650. * @returns the current Vector3
  2651. */
  2652. negateToRef(result: Vector3): Vector3;
  2653. /**
  2654. * Multiplies the Vector3 coordinates by the float "scale"
  2655. * @param scale defines the multiplier factor
  2656. * @returns the current updated Vector3
  2657. */
  2658. scaleInPlace(scale: number): Vector3;
  2659. /**
  2660. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2661. * @param scale defines the multiplier factor
  2662. * @returns a new Vector3
  2663. */
  2664. scale(scale: number): Vector3;
  2665. /**
  2666. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2667. * @param scale defines the multiplier factor
  2668. * @param result defines the Vector3 object where to store the result
  2669. * @returns the current Vector3
  2670. */
  2671. scaleToRef(scale: number, result: Vector3): Vector3;
  2672. /**
  2673. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2674. * @param scale defines the scale factor
  2675. * @param result defines the Vector3 object where to store the result
  2676. * @returns the unmodified current Vector3
  2677. */
  2678. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2679. /**
  2680. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2681. * @param origin defines the origin of the projection ray
  2682. * @param plane defines the plane to project to
  2683. * @returns the projected vector3
  2684. */
  2685. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2686. /**
  2687. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2688. * @param origin defines the origin of the projection ray
  2689. * @param plane defines the plane to project to
  2690. * @param result defines the Vector3 where to store the result
  2691. */
  2692. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2693. /**
  2694. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2695. * @param otherVector defines the second operand
  2696. * @returns true if both vectors are equals
  2697. */
  2698. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2699. /**
  2700. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2701. * @param otherVector defines the second operand
  2702. * @param epsilon defines the minimal distance to define values as equals
  2703. * @returns true if both vectors are distant less than epsilon
  2704. */
  2705. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2706. /**
  2707. * Returns true if the current Vector3 coordinates equals the given floats
  2708. * @param x defines the x coordinate of the operand
  2709. * @param y defines the y coordinate of the operand
  2710. * @param z defines the z coordinate of the operand
  2711. * @returns true if both vectors are equals
  2712. */
  2713. equalsToFloats(x: number, y: number, z: number): boolean;
  2714. /**
  2715. * Multiplies the current Vector3 coordinates by the given ones
  2716. * @param otherVector defines the second operand
  2717. * @returns the current updated Vector3
  2718. */
  2719. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2720. /**
  2721. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2722. * @param otherVector defines the second operand
  2723. * @returns the new Vector3
  2724. */
  2725. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2726. /**
  2727. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2728. * @param otherVector defines the second operand
  2729. * @param result defines the Vector3 object where to store the result
  2730. * @returns the current Vector3
  2731. */
  2732. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2733. /**
  2734. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2735. * @param x defines the x coordinate of the operand
  2736. * @param y defines the y coordinate of the operand
  2737. * @param z defines the z coordinate of the operand
  2738. * @returns the new Vector3
  2739. */
  2740. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2743. * @param otherVector defines the second operand
  2744. * @returns the new Vector3
  2745. */
  2746. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2747. /**
  2748. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2749. * @param otherVector defines the second operand
  2750. * @param result defines the Vector3 object where to store the result
  2751. * @returns the current Vector3
  2752. */
  2753. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2754. /**
  2755. * Divides the current Vector3 coordinates by the given ones.
  2756. * @param otherVector defines the second operand
  2757. * @returns the current updated Vector3
  2758. */
  2759. divideInPlace(otherVector: Vector3): Vector3;
  2760. /**
  2761. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2762. * @param other defines the second operand
  2763. * @returns the current updated Vector3
  2764. */
  2765. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2766. /**
  2767. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2768. * @param other defines the second operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2772. /**
  2773. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2774. * @param x defines the x coordinate of the operand
  2775. * @param y defines the y coordinate of the operand
  2776. * @param z defines the z coordinate of the operand
  2777. * @returns the current updated Vector3
  2778. */
  2779. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2780. /**
  2781. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2782. * @param x defines the x coordinate of the operand
  2783. * @param y defines the y coordinate of the operand
  2784. * @param z defines the z coordinate of the operand
  2785. * @returns the current updated Vector3
  2786. */
  2787. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2788. /**
  2789. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2790. * Check if is non uniform within a certain amount of decimal places to account for this
  2791. * @param epsilon the amount the values can differ
  2792. * @returns if the the vector is non uniform to a certain number of decimal places
  2793. */
  2794. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2795. /**
  2796. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2797. */
  2798. get isNonUniform(): boolean;
  2799. /**
  2800. * Gets a new Vector3 from current Vector3 floored values
  2801. * @returns a new Vector3
  2802. */
  2803. floor(): Vector3;
  2804. /**
  2805. * Gets a new Vector3 from current Vector3 floored values
  2806. * @returns a new Vector3
  2807. */
  2808. fract(): Vector3;
  2809. /**
  2810. * Gets the length of the Vector3
  2811. * @returns the length of the Vector3
  2812. */
  2813. length(): number;
  2814. /**
  2815. * Gets the squared length of the Vector3
  2816. * @returns squared length of the Vector3
  2817. */
  2818. lengthSquared(): number;
  2819. /**
  2820. * Normalize the current Vector3.
  2821. * Please note that this is an in place operation.
  2822. * @returns the current updated Vector3
  2823. */
  2824. normalize(): Vector3;
  2825. /**
  2826. * Reorders the x y z properties of the vector in place
  2827. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2828. * @returns the current updated vector
  2829. */
  2830. reorderInPlace(order: string): this;
  2831. /**
  2832. * Rotates the vector around 0,0,0 by a quaternion
  2833. * @param quaternion the rotation quaternion
  2834. * @param result vector to store the result
  2835. * @returns the resulting vector
  2836. */
  2837. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2838. /**
  2839. * Rotates a vector around a given point
  2840. * @param quaternion the rotation quaternion
  2841. * @param point the point to rotate around
  2842. * @param result vector to store the result
  2843. * @returns the resulting vector
  2844. */
  2845. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2846. /**
  2847. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2848. * The cross product is then orthogonal to both current and "other"
  2849. * @param other defines the right operand
  2850. * @returns the cross product
  2851. */
  2852. cross(other: Vector3): Vector3;
  2853. /**
  2854. * Normalize the current Vector3 with the given input length.
  2855. * Please note that this is an in place operation.
  2856. * @param len the length of the vector
  2857. * @returns the current updated Vector3
  2858. */
  2859. normalizeFromLength(len: number): Vector3;
  2860. /**
  2861. * Normalize the current Vector3 to a new vector
  2862. * @returns the new Vector3
  2863. */
  2864. normalizeToNew(): Vector3;
  2865. /**
  2866. * Normalize the current Vector3 to the reference
  2867. * @param reference define the Vector3 to update
  2868. * @returns the updated Vector3
  2869. */
  2870. normalizeToRef(reference: Vector3): Vector3;
  2871. /**
  2872. * Creates a new Vector3 copied from the current Vector3
  2873. * @returns the new Vector3
  2874. */
  2875. clone(): Vector3;
  2876. /**
  2877. * Copies the given vector coordinates to the current Vector3 ones
  2878. * @param source defines the source Vector3
  2879. * @returns the current updated Vector3
  2880. */
  2881. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2882. /**
  2883. * Copies the given floats to the current Vector3 coordinates
  2884. * @param x defines the x coordinate of the operand
  2885. * @param y defines the y coordinate of the operand
  2886. * @param z defines the z coordinate of the operand
  2887. * @returns the current updated Vector3
  2888. */
  2889. copyFromFloats(x: number, y: number, z: number): Vector3;
  2890. /**
  2891. * Copies the given floats to the current Vector3 coordinates
  2892. * @param x defines the x coordinate of the operand
  2893. * @param y defines the y coordinate of the operand
  2894. * @param z defines the z coordinate of the operand
  2895. * @returns the current updated Vector3
  2896. */
  2897. set(x: number, y: number, z: number): Vector3;
  2898. /**
  2899. * Copies the given float to the current Vector3 coordinates
  2900. * @param v defines the x, y and z coordinates of the operand
  2901. * @returns the current updated Vector3
  2902. */
  2903. setAll(v: number): Vector3;
  2904. /**
  2905. * Get the clip factor between two vectors
  2906. * @param vector0 defines the first operand
  2907. * @param vector1 defines the second operand
  2908. * @param axis defines the axis to use
  2909. * @param size defines the size along the axis
  2910. * @returns the clip factor
  2911. */
  2912. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2913. /**
  2914. * Get angle between two vectors
  2915. * @param vector0 angle between vector0 and vector1
  2916. * @param vector1 angle between vector0 and vector1
  2917. * @param normal direction of the normal
  2918. * @return the angle between vector0 and vector1
  2919. */
  2920. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2921. /**
  2922. * Returns a new Vector3 set from the index "offset" of the given array
  2923. * @param array defines the source array
  2924. * @param offset defines the offset in the source array
  2925. * @returns the new Vector3
  2926. */
  2927. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2930. * @param array defines the source array
  2931. * @param offset defines the offset in the source array
  2932. * @returns the new Vector3
  2933. * @deprecated Please use FromArray instead.
  2934. */
  2935. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2936. /**
  2937. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2938. * @param array defines the source array
  2939. * @param offset defines the offset in the source array
  2940. * @param result defines the Vector3 where to store the result
  2941. */
  2942. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2943. /**
  2944. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2945. * @param array defines the source array
  2946. * @param offset defines the offset in the source array
  2947. * @param result defines the Vector3 where to store the result
  2948. * @deprecated Please use FromArrayToRef instead.
  2949. */
  2950. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2951. /**
  2952. * Sets the given vector "result" with the given floats.
  2953. * @param x defines the x coordinate of the source
  2954. * @param y defines the y coordinate of the source
  2955. * @param z defines the z coordinate of the source
  2956. * @param result defines the Vector3 where to store the result
  2957. */
  2958. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2961. * @returns a new empty Vector3
  2962. */
  2963. static Zero(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2966. * @returns a new unit Vector3
  2967. */
  2968. static One(): Vector3;
  2969. /**
  2970. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2971. * @returns a new up Vector3
  2972. */
  2973. static Up(): Vector3;
  2974. /**
  2975. * Gets a up Vector3 that must not be updated
  2976. */
  2977. static get UpReadOnly(): DeepImmutable<Vector3>;
  2978. /**
  2979. * Gets a zero Vector3 that must not be updated
  2980. */
  2981. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2982. /**
  2983. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2984. * @returns a new down Vector3
  2985. */
  2986. static Down(): Vector3;
  2987. /**
  2988. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2989. * @param rightHandedSystem is the scene right-handed (negative z)
  2990. * @returns a new forward Vector3
  2991. */
  2992. static Forward(rightHandedSystem?: boolean): Vector3;
  2993. /**
  2994. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2995. * @param rightHandedSystem is the scene right-handed (negative-z)
  2996. * @returns a new forward Vector3
  2997. */
  2998. static Backward(rightHandedSystem?: boolean): Vector3;
  2999. /**
  3000. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3001. * @returns a new right Vector3
  3002. */
  3003. static Right(): Vector3;
  3004. /**
  3005. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3006. * @returns a new left Vector3
  3007. */
  3008. static Left(): Vector3;
  3009. /**
  3010. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3011. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3012. * @param vector defines the Vector3 to transform
  3013. * @param transformation defines the transformation matrix
  3014. * @returns the transformed Vector3
  3015. */
  3016. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3017. /**
  3018. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3019. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3020. * @param vector defines the Vector3 to transform
  3021. * @param transformation defines the transformation matrix
  3022. * @param result defines the Vector3 where to store the result
  3023. */
  3024. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3025. /**
  3026. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3027. * This method computes tranformed coordinates only, not transformed direction vectors
  3028. * @param x define the x coordinate of the source vector
  3029. * @param y define the y coordinate of the source vector
  3030. * @param z define the z coordinate of the source vector
  3031. * @param transformation defines the transformation matrix
  3032. * @param result defines the Vector3 where to store the result
  3033. */
  3034. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3035. /**
  3036. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3037. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3038. * @param vector defines the Vector3 to transform
  3039. * @param transformation defines the transformation matrix
  3040. * @returns the new Vector3
  3041. */
  3042. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3043. /**
  3044. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3045. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3046. * @param vector defines the Vector3 to transform
  3047. * @param transformation defines the transformation matrix
  3048. * @param result defines the Vector3 where to store the result
  3049. */
  3050. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3051. /**
  3052. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3053. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3054. * @param x define the x coordinate of the source vector
  3055. * @param y define the y coordinate of the source vector
  3056. * @param z define the z coordinate of the source vector
  3057. * @param transformation defines the transformation matrix
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3061. /**
  3062. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3063. * @param value1 defines the first control point
  3064. * @param value2 defines the second control point
  3065. * @param value3 defines the third control point
  3066. * @param value4 defines the fourth control point
  3067. * @param amount defines the amount on the spline to use
  3068. * @returns the new Vector3
  3069. */
  3070. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3071. /**
  3072. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3073. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3074. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3075. * @param value defines the current value
  3076. * @param min defines the lower range value
  3077. * @param max defines the upper range value
  3078. * @returns the new Vector3
  3079. */
  3080. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3081. /**
  3082. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3083. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3084. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3085. * @param value defines the current value
  3086. * @param min defines the lower range value
  3087. * @param max defines the upper range value
  3088. * @param result defines the Vector3 where to store the result
  3089. */
  3090. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3091. /**
  3092. * Checks if a given vector is inside a specific range
  3093. * @param v defines the vector to test
  3094. * @param min defines the minimum range
  3095. * @param max defines the maximum range
  3096. */
  3097. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3098. /**
  3099. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3100. * @param value1 defines the first control point
  3101. * @param tangent1 defines the first tangent vector
  3102. * @param value2 defines the second control point
  3103. * @param tangent2 defines the second tangent vector
  3104. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3105. * @returns the new Vector3
  3106. */
  3107. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3108. /**
  3109. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3110. * @param start defines the start value
  3111. * @param end defines the end value
  3112. * @param amount max defines amount between both (between 0 and 1)
  3113. * @returns the new Vector3
  3114. */
  3115. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3118. * @param start defines the start value
  3119. * @param end defines the end value
  3120. * @param amount max defines amount between both (between 0 and 1)
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3124. /**
  3125. * Returns the dot product (float) between the vectors "left" and "right"
  3126. * @param left defines the left operand
  3127. * @param right defines the right operand
  3128. * @returns the dot product
  3129. */
  3130. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3131. /**
  3132. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3133. * The cross product is then orthogonal to both "left" and "right"
  3134. * @param left defines the left operand
  3135. * @param right defines the right operand
  3136. * @returns the cross product
  3137. */
  3138. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3139. /**
  3140. * Sets the given vector "result" with the cross product of "left" and "right"
  3141. * The cross product is then orthogonal to both "left" and "right"
  3142. * @param left defines the left operand
  3143. * @param right defines the right operand
  3144. * @param result defines the Vector3 where to store the result
  3145. */
  3146. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3147. /**
  3148. * Returns a new Vector3 as the normalization of the given vector
  3149. * @param vector defines the Vector3 to normalize
  3150. * @returns the new Vector3
  3151. */
  3152. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3153. /**
  3154. * Sets the given vector "result" with the normalization of the given first vector
  3155. * @param vector defines the Vector3 to normalize
  3156. * @param result defines the Vector3 where to store the result
  3157. */
  3158. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3159. /**
  3160. * Project a Vector3 onto screen space
  3161. * @param vector defines the Vector3 to project
  3162. * @param world defines the world matrix to use
  3163. * @param transform defines the transform (view x projection) matrix to use
  3164. * @param viewport defines the screen viewport to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3168. /** @hidden */
  3169. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3170. /**
  3171. * Unproject from screen space to object space
  3172. * @param source defines the screen space Vector3 to use
  3173. * @param viewportWidth defines the current width of the viewport
  3174. * @param viewportHeight defines the current height of the viewport
  3175. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3176. * @param transform defines the transform (view x projection) matrix to use
  3177. * @returns the new Vector3
  3178. */
  3179. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3180. /**
  3181. * Unproject from screen space to object space
  3182. * @param source defines the screen space Vector3 to use
  3183. * @param viewportWidth defines the current width of the viewport
  3184. * @param viewportHeight defines the current height of the viewport
  3185. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3186. * @param view defines the view matrix to use
  3187. * @param projection defines the projection matrix to use
  3188. * @returns the new Vector3
  3189. */
  3190. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3191. /**
  3192. * Unproject from screen space to object space
  3193. * @param source defines the screen space Vector3 to use
  3194. * @param viewportWidth defines the current width of the viewport
  3195. * @param viewportHeight defines the current height of the viewport
  3196. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3197. * @param view defines the view matrix to use
  3198. * @param projection defines the projection matrix to use
  3199. * @param result defines the Vector3 where to store the result
  3200. */
  3201. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3202. /**
  3203. * Unproject from screen space to object space
  3204. * @param sourceX defines the screen space x coordinate to use
  3205. * @param sourceY defines the screen space y coordinate to use
  3206. * @param sourceZ defines the screen space z coordinate to use
  3207. * @param viewportWidth defines the current width of the viewport
  3208. * @param viewportHeight defines the current height of the viewport
  3209. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3210. * @param view defines the view matrix to use
  3211. * @param projection defines the projection matrix to use
  3212. * @param result defines the Vector3 where to store the result
  3213. */
  3214. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3215. /**
  3216. * Gets the minimal coordinate values between two Vector3
  3217. * @param left defines the first operand
  3218. * @param right defines the second operand
  3219. * @returns the new Vector3
  3220. */
  3221. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3222. /**
  3223. * Gets the maximal coordinate values between two Vector3
  3224. * @param left defines the first operand
  3225. * @param right defines the second operand
  3226. * @returns the new Vector3
  3227. */
  3228. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3229. /**
  3230. * Returns the distance between the vectors "value1" and "value2"
  3231. * @param value1 defines the first operand
  3232. * @param value2 defines the second operand
  3233. * @returns the distance
  3234. */
  3235. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3236. /**
  3237. * Returns the squared distance between the vectors "value1" and "value2"
  3238. * @param value1 defines the first operand
  3239. * @param value2 defines the second operand
  3240. * @returns the squared distance
  3241. */
  3242. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3243. /**
  3244. * Returns a new Vector3 located at the center between "value1" and "value2"
  3245. * @param value1 defines the first operand
  3246. * @param value2 defines the second operand
  3247. * @returns the new Vector3
  3248. */
  3249. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3250. /**
  3251. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3252. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3253. * to something in order to rotate it from its local system to the given target system
  3254. * Note: axis1, axis2 and axis3 are normalized during this operation
  3255. * @param axis1 defines the first axis
  3256. * @param axis2 defines the second axis
  3257. * @param axis3 defines the third axis
  3258. * @returns a new Vector3
  3259. */
  3260. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3261. /**
  3262. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3263. * @param axis1 defines the first axis
  3264. * @param axis2 defines the second axis
  3265. * @param axis3 defines the third axis
  3266. * @param ref defines the Vector3 where to store the result
  3267. */
  3268. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3269. }
  3270. /**
  3271. * Vector4 class created for EulerAngle class conversion to Quaternion
  3272. */
  3273. export class Vector4 {
  3274. /** x value of the vector */
  3275. x: number;
  3276. /** y value of the vector */
  3277. y: number;
  3278. /** z value of the vector */
  3279. z: number;
  3280. /** w value of the vector */
  3281. w: number;
  3282. /**
  3283. * Creates a Vector4 object from the given floats.
  3284. * @param x x value of the vector
  3285. * @param y y value of the vector
  3286. * @param z z value of the vector
  3287. * @param w w value of the vector
  3288. */
  3289. constructor(
  3290. /** x value of the vector */
  3291. x: number,
  3292. /** y value of the vector */
  3293. y: number,
  3294. /** z value of the vector */
  3295. z: number,
  3296. /** w value of the vector */
  3297. w: number);
  3298. /**
  3299. * Returns the string with the Vector4 coordinates.
  3300. * @returns a string containing all the vector values
  3301. */
  3302. toString(): string;
  3303. /**
  3304. * Returns the string "Vector4".
  3305. * @returns "Vector4"
  3306. */
  3307. getClassName(): string;
  3308. /**
  3309. * Returns the Vector4 hash code.
  3310. * @returns a unique hash code
  3311. */
  3312. getHashCode(): number;
  3313. /**
  3314. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3315. * @returns the resulting array
  3316. */
  3317. asArray(): number[];
  3318. /**
  3319. * Populates the given array from the given index with the Vector4 coordinates.
  3320. * @param array array to populate
  3321. * @param index index of the array to start at (default: 0)
  3322. * @returns the Vector4.
  3323. */
  3324. toArray(array: FloatArray, index?: number): Vector4;
  3325. /**
  3326. * Update the current vector from an array
  3327. * @param array defines the destination array
  3328. * @param index defines the offset in the destination array
  3329. * @returns the current Vector3
  3330. */
  3331. fromArray(array: FloatArray, index?: number): Vector4;
  3332. /**
  3333. * Adds the given vector to the current Vector4.
  3334. * @param otherVector the vector to add
  3335. * @returns the updated Vector4.
  3336. */
  3337. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3338. /**
  3339. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3340. * @param otherVector the vector to add
  3341. * @returns the resulting vector
  3342. */
  3343. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3344. /**
  3345. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3346. * @param otherVector the vector to add
  3347. * @param result the vector to store the result
  3348. * @returns the current Vector4.
  3349. */
  3350. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3351. /**
  3352. * Subtract in place the given vector from the current Vector4.
  3353. * @param otherVector the vector to subtract
  3354. * @returns the updated Vector4.
  3355. */
  3356. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3357. /**
  3358. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3359. * @param otherVector the vector to add
  3360. * @returns the new vector with the result
  3361. */
  3362. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3365. * @param otherVector the vector to subtract
  3366. * @param result the vector to store the result
  3367. * @returns the current Vector4.
  3368. */
  3369. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3372. */
  3373. /**
  3374. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3375. * @param x value to subtract
  3376. * @param y value to subtract
  3377. * @param z value to subtract
  3378. * @param w value to subtract
  3379. * @returns new vector containing the result
  3380. */
  3381. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3382. /**
  3383. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3384. * @param x value to subtract
  3385. * @param y value to subtract
  3386. * @param z value to subtract
  3387. * @param w value to subtract
  3388. * @param result the vector to store the result in
  3389. * @returns the current Vector4.
  3390. */
  3391. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3392. /**
  3393. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3394. * @returns a new vector with the negated values
  3395. */
  3396. negate(): Vector4;
  3397. /**
  3398. * Negate this vector in place
  3399. * @returns this
  3400. */
  3401. negateInPlace(): Vector4;
  3402. /**
  3403. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3404. * @param result defines the Vector3 object where to store the result
  3405. * @returns the current Vector4
  3406. */
  3407. negateToRef(result: Vector4): Vector4;
  3408. /**
  3409. * Multiplies the current Vector4 coordinates by scale (float).
  3410. * @param scale the number to scale with
  3411. * @returns the updated Vector4.
  3412. */
  3413. scaleInPlace(scale: number): Vector4;
  3414. /**
  3415. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3416. * @param scale the number to scale with
  3417. * @returns a new vector with the result
  3418. */
  3419. scale(scale: number): Vector4;
  3420. /**
  3421. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3422. * @param scale the number to scale with
  3423. * @param result a vector to store the result in
  3424. * @returns the current Vector4.
  3425. */
  3426. scaleToRef(scale: number, result: Vector4): Vector4;
  3427. /**
  3428. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3429. * @param scale defines the scale factor
  3430. * @param result defines the Vector4 object where to store the result
  3431. * @returns the unmodified current Vector4
  3432. */
  3433. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3434. /**
  3435. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3436. * @param otherVector the vector to compare against
  3437. * @returns true if they are equal
  3438. */
  3439. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3440. /**
  3441. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3442. * @param otherVector vector to compare against
  3443. * @param epsilon (Default: very small number)
  3444. * @returns true if they are equal
  3445. */
  3446. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3447. /**
  3448. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3449. * @param x x value to compare against
  3450. * @param y y value to compare against
  3451. * @param z z value to compare against
  3452. * @param w w value to compare against
  3453. * @returns true if equal
  3454. */
  3455. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3456. /**
  3457. * Multiplies in place the current Vector4 by the given one.
  3458. * @param otherVector vector to multiple with
  3459. * @returns the updated Vector4.
  3460. */
  3461. multiplyInPlace(otherVector: Vector4): Vector4;
  3462. /**
  3463. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3464. * @param otherVector vector to multiple with
  3465. * @returns resulting new vector
  3466. */
  3467. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3468. /**
  3469. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3470. * @param otherVector vector to multiple with
  3471. * @param result vector to store the result
  3472. * @returns the current Vector4.
  3473. */
  3474. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3475. /**
  3476. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3477. * @param x x value multiply with
  3478. * @param y y value multiply with
  3479. * @param z z value multiply with
  3480. * @param w w value multiply with
  3481. * @returns resulting new vector
  3482. */
  3483. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3484. /**
  3485. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3486. * @param otherVector vector to devide with
  3487. * @returns resulting new vector
  3488. */
  3489. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3490. /**
  3491. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3492. * @param otherVector vector to devide with
  3493. * @param result vector to store the result
  3494. * @returns the current Vector4.
  3495. */
  3496. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3497. /**
  3498. * Divides the current Vector3 coordinates by the given ones.
  3499. * @param otherVector vector to devide with
  3500. * @returns the updated Vector3.
  3501. */
  3502. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3503. /**
  3504. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3505. * @param other defines the second operand
  3506. * @returns the current updated Vector4
  3507. */
  3508. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3509. /**
  3510. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3511. * @param other defines the second operand
  3512. * @returns the current updated Vector4
  3513. */
  3514. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3515. /**
  3516. * Gets a new Vector4 from current Vector4 floored values
  3517. * @returns a new Vector4
  3518. */
  3519. floor(): Vector4;
  3520. /**
  3521. * Gets a new Vector4 from current Vector3 floored values
  3522. * @returns a new Vector4
  3523. */
  3524. fract(): Vector4;
  3525. /**
  3526. * Returns the Vector4 length (float).
  3527. * @returns the length
  3528. */
  3529. length(): number;
  3530. /**
  3531. * Returns the Vector4 squared length (float).
  3532. * @returns the length squared
  3533. */
  3534. lengthSquared(): number;
  3535. /**
  3536. * Normalizes in place the Vector4.
  3537. * @returns the updated Vector4.
  3538. */
  3539. normalize(): Vector4;
  3540. /**
  3541. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3542. * @returns this converted to a new vector3
  3543. */
  3544. toVector3(): Vector3;
  3545. /**
  3546. * Returns a new Vector4 copied from the current one.
  3547. * @returns the new cloned vector
  3548. */
  3549. clone(): Vector4;
  3550. /**
  3551. * Updates the current Vector4 with the given one coordinates.
  3552. * @param source the source vector to copy from
  3553. * @returns the updated Vector4.
  3554. */
  3555. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3556. /**
  3557. * Updates the current Vector4 coordinates with the given floats.
  3558. * @param x float to copy from
  3559. * @param y float to copy from
  3560. * @param z float to copy from
  3561. * @param w float to copy from
  3562. * @returns the updated Vector4.
  3563. */
  3564. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3565. /**
  3566. * Updates the current Vector4 coordinates with the given floats.
  3567. * @param x float to set from
  3568. * @param y float to set from
  3569. * @param z float to set from
  3570. * @param w float to set from
  3571. * @returns the updated Vector4.
  3572. */
  3573. set(x: number, y: number, z: number, w: number): Vector4;
  3574. /**
  3575. * Copies the given float to the current Vector3 coordinates
  3576. * @param v defines the x, y, z and w coordinates of the operand
  3577. * @returns the current updated Vector3
  3578. */
  3579. setAll(v: number): Vector4;
  3580. /**
  3581. * Returns a new Vector4 set from the starting index of the given array.
  3582. * @param array the array to pull values from
  3583. * @param offset the offset into the array to start at
  3584. * @returns the new vector
  3585. */
  3586. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3587. /**
  3588. * Updates the given vector "result" from the starting index of the given array.
  3589. * @param array the array to pull values from
  3590. * @param offset the offset into the array to start at
  3591. * @param result the vector to store the result in
  3592. */
  3593. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3594. /**
  3595. * Updates the given vector "result" from the starting index of the given Float32Array.
  3596. * @param array the array to pull values from
  3597. * @param offset the offset into the array to start at
  3598. * @param result the vector to store the result in
  3599. */
  3600. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3601. /**
  3602. * Updates the given vector "result" coordinates from the given floats.
  3603. * @param x float to set from
  3604. * @param y float to set from
  3605. * @param z float to set from
  3606. * @param w float to set from
  3607. * @param result the vector to the floats in
  3608. */
  3609. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3610. /**
  3611. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3612. * @returns the new vector
  3613. */
  3614. static Zero(): Vector4;
  3615. /**
  3616. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3617. * @returns the new vector
  3618. */
  3619. static One(): Vector4;
  3620. /**
  3621. * Returns a new normalized Vector4 from the given one.
  3622. * @param vector the vector to normalize
  3623. * @returns the vector
  3624. */
  3625. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3626. /**
  3627. * Updates the given vector "result" from the normalization of the given one.
  3628. * @param vector the vector to normalize
  3629. * @param result the vector to store the result in
  3630. */
  3631. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3632. /**
  3633. * Returns a vector with the minimum values from the left and right vectors
  3634. * @param left left vector to minimize
  3635. * @param right right vector to minimize
  3636. * @returns a new vector with the minimum of the left and right vector values
  3637. */
  3638. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3639. /**
  3640. * Returns a vector with the maximum values from the left and right vectors
  3641. * @param left left vector to maximize
  3642. * @param right right vector to maximize
  3643. * @returns a new vector with the maximum of the left and right vector values
  3644. */
  3645. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3646. /**
  3647. * Returns the distance (float) between the vectors "value1" and "value2".
  3648. * @param value1 value to calulate the distance between
  3649. * @param value2 value to calulate the distance between
  3650. * @return the distance between the two vectors
  3651. */
  3652. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3653. /**
  3654. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3655. * @param value1 value to calulate the distance between
  3656. * @param value2 value to calulate the distance between
  3657. * @return the distance between the two vectors squared
  3658. */
  3659. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3660. /**
  3661. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3662. * @param value1 value to calulate the center between
  3663. * @param value2 value to calulate the center between
  3664. * @return the center between the two vectors
  3665. */
  3666. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3667. /**
  3668. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3669. * This methods computes transformed normalized direction vectors only.
  3670. * @param vector the vector to transform
  3671. * @param transformation the transformation matrix to apply
  3672. * @returns the new vector
  3673. */
  3674. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3675. /**
  3676. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3677. * This methods computes transformed normalized direction vectors only.
  3678. * @param vector the vector to transform
  3679. * @param transformation the transformation matrix to apply
  3680. * @param result the vector to store the result in
  3681. */
  3682. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3683. /**
  3684. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3685. * This methods computes transformed normalized direction vectors only.
  3686. * @param x value to transform
  3687. * @param y value to transform
  3688. * @param z value to transform
  3689. * @param w value to transform
  3690. * @param transformation the transformation matrix to apply
  3691. * @param result the vector to store the results in
  3692. */
  3693. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3694. /**
  3695. * Creates a new Vector4 from a Vector3
  3696. * @param source defines the source data
  3697. * @param w defines the 4th component (default is 0)
  3698. * @returns a new Vector4
  3699. */
  3700. static FromVector3(source: Vector3, w?: number): Vector4;
  3701. }
  3702. /**
  3703. * Class used to store quaternion data
  3704. * @see https://en.wikipedia.org/wiki/Quaternion
  3705. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3706. */
  3707. export class Quaternion {
  3708. /** @hidden */
  3709. _x: number;
  3710. /** @hidden */
  3711. _y: number;
  3712. /** @hidden */
  3713. _z: number;
  3714. /** @hidden */
  3715. _w: number;
  3716. /** @hidden */
  3717. _isDirty: boolean;
  3718. /** Gets or sets the x coordinate */
  3719. get x(): number;
  3720. set x(value: number);
  3721. /** Gets or sets the y coordinate */
  3722. get y(): number;
  3723. set y(value: number);
  3724. /** Gets or sets the z coordinate */
  3725. get z(): number;
  3726. set z(value: number);
  3727. /** Gets or sets the w coordinate */
  3728. get w(): number;
  3729. set w(value: number);
  3730. /**
  3731. * Creates a new Quaternion from the given floats
  3732. * @param x defines the first component (0 by default)
  3733. * @param y defines the second component (0 by default)
  3734. * @param z defines the third component (0 by default)
  3735. * @param w defines the fourth component (1.0 by default)
  3736. */
  3737. constructor(x?: number, y?: number, z?: number, w?: number);
  3738. /**
  3739. * Gets a string representation for the current quaternion
  3740. * @returns a string with the Quaternion coordinates
  3741. */
  3742. toString(): string;
  3743. /**
  3744. * Gets the class name of the quaternion
  3745. * @returns the string "Quaternion"
  3746. */
  3747. getClassName(): string;
  3748. /**
  3749. * Gets a hash code for this quaternion
  3750. * @returns the quaternion hash code
  3751. */
  3752. getHashCode(): number;
  3753. /**
  3754. * Copy the quaternion to an array
  3755. * @returns a new array populated with 4 elements from the quaternion coordinates
  3756. */
  3757. asArray(): number[];
  3758. /**
  3759. * Check if two quaternions are equals
  3760. * @param otherQuaternion defines the second operand
  3761. * @return true if the current quaternion and the given one coordinates are strictly equals
  3762. */
  3763. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3764. /**
  3765. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3766. * @param otherQuaternion defines the other quaternion
  3767. * @param epsilon defines the minimal distance to consider equality
  3768. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3769. */
  3770. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3771. /**
  3772. * Clone the current quaternion
  3773. * @returns a new quaternion copied from the current one
  3774. */
  3775. clone(): Quaternion;
  3776. /**
  3777. * Copy a quaternion to the current one
  3778. * @param other defines the other quaternion
  3779. * @returns the updated current quaternion
  3780. */
  3781. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3782. /**
  3783. * Updates the current quaternion with the given float coordinates
  3784. * @param x defines the x coordinate
  3785. * @param y defines the y coordinate
  3786. * @param z defines the z coordinate
  3787. * @param w defines the w coordinate
  3788. * @returns the updated current quaternion
  3789. */
  3790. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3791. /**
  3792. * Updates the current quaternion from the given float coordinates
  3793. * @param x defines the x coordinate
  3794. * @param y defines the y coordinate
  3795. * @param z defines the z coordinate
  3796. * @param w defines the w coordinate
  3797. * @returns the updated current quaternion
  3798. */
  3799. set(x: number, y: number, z: number, w: number): Quaternion;
  3800. /**
  3801. * Adds two quaternions
  3802. * @param other defines the second operand
  3803. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3804. */
  3805. add(other: DeepImmutable<Quaternion>): Quaternion;
  3806. /**
  3807. * Add a quaternion to the current one
  3808. * @param other defines the quaternion to add
  3809. * @returns the current quaternion
  3810. */
  3811. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3812. /**
  3813. * Subtract two quaternions
  3814. * @param other defines the second operand
  3815. * @returns a new quaternion as the subtraction result of the given one from the current one
  3816. */
  3817. subtract(other: Quaternion): Quaternion;
  3818. /**
  3819. * Multiplies the current quaternion by a scale factor
  3820. * @param value defines the scale factor
  3821. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3822. */
  3823. scale(value: number): Quaternion;
  3824. /**
  3825. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3826. * @param scale defines the scale factor
  3827. * @param result defines the Quaternion object where to store the result
  3828. * @returns the unmodified current quaternion
  3829. */
  3830. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3831. /**
  3832. * Multiplies in place the current quaternion by a scale factor
  3833. * @param value defines the scale factor
  3834. * @returns the current modified quaternion
  3835. */
  3836. scaleInPlace(value: number): Quaternion;
  3837. /**
  3838. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3839. * @param scale defines the scale factor
  3840. * @param result defines the Quaternion object where to store the result
  3841. * @returns the unmodified current quaternion
  3842. */
  3843. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3844. /**
  3845. * Multiplies two quaternions
  3846. * @param q1 defines the second operand
  3847. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3848. */
  3849. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3850. /**
  3851. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3852. * @param q1 defines the second operand
  3853. * @param result defines the target quaternion
  3854. * @returns the current quaternion
  3855. */
  3856. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3857. /**
  3858. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3859. * @param q1 defines the second operand
  3860. * @returns the currentupdated quaternion
  3861. */
  3862. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3863. /**
  3864. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3865. * @param ref defines the target quaternion
  3866. * @returns the current quaternion
  3867. */
  3868. conjugateToRef(ref: Quaternion): Quaternion;
  3869. /**
  3870. * Conjugates in place (1-q) the current quaternion
  3871. * @returns the current updated quaternion
  3872. */
  3873. conjugateInPlace(): Quaternion;
  3874. /**
  3875. * Conjugates in place (1-q) the current quaternion
  3876. * @returns a new quaternion
  3877. */
  3878. conjugate(): Quaternion;
  3879. /**
  3880. * Gets length of current quaternion
  3881. * @returns the quaternion length (float)
  3882. */
  3883. length(): number;
  3884. /**
  3885. * Normalize in place the current quaternion
  3886. * @returns the current updated quaternion
  3887. */
  3888. normalize(): Quaternion;
  3889. /**
  3890. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3891. * @param order is a reserved parameter and is ignored for now
  3892. * @returns a new Vector3 containing the Euler angles
  3893. */
  3894. toEulerAngles(order?: string): Vector3;
  3895. /**
  3896. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3897. * @param result defines the vector which will be filled with the Euler angles
  3898. * @returns the current unchanged quaternion
  3899. */
  3900. toEulerAnglesToRef(result: Vector3): Quaternion;
  3901. /**
  3902. * Updates the given rotation matrix with the current quaternion values
  3903. * @param result defines the target matrix
  3904. * @returns the current unchanged quaternion
  3905. */
  3906. toRotationMatrix(result: Matrix): Quaternion;
  3907. /**
  3908. * Updates the current quaternion from the given rotation matrix values
  3909. * @param matrix defines the source matrix
  3910. * @returns the current updated quaternion
  3911. */
  3912. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3913. /**
  3914. * Creates a new quaternion from a rotation matrix
  3915. * @param matrix defines the source matrix
  3916. * @returns a new quaternion created from the given rotation matrix values
  3917. */
  3918. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3919. /**
  3920. * Updates the given quaternion with the given rotation matrix values
  3921. * @param matrix defines the source matrix
  3922. * @param result defines the target quaternion
  3923. */
  3924. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3925. /**
  3926. * Returns the dot product (float) between the quaternions "left" and "right"
  3927. * @param left defines the left operand
  3928. * @param right defines the right operand
  3929. * @returns the dot product
  3930. */
  3931. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3932. /**
  3933. * Checks if the two quaternions are close to each other
  3934. * @param quat0 defines the first quaternion to check
  3935. * @param quat1 defines the second quaternion to check
  3936. * @returns true if the two quaternions are close to each other
  3937. */
  3938. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3939. /**
  3940. * Creates an empty quaternion
  3941. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3942. */
  3943. static Zero(): Quaternion;
  3944. /**
  3945. * Inverse a given quaternion
  3946. * @param q defines the source quaternion
  3947. * @returns a new quaternion as the inverted current quaternion
  3948. */
  3949. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3950. /**
  3951. * Inverse a given quaternion
  3952. * @param q defines the source quaternion
  3953. * @param result the quaternion the result will be stored in
  3954. * @returns the result quaternion
  3955. */
  3956. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3957. /**
  3958. * Creates an identity quaternion
  3959. * @returns the identity quaternion
  3960. */
  3961. static Identity(): Quaternion;
  3962. /**
  3963. * Gets a boolean indicating if the given quaternion is identity
  3964. * @param quaternion defines the quaternion to check
  3965. * @returns true if the quaternion is identity
  3966. */
  3967. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3968. /**
  3969. * Creates a quaternion from a rotation around an axis
  3970. * @param axis defines the axis to use
  3971. * @param angle defines the angle to use
  3972. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3973. */
  3974. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3975. /**
  3976. * Creates a rotation around an axis and stores it into the given quaternion
  3977. * @param axis defines the axis to use
  3978. * @param angle defines the angle to use
  3979. * @param result defines the target quaternion
  3980. * @returns the target quaternion
  3981. */
  3982. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3983. /**
  3984. * Creates a new quaternion from data stored into an array
  3985. * @param array defines the data source
  3986. * @param offset defines the offset in the source array where the data starts
  3987. * @returns a new quaternion
  3988. */
  3989. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3990. /**
  3991. * Updates the given quaternion "result" from the starting index of the given array.
  3992. * @param array the array to pull values from
  3993. * @param offset the offset into the array to start at
  3994. * @param result the quaternion to store the result in
  3995. */
  3996. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3997. /**
  3998. * Create a quaternion from Euler rotation angles
  3999. * @param x Pitch
  4000. * @param y Yaw
  4001. * @param z Roll
  4002. * @returns the new Quaternion
  4003. */
  4004. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4005. /**
  4006. * Updates a quaternion from Euler rotation angles
  4007. * @param x Pitch
  4008. * @param y Yaw
  4009. * @param z Roll
  4010. * @param result the quaternion to store the result
  4011. * @returns the updated quaternion
  4012. */
  4013. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4014. /**
  4015. * Create a quaternion from Euler rotation vector
  4016. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4017. * @returns the new Quaternion
  4018. */
  4019. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4020. /**
  4021. * Updates a quaternion from Euler rotation vector
  4022. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4023. * @param result the quaternion to store the result
  4024. * @returns the updated quaternion
  4025. */
  4026. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4027. /**
  4028. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4029. * @param yaw defines the rotation around Y axis
  4030. * @param pitch defines the rotation around X axis
  4031. * @param roll defines the rotation around Z axis
  4032. * @returns the new quaternion
  4033. */
  4034. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4035. /**
  4036. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4037. * @param yaw defines the rotation around Y axis
  4038. * @param pitch defines the rotation around X axis
  4039. * @param roll defines the rotation around Z axis
  4040. * @param result defines the target quaternion
  4041. */
  4042. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4043. /**
  4044. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4045. * @param alpha defines the rotation around first axis
  4046. * @param beta defines the rotation around second axis
  4047. * @param gamma defines the rotation around third axis
  4048. * @returns the new quaternion
  4049. */
  4050. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4051. /**
  4052. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4053. * @param alpha defines the rotation around first axis
  4054. * @param beta defines the rotation around second axis
  4055. * @param gamma defines the rotation around third axis
  4056. * @param result defines the target quaternion
  4057. */
  4058. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4059. /**
  4060. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4061. * @param axis1 defines the first axis
  4062. * @param axis2 defines the second axis
  4063. * @param axis3 defines the third axis
  4064. * @returns the new quaternion
  4065. */
  4066. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4067. /**
  4068. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4069. * @param axis1 defines the first axis
  4070. * @param axis2 defines the second axis
  4071. * @param axis3 defines the third axis
  4072. * @param ref defines the target quaternion
  4073. */
  4074. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4075. /**
  4076. * Interpolates between two quaternions
  4077. * @param left defines first quaternion
  4078. * @param right defines second quaternion
  4079. * @param amount defines the gradient to use
  4080. * @returns the new interpolated quaternion
  4081. */
  4082. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4083. /**
  4084. * Interpolates between two quaternions and stores it into a target quaternion
  4085. * @param left defines first quaternion
  4086. * @param right defines second quaternion
  4087. * @param amount defines the gradient to use
  4088. * @param result defines the target quaternion
  4089. */
  4090. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4091. /**
  4092. * Interpolate between two quaternions using Hermite interpolation
  4093. * @param value1 defines first quaternion
  4094. * @param tangent1 defines the incoming tangent
  4095. * @param value2 defines second quaternion
  4096. * @param tangent2 defines the outgoing tangent
  4097. * @param amount defines the target quaternion
  4098. * @returns the new interpolated quaternion
  4099. */
  4100. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4101. }
  4102. /**
  4103. * Class used to store matrix data (4x4)
  4104. */
  4105. export class Matrix {
  4106. /**
  4107. * Gets the precision of matrix computations
  4108. */
  4109. static get Use64Bits(): boolean;
  4110. private static _updateFlagSeed;
  4111. private static _identityReadOnly;
  4112. private _isIdentity;
  4113. private _isIdentityDirty;
  4114. private _isIdentity3x2;
  4115. private _isIdentity3x2Dirty;
  4116. /**
  4117. * Gets the update flag of the matrix which is an unique number for the matrix.
  4118. * It will be incremented every time the matrix data change.
  4119. * You can use it to speed the comparison between two versions of the same matrix.
  4120. */
  4121. updateFlag: number;
  4122. private readonly _m;
  4123. /**
  4124. * Gets the internal data of the matrix
  4125. */
  4126. get m(): DeepImmutable<Float32Array | Array<number>>;
  4127. /** @hidden */
  4128. _markAsUpdated(): void;
  4129. /** @hidden */
  4130. private _updateIdentityStatus;
  4131. /**
  4132. * Creates an empty matrix (filled with zeros)
  4133. */
  4134. constructor();
  4135. /**
  4136. * Check if the current matrix is identity
  4137. * @returns true is the matrix is the identity matrix
  4138. */
  4139. isIdentity(): boolean;
  4140. /**
  4141. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4142. * @returns true is the matrix is the identity matrix
  4143. */
  4144. isIdentityAs3x2(): boolean;
  4145. /**
  4146. * Gets the determinant of the matrix
  4147. * @returns the matrix determinant
  4148. */
  4149. determinant(): number;
  4150. /**
  4151. * Returns the matrix as a Float32Array or Array<number>
  4152. * @returns the matrix underlying array
  4153. */
  4154. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4155. /**
  4156. * Returns the matrix as a Float32Array or Array<number>
  4157. * @returns the matrix underlying array.
  4158. */
  4159. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4160. /**
  4161. * Inverts the current matrix in place
  4162. * @returns the current inverted matrix
  4163. */
  4164. invert(): Matrix;
  4165. /**
  4166. * Sets all the matrix elements to zero
  4167. * @returns the current matrix
  4168. */
  4169. reset(): Matrix;
  4170. /**
  4171. * Adds the current matrix with a second one
  4172. * @param other defines the matrix to add
  4173. * @returns a new matrix as the addition of the current matrix and the given one
  4174. */
  4175. add(other: DeepImmutable<Matrix>): Matrix;
  4176. /**
  4177. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4178. * @param other defines the matrix to add
  4179. * @param result defines the target matrix
  4180. * @returns the current matrix
  4181. */
  4182. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4183. /**
  4184. * Adds in place the given matrix to the current matrix
  4185. * @param other defines the second operand
  4186. * @returns the current updated matrix
  4187. */
  4188. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4189. /**
  4190. * Sets the given matrix to the current inverted Matrix
  4191. * @param other defines the target matrix
  4192. * @returns the unmodified current matrix
  4193. */
  4194. invertToRef(other: Matrix): Matrix;
  4195. /**
  4196. * add a value at the specified position in the current Matrix
  4197. * @param index the index of the value within the matrix. between 0 and 15.
  4198. * @param value the value to be added
  4199. * @returns the current updated matrix
  4200. */
  4201. addAtIndex(index: number, value: number): Matrix;
  4202. /**
  4203. * mutiply the specified position in the current Matrix by a value
  4204. * @param index the index of the value within the matrix. between 0 and 15.
  4205. * @param value the value to be added
  4206. * @returns the current updated matrix
  4207. */
  4208. multiplyAtIndex(index: number, value: number): Matrix;
  4209. /**
  4210. * Inserts the translation vector (using 3 floats) in the current matrix
  4211. * @param x defines the 1st component of the translation
  4212. * @param y defines the 2nd component of the translation
  4213. * @param z defines the 3rd component of the translation
  4214. * @returns the current updated matrix
  4215. */
  4216. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4217. /**
  4218. * Adds the translation vector (using 3 floats) in the current matrix
  4219. * @param x defines the 1st component of the translation
  4220. * @param y defines the 2nd component of the translation
  4221. * @param z defines the 3rd component of the translation
  4222. * @returns the current updated matrix
  4223. */
  4224. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4225. /**
  4226. * Inserts the translation vector in the current matrix
  4227. * @param vector3 defines the translation to insert
  4228. * @returns the current updated matrix
  4229. */
  4230. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4231. /**
  4232. * Gets the translation value of the current matrix
  4233. * @returns a new Vector3 as the extracted translation from the matrix
  4234. */
  4235. getTranslation(): Vector3;
  4236. /**
  4237. * Fill a Vector3 with the extracted translation from the matrix
  4238. * @param result defines the Vector3 where to store the translation
  4239. * @returns the current matrix
  4240. */
  4241. getTranslationToRef(result: Vector3): Matrix;
  4242. /**
  4243. * Remove rotation and scaling part from the matrix
  4244. * @returns the updated matrix
  4245. */
  4246. removeRotationAndScaling(): Matrix;
  4247. /**
  4248. * Multiply two matrices
  4249. * @param other defines the second operand
  4250. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4251. */
  4252. multiply(other: DeepImmutable<Matrix>): Matrix;
  4253. /**
  4254. * Copy the current matrix from the given one
  4255. * @param other defines the source matrix
  4256. * @returns the current updated matrix
  4257. */
  4258. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4259. /**
  4260. * Populates the given array from the starting index with the current matrix values
  4261. * @param array defines the target array
  4262. * @param offset defines the offset in the target array where to start storing values
  4263. * @returns the current matrix
  4264. */
  4265. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4266. /**
  4267. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4268. * @param other defines the second operand
  4269. * @param result defines the matrix where to store the multiplication
  4270. * @returns the current matrix
  4271. */
  4272. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4273. /**
  4274. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4275. * @param other defines the second operand
  4276. * @param result defines the array where to store the multiplication
  4277. * @param offset defines the offset in the target array where to start storing values
  4278. * @returns the current matrix
  4279. */
  4280. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4281. /**
  4282. * Check equality between this matrix and a second one
  4283. * @param value defines the second matrix to compare
  4284. * @returns true is the current matrix and the given one values are strictly equal
  4285. */
  4286. equals(value: DeepImmutable<Matrix>): boolean;
  4287. /**
  4288. * Clone the current matrix
  4289. * @returns a new matrix from the current matrix
  4290. */
  4291. clone(): Matrix;
  4292. /**
  4293. * Returns the name of the current matrix class
  4294. * @returns the string "Matrix"
  4295. */
  4296. getClassName(): string;
  4297. /**
  4298. * Gets the hash code of the current matrix
  4299. * @returns the hash code
  4300. */
  4301. getHashCode(): number;
  4302. /**
  4303. * Decomposes the current Matrix into a translation, rotation and scaling components
  4304. * @param scale defines the scale vector3 given as a reference to update
  4305. * @param rotation defines the rotation quaternion given as a reference to update
  4306. * @param translation defines the translation vector3 given as a reference to update
  4307. * @returns true if operation was successful
  4308. */
  4309. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4310. /**
  4311. * Gets specific row of the matrix
  4312. * @param index defines the number of the row to get
  4313. * @returns the index-th row of the current matrix as a new Vector4
  4314. */
  4315. getRow(index: number): Nullable<Vector4>;
  4316. /**
  4317. * Sets the index-th row of the current matrix to the vector4 values
  4318. * @param index defines the number of the row to set
  4319. * @param row defines the target vector4
  4320. * @returns the updated current matrix
  4321. */
  4322. setRow(index: number, row: Vector4): Matrix;
  4323. /**
  4324. * Compute the transpose of the matrix
  4325. * @returns the new transposed matrix
  4326. */
  4327. transpose(): Matrix;
  4328. /**
  4329. * Compute the transpose of the matrix and store it in a given matrix
  4330. * @param result defines the target matrix
  4331. * @returns the current matrix
  4332. */
  4333. transposeToRef(result: Matrix): Matrix;
  4334. /**
  4335. * Sets the index-th row of the current matrix with the given 4 x float values
  4336. * @param index defines the row index
  4337. * @param x defines the x component to set
  4338. * @param y defines the y component to set
  4339. * @param z defines the z component to set
  4340. * @param w defines the w component to set
  4341. * @returns the updated current matrix
  4342. */
  4343. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4344. /**
  4345. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4346. * @param scale defines the scale factor
  4347. * @returns a new matrix
  4348. */
  4349. scale(scale: number): Matrix;
  4350. /**
  4351. * Scale the current matrix values by a factor to a given result matrix
  4352. * @param scale defines the scale factor
  4353. * @param result defines the matrix to store the result
  4354. * @returns the current matrix
  4355. */
  4356. scaleToRef(scale: number, result: Matrix): Matrix;
  4357. /**
  4358. * Scale the current matrix values by a factor and add the result to a given matrix
  4359. * @param scale defines the scale factor
  4360. * @param result defines the Matrix to store the result
  4361. * @returns the current matrix
  4362. */
  4363. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4364. /**
  4365. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4366. * @param ref matrix to store the result
  4367. */
  4368. toNormalMatrix(ref: Matrix): void;
  4369. /**
  4370. * Gets only rotation part of the current matrix
  4371. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4372. */
  4373. getRotationMatrix(): Matrix;
  4374. /**
  4375. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4376. * @param result defines the target matrix to store data to
  4377. * @returns the current matrix
  4378. */
  4379. getRotationMatrixToRef(result: Matrix): Matrix;
  4380. /**
  4381. * Toggles model matrix from being right handed to left handed in place and vice versa
  4382. */
  4383. toggleModelMatrixHandInPlace(): void;
  4384. /**
  4385. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4386. */
  4387. toggleProjectionMatrixHandInPlace(): void;
  4388. /**
  4389. * Creates a matrix from an array
  4390. * @param array defines the source array
  4391. * @param offset defines an offset in the source array
  4392. * @returns a new Matrix set from the starting index of the given array
  4393. */
  4394. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4395. /**
  4396. * Copy the content of an array into a given matrix
  4397. * @param array defines the source array
  4398. * @param offset defines an offset in the source array
  4399. * @param result defines the target matrix
  4400. */
  4401. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4402. /**
  4403. * Stores an array into a matrix after having multiplied each component by a given factor
  4404. * @param array defines the source array
  4405. * @param offset defines the offset in the source array
  4406. * @param scale defines the scaling factor
  4407. * @param result defines the target matrix
  4408. */
  4409. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4410. /**
  4411. * Gets an identity matrix that must not be updated
  4412. */
  4413. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4414. /**
  4415. * Stores a list of values (16) inside a given matrix
  4416. * @param initialM11 defines 1st value of 1st row
  4417. * @param initialM12 defines 2nd value of 1st row
  4418. * @param initialM13 defines 3rd value of 1st row
  4419. * @param initialM14 defines 4th value of 1st row
  4420. * @param initialM21 defines 1st value of 2nd row
  4421. * @param initialM22 defines 2nd value of 2nd row
  4422. * @param initialM23 defines 3rd value of 2nd row
  4423. * @param initialM24 defines 4th value of 2nd row
  4424. * @param initialM31 defines 1st value of 3rd row
  4425. * @param initialM32 defines 2nd value of 3rd row
  4426. * @param initialM33 defines 3rd value of 3rd row
  4427. * @param initialM34 defines 4th value of 3rd row
  4428. * @param initialM41 defines 1st value of 4th row
  4429. * @param initialM42 defines 2nd value of 4th row
  4430. * @param initialM43 defines 3rd value of 4th row
  4431. * @param initialM44 defines 4th value of 4th row
  4432. * @param result defines the target matrix
  4433. */
  4434. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4435. /**
  4436. * Creates new matrix from a list of values (16)
  4437. * @param initialM11 defines 1st value of 1st row
  4438. * @param initialM12 defines 2nd value of 1st row
  4439. * @param initialM13 defines 3rd value of 1st row
  4440. * @param initialM14 defines 4th value of 1st row
  4441. * @param initialM21 defines 1st value of 2nd row
  4442. * @param initialM22 defines 2nd value of 2nd row
  4443. * @param initialM23 defines 3rd value of 2nd row
  4444. * @param initialM24 defines 4th value of 2nd row
  4445. * @param initialM31 defines 1st value of 3rd row
  4446. * @param initialM32 defines 2nd value of 3rd row
  4447. * @param initialM33 defines 3rd value of 3rd row
  4448. * @param initialM34 defines 4th value of 3rd row
  4449. * @param initialM41 defines 1st value of 4th row
  4450. * @param initialM42 defines 2nd value of 4th row
  4451. * @param initialM43 defines 3rd value of 4th row
  4452. * @param initialM44 defines 4th value of 4th row
  4453. * @returns the new matrix
  4454. */
  4455. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4456. /**
  4457. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4458. * @param scale defines the scale vector3
  4459. * @param rotation defines the rotation quaternion
  4460. * @param translation defines the translation vector3
  4461. * @returns a new matrix
  4462. */
  4463. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4464. /**
  4465. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4466. * @param scale defines the scale vector3
  4467. * @param rotation defines the rotation quaternion
  4468. * @param translation defines the translation vector3
  4469. * @param result defines the target matrix
  4470. */
  4471. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4472. /**
  4473. * Creates a new identity matrix
  4474. * @returns a new identity matrix
  4475. */
  4476. static Identity(): Matrix;
  4477. /**
  4478. * Creates a new identity matrix and stores the result in a given matrix
  4479. * @param result defines the target matrix
  4480. */
  4481. static IdentityToRef(result: Matrix): void;
  4482. /**
  4483. * Creates a new zero matrix
  4484. * @returns a new zero matrix
  4485. */
  4486. static Zero(): Matrix;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the X axis
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationX(angle: number): Matrix;
  4493. /**
  4494. * Creates a new matrix as the invert of a given matrix
  4495. * @param source defines the source matrix
  4496. * @returns the new matrix
  4497. */
  4498. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4499. /**
  4500. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4501. * @param angle defines the angle (in radians) to use
  4502. * @param result defines the target matrix
  4503. */
  4504. static RotationXToRef(angle: number, result: Matrix): void;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the Y axis
  4507. * @param angle defines the angle (in radians) to use
  4508. * @return the new matrix
  4509. */
  4510. static RotationY(angle: number): Matrix;
  4511. /**
  4512. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4513. * @param angle defines the angle (in radians) to use
  4514. * @param result defines the target matrix
  4515. */
  4516. static RotationYToRef(angle: number, result: Matrix): void;
  4517. /**
  4518. * Creates a new rotation matrix for "angle" radians around the Z axis
  4519. * @param angle defines the angle (in radians) to use
  4520. * @return the new matrix
  4521. */
  4522. static RotationZ(angle: number): Matrix;
  4523. /**
  4524. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4525. * @param angle defines the angle (in radians) to use
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationZToRef(angle: number, result: Matrix): void;
  4529. /**
  4530. * Creates a new rotation matrix for "angle" radians around the given axis
  4531. * @param axis defines the axis to use
  4532. * @param angle defines the angle (in radians) to use
  4533. * @return the new matrix
  4534. */
  4535. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4536. /**
  4537. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4538. * @param axis defines the axis to use
  4539. * @param angle defines the angle (in radians) to use
  4540. * @param result defines the target matrix
  4541. */
  4542. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4543. /**
  4544. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4545. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4546. * @param from defines the vector to align
  4547. * @param to defines the vector to align to
  4548. * @param result defines the target matrix
  4549. */
  4550. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4551. /**
  4552. * Creates a rotation matrix
  4553. * @param yaw defines the yaw angle in radians (Y axis)
  4554. * @param pitch defines the pitch angle in radians (X axis)
  4555. * @param roll defines the roll angle in radians (Z axis)
  4556. * @returns the new rotation matrix
  4557. */
  4558. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4559. /**
  4560. * Creates a rotation matrix and stores it in a given matrix
  4561. * @param yaw defines the yaw angle in radians (Y axis)
  4562. * @param pitch defines the pitch angle in radians (X axis)
  4563. * @param roll defines the roll angle in radians (Z axis)
  4564. * @param result defines the target matrix
  4565. */
  4566. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4567. /**
  4568. * Creates a scaling matrix
  4569. * @param x defines the scale factor on X axis
  4570. * @param y defines the scale factor on Y axis
  4571. * @param z defines the scale factor on Z axis
  4572. * @returns the new matrix
  4573. */
  4574. static Scaling(x: number, y: number, z: number): Matrix;
  4575. /**
  4576. * Creates a scaling matrix and stores it in a given matrix
  4577. * @param x defines the scale factor on X axis
  4578. * @param y defines the scale factor on Y axis
  4579. * @param z defines the scale factor on Z axis
  4580. * @param result defines the target matrix
  4581. */
  4582. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4583. /**
  4584. * Creates a translation matrix
  4585. * @param x defines the translation on X axis
  4586. * @param y defines the translation on Y axis
  4587. * @param z defines the translationon Z axis
  4588. * @returns the new matrix
  4589. */
  4590. static Translation(x: number, y: number, z: number): Matrix;
  4591. /**
  4592. * Creates a translation matrix and stores it in a given matrix
  4593. * @param x defines the translation on X axis
  4594. * @param y defines the translation on Y axis
  4595. * @param z defines the translationon Z axis
  4596. * @param result defines the target matrix
  4597. */
  4598. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4599. /**
  4600. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4601. * @param startValue defines the start value
  4602. * @param endValue defines the end value
  4603. * @param gradient defines the gradient factor
  4604. * @returns the new matrix
  4605. */
  4606. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4607. /**
  4608. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4609. * @param startValue defines the start value
  4610. * @param endValue defines the end value
  4611. * @param gradient defines the gradient factor
  4612. * @param result defines the Matrix object where to store data
  4613. */
  4614. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * Builds a new matrix whose values are computed by:
  4617. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4618. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4619. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4620. * @param startValue defines the first matrix
  4621. * @param endValue defines the second matrix
  4622. * @param gradient defines the gradient between the two matrices
  4623. * @returns the new matrix
  4624. */
  4625. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4626. /**
  4627. * Update a matrix to values which are computed by:
  4628. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4629. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4630. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4631. * @param startValue defines the first matrix
  4632. * @param endValue defines the second matrix
  4633. * @param gradient defines the gradient between the two matrices
  4634. * @param result defines the target matrix
  4635. */
  4636. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4637. /**
  4638. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4639. * This function works in left handed mode
  4640. * @param eye defines the final position of the entity
  4641. * @param target defines where the entity should look at
  4642. * @param up defines the up vector for the entity
  4643. * @returns the new matrix
  4644. */
  4645. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4646. /**
  4647. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4648. * This function works in left handed mode
  4649. * @param eye defines the final position of the entity
  4650. * @param target defines where the entity should look at
  4651. * @param up defines the up vector for the entity
  4652. * @param result defines the target matrix
  4653. */
  4654. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4655. /**
  4656. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4657. * This function works in right handed mode
  4658. * @param eye defines the final position of the entity
  4659. * @param target defines where the entity should look at
  4660. * @param up defines the up vector for the entity
  4661. * @returns the new matrix
  4662. */
  4663. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4664. /**
  4665. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4666. * This function works in right handed mode
  4667. * @param eye defines the final position of the entity
  4668. * @param target defines where the entity should look at
  4669. * @param up defines the up vector for the entity
  4670. * @param result defines the target matrix
  4671. */
  4672. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4673. /**
  4674. * Create a left-handed orthographic projection matrix
  4675. * @param width defines the viewport width
  4676. * @param height defines the viewport height
  4677. * @param znear defines the near clip plane
  4678. * @param zfar defines the far clip plane
  4679. * @returns a new matrix as a left-handed orthographic projection matrix
  4680. */
  4681. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4682. /**
  4683. * Store a left-handed orthographic projection to a given matrix
  4684. * @param width defines the viewport width
  4685. * @param height defines the viewport height
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Create a left-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a left-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a left-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a right-handed orthographic projection matrix
  4715. * @param left defines the viewport left coordinate
  4716. * @param right defines the viewport right coordinate
  4717. * @param bottom defines the viewport bottom coordinate
  4718. * @param top defines the viewport top coordinate
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed orthographic projection matrix
  4722. */
  4723. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed orthographic projection into a given matrix
  4726. * @param left defines the viewport left coordinate
  4727. * @param right defines the viewport right coordinate
  4728. * @param bottom defines the viewport bottom coordinate
  4729. * @param top defines the viewport top coordinate
  4730. * @param znear defines the near clip plane
  4731. * @param zfar defines the far clip plane
  4732. * @param result defines the target matrix
  4733. */
  4734. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4735. /**
  4736. * Creates a left-handed perspective projection matrix
  4737. * @param width defines the viewport width
  4738. * @param height defines the viewport height
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @returns a new matrix as a left-handed perspective projection matrix
  4742. */
  4743. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4744. /**
  4745. * Creates a left-handed perspective projection matrix
  4746. * @param fov defines the horizontal field of view
  4747. * @param aspect defines the aspect ratio
  4748. * @param znear defines the near clip plane
  4749. * @param zfar defines the far clip plane
  4750. * @returns a new matrix as a left-handed perspective projection matrix
  4751. */
  4752. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4753. /**
  4754. * Stores a left-handed perspective projection into a given matrix
  4755. * @param fov defines the horizontal field of view
  4756. * @param aspect defines the aspect ratio
  4757. * @param znear defines the near clip plane
  4758. * @param zfar defines the far clip plane
  4759. * @param result defines the target matrix
  4760. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4761. */
  4762. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4763. /**
  4764. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4765. * @param fov defines the horizontal field of view
  4766. * @param aspect defines the aspect ratio
  4767. * @param znear defines the near clip plane
  4768. * @param zfar not used as infinity is used as far clip
  4769. * @param result defines the target matrix
  4770. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4771. */
  4772. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4773. /**
  4774. * Creates a right-handed perspective projection matrix
  4775. * @param fov defines the horizontal field of view
  4776. * @param aspect defines the aspect ratio
  4777. * @param znear defines the near clip plane
  4778. * @param zfar defines the far clip plane
  4779. * @returns a new matrix as a right-handed perspective projection matrix
  4780. */
  4781. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4782. /**
  4783. * Stores a right-handed perspective projection into a given matrix
  4784. * @param fov defines the horizontal field of view
  4785. * @param aspect defines the aspect ratio
  4786. * @param znear defines the near clip plane
  4787. * @param zfar defines the far clip plane
  4788. * @param result defines the target matrix
  4789. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4790. */
  4791. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4792. /**
  4793. * Stores a right-handed perspective projection into a given matrix
  4794. * @param fov defines the horizontal field of view
  4795. * @param aspect defines the aspect ratio
  4796. * @param znear defines the near clip plane
  4797. * @param zfar not used as infinity is used as far clip
  4798. * @param result defines the target matrix
  4799. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4800. */
  4801. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4802. /**
  4803. * Stores a perspective projection for WebVR info a given matrix
  4804. * @param fov defines the field of view
  4805. * @param znear defines the near clip plane
  4806. * @param zfar defines the far clip plane
  4807. * @param result defines the target matrix
  4808. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4809. */
  4810. static PerspectiveFovWebVRToRef(fov: {
  4811. upDegrees: number;
  4812. downDegrees: number;
  4813. leftDegrees: number;
  4814. rightDegrees: number;
  4815. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4816. /**
  4817. * Computes a complete transformation matrix
  4818. * @param viewport defines the viewport to use
  4819. * @param world defines the world matrix
  4820. * @param view defines the view matrix
  4821. * @param projection defines the projection matrix
  4822. * @param zmin defines the near clip plane
  4823. * @param zmax defines the far clip plane
  4824. * @returns the transformation matrix
  4825. */
  4826. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4827. /**
  4828. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4829. * @param matrix defines the matrix to use
  4830. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4831. */
  4832. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4833. /**
  4834. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4835. * @param matrix defines the matrix to use
  4836. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4837. */
  4838. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4839. /**
  4840. * Compute the transpose of a given matrix
  4841. * @param matrix defines the matrix to transpose
  4842. * @returns the new matrix
  4843. */
  4844. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4845. /**
  4846. * Compute the transpose of a matrix and store it in a target matrix
  4847. * @param matrix defines the matrix to transpose
  4848. * @param result defines the target matrix
  4849. */
  4850. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4851. /**
  4852. * Computes a reflection matrix from a plane
  4853. * @param plane defines the reflection plane
  4854. * @returns a new matrix
  4855. */
  4856. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4857. /**
  4858. * Computes a reflection matrix from a plane
  4859. * @param plane defines the reflection plane
  4860. * @param result defines the target matrix
  4861. */
  4862. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4863. /**
  4864. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4865. * @param xaxis defines the value of the 1st axis
  4866. * @param yaxis defines the value of the 2nd axis
  4867. * @param zaxis defines the value of the 3rd axis
  4868. * @param result defines the target matrix
  4869. */
  4870. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4871. /**
  4872. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4873. * @param quat defines the quaternion to use
  4874. * @param result defines the target matrix
  4875. */
  4876. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4877. }
  4878. /**
  4879. * @hidden
  4880. */
  4881. export class TmpVectors {
  4882. static Vector2: Vector2[];
  4883. static Vector3: Vector3[];
  4884. static Vector4: Vector4[];
  4885. static Quaternion: Quaternion[];
  4886. static Matrix: Matrix[];
  4887. }
  4888. }
  4889. declare module "babylonjs/Maths/math.path" {
  4890. import { DeepImmutable, Nullable } from "babylonjs/types";
  4891. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4892. /**
  4893. * Defines potential orientation for back face culling
  4894. */
  4895. export enum Orientation {
  4896. /**
  4897. * Clockwise
  4898. */
  4899. CW = 0,
  4900. /** Counter clockwise */
  4901. CCW = 1
  4902. }
  4903. /** Class used to represent a Bezier curve */
  4904. export class BezierCurve {
  4905. /**
  4906. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4907. * @param t defines the time
  4908. * @param x1 defines the left coordinate on X axis
  4909. * @param y1 defines the left coordinate on Y axis
  4910. * @param x2 defines the right coordinate on X axis
  4911. * @param y2 defines the right coordinate on Y axis
  4912. * @returns the interpolated value
  4913. */
  4914. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4915. }
  4916. /**
  4917. * Defines angle representation
  4918. */
  4919. export class Angle {
  4920. private _radians;
  4921. /**
  4922. * Creates an Angle object of "radians" radians (float).
  4923. * @param radians the angle in radians
  4924. */
  4925. constructor(radians: number);
  4926. /**
  4927. * Get value in degrees
  4928. * @returns the Angle value in degrees (float)
  4929. */
  4930. degrees(): number;
  4931. /**
  4932. * Get value in radians
  4933. * @returns the Angle value in radians (float)
  4934. */
  4935. radians(): number;
  4936. /**
  4937. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4938. * @param a defines first point as the origin
  4939. * @param b defines point
  4940. * @returns a new Angle
  4941. */
  4942. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4943. /**
  4944. * Gets a new Angle object from the given float in radians
  4945. * @param radians defines the angle value in radians
  4946. * @returns a new Angle
  4947. */
  4948. static FromRadians(radians: number): Angle;
  4949. /**
  4950. * Gets a new Angle object from the given float in degrees
  4951. * @param degrees defines the angle value in degrees
  4952. * @returns a new Angle
  4953. */
  4954. static FromDegrees(degrees: number): Angle;
  4955. }
  4956. /**
  4957. * This represents an arc in a 2d space.
  4958. */
  4959. export class Arc2 {
  4960. /** Defines the start point of the arc */
  4961. startPoint: Vector2;
  4962. /** Defines the mid point of the arc */
  4963. midPoint: Vector2;
  4964. /** Defines the end point of the arc */
  4965. endPoint: Vector2;
  4966. /**
  4967. * Defines the center point of the arc.
  4968. */
  4969. centerPoint: Vector2;
  4970. /**
  4971. * Defines the radius of the arc.
  4972. */
  4973. radius: number;
  4974. /**
  4975. * Defines the angle of the arc (from mid point to end point).
  4976. */
  4977. angle: Angle;
  4978. /**
  4979. * Defines the start angle of the arc (from start point to middle point).
  4980. */
  4981. startAngle: Angle;
  4982. /**
  4983. * Defines the orientation of the arc (clock wise/counter clock wise).
  4984. */
  4985. orientation: Orientation;
  4986. /**
  4987. * Creates an Arc object from the three given points : start, middle and end.
  4988. * @param startPoint Defines the start point of the arc
  4989. * @param midPoint Defines the midlle point of the arc
  4990. * @param endPoint Defines the end point of the arc
  4991. */
  4992. constructor(
  4993. /** Defines the start point of the arc */
  4994. startPoint: Vector2,
  4995. /** Defines the mid point of the arc */
  4996. midPoint: Vector2,
  4997. /** Defines the end point of the arc */
  4998. endPoint: Vector2);
  4999. }
  5000. /**
  5001. * Represents a 2D path made up of multiple 2D points
  5002. */
  5003. export class Path2 {
  5004. private _points;
  5005. private _length;
  5006. /**
  5007. * If the path start and end point are the same
  5008. */
  5009. closed: boolean;
  5010. /**
  5011. * Creates a Path2 object from the starting 2D coordinates x and y.
  5012. * @param x the starting points x value
  5013. * @param y the starting points y value
  5014. */
  5015. constructor(x: number, y: number);
  5016. /**
  5017. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5018. * @param x the added points x value
  5019. * @param y the added points y value
  5020. * @returns the updated Path2.
  5021. */
  5022. addLineTo(x: number, y: number): Path2;
  5023. /**
  5024. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5025. * @param midX middle point x value
  5026. * @param midY middle point y value
  5027. * @param endX end point x value
  5028. * @param endY end point y value
  5029. * @param numberOfSegments (default: 36)
  5030. * @returns the updated Path2.
  5031. */
  5032. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5033. /**
  5034. * Closes the Path2.
  5035. * @returns the Path2.
  5036. */
  5037. close(): Path2;
  5038. /**
  5039. * Gets the sum of the distance between each sequential point in the path
  5040. * @returns the Path2 total length (float).
  5041. */
  5042. length(): number;
  5043. /**
  5044. * Gets the points which construct the path
  5045. * @returns the Path2 internal array of points.
  5046. */
  5047. getPoints(): Vector2[];
  5048. /**
  5049. * Retreives the point at the distance aways from the starting point
  5050. * @param normalizedLengthPosition the length along the path to retreive the point from
  5051. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5052. */
  5053. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5054. /**
  5055. * Creates a new path starting from an x and y position
  5056. * @param x starting x value
  5057. * @param y starting y value
  5058. * @returns a new Path2 starting at the coordinates (x, y).
  5059. */
  5060. static StartingAt(x: number, y: number): Path2;
  5061. }
  5062. /**
  5063. * Represents a 3D path made up of multiple 3D points
  5064. */
  5065. export class Path3D {
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[];
  5070. private _curve;
  5071. private _distances;
  5072. private _tangents;
  5073. private _normals;
  5074. private _binormals;
  5075. private _raw;
  5076. private _alignTangentsWithPath;
  5077. private readonly _pointAtData;
  5078. /**
  5079. * new Path3D(path, normal, raw)
  5080. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5081. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5082. * @param path an array of Vector3, the curve axis of the Path3D
  5083. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5084. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5085. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5086. */
  5087. constructor(
  5088. /**
  5089. * an array of Vector3, the curve axis of the Path3D
  5090. */
  5091. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5092. /**
  5093. * Returns the Path3D array of successive Vector3 designing its curve.
  5094. * @returns the Path3D array of successive Vector3 designing its curve.
  5095. */
  5096. getCurve(): Vector3[];
  5097. /**
  5098. * Returns the Path3D array of successive Vector3 designing its curve.
  5099. * @returns the Path3D array of successive Vector3 designing its curve.
  5100. */
  5101. getPoints(): Vector3[];
  5102. /**
  5103. * @returns the computed length (float) of the path.
  5104. */
  5105. length(): number;
  5106. /**
  5107. * Returns an array populated with tangent vectors on each Path3D curve point.
  5108. * @returns an array populated with tangent vectors on each Path3D curve point.
  5109. */
  5110. getTangents(): Vector3[];
  5111. /**
  5112. * Returns an array populated with normal vectors on each Path3D curve point.
  5113. * @returns an array populated with normal vectors on each Path3D curve point.
  5114. */
  5115. getNormals(): Vector3[];
  5116. /**
  5117. * Returns an array populated with binormal vectors on each Path3D curve point.
  5118. * @returns an array populated with binormal vectors on each Path3D curve point.
  5119. */
  5120. getBinormals(): Vector3[];
  5121. /**
  5122. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5123. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5124. */
  5125. getDistances(): number[];
  5126. /**
  5127. * Returns an interpolated point along this path
  5128. * @param position the position of the point along this path, from 0.0 to 1.0
  5129. * @returns a new Vector3 as the point
  5130. */
  5131. getPointAt(position: number): Vector3;
  5132. /**
  5133. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5134. * @param position the position of the point along this path, from 0.0 to 1.0
  5135. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5136. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5137. */
  5138. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5139. /**
  5140. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5141. * @param position the position of the point along this path, from 0.0 to 1.0
  5142. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5143. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5144. */
  5145. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5146. /**
  5147. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5148. * @param position the position of the point along this path, from 0.0 to 1.0
  5149. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5150. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5151. */
  5152. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5153. /**
  5154. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5155. * @param position the position of the point along this path, from 0.0 to 1.0
  5156. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5157. */
  5158. getDistanceAt(position: number): number;
  5159. /**
  5160. * Returns the array index of the previous point of an interpolated point along this path
  5161. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5162. * @returns the array index
  5163. */
  5164. getPreviousPointIndexAt(position: number): number;
  5165. /**
  5166. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5167. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5168. * @returns the sub position
  5169. */
  5170. getSubPositionAt(position: number): number;
  5171. /**
  5172. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5173. * @param target the vector of which to get the closest position to
  5174. * @returns the position of the closest virtual point on this path to the target vector
  5175. */
  5176. getClosestPositionTo(target: Vector3): number;
  5177. /**
  5178. * Returns a sub path (slice) of this path
  5179. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5180. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5181. * @returns a sub path (slice) of this path
  5182. */
  5183. slice(start?: number, end?: number): Path3D;
  5184. /**
  5185. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5186. * @param path path which all values are copied into the curves points
  5187. * @param firstNormal which should be projected onto the curve
  5188. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5189. * @returns the same object updated.
  5190. */
  5191. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5192. private _compute;
  5193. private _getFirstNonNullVector;
  5194. private _getLastNonNullVector;
  5195. private _normalVector;
  5196. /**
  5197. * Updates the point at data for an interpolated point along this curve
  5198. * @param position the position of the point along this curve, from 0.0 to 1.0
  5199. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5200. * @returns the (updated) point at data
  5201. */
  5202. private _updatePointAtData;
  5203. /**
  5204. * Updates the point at data from the specified parameters
  5205. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5206. * @param point the interpolated point
  5207. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5208. */
  5209. private _setPointAtData;
  5210. /**
  5211. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5212. */
  5213. private _updateInterpolationMatrix;
  5214. }
  5215. /**
  5216. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5217. * A Curve3 is designed from a series of successive Vector3.
  5218. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5219. */
  5220. export class Curve3 {
  5221. private _points;
  5222. private _length;
  5223. /**
  5224. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5225. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5226. * @param v1 (Vector3) the control point
  5227. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5228. * @param nbPoints (integer) the wanted number of points in the curve
  5229. * @returns the created Curve3
  5230. */
  5231. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5232. /**
  5233. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5234. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5235. * @param v1 (Vector3) the first control point
  5236. * @param v2 (Vector3) the second control point
  5237. * @param v3 (Vector3) the end point of the Cubic Bezier
  5238. * @param nbPoints (integer) the wanted number of points in the curve
  5239. * @returns the created Curve3
  5240. */
  5241. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5242. /**
  5243. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5244. * @param p1 (Vector3) the origin point of the Hermite Spline
  5245. * @param t1 (Vector3) the tangent vector at the origin point
  5246. * @param p2 (Vector3) the end point of the Hermite Spline
  5247. * @param t2 (Vector3) the tangent vector at the end point
  5248. * @param nbPoints (integer) the wanted number of points in the curve
  5249. * @returns the created Curve3
  5250. */
  5251. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5252. /**
  5253. * Returns a Curve3 object along a CatmullRom Spline curve :
  5254. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5255. * @param nbPoints (integer) the wanted number of points between each curve control points
  5256. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5257. * @returns the created Curve3
  5258. */
  5259. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5260. /**
  5261. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5262. * A Curve3 is designed from a series of successive Vector3.
  5263. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5264. * @param points points which make up the curve
  5265. */
  5266. constructor(points: Vector3[]);
  5267. /**
  5268. * @returns the Curve3 stored array of successive Vector3
  5269. */
  5270. getPoints(): Vector3[];
  5271. /**
  5272. * @returns the computed length (float) of the curve.
  5273. */
  5274. length(): number;
  5275. /**
  5276. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5277. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5278. * curveA and curveB keep unchanged.
  5279. * @param curve the curve to continue from this curve
  5280. * @returns the newly constructed curve
  5281. */
  5282. continue(curve: DeepImmutable<Curve3>): Curve3;
  5283. private _computeLength;
  5284. }
  5285. }
  5286. declare module "babylonjs/Animations/easing" {
  5287. /**
  5288. * This represents the main contract an easing function should follow.
  5289. * Easing functions are used throughout the animation system.
  5290. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5291. */
  5292. export interface IEasingFunction {
  5293. /**
  5294. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5295. * of the easing function.
  5296. * The link below provides some of the most common examples of easing functions.
  5297. * @see https://easings.net/
  5298. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5299. * @returns the corresponding value on the curve defined by the easing function
  5300. */
  5301. ease(gradient: number): number;
  5302. }
  5303. /**
  5304. * Base class used for every default easing function.
  5305. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5306. */
  5307. export class EasingFunction implements IEasingFunction {
  5308. /**
  5309. * Interpolation follows the mathematical formula associated with the easing function.
  5310. */
  5311. static readonly EASINGMODE_EASEIN: number;
  5312. /**
  5313. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5314. */
  5315. static readonly EASINGMODE_EASEOUT: number;
  5316. /**
  5317. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5318. */
  5319. static readonly EASINGMODE_EASEINOUT: number;
  5320. private _easingMode;
  5321. /**
  5322. * Sets the easing mode of the current function.
  5323. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5324. */
  5325. setEasingMode(easingMode: number): void;
  5326. /**
  5327. * Gets the current easing mode.
  5328. * @returns the easing mode
  5329. */
  5330. getEasingMode(): number;
  5331. /**
  5332. * @hidden
  5333. */
  5334. easeInCore(gradient: number): number;
  5335. /**
  5336. * Given an input gradient between 0 and 1, this returns the corresponding value
  5337. * of the easing function.
  5338. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5339. * @returns the corresponding value on the curve defined by the easing function
  5340. */
  5341. ease(gradient: number): number;
  5342. }
  5343. /**
  5344. * Easing function with a circle shape (see link below).
  5345. * @see https://easings.net/#easeInCirc
  5346. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5347. */
  5348. export class CircleEase extends EasingFunction implements IEasingFunction {
  5349. /** @hidden */
  5350. easeInCore(gradient: number): number;
  5351. }
  5352. /**
  5353. * Easing function with a ease back shape (see link below).
  5354. * @see https://easings.net/#easeInBack
  5355. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5356. */
  5357. export class BackEase extends EasingFunction implements IEasingFunction {
  5358. /** Defines the amplitude of the function */
  5359. amplitude: number;
  5360. /**
  5361. * Instantiates a back ease easing
  5362. * @see https://easings.net/#easeInBack
  5363. * @param amplitude Defines the amplitude of the function
  5364. */
  5365. constructor(
  5366. /** Defines the amplitude of the function */
  5367. amplitude?: number);
  5368. /** @hidden */
  5369. easeInCore(gradient: number): number;
  5370. }
  5371. /**
  5372. * Easing function with a bouncing shape (see link below).
  5373. * @see https://easings.net/#easeInBounce
  5374. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5375. */
  5376. export class BounceEase extends EasingFunction implements IEasingFunction {
  5377. /** Defines the number of bounces */
  5378. bounces: number;
  5379. /** Defines the amplitude of the bounce */
  5380. bounciness: number;
  5381. /**
  5382. * Instantiates a bounce easing
  5383. * @see https://easings.net/#easeInBounce
  5384. * @param bounces Defines the number of bounces
  5385. * @param bounciness Defines the amplitude of the bounce
  5386. */
  5387. constructor(
  5388. /** Defines the number of bounces */
  5389. bounces?: number,
  5390. /** Defines the amplitude of the bounce */
  5391. bounciness?: number);
  5392. /** @hidden */
  5393. easeInCore(gradient: number): number;
  5394. }
  5395. /**
  5396. * Easing function with a power of 3 shape (see link below).
  5397. * @see https://easings.net/#easeInCubic
  5398. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5399. */
  5400. export class CubicEase extends EasingFunction implements IEasingFunction {
  5401. /** @hidden */
  5402. easeInCore(gradient: number): number;
  5403. }
  5404. /**
  5405. * Easing function with an elastic shape (see link below).
  5406. * @see https://easings.net/#easeInElastic
  5407. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5408. */
  5409. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5410. /** Defines the number of oscillations*/
  5411. oscillations: number;
  5412. /** Defines the amplitude of the oscillations*/
  5413. springiness: number;
  5414. /**
  5415. * Instantiates an elastic easing function
  5416. * @see https://easings.net/#easeInElastic
  5417. * @param oscillations Defines the number of oscillations
  5418. * @param springiness Defines the amplitude of the oscillations
  5419. */
  5420. constructor(
  5421. /** Defines the number of oscillations*/
  5422. oscillations?: number,
  5423. /** Defines the amplitude of the oscillations*/
  5424. springiness?: number);
  5425. /** @hidden */
  5426. easeInCore(gradient: number): number;
  5427. }
  5428. /**
  5429. * Easing function with an exponential shape (see link below).
  5430. * @see https://easings.net/#easeInExpo
  5431. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5432. */
  5433. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5434. /** Defines the exponent of the function */
  5435. exponent: number;
  5436. /**
  5437. * Instantiates an exponential easing function
  5438. * @see https://easings.net/#easeInExpo
  5439. * @param exponent Defines the exponent of the function
  5440. */
  5441. constructor(
  5442. /** Defines the exponent of the function */
  5443. exponent?: number);
  5444. /** @hidden */
  5445. easeInCore(gradient: number): number;
  5446. }
  5447. /**
  5448. * Easing function with a power shape (see link below).
  5449. * @see https://easings.net/#easeInQuad
  5450. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5451. */
  5452. export class PowerEase extends EasingFunction implements IEasingFunction {
  5453. /** Defines the power of the function */
  5454. power: number;
  5455. /**
  5456. * Instantiates an power base easing function
  5457. * @see https://easings.net/#easeInQuad
  5458. * @param power Defines the power of the function
  5459. */
  5460. constructor(
  5461. /** Defines the power of the function */
  5462. power?: number);
  5463. /** @hidden */
  5464. easeInCore(gradient: number): number;
  5465. }
  5466. /**
  5467. * Easing function with a power of 2 shape (see link below).
  5468. * @see https://easings.net/#easeInQuad
  5469. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5470. */
  5471. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5472. /** @hidden */
  5473. easeInCore(gradient: number): number;
  5474. }
  5475. /**
  5476. * Easing function with a power of 4 shape (see link below).
  5477. * @see https://easings.net/#easeInQuart
  5478. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5479. */
  5480. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5481. /** @hidden */
  5482. easeInCore(gradient: number): number;
  5483. }
  5484. /**
  5485. * Easing function with a power of 5 shape (see link below).
  5486. * @see https://easings.net/#easeInQuint
  5487. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5488. */
  5489. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5490. /** @hidden */
  5491. easeInCore(gradient: number): number;
  5492. }
  5493. /**
  5494. * Easing function with a sin shape (see link below).
  5495. * @see https://easings.net/#easeInSine
  5496. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5497. */
  5498. export class SineEase extends EasingFunction implements IEasingFunction {
  5499. /** @hidden */
  5500. easeInCore(gradient: number): number;
  5501. }
  5502. /**
  5503. * Easing function with a bezier shape (see link below).
  5504. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5505. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5506. */
  5507. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5508. /** Defines the x component of the start tangent in the bezier curve */
  5509. x1: number;
  5510. /** Defines the y component of the start tangent in the bezier curve */
  5511. y1: number;
  5512. /** Defines the x component of the end tangent in the bezier curve */
  5513. x2: number;
  5514. /** Defines the y component of the end tangent in the bezier curve */
  5515. y2: number;
  5516. /**
  5517. * Instantiates a bezier function
  5518. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5519. * @param x1 Defines the x component of the start tangent in the bezier curve
  5520. * @param y1 Defines the y component of the start tangent in the bezier curve
  5521. * @param x2 Defines the x component of the end tangent in the bezier curve
  5522. * @param y2 Defines the y component of the end tangent in the bezier curve
  5523. */
  5524. constructor(
  5525. /** Defines the x component of the start tangent in the bezier curve */
  5526. x1?: number,
  5527. /** Defines the y component of the start tangent in the bezier curve */
  5528. y1?: number,
  5529. /** Defines the x component of the end tangent in the bezier curve */
  5530. x2?: number,
  5531. /** Defines the y component of the end tangent in the bezier curve */
  5532. y2?: number);
  5533. /** @hidden */
  5534. easeInCore(gradient: number): number;
  5535. }
  5536. }
  5537. declare module "babylonjs/Maths/math.color" {
  5538. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5539. /**
  5540. * Class used to hold a RBG color
  5541. */
  5542. export class Color3 {
  5543. /**
  5544. * Defines the red component (between 0 and 1, default is 0)
  5545. */
  5546. r: number;
  5547. /**
  5548. * Defines the green component (between 0 and 1, default is 0)
  5549. */
  5550. g: number;
  5551. /**
  5552. * Defines the blue component (between 0 and 1, default is 0)
  5553. */
  5554. b: number;
  5555. /**
  5556. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5557. * @param r defines the red component (between 0 and 1, default is 0)
  5558. * @param g defines the green component (between 0 and 1, default is 0)
  5559. * @param b defines the blue component (between 0 and 1, default is 0)
  5560. */
  5561. constructor(
  5562. /**
  5563. * Defines the red component (between 0 and 1, default is 0)
  5564. */
  5565. r?: number,
  5566. /**
  5567. * Defines the green component (between 0 and 1, default is 0)
  5568. */
  5569. g?: number,
  5570. /**
  5571. * Defines the blue component (between 0 and 1, default is 0)
  5572. */
  5573. b?: number);
  5574. /**
  5575. * Creates a string with the Color3 current values
  5576. * @returns the string representation of the Color3 object
  5577. */
  5578. toString(): string;
  5579. /**
  5580. * Returns the string "Color3"
  5581. * @returns "Color3"
  5582. */
  5583. getClassName(): string;
  5584. /**
  5585. * Compute the Color3 hash code
  5586. * @returns an unique number that can be used to hash Color3 objects
  5587. */
  5588. getHashCode(): number;
  5589. /**
  5590. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5591. * @param array defines the array where to store the r,g,b components
  5592. * @param index defines an optional index in the target array to define where to start storing values
  5593. * @returns the current Color3 object
  5594. */
  5595. toArray(array: FloatArray, index?: number): Color3;
  5596. /**
  5597. * Update the current color with values stored in an array from the starting index of the given array
  5598. * @param array defines the source array
  5599. * @param offset defines an offset in the source array
  5600. * @returns the current Color3 object
  5601. */
  5602. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5603. /**
  5604. * Returns a new Color4 object from the current Color3 and the given alpha
  5605. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5606. * @returns a new Color4 object
  5607. */
  5608. toColor4(alpha?: number): Color4;
  5609. /**
  5610. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5611. * @returns the new array
  5612. */
  5613. asArray(): number[];
  5614. /**
  5615. * Returns the luminance value
  5616. * @returns a float value
  5617. */
  5618. toLuminance(): number;
  5619. /**
  5620. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5621. * @param otherColor defines the second operand
  5622. * @returns the new Color3 object
  5623. */
  5624. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5625. /**
  5626. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5627. * @param otherColor defines the second operand
  5628. * @param result defines the Color3 object where to store the result
  5629. * @returns the current Color3
  5630. */
  5631. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5632. /**
  5633. * Determines equality between Color3 objects
  5634. * @param otherColor defines the second operand
  5635. * @returns true if the rgb values are equal to the given ones
  5636. */
  5637. equals(otherColor: DeepImmutable<Color3>): boolean;
  5638. /**
  5639. * Determines equality between the current Color3 object and a set of r,b,g values
  5640. * @param r defines the red component to check
  5641. * @param g defines the green component to check
  5642. * @param b defines the blue component to check
  5643. * @returns true if the rgb values are equal to the given ones
  5644. */
  5645. equalsFloats(r: number, g: number, b: number): boolean;
  5646. /**
  5647. * Multiplies in place each rgb value by scale
  5648. * @param scale defines the scaling factor
  5649. * @returns the updated Color3
  5650. */
  5651. scale(scale: number): Color3;
  5652. /**
  5653. * Multiplies the rgb values by scale and stores the result into "result"
  5654. * @param scale defines the scaling factor
  5655. * @param result defines the Color3 object where to store the result
  5656. * @returns the unmodified current Color3
  5657. */
  5658. scaleToRef(scale: number, result: Color3): Color3;
  5659. /**
  5660. * Scale the current Color3 values by a factor and add the result to a given Color3
  5661. * @param scale defines the scale factor
  5662. * @param result defines color to store the result into
  5663. * @returns the unmodified current Color3
  5664. */
  5665. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5666. /**
  5667. * Clamps the rgb values by the min and max values and stores the result into "result"
  5668. * @param min defines minimum clamping value (default is 0)
  5669. * @param max defines maximum clamping value (default is 1)
  5670. * @param result defines color to store the result into
  5671. * @returns the original Color3
  5672. */
  5673. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5674. /**
  5675. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5676. * @param otherColor defines the second operand
  5677. * @returns the new Color3
  5678. */
  5679. add(otherColor: DeepImmutable<Color3>): Color3;
  5680. /**
  5681. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5682. * @param otherColor defines the second operand
  5683. * @param result defines Color3 object to store the result into
  5684. * @returns the unmodified current Color3
  5685. */
  5686. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5687. /**
  5688. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5689. * @param otherColor defines the second operand
  5690. * @returns the new Color3
  5691. */
  5692. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5693. /**
  5694. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5695. * @param otherColor defines the second operand
  5696. * @param result defines Color3 object to store the result into
  5697. * @returns the unmodified current Color3
  5698. */
  5699. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5700. /**
  5701. * Copy the current object
  5702. * @returns a new Color3 copied the current one
  5703. */
  5704. clone(): Color3;
  5705. /**
  5706. * Copies the rgb values from the source in the current Color3
  5707. * @param source defines the source Color3 object
  5708. * @returns the updated Color3 object
  5709. */
  5710. copyFrom(source: DeepImmutable<Color3>): Color3;
  5711. /**
  5712. * Updates the Color3 rgb values from the given floats
  5713. * @param r defines the red component to read from
  5714. * @param g defines the green component to read from
  5715. * @param b defines the blue component to read from
  5716. * @returns the current Color3 object
  5717. */
  5718. copyFromFloats(r: number, g: number, b: number): Color3;
  5719. /**
  5720. * Updates the Color3 rgb values from the given floats
  5721. * @param r defines the red component to read from
  5722. * @param g defines the green component to read from
  5723. * @param b defines the blue component to read from
  5724. * @returns the current Color3 object
  5725. */
  5726. set(r: number, g: number, b: number): Color3;
  5727. /**
  5728. * Compute the Color3 hexadecimal code as a string
  5729. * @returns a string containing the hexadecimal representation of the Color3 object
  5730. */
  5731. toHexString(): string;
  5732. /**
  5733. * Computes a new Color3 converted from the current one to linear space
  5734. * @returns a new Color3 object
  5735. */
  5736. toLinearSpace(): Color3;
  5737. /**
  5738. * Converts current color in rgb space to HSV values
  5739. * @returns a new color3 representing the HSV values
  5740. */
  5741. toHSV(): Color3;
  5742. /**
  5743. * Converts current color in rgb space to HSV values
  5744. * @param result defines the Color3 where to store the HSV values
  5745. */
  5746. toHSVToRef(result: Color3): void;
  5747. /**
  5748. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5749. * @param convertedColor defines the Color3 object where to store the linear space version
  5750. * @returns the unmodified Color3
  5751. */
  5752. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5753. /**
  5754. * Computes a new Color3 converted from the current one to gamma space
  5755. * @returns a new Color3 object
  5756. */
  5757. toGammaSpace(): Color3;
  5758. /**
  5759. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5760. * @param convertedColor defines the Color3 object where to store the gamma space version
  5761. * @returns the unmodified Color3
  5762. */
  5763. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5764. private static _BlackReadOnly;
  5765. /**
  5766. * Convert Hue, saturation and value to a Color3 (RGB)
  5767. * @param hue defines the hue
  5768. * @param saturation defines the saturation
  5769. * @param value defines the value
  5770. * @param result defines the Color3 where to store the RGB values
  5771. */
  5772. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5773. /**
  5774. * Creates a new Color3 from the string containing valid hexadecimal values
  5775. * @param hex defines a string containing valid hexadecimal values
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromHexString(hex: string): Color3;
  5779. /**
  5780. * Creates a new Color3 from the starting index of the given array
  5781. * @param array defines the source array
  5782. * @param offset defines an offset in the source array
  5783. * @returns a new Color3 object
  5784. */
  5785. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5786. /**
  5787. * Creates a new Color3 from the starting index element of the given array
  5788. * @param array defines the source array to read from
  5789. * @param offset defines the offset in the source array
  5790. * @param result defines the target Color3 object
  5791. */
  5792. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5793. /**
  5794. * Creates a new Color3 from integer values (< 256)
  5795. * @param r defines the red component to read from (value between 0 and 255)
  5796. * @param g defines the green component to read from (value between 0 and 255)
  5797. * @param b defines the blue component to read from (value between 0 and 255)
  5798. * @returns a new Color3 object
  5799. */
  5800. static FromInts(r: number, g: number, b: number): Color3;
  5801. /**
  5802. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5803. * @param start defines the start Color3 value
  5804. * @param end defines the end Color3 value
  5805. * @param amount defines the gradient value between start and end
  5806. * @returns a new Color3 object
  5807. */
  5808. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5809. /**
  5810. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5811. * @param left defines the start value
  5812. * @param right defines the end value
  5813. * @param amount defines the gradient factor
  5814. * @param result defines the Color3 object where to store the result
  5815. */
  5816. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5817. /**
  5818. * Returns a Color3 value containing a red color
  5819. * @returns a new Color3 object
  5820. */
  5821. static Red(): Color3;
  5822. /**
  5823. * Returns a Color3 value containing a green color
  5824. * @returns a new Color3 object
  5825. */
  5826. static Green(): Color3;
  5827. /**
  5828. * Returns a Color3 value containing a blue color
  5829. * @returns a new Color3 object
  5830. */
  5831. static Blue(): Color3;
  5832. /**
  5833. * Returns a Color3 value containing a black color
  5834. * @returns a new Color3 object
  5835. */
  5836. static Black(): Color3;
  5837. /**
  5838. * Gets a Color3 value containing a black color that must not be updated
  5839. */
  5840. static get BlackReadOnly(): DeepImmutable<Color3>;
  5841. /**
  5842. * Returns a Color3 value containing a white color
  5843. * @returns a new Color3 object
  5844. */
  5845. static White(): Color3;
  5846. /**
  5847. * Returns a Color3 value containing a purple color
  5848. * @returns a new Color3 object
  5849. */
  5850. static Purple(): Color3;
  5851. /**
  5852. * Returns a Color3 value containing a magenta color
  5853. * @returns a new Color3 object
  5854. */
  5855. static Magenta(): Color3;
  5856. /**
  5857. * Returns a Color3 value containing a yellow color
  5858. * @returns a new Color3 object
  5859. */
  5860. static Yellow(): Color3;
  5861. /**
  5862. * Returns a Color3 value containing a gray color
  5863. * @returns a new Color3 object
  5864. */
  5865. static Gray(): Color3;
  5866. /**
  5867. * Returns a Color3 value containing a teal color
  5868. * @returns a new Color3 object
  5869. */
  5870. static Teal(): Color3;
  5871. /**
  5872. * Returns a Color3 value containing a random color
  5873. * @returns a new Color3 object
  5874. */
  5875. static Random(): Color3;
  5876. }
  5877. /**
  5878. * Class used to hold a RBGA color
  5879. */
  5880. export class Color4 {
  5881. /**
  5882. * Defines the red component (between 0 and 1, default is 0)
  5883. */
  5884. r: number;
  5885. /**
  5886. * Defines the green component (between 0 and 1, default is 0)
  5887. */
  5888. g: number;
  5889. /**
  5890. * Defines the blue component (between 0 and 1, default is 0)
  5891. */
  5892. b: number;
  5893. /**
  5894. * Defines the alpha component (between 0 and 1, default is 1)
  5895. */
  5896. a: number;
  5897. /**
  5898. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5899. * @param r defines the red component (between 0 and 1, default is 0)
  5900. * @param g defines the green component (between 0 and 1, default is 0)
  5901. * @param b defines the blue component (between 0 and 1, default is 0)
  5902. * @param a defines the alpha component (between 0 and 1, default is 1)
  5903. */
  5904. constructor(
  5905. /**
  5906. * Defines the red component (between 0 and 1, default is 0)
  5907. */
  5908. r?: number,
  5909. /**
  5910. * Defines the green component (between 0 and 1, default is 0)
  5911. */
  5912. g?: number,
  5913. /**
  5914. * Defines the blue component (between 0 and 1, default is 0)
  5915. */
  5916. b?: number,
  5917. /**
  5918. * Defines the alpha component (between 0 and 1, default is 1)
  5919. */
  5920. a?: number);
  5921. /**
  5922. * Adds in place the given Color4 values to the current Color4 object
  5923. * @param right defines the second operand
  5924. * @returns the current updated Color4 object
  5925. */
  5926. addInPlace(right: DeepImmutable<Color4>): Color4;
  5927. /**
  5928. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5929. * @returns the new array
  5930. */
  5931. asArray(): number[];
  5932. /**
  5933. * Stores from the starting index in the given array the Color4 successive values
  5934. * @param array defines the array where to store the r,g,b components
  5935. * @param index defines an optional index in the target array to define where to start storing values
  5936. * @returns the current Color4 object
  5937. */
  5938. toArray(array: number[], index?: number): Color4;
  5939. /**
  5940. * Update the current color with values stored in an array from the starting index of the given array
  5941. * @param array defines the source array
  5942. * @param offset defines an offset in the source array
  5943. * @returns the current Color4 object
  5944. */
  5945. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5946. /**
  5947. * Determines equality between Color4 objects
  5948. * @param otherColor defines the second operand
  5949. * @returns true if the rgba values are equal to the given ones
  5950. */
  5951. equals(otherColor: DeepImmutable<Color4>): boolean;
  5952. /**
  5953. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5954. * @param right defines the second operand
  5955. * @returns a new Color4 object
  5956. */
  5957. add(right: DeepImmutable<Color4>): Color4;
  5958. /**
  5959. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5960. * @param right defines the second operand
  5961. * @returns a new Color4 object
  5962. */
  5963. subtract(right: DeepImmutable<Color4>): Color4;
  5964. /**
  5965. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5966. * @param right defines the second operand
  5967. * @param result defines the Color4 object where to store the result
  5968. * @returns the current Color4 object
  5969. */
  5970. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5971. /**
  5972. * Creates a new Color4 with the current Color4 values multiplied by scale
  5973. * @param scale defines the scaling factor to apply
  5974. * @returns a new Color4 object
  5975. */
  5976. scale(scale: number): Color4;
  5977. /**
  5978. * Multiplies the current Color4 values by scale and stores the result in "result"
  5979. * @param scale defines the scaling factor to apply
  5980. * @param result defines the Color4 object where to store the result
  5981. * @returns the current unmodified Color4
  5982. */
  5983. scaleToRef(scale: number, result: Color4): Color4;
  5984. /**
  5985. * Scale the current Color4 values by a factor and add the result to a given Color4
  5986. * @param scale defines the scale factor
  5987. * @param result defines the Color4 object where to store the result
  5988. * @returns the unmodified current Color4
  5989. */
  5990. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5991. /**
  5992. * Clamps the rgb values by the min and max values and stores the result into "result"
  5993. * @param min defines minimum clamping value (default is 0)
  5994. * @param max defines maximum clamping value (default is 1)
  5995. * @param result defines color to store the result into.
  5996. * @returns the cuurent Color4
  5997. */
  5998. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5999. /**
  6000. * Multipy an Color4 value by another and return a new Color4 object
  6001. * @param color defines the Color4 value to multiply by
  6002. * @returns a new Color4 object
  6003. */
  6004. multiply(color: Color4): Color4;
  6005. /**
  6006. * Multipy a Color4 value by another and push the result in a reference value
  6007. * @param color defines the Color4 value to multiply by
  6008. * @param result defines the Color4 to fill the result in
  6009. * @returns the result Color4
  6010. */
  6011. multiplyToRef(color: Color4, result: Color4): Color4;
  6012. /**
  6013. * Creates a string with the Color4 current values
  6014. * @returns the string representation of the Color4 object
  6015. */
  6016. toString(): string;
  6017. /**
  6018. * Returns the string "Color4"
  6019. * @returns "Color4"
  6020. */
  6021. getClassName(): string;
  6022. /**
  6023. * Compute the Color4 hash code
  6024. * @returns an unique number that can be used to hash Color4 objects
  6025. */
  6026. getHashCode(): number;
  6027. /**
  6028. * Creates a new Color4 copied from the current one
  6029. * @returns a new Color4 object
  6030. */
  6031. clone(): Color4;
  6032. /**
  6033. * Copies the given Color4 values into the current one
  6034. * @param source defines the source Color4 object
  6035. * @returns the current updated Color4 object
  6036. */
  6037. copyFrom(source: Color4): Color4;
  6038. /**
  6039. * Copies the given float values into the current one
  6040. * @param r defines the red component to read from
  6041. * @param g defines the green component to read from
  6042. * @param b defines the blue component to read from
  6043. * @param a defines the alpha component to read from
  6044. * @returns the current updated Color4 object
  6045. */
  6046. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6047. /**
  6048. * Copies the given float values into the current one
  6049. * @param r defines the red component to read from
  6050. * @param g defines the green component to read from
  6051. * @param b defines the blue component to read from
  6052. * @param a defines the alpha component to read from
  6053. * @returns the current updated Color4 object
  6054. */
  6055. set(r: number, g: number, b: number, a: number): Color4;
  6056. /**
  6057. * Compute the Color4 hexadecimal code as a string
  6058. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6059. * @returns a string containing the hexadecimal representation of the Color4 object
  6060. */
  6061. toHexString(returnAsColor3?: boolean): string;
  6062. /**
  6063. * Computes a new Color4 converted from the current one to linear space
  6064. * @returns a new Color4 object
  6065. */
  6066. toLinearSpace(): Color4;
  6067. /**
  6068. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6069. * @param convertedColor defines the Color4 object where to store the linear space version
  6070. * @returns the unmodified Color4
  6071. */
  6072. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6073. /**
  6074. * Computes a new Color4 converted from the current one to gamma space
  6075. * @returns a new Color4 object
  6076. */
  6077. toGammaSpace(): Color4;
  6078. /**
  6079. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6080. * @param convertedColor defines the Color4 object where to store the gamma space version
  6081. * @returns the unmodified Color4
  6082. */
  6083. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6084. /**
  6085. * Creates a new Color4 from the string containing valid hexadecimal values
  6086. * @param hex defines a string containing valid hexadecimal values
  6087. * @returns a new Color4 object
  6088. */
  6089. static FromHexString(hex: string): Color4;
  6090. /**
  6091. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6092. * @param left defines the start value
  6093. * @param right defines the end value
  6094. * @param amount defines the gradient factor
  6095. * @returns a new Color4 object
  6096. */
  6097. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6098. /**
  6099. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6100. * @param left defines the start value
  6101. * @param right defines the end value
  6102. * @param amount defines the gradient factor
  6103. * @param result defines the Color4 object where to store data
  6104. */
  6105. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6106. /**
  6107. * Creates a new Color4 from a Color3 and an alpha value
  6108. * @param color3 defines the source Color3 to read from
  6109. * @param alpha defines the alpha component (1.0 by default)
  6110. * @returns a new Color4 object
  6111. */
  6112. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6113. /**
  6114. * Creates a new Color4 from the starting index element of the given array
  6115. * @param array defines the source array to read from
  6116. * @param offset defines the offset in the source array
  6117. * @returns a new Color4 object
  6118. */
  6119. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6120. /**
  6121. * Creates a new Color4 from the starting index element of the given array
  6122. * @param array defines the source array to read from
  6123. * @param offset defines the offset in the source array
  6124. * @param result defines the target Color4 object
  6125. */
  6126. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6127. /**
  6128. * Creates a new Color3 from integer values (< 256)
  6129. * @param r defines the red component to read from (value between 0 and 255)
  6130. * @param g defines the green component to read from (value between 0 and 255)
  6131. * @param b defines the blue component to read from (value between 0 and 255)
  6132. * @param a defines the alpha component to read from (value between 0 and 255)
  6133. * @returns a new Color3 object
  6134. */
  6135. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6136. /**
  6137. * Check the content of a given array and convert it to an array containing RGBA data
  6138. * If the original array was already containing count * 4 values then it is returned directly
  6139. * @param colors defines the array to check
  6140. * @param count defines the number of RGBA data to expect
  6141. * @returns an array containing count * 4 values (RGBA)
  6142. */
  6143. static CheckColors4(colors: number[], count: number): number[];
  6144. }
  6145. /**
  6146. * @hidden
  6147. */
  6148. export class TmpColors {
  6149. static Color3: Color3[];
  6150. static Color4: Color4[];
  6151. }
  6152. }
  6153. declare module "babylonjs/Animations/animationKey" {
  6154. /**
  6155. * Defines an interface which represents an animation key frame
  6156. */
  6157. export interface IAnimationKey {
  6158. /**
  6159. * Frame of the key frame
  6160. */
  6161. frame: number;
  6162. /**
  6163. * Value at the specifies key frame
  6164. */
  6165. value: any;
  6166. /**
  6167. * The input tangent for the cubic hermite spline
  6168. */
  6169. inTangent?: any;
  6170. /**
  6171. * The output tangent for the cubic hermite spline
  6172. */
  6173. outTangent?: any;
  6174. /**
  6175. * The animation interpolation type
  6176. */
  6177. interpolation?: AnimationKeyInterpolation;
  6178. }
  6179. /**
  6180. * Enum for the animation key frame interpolation type
  6181. */
  6182. export enum AnimationKeyInterpolation {
  6183. /**
  6184. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6185. */
  6186. STEP = 1
  6187. }
  6188. }
  6189. declare module "babylonjs/Animations/animationRange" {
  6190. /**
  6191. * Represents the range of an animation
  6192. */
  6193. export class AnimationRange {
  6194. /**The name of the animation range**/
  6195. name: string;
  6196. /**The starting frame of the animation */
  6197. from: number;
  6198. /**The ending frame of the animation*/
  6199. to: number;
  6200. /**
  6201. * Initializes the range of an animation
  6202. * @param name The name of the animation range
  6203. * @param from The starting frame of the animation
  6204. * @param to The ending frame of the animation
  6205. */
  6206. constructor(
  6207. /**The name of the animation range**/
  6208. name: string,
  6209. /**The starting frame of the animation */
  6210. from: number,
  6211. /**The ending frame of the animation*/
  6212. to: number);
  6213. /**
  6214. * Makes a copy of the animation range
  6215. * @returns A copy of the animation range
  6216. */
  6217. clone(): AnimationRange;
  6218. }
  6219. }
  6220. declare module "babylonjs/Animations/animationEvent" {
  6221. /**
  6222. * Composed of a frame, and an action function
  6223. */
  6224. export class AnimationEvent {
  6225. /** The frame for which the event is triggered **/
  6226. frame: number;
  6227. /** The event to perform when triggered **/
  6228. action: (currentFrame: number) => void;
  6229. /** Specifies if the event should be triggered only once**/
  6230. onlyOnce?: boolean | undefined;
  6231. /**
  6232. * Specifies if the animation event is done
  6233. */
  6234. isDone: boolean;
  6235. /**
  6236. * Initializes the animation event
  6237. * @param frame The frame for which the event is triggered
  6238. * @param action The event to perform when triggered
  6239. * @param onlyOnce Specifies if the event should be triggered only once
  6240. */
  6241. constructor(
  6242. /** The frame for which the event is triggered **/
  6243. frame: number,
  6244. /** The event to perform when triggered **/
  6245. action: (currentFrame: number) => void,
  6246. /** Specifies if the event should be triggered only once**/
  6247. onlyOnce?: boolean | undefined);
  6248. /** @hidden */
  6249. _clone(): AnimationEvent;
  6250. }
  6251. }
  6252. declare module "babylonjs/Behaviors/behavior" {
  6253. import { Nullable } from "babylonjs/types";
  6254. /**
  6255. * Interface used to define a behavior
  6256. */
  6257. export interface Behavior<T> {
  6258. /** gets or sets behavior's name */
  6259. name: string;
  6260. /**
  6261. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6262. */
  6263. init(): void;
  6264. /**
  6265. * Called when the behavior is attached to a target
  6266. * @param target defines the target where the behavior is attached to
  6267. */
  6268. attach(target: T): void;
  6269. /**
  6270. * Called when the behavior is detached from its target
  6271. */
  6272. detach(): void;
  6273. }
  6274. /**
  6275. * Interface implemented by classes supporting behaviors
  6276. */
  6277. export interface IBehaviorAware<T> {
  6278. /**
  6279. * Attach a behavior
  6280. * @param behavior defines the behavior to attach
  6281. * @returns the current host
  6282. */
  6283. addBehavior(behavior: Behavior<T>): T;
  6284. /**
  6285. * Remove a behavior from the current object
  6286. * @param behavior defines the behavior to detach
  6287. * @returns the current host
  6288. */
  6289. removeBehavior(behavior: Behavior<T>): T;
  6290. /**
  6291. * Gets a behavior using its name to search
  6292. * @param name defines the name to search
  6293. * @returns the behavior or null if not found
  6294. */
  6295. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6296. }
  6297. }
  6298. declare module "babylonjs/Misc/smartArray" {
  6299. /**
  6300. * Defines an array and its length.
  6301. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6302. */
  6303. export interface ISmartArrayLike<T> {
  6304. /**
  6305. * The data of the array.
  6306. */
  6307. data: Array<T>;
  6308. /**
  6309. * The active length of the array.
  6310. */
  6311. length: number;
  6312. }
  6313. /**
  6314. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6315. */
  6316. export class SmartArray<T> implements ISmartArrayLike<T> {
  6317. /**
  6318. * The full set of data from the array.
  6319. */
  6320. data: Array<T>;
  6321. /**
  6322. * The active length of the array.
  6323. */
  6324. length: number;
  6325. protected _id: number;
  6326. /**
  6327. * Instantiates a Smart Array.
  6328. * @param capacity defines the default capacity of the array.
  6329. */
  6330. constructor(capacity: number);
  6331. /**
  6332. * Pushes a value at the end of the active data.
  6333. * @param value defines the object to push in the array.
  6334. */
  6335. push(value: T): void;
  6336. /**
  6337. * Iterates over the active data and apply the lambda to them.
  6338. * @param func defines the action to apply on each value.
  6339. */
  6340. forEach(func: (content: T) => void): void;
  6341. /**
  6342. * Sorts the full sets of data.
  6343. * @param compareFn defines the comparison function to apply.
  6344. */
  6345. sort(compareFn: (a: T, b: T) => number): void;
  6346. /**
  6347. * Resets the active data to an empty array.
  6348. */
  6349. reset(): void;
  6350. /**
  6351. * Releases all the data from the array as well as the array.
  6352. */
  6353. dispose(): void;
  6354. /**
  6355. * Concats the active data with a given array.
  6356. * @param array defines the data to concatenate with.
  6357. */
  6358. concat(array: any): void;
  6359. /**
  6360. * Returns the position of a value in the active data.
  6361. * @param value defines the value to find the index for
  6362. * @returns the index if found in the active data otherwise -1
  6363. */
  6364. indexOf(value: T): number;
  6365. /**
  6366. * Returns whether an element is part of the active data.
  6367. * @param value defines the value to look for
  6368. * @returns true if found in the active data otherwise false
  6369. */
  6370. contains(value: T): boolean;
  6371. private static _GlobalId;
  6372. }
  6373. /**
  6374. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6375. * The data in this array can only be present once
  6376. */
  6377. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6378. private _duplicateId;
  6379. /**
  6380. * Pushes a value at the end of the active data.
  6381. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6382. * @param value defines the object to push in the array.
  6383. */
  6384. push(value: T): void;
  6385. /**
  6386. * Pushes a value at the end of the active data.
  6387. * If the data is already present, it won t be added again
  6388. * @param value defines the object to push in the array.
  6389. * @returns true if added false if it was already present
  6390. */
  6391. pushNoDuplicate(value: T): boolean;
  6392. /**
  6393. * Resets the active data to an empty array.
  6394. */
  6395. reset(): void;
  6396. /**
  6397. * Concats the active data with a given array.
  6398. * This ensures no dupplicate will be present in the result.
  6399. * @param array defines the data to concatenate with.
  6400. */
  6401. concatWithNoDuplicate(array: any): void;
  6402. }
  6403. }
  6404. declare module "babylonjs/Cameras/cameraInputsManager" {
  6405. import { Nullable } from "babylonjs/types";
  6406. import { Camera } from "babylonjs/Cameras/camera";
  6407. /**
  6408. * @ignore
  6409. * This is a list of all the different input types that are available in the application.
  6410. * Fo instance: ArcRotateCameraGamepadInput...
  6411. */
  6412. export var CameraInputTypes: {};
  6413. /**
  6414. * This is the contract to implement in order to create a new input class.
  6415. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6416. */
  6417. export interface ICameraInput<TCamera extends Camera> {
  6418. /**
  6419. * Defines the camera the input is attached to.
  6420. */
  6421. camera: Nullable<TCamera>;
  6422. /**
  6423. * Gets the class name of the current intput.
  6424. * @returns the class name
  6425. */
  6426. getClassName(): string;
  6427. /**
  6428. * Get the friendly name associated with the input class.
  6429. * @returns the input friendly name
  6430. */
  6431. getSimpleName(): string;
  6432. /**
  6433. * Attach the input controls to a specific dom element to get the input from.
  6434. * @param element Defines the element the controls should be listened from
  6435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6436. */
  6437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6438. /**
  6439. * Detach the current controls from the specified dom element.
  6440. * @param element Defines the element to stop listening the inputs from
  6441. */
  6442. detachControl(element: Nullable<HTMLElement>): void;
  6443. /**
  6444. * Update the current camera state depending on the inputs that have been used this frame.
  6445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6446. */
  6447. checkInputs?: () => void;
  6448. }
  6449. /**
  6450. * Represents a map of input types to input instance or input index to input instance.
  6451. */
  6452. export interface CameraInputsMap<TCamera extends Camera> {
  6453. /**
  6454. * Accessor to the input by input type.
  6455. */
  6456. [name: string]: ICameraInput<TCamera>;
  6457. /**
  6458. * Accessor to the input by input index.
  6459. */
  6460. [idx: number]: ICameraInput<TCamera>;
  6461. }
  6462. /**
  6463. * This represents the input manager used within a camera.
  6464. * It helps dealing with all the different kind of input attached to a camera.
  6465. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6466. */
  6467. export class CameraInputsManager<TCamera extends Camera> {
  6468. /**
  6469. * Defines the list of inputs attahed to the camera.
  6470. */
  6471. attached: CameraInputsMap<TCamera>;
  6472. /**
  6473. * Defines the dom element the camera is collecting inputs from.
  6474. * This is null if the controls have not been attached.
  6475. */
  6476. attachedElement: Nullable<HTMLElement>;
  6477. /**
  6478. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6479. */
  6480. noPreventDefault: boolean;
  6481. /**
  6482. * Defined the camera the input manager belongs to.
  6483. */
  6484. camera: TCamera;
  6485. /**
  6486. * Update the current camera state depending on the inputs that have been used this frame.
  6487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6488. */
  6489. checkInputs: () => void;
  6490. /**
  6491. * Instantiate a new Camera Input Manager.
  6492. * @param camera Defines the camera the input manager blongs to
  6493. */
  6494. constructor(camera: TCamera);
  6495. /**
  6496. * Add an input method to a camera
  6497. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6498. * @param input camera input method
  6499. */
  6500. add(input: ICameraInput<TCamera>): void;
  6501. /**
  6502. * Remove a specific input method from a camera
  6503. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6504. * @param inputToRemove camera input method
  6505. */
  6506. remove(inputToRemove: ICameraInput<TCamera>): void;
  6507. /**
  6508. * Remove a specific input type from a camera
  6509. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6510. * @param inputType the type of the input to remove
  6511. */
  6512. removeByType(inputType: string): void;
  6513. private _addCheckInputs;
  6514. /**
  6515. * Attach the input controls to the currently attached dom element to listen the events from.
  6516. * @param input Defines the input to attach
  6517. */
  6518. attachInput(input: ICameraInput<TCamera>): void;
  6519. /**
  6520. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6521. * @param element Defines the dom element to collect the events from
  6522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6523. */
  6524. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6525. /**
  6526. * Detach the current manager inputs controls from a specific dom element.
  6527. * @param element Defines the dom element to collect the events from
  6528. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6529. */
  6530. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6531. /**
  6532. * Rebuild the dynamic inputCheck function from the current list of
  6533. * defined inputs in the manager.
  6534. */
  6535. rebuildInputCheck(): void;
  6536. /**
  6537. * Remove all attached input methods from a camera
  6538. */
  6539. clear(): void;
  6540. /**
  6541. * Serialize the current input manager attached to a camera.
  6542. * This ensures than once parsed,
  6543. * the input associated to the camera will be identical to the current ones
  6544. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6545. */
  6546. serialize(serializedCamera: any): void;
  6547. /**
  6548. * Parses an input manager serialized JSON to restore the previous list of inputs
  6549. * and states associated to a camera.
  6550. * @param parsedCamera Defines the JSON to parse
  6551. */
  6552. parse(parsedCamera: any): void;
  6553. }
  6554. }
  6555. declare module "babylonjs/Meshes/buffer" {
  6556. import { Nullable, DataArray } from "babylonjs/types";
  6557. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6558. /**
  6559. * Class used to store data that will be store in GPU memory
  6560. */
  6561. export class Buffer {
  6562. private _engine;
  6563. private _buffer;
  6564. /** @hidden */
  6565. _data: Nullable<DataArray>;
  6566. private _updatable;
  6567. private _instanced;
  6568. private _divisor;
  6569. /**
  6570. * Gets the byte stride.
  6571. */
  6572. readonly byteStride: number;
  6573. /**
  6574. * Constructor
  6575. * @param engine the engine
  6576. * @param data the data to use for this buffer
  6577. * @param updatable whether the data is updatable
  6578. * @param stride the stride (optional)
  6579. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6580. * @param instanced whether the buffer is instanced (optional)
  6581. * @param useBytes set to true if the stride in in bytes (optional)
  6582. * @param divisor sets an optional divisor for instances (1 by default)
  6583. */
  6584. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6585. /**
  6586. * Create a new VertexBuffer based on the current buffer
  6587. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6588. * @param offset defines offset in the buffer (0 by default)
  6589. * @param size defines the size in floats of attributes (position is 3 for instance)
  6590. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6591. * @param instanced defines if the vertex buffer contains indexed data
  6592. * @param useBytes defines if the offset and stride are in bytes *
  6593. * @param divisor sets an optional divisor for instances (1 by default)
  6594. * @returns the new vertex buffer
  6595. */
  6596. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6597. /**
  6598. * Gets a boolean indicating if the Buffer is updatable?
  6599. * @returns true if the buffer is updatable
  6600. */
  6601. isUpdatable(): boolean;
  6602. /**
  6603. * Gets current buffer's data
  6604. * @returns a DataArray or null
  6605. */
  6606. getData(): Nullable<DataArray>;
  6607. /**
  6608. * Gets underlying native buffer
  6609. * @returns underlying native buffer
  6610. */
  6611. getBuffer(): Nullable<DataBuffer>;
  6612. /**
  6613. * Gets the stride in float32 units (i.e. byte stride / 4).
  6614. * May not be an integer if the byte stride is not divisible by 4.
  6615. * @returns the stride in float32 units
  6616. * @deprecated Please use byteStride instead.
  6617. */
  6618. getStrideSize(): number;
  6619. /**
  6620. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6621. * @param data defines the data to store
  6622. */
  6623. create(data?: Nullable<DataArray>): void;
  6624. /** @hidden */
  6625. _rebuild(): void;
  6626. /**
  6627. * Update current buffer data
  6628. * @param data defines the data to store
  6629. */
  6630. update(data: DataArray): void;
  6631. /**
  6632. * Updates the data directly.
  6633. * @param data the new data
  6634. * @param offset the new offset
  6635. * @param vertexCount the vertex count (optional)
  6636. * @param useBytes set to true if the offset is in bytes
  6637. */
  6638. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6639. /**
  6640. * Release all resources
  6641. */
  6642. dispose(): void;
  6643. }
  6644. /**
  6645. * Specialized buffer used to store vertex data
  6646. */
  6647. export class VertexBuffer {
  6648. /** @hidden */
  6649. _buffer: Buffer;
  6650. private _kind;
  6651. private _size;
  6652. private _ownsBuffer;
  6653. private _instanced;
  6654. private _instanceDivisor;
  6655. /**
  6656. * The byte type.
  6657. */
  6658. static readonly BYTE: number;
  6659. /**
  6660. * The unsigned byte type.
  6661. */
  6662. static readonly UNSIGNED_BYTE: number;
  6663. /**
  6664. * The short type.
  6665. */
  6666. static readonly SHORT: number;
  6667. /**
  6668. * The unsigned short type.
  6669. */
  6670. static readonly UNSIGNED_SHORT: number;
  6671. /**
  6672. * The integer type.
  6673. */
  6674. static readonly INT: number;
  6675. /**
  6676. * The unsigned integer type.
  6677. */
  6678. static readonly UNSIGNED_INT: number;
  6679. /**
  6680. * The float type.
  6681. */
  6682. static readonly FLOAT: number;
  6683. /**
  6684. * Gets or sets the instance divisor when in instanced mode
  6685. */
  6686. get instanceDivisor(): number;
  6687. set instanceDivisor(value: number);
  6688. /**
  6689. * Gets the byte stride.
  6690. */
  6691. readonly byteStride: number;
  6692. /**
  6693. * Gets the byte offset.
  6694. */
  6695. readonly byteOffset: number;
  6696. /**
  6697. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6698. */
  6699. readonly normalized: boolean;
  6700. /**
  6701. * Gets the data type of each component in the array.
  6702. */
  6703. readonly type: number;
  6704. /**
  6705. * Constructor
  6706. * @param engine the engine
  6707. * @param data the data to use for this vertex buffer
  6708. * @param kind the vertex buffer kind
  6709. * @param updatable whether the data is updatable
  6710. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6711. * @param stride the stride (optional)
  6712. * @param instanced whether the buffer is instanced (optional)
  6713. * @param offset the offset of the data (optional)
  6714. * @param size the number of components (optional)
  6715. * @param type the type of the component (optional)
  6716. * @param normalized whether the data contains normalized data (optional)
  6717. * @param useBytes set to true if stride and offset are in bytes (optional)
  6718. * @param divisor defines the instance divisor to use (1 by default)
  6719. */
  6720. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6721. /** @hidden */
  6722. _rebuild(): void;
  6723. /**
  6724. * Returns the kind of the VertexBuffer (string)
  6725. * @returns a string
  6726. */
  6727. getKind(): string;
  6728. /**
  6729. * Gets a boolean indicating if the VertexBuffer is updatable?
  6730. * @returns true if the buffer is updatable
  6731. */
  6732. isUpdatable(): boolean;
  6733. /**
  6734. * Gets current buffer's data
  6735. * @returns a DataArray or null
  6736. */
  6737. getData(): Nullable<DataArray>;
  6738. /**
  6739. * Gets underlying native buffer
  6740. * @returns underlying native buffer
  6741. */
  6742. getBuffer(): Nullable<DataBuffer>;
  6743. /**
  6744. * Gets the stride in float32 units (i.e. byte stride / 4).
  6745. * May not be an integer if the byte stride is not divisible by 4.
  6746. * @returns the stride in float32 units
  6747. * @deprecated Please use byteStride instead.
  6748. */
  6749. getStrideSize(): number;
  6750. /**
  6751. * Returns the offset as a multiple of the type byte length.
  6752. * @returns the offset in bytes
  6753. * @deprecated Please use byteOffset instead.
  6754. */
  6755. getOffset(): number;
  6756. /**
  6757. * Returns the number of components per vertex attribute (integer)
  6758. * @returns the size in float
  6759. */
  6760. getSize(): number;
  6761. /**
  6762. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6763. * @returns true if this buffer is instanced
  6764. */
  6765. getIsInstanced(): boolean;
  6766. /**
  6767. * Returns the instancing divisor, zero for non-instanced (integer).
  6768. * @returns a number
  6769. */
  6770. getInstanceDivisor(): number;
  6771. /**
  6772. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6773. * @param data defines the data to store
  6774. */
  6775. create(data?: DataArray): void;
  6776. /**
  6777. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6778. * This function will create a new buffer if the current one is not updatable
  6779. * @param data defines the data to store
  6780. */
  6781. update(data: DataArray): void;
  6782. /**
  6783. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6784. * Returns the directly updated WebGLBuffer.
  6785. * @param data the new data
  6786. * @param offset the new offset
  6787. * @param useBytes set to true if the offset is in bytes
  6788. */
  6789. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6790. /**
  6791. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6792. */
  6793. dispose(): void;
  6794. /**
  6795. * Enumerates each value of this vertex buffer as numbers.
  6796. * @param count the number of values to enumerate
  6797. * @param callback the callback function called for each value
  6798. */
  6799. forEach(count: number, callback: (value: number, index: number) => void): void;
  6800. /**
  6801. * Positions
  6802. */
  6803. static readonly PositionKind: string;
  6804. /**
  6805. * Normals
  6806. */
  6807. static readonly NormalKind: string;
  6808. /**
  6809. * Tangents
  6810. */
  6811. static readonly TangentKind: string;
  6812. /**
  6813. * Texture coordinates
  6814. */
  6815. static readonly UVKind: string;
  6816. /**
  6817. * Texture coordinates 2
  6818. */
  6819. static readonly UV2Kind: string;
  6820. /**
  6821. * Texture coordinates 3
  6822. */
  6823. static readonly UV3Kind: string;
  6824. /**
  6825. * Texture coordinates 4
  6826. */
  6827. static readonly UV4Kind: string;
  6828. /**
  6829. * Texture coordinates 5
  6830. */
  6831. static readonly UV5Kind: string;
  6832. /**
  6833. * Texture coordinates 6
  6834. */
  6835. static readonly UV6Kind: string;
  6836. /**
  6837. * Colors
  6838. */
  6839. static readonly ColorKind: string;
  6840. /**
  6841. * Matrix indices (for bones)
  6842. */
  6843. static readonly MatricesIndicesKind: string;
  6844. /**
  6845. * Matrix weights (for bones)
  6846. */
  6847. static readonly MatricesWeightsKind: string;
  6848. /**
  6849. * Additional matrix indices (for bones)
  6850. */
  6851. static readonly MatricesIndicesExtraKind: string;
  6852. /**
  6853. * Additional matrix weights (for bones)
  6854. */
  6855. static readonly MatricesWeightsExtraKind: string;
  6856. /**
  6857. * Deduces the stride given a kind.
  6858. * @param kind The kind string to deduce
  6859. * @returns The deduced stride
  6860. */
  6861. static DeduceStride(kind: string): number;
  6862. /**
  6863. * Gets the byte length of the given type.
  6864. * @param type the type
  6865. * @returns the number of bytes
  6866. */
  6867. static GetTypeByteLength(type: number): number;
  6868. /**
  6869. * Enumerates each value of the given parameters as numbers.
  6870. * @param data the data to enumerate
  6871. * @param byteOffset the byte offset of the data
  6872. * @param byteStride the byte stride of the data
  6873. * @param componentCount the number of components per element
  6874. * @param componentType the type of the component
  6875. * @param count the number of values to enumerate
  6876. * @param normalized whether the data is normalized
  6877. * @param callback the callback function called for each value
  6878. */
  6879. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6880. private static _GetFloatValue;
  6881. }
  6882. }
  6883. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6884. import { Vector3 } from "babylonjs/Maths/math.vector";
  6885. import { Mesh } from "babylonjs/Meshes/mesh";
  6886. /**
  6887. * The options Interface for creating a Capsule Mesh
  6888. */
  6889. export interface ICreateCapsuleOptions {
  6890. /** The Orientation of the capsule. Default : Vector3.Up() */
  6891. orientation?: Vector3;
  6892. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6893. subdivisions: number;
  6894. /** Number of cylindrical segments on the capsule. */
  6895. tessellation: number;
  6896. /** Height or Length of the capsule. */
  6897. height: number;
  6898. /** Radius of the capsule. */
  6899. radius: number;
  6900. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6901. capSubdivisions: number;
  6902. /** Overwrite for the top radius. */
  6903. radiusTop?: number;
  6904. /** Overwrite for the bottom radius. */
  6905. radiusBottom?: number;
  6906. /** Overwrite for the top capSubdivisions. */
  6907. topCapSubdivisions?: number;
  6908. /** Overwrite for the bottom capSubdivisions. */
  6909. bottomCapSubdivisions?: number;
  6910. }
  6911. /**
  6912. * Class containing static functions to help procedurally build meshes
  6913. */
  6914. export class CapsuleBuilder {
  6915. /**
  6916. * Creates a capsule or a pill mesh
  6917. * @param name defines the name of the mesh
  6918. * @param options The constructors options.
  6919. * @param scene The scene the mesh is scoped to.
  6920. * @returns Capsule Mesh
  6921. */
  6922. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6923. }
  6924. }
  6925. declare module "babylonjs/Collisions/intersectionInfo" {
  6926. import { Nullable } from "babylonjs/types";
  6927. /**
  6928. * @hidden
  6929. */
  6930. export class IntersectionInfo {
  6931. bu: Nullable<number>;
  6932. bv: Nullable<number>;
  6933. distance: number;
  6934. faceId: number;
  6935. subMeshId: number;
  6936. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6937. }
  6938. }
  6939. declare module "babylonjs/Culling/boundingSphere" {
  6940. import { DeepImmutable } from "babylonjs/types";
  6941. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6942. import { Plane } from "babylonjs/Maths/math.plane";
  6943. /**
  6944. * Class used to store bounding sphere information
  6945. */
  6946. export class BoundingSphere {
  6947. /**
  6948. * Gets the center of the bounding sphere in local space
  6949. */
  6950. readonly center: Vector3;
  6951. /**
  6952. * Radius of the bounding sphere in local space
  6953. */
  6954. radius: number;
  6955. /**
  6956. * Gets the center of the bounding sphere in world space
  6957. */
  6958. readonly centerWorld: Vector3;
  6959. /**
  6960. * Radius of the bounding sphere in world space
  6961. */
  6962. radiusWorld: number;
  6963. /**
  6964. * Gets the minimum vector in local space
  6965. */
  6966. readonly minimum: Vector3;
  6967. /**
  6968. * Gets the maximum vector in local space
  6969. */
  6970. readonly maximum: Vector3;
  6971. private _worldMatrix;
  6972. private static readonly TmpVector3;
  6973. /**
  6974. * Creates a new bounding sphere
  6975. * @param min defines the minimum vector (in local space)
  6976. * @param max defines the maximum vector (in local space)
  6977. * @param worldMatrix defines the new world matrix
  6978. */
  6979. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6980. /**
  6981. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6982. * @param min defines the new minimum vector (in local space)
  6983. * @param max defines the new maximum vector (in local space)
  6984. * @param worldMatrix defines the new world matrix
  6985. */
  6986. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6987. /**
  6988. * Scale the current bounding sphere by applying a scale factor
  6989. * @param factor defines the scale factor to apply
  6990. * @returns the current bounding box
  6991. */
  6992. scale(factor: number): BoundingSphere;
  6993. /**
  6994. * Gets the world matrix of the bounding box
  6995. * @returns a matrix
  6996. */
  6997. getWorldMatrix(): DeepImmutable<Matrix>;
  6998. /** @hidden */
  6999. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7000. /**
  7001. * Tests if the bounding sphere is intersecting the frustum planes
  7002. * @param frustumPlanes defines the frustum planes to test
  7003. * @returns true if there is an intersection
  7004. */
  7005. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7006. /**
  7007. * Tests if the bounding sphere center is in between the frustum planes.
  7008. * Used for optimistic fast inclusion.
  7009. * @param frustumPlanes defines the frustum planes to test
  7010. * @returns true if the sphere center is in between the frustum planes
  7011. */
  7012. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7013. /**
  7014. * Tests if a point is inside the bounding sphere
  7015. * @param point defines the point to test
  7016. * @returns true if the point is inside the bounding sphere
  7017. */
  7018. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7019. /**
  7020. * Checks if two sphere intersct
  7021. * @param sphere0 sphere 0
  7022. * @param sphere1 sphere 1
  7023. * @returns true if the speres intersect
  7024. */
  7025. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7026. }
  7027. }
  7028. declare module "babylonjs/Culling/boundingBox" {
  7029. import { DeepImmutable } from "babylonjs/types";
  7030. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7031. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7032. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7033. import { Plane } from "babylonjs/Maths/math.plane";
  7034. /**
  7035. * Class used to store bounding box information
  7036. */
  7037. export class BoundingBox implements ICullable {
  7038. /**
  7039. * Gets the 8 vectors representing the bounding box in local space
  7040. */
  7041. readonly vectors: Vector3[];
  7042. /**
  7043. * Gets the center of the bounding box in local space
  7044. */
  7045. readonly center: Vector3;
  7046. /**
  7047. * Gets the center of the bounding box in world space
  7048. */
  7049. readonly centerWorld: Vector3;
  7050. /**
  7051. * Gets the extend size in local space
  7052. */
  7053. readonly extendSize: Vector3;
  7054. /**
  7055. * Gets the extend size in world space
  7056. */
  7057. readonly extendSizeWorld: Vector3;
  7058. /**
  7059. * Gets the OBB (object bounding box) directions
  7060. */
  7061. readonly directions: Vector3[];
  7062. /**
  7063. * Gets the 8 vectors representing the bounding box in world space
  7064. */
  7065. readonly vectorsWorld: Vector3[];
  7066. /**
  7067. * Gets the minimum vector in world space
  7068. */
  7069. readonly minimumWorld: Vector3;
  7070. /**
  7071. * Gets the maximum vector in world space
  7072. */
  7073. readonly maximumWorld: Vector3;
  7074. /**
  7075. * Gets the minimum vector in local space
  7076. */
  7077. readonly minimum: Vector3;
  7078. /**
  7079. * Gets the maximum vector in local space
  7080. */
  7081. readonly maximum: Vector3;
  7082. private _worldMatrix;
  7083. private static readonly TmpVector3;
  7084. /**
  7085. * @hidden
  7086. */
  7087. _tag: number;
  7088. /**
  7089. * Creates a new bounding box
  7090. * @param min defines the minimum vector (in local space)
  7091. * @param max defines the maximum vector (in local space)
  7092. * @param worldMatrix defines the new world matrix
  7093. */
  7094. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7095. /**
  7096. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7097. * @param min defines the new minimum vector (in local space)
  7098. * @param max defines the new maximum vector (in local space)
  7099. * @param worldMatrix defines the new world matrix
  7100. */
  7101. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7102. /**
  7103. * Scale the current bounding box by applying a scale factor
  7104. * @param factor defines the scale factor to apply
  7105. * @returns the current bounding box
  7106. */
  7107. scale(factor: number): BoundingBox;
  7108. /**
  7109. * Gets the world matrix of the bounding box
  7110. * @returns a matrix
  7111. */
  7112. getWorldMatrix(): DeepImmutable<Matrix>;
  7113. /** @hidden */
  7114. _update(world: DeepImmutable<Matrix>): void;
  7115. /**
  7116. * Tests if the bounding box is intersecting the frustum planes
  7117. * @param frustumPlanes defines the frustum planes to test
  7118. * @returns true if there is an intersection
  7119. */
  7120. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7121. /**
  7122. * Tests if the bounding box is entirely inside the frustum planes
  7123. * @param frustumPlanes defines the frustum planes to test
  7124. * @returns true if there is an inclusion
  7125. */
  7126. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7127. /**
  7128. * Tests if a point is inside the bounding box
  7129. * @param point defines the point to test
  7130. * @returns true if the point is inside the bounding box
  7131. */
  7132. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7133. /**
  7134. * Tests if the bounding box intersects with a bounding sphere
  7135. * @param sphere defines the sphere to test
  7136. * @returns true if there is an intersection
  7137. */
  7138. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7139. /**
  7140. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7141. * @param min defines the min vector to use
  7142. * @param max defines the max vector to use
  7143. * @returns true if there is an intersection
  7144. */
  7145. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7146. /**
  7147. * Tests if two bounding boxes are intersections
  7148. * @param box0 defines the first box to test
  7149. * @param box1 defines the second box to test
  7150. * @returns true if there is an intersection
  7151. */
  7152. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7153. /**
  7154. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7155. * @param minPoint defines the minimum vector of the bounding box
  7156. * @param maxPoint defines the maximum vector of the bounding box
  7157. * @param sphereCenter defines the sphere center
  7158. * @param sphereRadius defines the sphere radius
  7159. * @returns true if there is an intersection
  7160. */
  7161. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7162. /**
  7163. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7164. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7165. * @param frustumPlanes defines the frustum planes to test
  7166. * @return true if there is an inclusion
  7167. */
  7168. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7169. /**
  7170. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7171. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7172. * @param frustumPlanes defines the frustum planes to test
  7173. * @return true if there is an intersection
  7174. */
  7175. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7176. }
  7177. }
  7178. declare module "babylonjs/Collisions/collider" {
  7179. import { Nullable, IndicesArray } from "babylonjs/types";
  7180. import { Vector3 } from "babylonjs/Maths/math.vector";
  7181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7182. import { Plane } from "babylonjs/Maths/math.plane";
  7183. /** @hidden */
  7184. export class Collider {
  7185. /** Define if a collision was found */
  7186. collisionFound: boolean;
  7187. /**
  7188. * Define last intersection point in local space
  7189. */
  7190. intersectionPoint: Vector3;
  7191. /**
  7192. * Define last collided mesh
  7193. */
  7194. collidedMesh: Nullable<AbstractMesh>;
  7195. private _collisionPoint;
  7196. private _planeIntersectionPoint;
  7197. private _tempVector;
  7198. private _tempVector2;
  7199. private _tempVector3;
  7200. private _tempVector4;
  7201. private _edge;
  7202. private _baseToVertex;
  7203. private _destinationPoint;
  7204. private _slidePlaneNormal;
  7205. private _displacementVector;
  7206. /** @hidden */
  7207. _radius: Vector3;
  7208. /** @hidden */
  7209. _retry: number;
  7210. private _velocity;
  7211. private _basePoint;
  7212. private _epsilon;
  7213. /** @hidden */
  7214. _velocityWorldLength: number;
  7215. /** @hidden */
  7216. _basePointWorld: Vector3;
  7217. private _velocityWorld;
  7218. private _normalizedVelocity;
  7219. /** @hidden */
  7220. _initialVelocity: Vector3;
  7221. /** @hidden */
  7222. _initialPosition: Vector3;
  7223. private _nearestDistance;
  7224. private _collisionMask;
  7225. get collisionMask(): number;
  7226. set collisionMask(mask: number);
  7227. /**
  7228. * Gets the plane normal used to compute the sliding response (in local space)
  7229. */
  7230. get slidePlaneNormal(): Vector3;
  7231. /** @hidden */
  7232. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7233. /** @hidden */
  7234. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7235. /** @hidden */
  7236. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7237. /** @hidden */
  7238. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7239. /** @hidden */
  7240. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7241. /** @hidden */
  7242. _getResponse(pos: Vector3, vel: Vector3): void;
  7243. }
  7244. }
  7245. declare module "babylonjs/Culling/boundingInfo" {
  7246. import { DeepImmutable } from "babylonjs/types";
  7247. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7248. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7249. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7250. import { Plane } from "babylonjs/Maths/math.plane";
  7251. import { Collider } from "babylonjs/Collisions/collider";
  7252. /**
  7253. * Interface for cullable objects
  7254. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7255. */
  7256. export interface ICullable {
  7257. /**
  7258. * Checks if the object or part of the object is in the frustum
  7259. * @param frustumPlanes Camera near/planes
  7260. * @returns true if the object is in frustum otherwise false
  7261. */
  7262. isInFrustum(frustumPlanes: Plane[]): boolean;
  7263. /**
  7264. * Checks if a cullable object (mesh...) is in the camera frustum
  7265. * Unlike isInFrustum this cheks the full bounding box
  7266. * @param frustumPlanes Camera near/planes
  7267. * @returns true if the object is in frustum otherwise false
  7268. */
  7269. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7270. }
  7271. /**
  7272. * Info for a bounding data of a mesh
  7273. */
  7274. export class BoundingInfo implements ICullable {
  7275. /**
  7276. * Bounding box for the mesh
  7277. */
  7278. readonly boundingBox: BoundingBox;
  7279. /**
  7280. * Bounding sphere for the mesh
  7281. */
  7282. readonly boundingSphere: BoundingSphere;
  7283. private _isLocked;
  7284. private static readonly TmpVector3;
  7285. /**
  7286. * Constructs bounding info
  7287. * @param minimum min vector of the bounding box/sphere
  7288. * @param maximum max vector of the bounding box/sphere
  7289. * @param worldMatrix defines the new world matrix
  7290. */
  7291. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7292. /**
  7293. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7294. * @param min defines the new minimum vector (in local space)
  7295. * @param max defines the new maximum vector (in local space)
  7296. * @param worldMatrix defines the new world matrix
  7297. */
  7298. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7299. /**
  7300. * min vector of the bounding box/sphere
  7301. */
  7302. get minimum(): Vector3;
  7303. /**
  7304. * max vector of the bounding box/sphere
  7305. */
  7306. get maximum(): Vector3;
  7307. /**
  7308. * If the info is locked and won't be updated to avoid perf overhead
  7309. */
  7310. get isLocked(): boolean;
  7311. set isLocked(value: boolean);
  7312. /**
  7313. * Updates the bounding sphere and box
  7314. * @param world world matrix to be used to update
  7315. */
  7316. update(world: DeepImmutable<Matrix>): void;
  7317. /**
  7318. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7319. * @param center New center of the bounding info
  7320. * @param extend New extend of the bounding info
  7321. * @returns the current bounding info
  7322. */
  7323. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7324. /**
  7325. * Scale the current bounding info by applying a scale factor
  7326. * @param factor defines the scale factor to apply
  7327. * @returns the current bounding info
  7328. */
  7329. scale(factor: number): BoundingInfo;
  7330. /**
  7331. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7332. * @param frustumPlanes defines the frustum to test
  7333. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7334. * @returns true if the bounding info is in the frustum planes
  7335. */
  7336. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7337. /**
  7338. * Gets the world distance between the min and max points of the bounding box
  7339. */
  7340. get diagonalLength(): number;
  7341. /**
  7342. * Checks if a cullable object (mesh...) is in the camera frustum
  7343. * Unlike isInFrustum this cheks the full bounding box
  7344. * @param frustumPlanes Camera near/planes
  7345. * @returns true if the object is in frustum otherwise false
  7346. */
  7347. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7348. /** @hidden */
  7349. _checkCollision(collider: Collider): boolean;
  7350. /**
  7351. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7352. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7353. * @param point the point to check intersection with
  7354. * @returns if the point intersects
  7355. */
  7356. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7357. /**
  7358. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7359. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7360. * @param boundingInfo the bounding info to check intersection with
  7361. * @param precise if the intersection should be done using OBB
  7362. * @returns if the bounding info intersects
  7363. */
  7364. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7365. }
  7366. }
  7367. declare module "babylonjs/Maths/math.functions" {
  7368. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7369. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7370. /**
  7371. * Extracts minimum and maximum values from a list of indexed positions
  7372. * @param positions defines the positions to use
  7373. * @param indices defines the indices to the positions
  7374. * @param indexStart defines the start index
  7375. * @param indexCount defines the end index
  7376. * @param bias defines bias value to add to the result
  7377. * @return minimum and maximum values
  7378. */
  7379. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7380. minimum: Vector3;
  7381. maximum: Vector3;
  7382. };
  7383. /**
  7384. * Extracts minimum and maximum values from a list of positions
  7385. * @param positions defines the positions to use
  7386. * @param start defines the start index in the positions array
  7387. * @param count defines the number of positions to handle
  7388. * @param bias defines bias value to add to the result
  7389. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7390. * @return minimum and maximum values
  7391. */
  7392. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7393. minimum: Vector3;
  7394. maximum: Vector3;
  7395. };
  7396. }
  7397. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7398. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7399. /** @hidden */
  7400. export class WebGLDataBuffer extends DataBuffer {
  7401. private _buffer;
  7402. constructor(resource: WebGLBuffer);
  7403. get underlyingResource(): any;
  7404. }
  7405. }
  7406. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7407. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7408. import { Nullable } from "babylonjs/types";
  7409. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7410. /** @hidden */
  7411. export class WebGLPipelineContext implements IPipelineContext {
  7412. engine: ThinEngine;
  7413. program: Nullable<WebGLProgram>;
  7414. context?: WebGLRenderingContext;
  7415. vertexShader?: WebGLShader;
  7416. fragmentShader?: WebGLShader;
  7417. isParallelCompiled: boolean;
  7418. onCompiled?: () => void;
  7419. transformFeedback?: WebGLTransformFeedback | null;
  7420. vertexCompilationError: Nullable<string>;
  7421. fragmentCompilationError: Nullable<string>;
  7422. programLinkError: Nullable<string>;
  7423. programValidationError: Nullable<string>;
  7424. get isAsync(): boolean;
  7425. get isReady(): boolean;
  7426. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7427. _getVertexShaderCode(): string | null;
  7428. _getFragmentShaderCode(): string | null;
  7429. }
  7430. }
  7431. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7432. import { FloatArray, Nullable } from "babylonjs/types";
  7433. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7434. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7435. module "babylonjs/Engines/thinEngine" {
  7436. interface ThinEngine {
  7437. /**
  7438. * Create an uniform buffer
  7439. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7440. * @param elements defines the content of the uniform buffer
  7441. * @returns the webGL uniform buffer
  7442. */
  7443. createUniformBuffer(elements: FloatArray): DataBuffer;
  7444. /**
  7445. * Create a dynamic uniform buffer
  7446. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7447. * @param elements defines the content of the uniform buffer
  7448. * @returns the webGL uniform buffer
  7449. */
  7450. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7451. /**
  7452. * Update an existing uniform buffer
  7453. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7454. * @param uniformBuffer defines the target uniform buffer
  7455. * @param elements defines the content to update
  7456. * @param offset defines the offset in the uniform buffer where update should start
  7457. * @param count defines the size of the data to update
  7458. */
  7459. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7460. /**
  7461. * Bind an uniform buffer to the current webGL context
  7462. * @param buffer defines the buffer to bind
  7463. */
  7464. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7465. /**
  7466. * Bind a buffer to the current webGL context at a given location
  7467. * @param buffer defines the buffer to bind
  7468. * @param location defines the index where to bind the buffer
  7469. */
  7470. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7471. /**
  7472. * Bind a specific block at a given index in a specific shader program
  7473. * @param pipelineContext defines the pipeline context to use
  7474. * @param blockName defines the block name
  7475. * @param index defines the index where to bind the block
  7476. */
  7477. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7478. }
  7479. }
  7480. }
  7481. declare module "babylonjs/Materials/uniformBuffer" {
  7482. import { Nullable, FloatArray } from "babylonjs/types";
  7483. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7484. import { Engine } from "babylonjs/Engines/engine";
  7485. import { Effect } from "babylonjs/Materials/effect";
  7486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7487. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7488. import { Color3 } from "babylonjs/Maths/math.color";
  7489. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7490. /**
  7491. * Uniform buffer objects.
  7492. *
  7493. * Handles blocks of uniform on the GPU.
  7494. *
  7495. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7496. *
  7497. * For more information, please refer to :
  7498. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7499. */
  7500. export class UniformBuffer {
  7501. private _engine;
  7502. private _buffer;
  7503. private _data;
  7504. private _bufferData;
  7505. private _dynamic?;
  7506. private _uniformLocations;
  7507. private _uniformSizes;
  7508. private _uniformLocationPointer;
  7509. private _needSync;
  7510. private _noUBO;
  7511. private _currentEffect;
  7512. /** @hidden */
  7513. _alreadyBound: boolean;
  7514. private static _MAX_UNIFORM_SIZE;
  7515. private static _tempBuffer;
  7516. /**
  7517. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7518. * This is dynamic to allow compat with webgl 1 and 2.
  7519. * You will need to pass the name of the uniform as well as the value.
  7520. */
  7521. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7522. /**
  7523. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7524. * This is dynamic to allow compat with webgl 1 and 2.
  7525. * You will need to pass the name of the uniform as well as the value.
  7526. */
  7527. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7528. /**
  7529. * Lambda to Update a single float in a uniform buffer.
  7530. * This is dynamic to allow compat with webgl 1 and 2.
  7531. * You will need to pass the name of the uniform as well as the value.
  7532. */
  7533. updateFloat: (name: string, x: number) => void;
  7534. /**
  7535. * Lambda to Update a vec2 of float in a uniform buffer.
  7536. * This is dynamic to allow compat with webgl 1 and 2.
  7537. * You will need to pass the name of the uniform as well as the value.
  7538. */
  7539. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7540. /**
  7541. * Lambda to Update a vec3 of float in a uniform buffer.
  7542. * This is dynamic to allow compat with webgl 1 and 2.
  7543. * You will need to pass the name of the uniform as well as the value.
  7544. */
  7545. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7546. /**
  7547. * Lambda to Update a vec4 of float in a uniform buffer.
  7548. * This is dynamic to allow compat with webgl 1 and 2.
  7549. * You will need to pass the name of the uniform as well as the value.
  7550. */
  7551. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7552. /**
  7553. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7554. * This is dynamic to allow compat with webgl 1 and 2.
  7555. * You will need to pass the name of the uniform as well as the value.
  7556. */
  7557. updateMatrix: (name: string, mat: Matrix) => void;
  7558. /**
  7559. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7560. * This is dynamic to allow compat with webgl 1 and 2.
  7561. * You will need to pass the name of the uniform as well as the value.
  7562. */
  7563. updateVector3: (name: string, vector: Vector3) => void;
  7564. /**
  7565. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7566. * This is dynamic to allow compat with webgl 1 and 2.
  7567. * You will need to pass the name of the uniform as well as the value.
  7568. */
  7569. updateVector4: (name: string, vector: Vector4) => void;
  7570. /**
  7571. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7572. * This is dynamic to allow compat with webgl 1 and 2.
  7573. * You will need to pass the name of the uniform as well as the value.
  7574. */
  7575. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7576. /**
  7577. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7578. * This is dynamic to allow compat with webgl 1 and 2.
  7579. * You will need to pass the name of the uniform as well as the value.
  7580. */
  7581. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7582. /**
  7583. * Instantiates a new Uniform buffer objects.
  7584. *
  7585. * Handles blocks of uniform on the GPU.
  7586. *
  7587. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7588. *
  7589. * For more information, please refer to :
  7590. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7591. * @param engine Define the engine the buffer is associated with
  7592. * @param data Define the data contained in the buffer
  7593. * @param dynamic Define if the buffer is updatable
  7594. */
  7595. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7596. /**
  7597. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7598. * or just falling back on setUniformXXX calls.
  7599. */
  7600. get useUbo(): boolean;
  7601. /**
  7602. * Indicates if the WebGL underlying uniform buffer is in sync
  7603. * with the javascript cache data.
  7604. */
  7605. get isSync(): boolean;
  7606. /**
  7607. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7608. * Also, a dynamic UniformBuffer will disable cache verification and always
  7609. * update the underlying WebGL uniform buffer to the GPU.
  7610. * @returns if Dynamic, otherwise false
  7611. */
  7612. isDynamic(): boolean;
  7613. /**
  7614. * The data cache on JS side.
  7615. * @returns the underlying data as a float array
  7616. */
  7617. getData(): Float32Array;
  7618. /**
  7619. * The underlying WebGL Uniform buffer.
  7620. * @returns the webgl buffer
  7621. */
  7622. getBuffer(): Nullable<DataBuffer>;
  7623. /**
  7624. * std140 layout specifies how to align data within an UBO structure.
  7625. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7626. * for specs.
  7627. */
  7628. private _fillAlignment;
  7629. /**
  7630. * Adds an uniform in the buffer.
  7631. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7632. * for the layout to be correct !
  7633. * @param name Name of the uniform, as used in the uniform block in the shader.
  7634. * @param size Data size, or data directly.
  7635. */
  7636. addUniform(name: string, size: number | number[]): void;
  7637. /**
  7638. * Adds a Matrix 4x4 to the uniform buffer.
  7639. * @param name Name of the uniform, as used in the uniform block in the shader.
  7640. * @param mat A 4x4 matrix.
  7641. */
  7642. addMatrix(name: string, mat: Matrix): void;
  7643. /**
  7644. * Adds a vec2 to the uniform buffer.
  7645. * @param name Name of the uniform, as used in the uniform block in the shader.
  7646. * @param x Define the x component value of the vec2
  7647. * @param y Define the y component value of the vec2
  7648. */
  7649. addFloat2(name: string, x: number, y: number): void;
  7650. /**
  7651. * Adds a vec3 to the uniform buffer.
  7652. * @param name Name of the uniform, as used in the uniform block in the shader.
  7653. * @param x Define the x component value of the vec3
  7654. * @param y Define the y component value of the vec3
  7655. * @param z Define the z component value of the vec3
  7656. */
  7657. addFloat3(name: string, x: number, y: number, z: number): void;
  7658. /**
  7659. * Adds a vec3 to the uniform buffer.
  7660. * @param name Name of the uniform, as used in the uniform block in the shader.
  7661. * @param color Define the vec3 from a Color
  7662. */
  7663. addColor3(name: string, color: Color3): void;
  7664. /**
  7665. * Adds a vec4 to the uniform buffer.
  7666. * @param name Name of the uniform, as used in the uniform block in the shader.
  7667. * @param color Define the rgb components from a Color
  7668. * @param alpha Define the a component of the vec4
  7669. */
  7670. addColor4(name: string, color: Color3, alpha: number): void;
  7671. /**
  7672. * Adds a vec3 to the uniform buffer.
  7673. * @param name Name of the uniform, as used in the uniform block in the shader.
  7674. * @param vector Define the vec3 components from a Vector
  7675. */
  7676. addVector3(name: string, vector: Vector3): void;
  7677. /**
  7678. * Adds a Matrix 3x3 to the uniform buffer.
  7679. * @param name Name of the uniform, as used in the uniform block in the shader.
  7680. */
  7681. addMatrix3x3(name: string): void;
  7682. /**
  7683. * Adds a Matrix 2x2 to the uniform buffer.
  7684. * @param name Name of the uniform, as used in the uniform block in the shader.
  7685. */
  7686. addMatrix2x2(name: string): void;
  7687. /**
  7688. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7689. */
  7690. create(): void;
  7691. /** @hidden */
  7692. _rebuild(): void;
  7693. /**
  7694. * Updates the WebGL Uniform Buffer on the GPU.
  7695. * If the `dynamic` flag is set to true, no cache comparison is done.
  7696. * Otherwise, the buffer will be updated only if the cache differs.
  7697. */
  7698. update(): void;
  7699. /**
  7700. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7701. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7702. * @param data Define the flattened data
  7703. * @param size Define the size of the data.
  7704. */
  7705. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7706. private _valueCache;
  7707. private _cacheMatrix;
  7708. private _updateMatrix3x3ForUniform;
  7709. private _updateMatrix3x3ForEffect;
  7710. private _updateMatrix2x2ForEffect;
  7711. private _updateMatrix2x2ForUniform;
  7712. private _updateFloatForEffect;
  7713. private _updateFloatForUniform;
  7714. private _updateFloat2ForEffect;
  7715. private _updateFloat2ForUniform;
  7716. private _updateFloat3ForEffect;
  7717. private _updateFloat3ForUniform;
  7718. private _updateFloat4ForEffect;
  7719. private _updateFloat4ForUniform;
  7720. private _updateMatrixForEffect;
  7721. private _updateMatrixForUniform;
  7722. private _updateVector3ForEffect;
  7723. private _updateVector3ForUniform;
  7724. private _updateVector4ForEffect;
  7725. private _updateVector4ForUniform;
  7726. private _updateColor3ForEffect;
  7727. private _updateColor3ForUniform;
  7728. private _updateColor4ForEffect;
  7729. private _updateColor4ForUniform;
  7730. /**
  7731. * Sets a sampler uniform on the effect.
  7732. * @param name Define the name of the sampler.
  7733. * @param texture Define the texture to set in the sampler
  7734. */
  7735. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7736. /**
  7737. * Directly updates the value of the uniform in the cache AND on the GPU.
  7738. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7739. * @param data Define the flattened data
  7740. */
  7741. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7742. /**
  7743. * Binds this uniform buffer to an effect.
  7744. * @param effect Define the effect to bind the buffer to
  7745. * @param name Name of the uniform block in the shader.
  7746. */
  7747. bindToEffect(effect: Effect, name: string): void;
  7748. /**
  7749. * Disposes the uniform buffer.
  7750. */
  7751. dispose(): void;
  7752. }
  7753. }
  7754. declare module "babylonjs/Misc/iInspectable" {
  7755. /**
  7756. * Enum that determines the text-wrapping mode to use.
  7757. */
  7758. export enum InspectableType {
  7759. /**
  7760. * Checkbox for booleans
  7761. */
  7762. Checkbox = 0,
  7763. /**
  7764. * Sliders for numbers
  7765. */
  7766. Slider = 1,
  7767. /**
  7768. * Vector3
  7769. */
  7770. Vector3 = 2,
  7771. /**
  7772. * Quaternions
  7773. */
  7774. Quaternion = 3,
  7775. /**
  7776. * Color3
  7777. */
  7778. Color3 = 4,
  7779. /**
  7780. * String
  7781. */
  7782. String = 5
  7783. }
  7784. /**
  7785. * Interface used to define custom inspectable properties.
  7786. * This interface is used by the inspector to display custom property grids
  7787. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7788. */
  7789. export interface IInspectable {
  7790. /**
  7791. * Gets the label to display
  7792. */
  7793. label: string;
  7794. /**
  7795. * Gets the name of the property to edit
  7796. */
  7797. propertyName: string;
  7798. /**
  7799. * Gets the type of the editor to use
  7800. */
  7801. type: InspectableType;
  7802. /**
  7803. * Gets the minimum value of the property when using in "slider" mode
  7804. */
  7805. min?: number;
  7806. /**
  7807. * Gets the maximum value of the property when using in "slider" mode
  7808. */
  7809. max?: number;
  7810. /**
  7811. * Gets the setp to use when using in "slider" mode
  7812. */
  7813. step?: number;
  7814. }
  7815. }
  7816. declare module "babylonjs/Misc/timingTools" {
  7817. /**
  7818. * Class used to provide helper for timing
  7819. */
  7820. export class TimingTools {
  7821. /**
  7822. * Polyfill for setImmediate
  7823. * @param action defines the action to execute after the current execution block
  7824. */
  7825. static SetImmediate(action: () => void): void;
  7826. }
  7827. }
  7828. declare module "babylonjs/Misc/instantiationTools" {
  7829. /**
  7830. * Class used to enable instatition of objects by class name
  7831. */
  7832. export class InstantiationTools {
  7833. /**
  7834. * Use this object to register external classes like custom textures or material
  7835. * to allow the laoders to instantiate them
  7836. */
  7837. static RegisteredExternalClasses: {
  7838. [key: string]: Object;
  7839. };
  7840. /**
  7841. * Tries to instantiate a new object from a given class name
  7842. * @param className defines the class name to instantiate
  7843. * @returns the new object or null if the system was not able to do the instantiation
  7844. */
  7845. static Instantiate(className: string): any;
  7846. }
  7847. }
  7848. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7849. /**
  7850. * Define options used to create a depth texture
  7851. */
  7852. export class DepthTextureCreationOptions {
  7853. /** Specifies whether or not a stencil should be allocated in the texture */
  7854. generateStencil?: boolean;
  7855. /** Specifies whether or not bilinear filtering is enable on the texture */
  7856. bilinearFiltering?: boolean;
  7857. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7858. comparisonFunction?: number;
  7859. /** Specifies if the created texture is a cube texture */
  7860. isCube?: boolean;
  7861. }
  7862. }
  7863. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7864. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7865. import { Nullable } from "babylonjs/types";
  7866. import { Scene } from "babylonjs/scene";
  7867. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7868. module "babylonjs/Engines/thinEngine" {
  7869. interface ThinEngine {
  7870. /**
  7871. * Creates a depth stencil cube texture.
  7872. * This is only available in WebGL 2.
  7873. * @param size The size of face edge in the cube texture.
  7874. * @param options The options defining the cube texture.
  7875. * @returns The cube texture
  7876. */
  7877. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7878. /**
  7879. * Creates a cube texture
  7880. * @param rootUrl defines the url where the files to load is located
  7881. * @param scene defines the current scene
  7882. * @param files defines the list of files to load (1 per face)
  7883. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7884. * @param onLoad defines an optional callback raised when the texture is loaded
  7885. * @param onError defines an optional callback raised if there is an issue to load the texture
  7886. * @param format defines the format of the data
  7887. * @param forcedExtension defines the extension to use to pick the right loader
  7888. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7889. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7890. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7891. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7892. * @returns the cube texture as an InternalTexture
  7893. */
  7894. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7895. /**
  7896. * Creates a cube texture
  7897. * @param rootUrl defines the url where the files to load is located
  7898. * @param scene defines the current scene
  7899. * @param files defines the list of files to load (1 per face)
  7900. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7901. * @param onLoad defines an optional callback raised when the texture is loaded
  7902. * @param onError defines an optional callback raised if there is an issue to load the texture
  7903. * @param format defines the format of the data
  7904. * @param forcedExtension defines the extension to use to pick the right loader
  7905. * @returns the cube texture as an InternalTexture
  7906. */
  7907. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7908. /**
  7909. * Creates a cube texture
  7910. * @param rootUrl defines the url where the files to load is located
  7911. * @param scene defines the current scene
  7912. * @param files defines the list of files to load (1 per face)
  7913. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7914. * @param onLoad defines an optional callback raised when the texture is loaded
  7915. * @param onError defines an optional callback raised if there is an issue to load the texture
  7916. * @param format defines the format of the data
  7917. * @param forcedExtension defines the extension to use to pick the right loader
  7918. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7919. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7920. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7921. * @returns the cube texture as an InternalTexture
  7922. */
  7923. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7924. /** @hidden */
  7925. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7926. /** @hidden */
  7927. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7928. /** @hidden */
  7929. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7930. /** @hidden */
  7931. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7932. /**
  7933. * @hidden
  7934. */
  7935. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7936. }
  7937. }
  7938. }
  7939. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7940. import { Nullable } from "babylonjs/types";
  7941. import { Scene } from "babylonjs/scene";
  7942. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7943. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7944. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7945. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7946. import { Observable } from "babylonjs/Misc/observable";
  7947. /**
  7948. * Class for creating a cube texture
  7949. */
  7950. export class CubeTexture extends BaseTexture {
  7951. private _delayedOnLoad;
  7952. /**
  7953. * Observable triggered once the texture has been loaded.
  7954. */
  7955. onLoadObservable: Observable<CubeTexture>;
  7956. /**
  7957. * The url of the texture
  7958. */
  7959. url: string;
  7960. /**
  7961. * Gets or sets the center of the bounding box associated with the cube texture.
  7962. * It must define where the camera used to render the texture was set
  7963. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7964. */
  7965. boundingBoxPosition: Vector3;
  7966. private _boundingBoxSize;
  7967. /**
  7968. * Gets or sets the size of the bounding box associated with the cube texture
  7969. * When defined, the cubemap will switch to local mode
  7970. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7971. * @example https://www.babylonjs-playground.com/#RNASML
  7972. */
  7973. set boundingBoxSize(value: Vector3);
  7974. /**
  7975. * Returns the bounding box size
  7976. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7977. */
  7978. get boundingBoxSize(): Vector3;
  7979. protected _rotationY: number;
  7980. /**
  7981. * Sets texture matrix rotation angle around Y axis in radians.
  7982. */
  7983. set rotationY(value: number);
  7984. /**
  7985. * Gets texture matrix rotation angle around Y axis radians.
  7986. */
  7987. get rotationY(): number;
  7988. /**
  7989. * Are mip maps generated for this texture or not.
  7990. */
  7991. get noMipmap(): boolean;
  7992. private _noMipmap;
  7993. private _files;
  7994. protected _forcedExtension: Nullable<string>;
  7995. private _extensions;
  7996. private _textureMatrix;
  7997. private _format;
  7998. private _createPolynomials;
  7999. /**
  8000. * Creates a cube texture from an array of image urls
  8001. * @param files defines an array of image urls
  8002. * @param scene defines the hosting scene
  8003. * @param noMipmap specifies if mip maps are not used
  8004. * @returns a cube texture
  8005. */
  8006. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8007. /**
  8008. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8009. * @param url defines the url of the prefiltered texture
  8010. * @param scene defines the scene the texture is attached to
  8011. * @param forcedExtension defines the extension of the file if different from the url
  8012. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8013. * @return the prefiltered texture
  8014. */
  8015. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8016. /**
  8017. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8018. * as prefiltered data.
  8019. * @param rootUrl defines the url of the texture or the root name of the six images
  8020. * @param null defines the scene or engine the texture is attached to
  8021. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8022. * @param noMipmap defines if mipmaps should be created or not
  8023. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8024. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8025. * @param onError defines a callback triggered in case of error during load
  8026. * @param format defines the internal format to use for the texture once loaded
  8027. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8028. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8029. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8030. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8031. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8032. * @return the cube texture
  8033. */
  8034. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  8035. /**
  8036. * Get the current class name of the texture useful for serialization or dynamic coding.
  8037. * @returns "CubeTexture"
  8038. */
  8039. getClassName(): string;
  8040. /**
  8041. * Update the url (and optional buffer) of this texture if url was null during construction.
  8042. * @param url the url of the texture
  8043. * @param forcedExtension defines the extension to use
  8044. * @param onLoad callback called when the texture is loaded (defaults to null)
  8045. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8046. */
  8047. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8048. /**
  8049. * Delays loading of the cube texture
  8050. * @param forcedExtension defines the extension to use
  8051. */
  8052. delayLoad(forcedExtension?: string): void;
  8053. /**
  8054. * Returns the reflection texture matrix
  8055. * @returns the reflection texture matrix
  8056. */
  8057. getReflectionTextureMatrix(): Matrix;
  8058. /**
  8059. * Sets the reflection texture matrix
  8060. * @param value Reflection texture matrix
  8061. */
  8062. setReflectionTextureMatrix(value: Matrix): void;
  8063. /**
  8064. * Parses text to create a cube texture
  8065. * @param parsedTexture define the serialized text to read from
  8066. * @param scene defines the hosting scene
  8067. * @param rootUrl defines the root url of the cube texture
  8068. * @returns a cube texture
  8069. */
  8070. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8071. /**
  8072. * Makes a clone, or deep copy, of the cube texture
  8073. * @returns a new cube texture
  8074. */
  8075. clone(): CubeTexture;
  8076. }
  8077. }
  8078. declare module "babylonjs/Materials/materialDefines" {
  8079. /**
  8080. * Manages the defines for the Material
  8081. */
  8082. export class MaterialDefines {
  8083. /** @hidden */
  8084. protected _keys: string[];
  8085. private _isDirty;
  8086. /** @hidden */
  8087. _renderId: number;
  8088. /** @hidden */
  8089. _areLightsDirty: boolean;
  8090. /** @hidden */
  8091. _areLightsDisposed: boolean;
  8092. /** @hidden */
  8093. _areAttributesDirty: boolean;
  8094. /** @hidden */
  8095. _areTexturesDirty: boolean;
  8096. /** @hidden */
  8097. _areFresnelDirty: boolean;
  8098. /** @hidden */
  8099. _areMiscDirty: boolean;
  8100. /** @hidden */
  8101. _arePrePassDirty: boolean;
  8102. /** @hidden */
  8103. _areImageProcessingDirty: boolean;
  8104. /** @hidden */
  8105. _normals: boolean;
  8106. /** @hidden */
  8107. _uvs: boolean;
  8108. /** @hidden */
  8109. _needNormals: boolean;
  8110. /** @hidden */
  8111. _needUVs: boolean;
  8112. [id: string]: any;
  8113. /**
  8114. * Specifies if the material needs to be re-calculated
  8115. */
  8116. get isDirty(): boolean;
  8117. /**
  8118. * Marks the material to indicate that it has been re-calculated
  8119. */
  8120. markAsProcessed(): void;
  8121. /**
  8122. * Marks the material to indicate that it needs to be re-calculated
  8123. */
  8124. markAsUnprocessed(): void;
  8125. /**
  8126. * Marks the material to indicate all of its defines need to be re-calculated
  8127. */
  8128. markAllAsDirty(): void;
  8129. /**
  8130. * Marks the material to indicate that image processing needs to be re-calculated
  8131. */
  8132. markAsImageProcessingDirty(): void;
  8133. /**
  8134. * Marks the material to indicate the lights need to be re-calculated
  8135. * @param disposed Defines whether the light is dirty due to dispose or not
  8136. */
  8137. markAsLightDirty(disposed?: boolean): void;
  8138. /**
  8139. * Marks the attribute state as changed
  8140. */
  8141. markAsAttributesDirty(): void;
  8142. /**
  8143. * Marks the texture state as changed
  8144. */
  8145. markAsTexturesDirty(): void;
  8146. /**
  8147. * Marks the fresnel state as changed
  8148. */
  8149. markAsFresnelDirty(): void;
  8150. /**
  8151. * Marks the misc state as changed
  8152. */
  8153. markAsMiscDirty(): void;
  8154. /**
  8155. * Marks the prepass state as changed
  8156. */
  8157. markAsPrePassDirty(): void;
  8158. /**
  8159. * Rebuilds the material defines
  8160. */
  8161. rebuild(): void;
  8162. /**
  8163. * Specifies if two material defines are equal
  8164. * @param other - A material define instance to compare to
  8165. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8166. */
  8167. isEqual(other: MaterialDefines): boolean;
  8168. /**
  8169. * Clones this instance's defines to another instance
  8170. * @param other - material defines to clone values to
  8171. */
  8172. cloneTo(other: MaterialDefines): void;
  8173. /**
  8174. * Resets the material define values
  8175. */
  8176. reset(): void;
  8177. /**
  8178. * Converts the material define values to a string
  8179. * @returns - String of material define information
  8180. */
  8181. toString(): string;
  8182. }
  8183. }
  8184. declare module "babylonjs/Materials/colorCurves" {
  8185. import { Effect } from "babylonjs/Materials/effect";
  8186. /**
  8187. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8188. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8189. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8190. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8191. */
  8192. export class ColorCurves {
  8193. private _dirty;
  8194. private _tempColor;
  8195. private _globalCurve;
  8196. private _highlightsCurve;
  8197. private _midtonesCurve;
  8198. private _shadowsCurve;
  8199. private _positiveCurve;
  8200. private _negativeCurve;
  8201. private _globalHue;
  8202. private _globalDensity;
  8203. private _globalSaturation;
  8204. private _globalExposure;
  8205. /**
  8206. * Gets the global Hue value.
  8207. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8208. */
  8209. get globalHue(): number;
  8210. /**
  8211. * Sets the global Hue value.
  8212. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8213. */
  8214. set globalHue(value: number);
  8215. /**
  8216. * Gets the global Density value.
  8217. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8218. * Values less than zero provide a filter of opposite hue.
  8219. */
  8220. get globalDensity(): number;
  8221. /**
  8222. * Sets the global Density value.
  8223. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8224. * Values less than zero provide a filter of opposite hue.
  8225. */
  8226. set globalDensity(value: number);
  8227. /**
  8228. * Gets the global Saturation value.
  8229. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8230. */
  8231. get globalSaturation(): number;
  8232. /**
  8233. * Sets the global Saturation value.
  8234. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8235. */
  8236. set globalSaturation(value: number);
  8237. /**
  8238. * Gets the global Exposure value.
  8239. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8240. */
  8241. get globalExposure(): number;
  8242. /**
  8243. * Sets the global Exposure value.
  8244. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8245. */
  8246. set globalExposure(value: number);
  8247. private _highlightsHue;
  8248. private _highlightsDensity;
  8249. private _highlightsSaturation;
  8250. private _highlightsExposure;
  8251. /**
  8252. * Gets the highlights Hue value.
  8253. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8254. */
  8255. get highlightsHue(): number;
  8256. /**
  8257. * Sets the highlights Hue value.
  8258. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8259. */
  8260. set highlightsHue(value: number);
  8261. /**
  8262. * Gets the highlights Density value.
  8263. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8264. * Values less than zero provide a filter of opposite hue.
  8265. */
  8266. get highlightsDensity(): number;
  8267. /**
  8268. * Sets the highlights Density value.
  8269. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8270. * Values less than zero provide a filter of opposite hue.
  8271. */
  8272. set highlightsDensity(value: number);
  8273. /**
  8274. * Gets the highlights Saturation value.
  8275. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8276. */
  8277. get highlightsSaturation(): number;
  8278. /**
  8279. * Sets the highlights Saturation value.
  8280. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8281. */
  8282. set highlightsSaturation(value: number);
  8283. /**
  8284. * Gets the highlights Exposure value.
  8285. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8286. */
  8287. get highlightsExposure(): number;
  8288. /**
  8289. * Sets the highlights Exposure value.
  8290. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8291. */
  8292. set highlightsExposure(value: number);
  8293. private _midtonesHue;
  8294. private _midtonesDensity;
  8295. private _midtonesSaturation;
  8296. private _midtonesExposure;
  8297. /**
  8298. * Gets the midtones Hue value.
  8299. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8300. */
  8301. get midtonesHue(): number;
  8302. /**
  8303. * Sets the midtones Hue value.
  8304. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8305. */
  8306. set midtonesHue(value: number);
  8307. /**
  8308. * Gets the midtones Density value.
  8309. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8310. * Values less than zero provide a filter of opposite hue.
  8311. */
  8312. get midtonesDensity(): number;
  8313. /**
  8314. * Sets the midtones Density value.
  8315. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8316. * Values less than zero provide a filter of opposite hue.
  8317. */
  8318. set midtonesDensity(value: number);
  8319. /**
  8320. * Gets the midtones Saturation value.
  8321. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8322. */
  8323. get midtonesSaturation(): number;
  8324. /**
  8325. * Sets the midtones Saturation value.
  8326. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8327. */
  8328. set midtonesSaturation(value: number);
  8329. /**
  8330. * Gets the midtones Exposure value.
  8331. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8332. */
  8333. get midtonesExposure(): number;
  8334. /**
  8335. * Sets the midtones Exposure value.
  8336. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8337. */
  8338. set midtonesExposure(value: number);
  8339. private _shadowsHue;
  8340. private _shadowsDensity;
  8341. private _shadowsSaturation;
  8342. private _shadowsExposure;
  8343. /**
  8344. * Gets the shadows Hue value.
  8345. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8346. */
  8347. get shadowsHue(): number;
  8348. /**
  8349. * Sets the shadows Hue value.
  8350. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8351. */
  8352. set shadowsHue(value: number);
  8353. /**
  8354. * Gets the shadows Density value.
  8355. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8356. * Values less than zero provide a filter of opposite hue.
  8357. */
  8358. get shadowsDensity(): number;
  8359. /**
  8360. * Sets the shadows Density value.
  8361. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8362. * Values less than zero provide a filter of opposite hue.
  8363. */
  8364. set shadowsDensity(value: number);
  8365. /**
  8366. * Gets the shadows Saturation value.
  8367. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8368. */
  8369. get shadowsSaturation(): number;
  8370. /**
  8371. * Sets the shadows Saturation value.
  8372. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8373. */
  8374. set shadowsSaturation(value: number);
  8375. /**
  8376. * Gets the shadows Exposure value.
  8377. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8378. */
  8379. get shadowsExposure(): number;
  8380. /**
  8381. * Sets the shadows Exposure value.
  8382. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8383. */
  8384. set shadowsExposure(value: number);
  8385. /**
  8386. * Returns the class name
  8387. * @returns The class name
  8388. */
  8389. getClassName(): string;
  8390. /**
  8391. * Binds the color curves to the shader.
  8392. * @param colorCurves The color curve to bind
  8393. * @param effect The effect to bind to
  8394. * @param positiveUniform The positive uniform shader parameter
  8395. * @param neutralUniform The neutral uniform shader parameter
  8396. * @param negativeUniform The negative uniform shader parameter
  8397. */
  8398. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8399. /**
  8400. * Prepare the list of uniforms associated with the ColorCurves effects.
  8401. * @param uniformsList The list of uniforms used in the effect
  8402. */
  8403. static PrepareUniforms(uniformsList: string[]): void;
  8404. /**
  8405. * Returns color grading data based on a hue, density, saturation and exposure value.
  8406. * @param filterHue The hue of the color filter.
  8407. * @param filterDensity The density of the color filter.
  8408. * @param saturation The saturation.
  8409. * @param exposure The exposure.
  8410. * @param result The result data container.
  8411. */
  8412. private getColorGradingDataToRef;
  8413. /**
  8414. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8415. * @param value The input slider value in range [-100,100].
  8416. * @returns Adjusted value.
  8417. */
  8418. private static applyColorGradingSliderNonlinear;
  8419. /**
  8420. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8421. * @param hue The hue (H) input.
  8422. * @param saturation The saturation (S) input.
  8423. * @param brightness The brightness (B) input.
  8424. * @result An RGBA color represented as Vector4.
  8425. */
  8426. private static fromHSBToRef;
  8427. /**
  8428. * Returns a value clamped between min and max
  8429. * @param value The value to clamp
  8430. * @param min The minimum of value
  8431. * @param max The maximum of value
  8432. * @returns The clamped value.
  8433. */
  8434. private static clamp;
  8435. /**
  8436. * Clones the current color curve instance.
  8437. * @return The cloned curves
  8438. */
  8439. clone(): ColorCurves;
  8440. /**
  8441. * Serializes the current color curve instance to a json representation.
  8442. * @return a JSON representation
  8443. */
  8444. serialize(): any;
  8445. /**
  8446. * Parses the color curve from a json representation.
  8447. * @param source the JSON source to parse
  8448. * @return The parsed curves
  8449. */
  8450. static Parse(source: any): ColorCurves;
  8451. }
  8452. }
  8453. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8454. import { Observable } from "babylonjs/Misc/observable";
  8455. import { Nullable } from "babylonjs/types";
  8456. import { Color4 } from "babylonjs/Maths/math.color";
  8457. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8458. import { Effect } from "babylonjs/Materials/effect";
  8459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8460. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8461. /**
  8462. * Interface to follow in your material defines to integrate easily the
  8463. * Image proccessing functions.
  8464. * @hidden
  8465. */
  8466. export interface IImageProcessingConfigurationDefines {
  8467. IMAGEPROCESSING: boolean;
  8468. VIGNETTE: boolean;
  8469. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8470. VIGNETTEBLENDMODEOPAQUE: boolean;
  8471. TONEMAPPING: boolean;
  8472. TONEMAPPING_ACES: boolean;
  8473. CONTRAST: boolean;
  8474. EXPOSURE: boolean;
  8475. COLORCURVES: boolean;
  8476. COLORGRADING: boolean;
  8477. COLORGRADING3D: boolean;
  8478. SAMPLER3DGREENDEPTH: boolean;
  8479. SAMPLER3DBGRMAP: boolean;
  8480. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8481. }
  8482. /**
  8483. * @hidden
  8484. */
  8485. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8486. IMAGEPROCESSING: boolean;
  8487. VIGNETTE: boolean;
  8488. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8489. VIGNETTEBLENDMODEOPAQUE: boolean;
  8490. TONEMAPPING: boolean;
  8491. TONEMAPPING_ACES: boolean;
  8492. CONTRAST: boolean;
  8493. COLORCURVES: boolean;
  8494. COLORGRADING: boolean;
  8495. COLORGRADING3D: boolean;
  8496. SAMPLER3DGREENDEPTH: boolean;
  8497. SAMPLER3DBGRMAP: boolean;
  8498. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8499. EXPOSURE: boolean;
  8500. constructor();
  8501. }
  8502. /**
  8503. * This groups together the common properties used for image processing either in direct forward pass
  8504. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8505. * or not.
  8506. */
  8507. export class ImageProcessingConfiguration {
  8508. /**
  8509. * Default tone mapping applied in BabylonJS.
  8510. */
  8511. static readonly TONEMAPPING_STANDARD: number;
  8512. /**
  8513. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8514. * to other engines rendering to increase portability.
  8515. */
  8516. static readonly TONEMAPPING_ACES: number;
  8517. /**
  8518. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8519. */
  8520. colorCurves: Nullable<ColorCurves>;
  8521. private _colorCurvesEnabled;
  8522. /**
  8523. * Gets wether the color curves effect is enabled.
  8524. */
  8525. get colorCurvesEnabled(): boolean;
  8526. /**
  8527. * Sets wether the color curves effect is enabled.
  8528. */
  8529. set colorCurvesEnabled(value: boolean);
  8530. private _colorGradingTexture;
  8531. /**
  8532. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8533. */
  8534. get colorGradingTexture(): Nullable<BaseTexture>;
  8535. /**
  8536. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8537. */
  8538. set colorGradingTexture(value: Nullable<BaseTexture>);
  8539. private _colorGradingEnabled;
  8540. /**
  8541. * Gets wether the color grading effect is enabled.
  8542. */
  8543. get colorGradingEnabled(): boolean;
  8544. /**
  8545. * Sets wether the color grading effect is enabled.
  8546. */
  8547. set colorGradingEnabled(value: boolean);
  8548. private _colorGradingWithGreenDepth;
  8549. /**
  8550. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8551. */
  8552. get colorGradingWithGreenDepth(): boolean;
  8553. /**
  8554. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8555. */
  8556. set colorGradingWithGreenDepth(value: boolean);
  8557. private _colorGradingBGR;
  8558. /**
  8559. * Gets wether the color grading texture contains BGR values.
  8560. */
  8561. get colorGradingBGR(): boolean;
  8562. /**
  8563. * Sets wether the color grading texture contains BGR values.
  8564. */
  8565. set colorGradingBGR(value: boolean);
  8566. /** @hidden */
  8567. _exposure: number;
  8568. /**
  8569. * Gets the Exposure used in the effect.
  8570. */
  8571. get exposure(): number;
  8572. /**
  8573. * Sets the Exposure used in the effect.
  8574. */
  8575. set exposure(value: number);
  8576. private _toneMappingEnabled;
  8577. /**
  8578. * Gets wether the tone mapping effect is enabled.
  8579. */
  8580. get toneMappingEnabled(): boolean;
  8581. /**
  8582. * Sets wether the tone mapping effect is enabled.
  8583. */
  8584. set toneMappingEnabled(value: boolean);
  8585. private _toneMappingType;
  8586. /**
  8587. * Gets the type of tone mapping effect.
  8588. */
  8589. get toneMappingType(): number;
  8590. /**
  8591. * Sets the type of tone mapping effect used in BabylonJS.
  8592. */
  8593. set toneMappingType(value: number);
  8594. protected _contrast: number;
  8595. /**
  8596. * Gets the contrast used in the effect.
  8597. */
  8598. get contrast(): number;
  8599. /**
  8600. * Sets the contrast used in the effect.
  8601. */
  8602. set contrast(value: number);
  8603. /**
  8604. * Vignette stretch size.
  8605. */
  8606. vignetteStretch: number;
  8607. /**
  8608. * Vignette centre X Offset.
  8609. */
  8610. vignetteCentreX: number;
  8611. /**
  8612. * Vignette centre Y Offset.
  8613. */
  8614. vignetteCentreY: number;
  8615. /**
  8616. * Vignette weight or intensity of the vignette effect.
  8617. */
  8618. vignetteWeight: number;
  8619. /**
  8620. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8621. * if vignetteEnabled is set to true.
  8622. */
  8623. vignetteColor: Color4;
  8624. /**
  8625. * Camera field of view used by the Vignette effect.
  8626. */
  8627. vignetteCameraFov: number;
  8628. private _vignetteBlendMode;
  8629. /**
  8630. * Gets the vignette blend mode allowing different kind of effect.
  8631. */
  8632. get vignetteBlendMode(): number;
  8633. /**
  8634. * Sets the vignette blend mode allowing different kind of effect.
  8635. */
  8636. set vignetteBlendMode(value: number);
  8637. private _vignetteEnabled;
  8638. /**
  8639. * Gets wether the vignette effect is enabled.
  8640. */
  8641. get vignetteEnabled(): boolean;
  8642. /**
  8643. * Sets wether the vignette effect is enabled.
  8644. */
  8645. set vignetteEnabled(value: boolean);
  8646. private _applyByPostProcess;
  8647. /**
  8648. * Gets wether the image processing is applied through a post process or not.
  8649. */
  8650. get applyByPostProcess(): boolean;
  8651. /**
  8652. * Sets wether the image processing is applied through a post process or not.
  8653. */
  8654. set applyByPostProcess(value: boolean);
  8655. private _isEnabled;
  8656. /**
  8657. * Gets wether the image processing is enabled or not.
  8658. */
  8659. get isEnabled(): boolean;
  8660. /**
  8661. * Sets wether the image processing is enabled or not.
  8662. */
  8663. set isEnabled(value: boolean);
  8664. /**
  8665. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8666. */
  8667. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8668. /**
  8669. * Method called each time the image processing information changes requires to recompile the effect.
  8670. */
  8671. protected _updateParameters(): void;
  8672. /**
  8673. * Gets the current class name.
  8674. * @return "ImageProcessingConfiguration"
  8675. */
  8676. getClassName(): string;
  8677. /**
  8678. * Prepare the list of uniforms associated with the Image Processing effects.
  8679. * @param uniforms The list of uniforms used in the effect
  8680. * @param defines the list of defines currently in use
  8681. */
  8682. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8683. /**
  8684. * Prepare the list of samplers associated with the Image Processing effects.
  8685. * @param samplersList The list of uniforms used in the effect
  8686. * @param defines the list of defines currently in use
  8687. */
  8688. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8689. /**
  8690. * Prepare the list of defines associated to the shader.
  8691. * @param defines the list of defines to complete
  8692. * @param forPostProcess Define if we are currently in post process mode or not
  8693. */
  8694. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8695. /**
  8696. * Returns true if all the image processing information are ready.
  8697. * @returns True if ready, otherwise, false
  8698. */
  8699. isReady(): boolean;
  8700. /**
  8701. * Binds the image processing to the shader.
  8702. * @param effect The effect to bind to
  8703. * @param overrideAspectRatio Override the aspect ratio of the effect
  8704. */
  8705. bind(effect: Effect, overrideAspectRatio?: number): void;
  8706. /**
  8707. * Clones the current image processing instance.
  8708. * @return The cloned image processing
  8709. */
  8710. clone(): ImageProcessingConfiguration;
  8711. /**
  8712. * Serializes the current image processing instance to a json representation.
  8713. * @return a JSON representation
  8714. */
  8715. serialize(): any;
  8716. /**
  8717. * Parses the image processing from a json representation.
  8718. * @param source the JSON source to parse
  8719. * @return The parsed image processing
  8720. */
  8721. static Parse(source: any): ImageProcessingConfiguration;
  8722. private static _VIGNETTEMODE_MULTIPLY;
  8723. private static _VIGNETTEMODE_OPAQUE;
  8724. /**
  8725. * Used to apply the vignette as a mix with the pixel color.
  8726. */
  8727. static get VIGNETTEMODE_MULTIPLY(): number;
  8728. /**
  8729. * Used to apply the vignette as a replacement of the pixel color.
  8730. */
  8731. static get VIGNETTEMODE_OPAQUE(): number;
  8732. }
  8733. }
  8734. declare module "babylonjs/Shaders/postprocess.vertex" {
  8735. /** @hidden */
  8736. export var postprocessVertexShader: {
  8737. name: string;
  8738. shader: string;
  8739. };
  8740. }
  8741. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8742. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8743. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8744. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8745. /**
  8746. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8747. */
  8748. export type RenderTargetTextureSize = number | {
  8749. width: number;
  8750. height: number;
  8751. layers?: number;
  8752. };
  8753. module "babylonjs/Engines/thinEngine" {
  8754. interface ThinEngine {
  8755. /**
  8756. * Creates a new render target texture
  8757. * @param size defines the size of the texture
  8758. * @param options defines the options used to create the texture
  8759. * @returns a new render target texture stored in an InternalTexture
  8760. */
  8761. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8762. /**
  8763. * Creates a depth stencil texture.
  8764. * This is only available in WebGL 2 or with the depth texture extension available.
  8765. * @param size The size of face edge in the texture.
  8766. * @param options The options defining the texture.
  8767. * @returns The texture
  8768. */
  8769. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8770. /** @hidden */
  8771. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8772. }
  8773. }
  8774. }
  8775. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8776. /**
  8777. * Defines the kind of connection point for node based material
  8778. */
  8779. export enum NodeMaterialBlockConnectionPointTypes {
  8780. /** Float */
  8781. Float = 1,
  8782. /** Int */
  8783. Int = 2,
  8784. /** Vector2 */
  8785. Vector2 = 4,
  8786. /** Vector3 */
  8787. Vector3 = 8,
  8788. /** Vector4 */
  8789. Vector4 = 16,
  8790. /** Color3 */
  8791. Color3 = 32,
  8792. /** Color4 */
  8793. Color4 = 64,
  8794. /** Matrix */
  8795. Matrix = 128,
  8796. /** Custom object */
  8797. Object = 256,
  8798. /** Detect type based on connection */
  8799. AutoDetect = 1024,
  8800. /** Output type that will be defined by input type */
  8801. BasedOnInput = 2048
  8802. }
  8803. }
  8804. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8805. /**
  8806. * Enum used to define the target of a block
  8807. */
  8808. export enum NodeMaterialBlockTargets {
  8809. /** Vertex shader */
  8810. Vertex = 1,
  8811. /** Fragment shader */
  8812. Fragment = 2,
  8813. /** Neutral */
  8814. Neutral = 4,
  8815. /** Vertex and Fragment */
  8816. VertexAndFragment = 3
  8817. }
  8818. }
  8819. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8820. /**
  8821. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8822. */
  8823. export enum NodeMaterialBlockConnectionPointMode {
  8824. /** Value is an uniform */
  8825. Uniform = 0,
  8826. /** Value is a mesh attribute */
  8827. Attribute = 1,
  8828. /** Value is a varying between vertex and fragment shaders */
  8829. Varying = 2,
  8830. /** Mode is undefined */
  8831. Undefined = 3
  8832. }
  8833. }
  8834. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8835. /**
  8836. * Enum used to define system values e.g. values automatically provided by the system
  8837. */
  8838. export enum NodeMaterialSystemValues {
  8839. /** World */
  8840. World = 1,
  8841. /** View */
  8842. View = 2,
  8843. /** Projection */
  8844. Projection = 3,
  8845. /** ViewProjection */
  8846. ViewProjection = 4,
  8847. /** WorldView */
  8848. WorldView = 5,
  8849. /** WorldViewProjection */
  8850. WorldViewProjection = 6,
  8851. /** CameraPosition */
  8852. CameraPosition = 7,
  8853. /** Fog Color */
  8854. FogColor = 8,
  8855. /** Delta time */
  8856. DeltaTime = 9
  8857. }
  8858. }
  8859. declare module "babylonjs/Maths/math.axis" {
  8860. import { Vector3 } from "babylonjs/Maths/math.vector";
  8861. /** Defines supported spaces */
  8862. export enum Space {
  8863. /** Local (object) space */
  8864. LOCAL = 0,
  8865. /** World space */
  8866. WORLD = 1,
  8867. /** Bone space */
  8868. BONE = 2
  8869. }
  8870. /** Defines the 3 main axes */
  8871. export class Axis {
  8872. /** X axis */
  8873. static X: Vector3;
  8874. /** Y axis */
  8875. static Y: Vector3;
  8876. /** Z axis */
  8877. static Z: Vector3;
  8878. }
  8879. }
  8880. declare module "babylonjs/Maths/math.frustum" {
  8881. import { Matrix } from "babylonjs/Maths/math.vector";
  8882. import { DeepImmutable } from "babylonjs/types";
  8883. import { Plane } from "babylonjs/Maths/math.plane";
  8884. /**
  8885. * Represents a camera frustum
  8886. */
  8887. export class Frustum {
  8888. /**
  8889. * Gets the planes representing the frustum
  8890. * @param transform matrix to be applied to the returned planes
  8891. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8892. */
  8893. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8894. /**
  8895. * Gets the near frustum plane transformed by the transform matrix
  8896. * @param transform transformation matrix to be applied to the resulting frustum plane
  8897. * @param frustumPlane the resuling frustum plane
  8898. */
  8899. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8900. /**
  8901. * Gets the far frustum plane transformed by the transform matrix
  8902. * @param transform transformation matrix to be applied to the resulting frustum plane
  8903. * @param frustumPlane the resuling frustum plane
  8904. */
  8905. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8906. /**
  8907. * Gets the left frustum plane transformed by the transform matrix
  8908. * @param transform transformation matrix to be applied to the resulting frustum plane
  8909. * @param frustumPlane the resuling frustum plane
  8910. */
  8911. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8912. /**
  8913. * Gets the right frustum plane transformed by the transform matrix
  8914. * @param transform transformation matrix to be applied to the resulting frustum plane
  8915. * @param frustumPlane the resuling frustum plane
  8916. */
  8917. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8918. /**
  8919. * Gets the top frustum plane transformed by the transform matrix
  8920. * @param transform transformation matrix to be applied to the resulting frustum plane
  8921. * @param frustumPlane the resuling frustum plane
  8922. */
  8923. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8924. /**
  8925. * Gets the bottom frustum plane transformed by the transform matrix
  8926. * @param transform transformation matrix to be applied to the resulting frustum plane
  8927. * @param frustumPlane the resuling frustum plane
  8928. */
  8929. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8930. /**
  8931. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8932. * @param transform transformation matrix to be applied to the resulting frustum planes
  8933. * @param frustumPlanes the resuling frustum planes
  8934. */
  8935. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8936. }
  8937. }
  8938. declare module "babylonjs/Maths/math.size" {
  8939. /**
  8940. * Interface for the size containing width and height
  8941. */
  8942. export interface ISize {
  8943. /**
  8944. * Width
  8945. */
  8946. width: number;
  8947. /**
  8948. * Heighht
  8949. */
  8950. height: number;
  8951. }
  8952. /**
  8953. * Size containing widht and height
  8954. */
  8955. export class Size implements ISize {
  8956. /**
  8957. * Width
  8958. */
  8959. width: number;
  8960. /**
  8961. * Height
  8962. */
  8963. height: number;
  8964. /**
  8965. * Creates a Size object from the given width and height (floats).
  8966. * @param width width of the new size
  8967. * @param height height of the new size
  8968. */
  8969. constructor(width: number, height: number);
  8970. /**
  8971. * Returns a string with the Size width and height
  8972. * @returns a string with the Size width and height
  8973. */
  8974. toString(): string;
  8975. /**
  8976. * "Size"
  8977. * @returns the string "Size"
  8978. */
  8979. getClassName(): string;
  8980. /**
  8981. * Returns the Size hash code.
  8982. * @returns a hash code for a unique width and height
  8983. */
  8984. getHashCode(): number;
  8985. /**
  8986. * Updates the current size from the given one.
  8987. * @param src the given size
  8988. */
  8989. copyFrom(src: Size): void;
  8990. /**
  8991. * Updates in place the current Size from the given floats.
  8992. * @param width width of the new size
  8993. * @param height height of the new size
  8994. * @returns the updated Size.
  8995. */
  8996. copyFromFloats(width: number, height: number): Size;
  8997. /**
  8998. * Updates in place the current Size from the given floats.
  8999. * @param width width to set
  9000. * @param height height to set
  9001. * @returns the updated Size.
  9002. */
  9003. set(width: number, height: number): Size;
  9004. /**
  9005. * Multiplies the width and height by numbers
  9006. * @param w factor to multiple the width by
  9007. * @param h factor to multiple the height by
  9008. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9009. */
  9010. multiplyByFloats(w: number, h: number): Size;
  9011. /**
  9012. * Clones the size
  9013. * @returns a new Size copied from the given one.
  9014. */
  9015. clone(): Size;
  9016. /**
  9017. * True if the current Size and the given one width and height are strictly equal.
  9018. * @param other the other size to compare against
  9019. * @returns True if the current Size and the given one width and height are strictly equal.
  9020. */
  9021. equals(other: Size): boolean;
  9022. /**
  9023. * The surface of the Size : width * height (float).
  9024. */
  9025. get surface(): number;
  9026. /**
  9027. * Create a new size of zero
  9028. * @returns a new Size set to (0.0, 0.0)
  9029. */
  9030. static Zero(): Size;
  9031. /**
  9032. * Sums the width and height of two sizes
  9033. * @param otherSize size to add to this size
  9034. * @returns a new Size set as the addition result of the current Size and the given one.
  9035. */
  9036. add(otherSize: Size): Size;
  9037. /**
  9038. * Subtracts the width and height of two
  9039. * @param otherSize size to subtract to this size
  9040. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9041. */
  9042. subtract(otherSize: Size): Size;
  9043. /**
  9044. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9045. * @param start starting size to lerp between
  9046. * @param end end size to lerp between
  9047. * @param amount amount to lerp between the start and end values
  9048. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9049. */
  9050. static Lerp(start: Size, end: Size, amount: number): Size;
  9051. }
  9052. }
  9053. declare module "babylonjs/Maths/math.vertexFormat" {
  9054. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9055. /**
  9056. * Contains position and normal vectors for a vertex
  9057. */
  9058. export class PositionNormalVertex {
  9059. /** the position of the vertex (defaut: 0,0,0) */
  9060. position: Vector3;
  9061. /** the normal of the vertex (defaut: 0,1,0) */
  9062. normal: Vector3;
  9063. /**
  9064. * Creates a PositionNormalVertex
  9065. * @param position the position of the vertex (defaut: 0,0,0)
  9066. * @param normal the normal of the vertex (defaut: 0,1,0)
  9067. */
  9068. constructor(
  9069. /** the position of the vertex (defaut: 0,0,0) */
  9070. position?: Vector3,
  9071. /** the normal of the vertex (defaut: 0,1,0) */
  9072. normal?: Vector3);
  9073. /**
  9074. * Clones the PositionNormalVertex
  9075. * @returns the cloned PositionNormalVertex
  9076. */
  9077. clone(): PositionNormalVertex;
  9078. }
  9079. /**
  9080. * Contains position, normal and uv vectors for a vertex
  9081. */
  9082. export class PositionNormalTextureVertex {
  9083. /** the position of the vertex (defaut: 0,0,0) */
  9084. position: Vector3;
  9085. /** the normal of the vertex (defaut: 0,1,0) */
  9086. normal: Vector3;
  9087. /** the uv of the vertex (default: 0,0) */
  9088. uv: Vector2;
  9089. /**
  9090. * Creates a PositionNormalTextureVertex
  9091. * @param position the position of the vertex (defaut: 0,0,0)
  9092. * @param normal the normal of the vertex (defaut: 0,1,0)
  9093. * @param uv the uv of the vertex (default: 0,0)
  9094. */
  9095. constructor(
  9096. /** the position of the vertex (defaut: 0,0,0) */
  9097. position?: Vector3,
  9098. /** the normal of the vertex (defaut: 0,1,0) */
  9099. normal?: Vector3,
  9100. /** the uv of the vertex (default: 0,0) */
  9101. uv?: Vector2);
  9102. /**
  9103. * Clones the PositionNormalTextureVertex
  9104. * @returns the cloned PositionNormalTextureVertex
  9105. */
  9106. clone(): PositionNormalTextureVertex;
  9107. }
  9108. }
  9109. declare module "babylonjs/Maths/math" {
  9110. export * from "babylonjs/Maths/math.axis";
  9111. export * from "babylonjs/Maths/math.color";
  9112. export * from "babylonjs/Maths/math.constants";
  9113. export * from "babylonjs/Maths/math.frustum";
  9114. export * from "babylonjs/Maths/math.path";
  9115. export * from "babylonjs/Maths/math.plane";
  9116. export * from "babylonjs/Maths/math.size";
  9117. export * from "babylonjs/Maths/math.vector";
  9118. export * from "babylonjs/Maths/math.vertexFormat";
  9119. export * from "babylonjs/Maths/math.viewport";
  9120. }
  9121. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9122. /**
  9123. * Enum defining the type of animations supported by InputBlock
  9124. */
  9125. export enum AnimatedInputBlockTypes {
  9126. /** No animation */
  9127. None = 0,
  9128. /** Time based animation. Will only work for floats */
  9129. Time = 1
  9130. }
  9131. }
  9132. declare module "babylonjs/Lights/shadowLight" {
  9133. import { Camera } from "babylonjs/Cameras/camera";
  9134. import { Scene } from "babylonjs/scene";
  9135. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9137. import { Light } from "babylonjs/Lights/light";
  9138. /**
  9139. * Interface describing all the common properties and methods a shadow light needs to implement.
  9140. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9141. * as well as binding the different shadow properties to the effects.
  9142. */
  9143. export interface IShadowLight extends Light {
  9144. /**
  9145. * The light id in the scene (used in scene.findLighById for instance)
  9146. */
  9147. id: string;
  9148. /**
  9149. * The position the shdow will be casted from.
  9150. */
  9151. position: Vector3;
  9152. /**
  9153. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9154. */
  9155. direction: Vector3;
  9156. /**
  9157. * The transformed position. Position of the light in world space taking parenting in account.
  9158. */
  9159. transformedPosition: Vector3;
  9160. /**
  9161. * The transformed direction. Direction of the light in world space taking parenting in account.
  9162. */
  9163. transformedDirection: Vector3;
  9164. /**
  9165. * The friendly name of the light in the scene.
  9166. */
  9167. name: string;
  9168. /**
  9169. * Defines the shadow projection clipping minimum z value.
  9170. */
  9171. shadowMinZ: number;
  9172. /**
  9173. * Defines the shadow projection clipping maximum z value.
  9174. */
  9175. shadowMaxZ: number;
  9176. /**
  9177. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9178. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9179. */
  9180. computeTransformedInformation(): boolean;
  9181. /**
  9182. * Gets the scene the light belongs to.
  9183. * @returns The scene
  9184. */
  9185. getScene(): Scene;
  9186. /**
  9187. * Callback defining a custom Projection Matrix Builder.
  9188. * This can be used to override the default projection matrix computation.
  9189. */
  9190. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9191. /**
  9192. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9193. * @param matrix The materix to updated with the projection information
  9194. * @param viewMatrix The transform matrix of the light
  9195. * @param renderList The list of mesh to render in the map
  9196. * @returns The current light
  9197. */
  9198. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9199. /**
  9200. * Gets the current depth scale used in ESM.
  9201. * @returns The scale
  9202. */
  9203. getDepthScale(): number;
  9204. /**
  9205. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9206. * @returns true if a cube texture needs to be use
  9207. */
  9208. needCube(): boolean;
  9209. /**
  9210. * Detects if the projection matrix requires to be recomputed this frame.
  9211. * @returns true if it requires to be recomputed otherwise, false.
  9212. */
  9213. needProjectionMatrixCompute(): boolean;
  9214. /**
  9215. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9216. */
  9217. forceProjectionMatrixCompute(): void;
  9218. /**
  9219. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9220. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9221. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9222. */
  9223. getShadowDirection(faceIndex?: number): Vector3;
  9224. /**
  9225. * Gets the minZ used for shadow according to both the scene and the light.
  9226. * @param activeCamera The camera we are returning the min for
  9227. * @returns the depth min z
  9228. */
  9229. getDepthMinZ(activeCamera: Camera): number;
  9230. /**
  9231. * Gets the maxZ used for shadow according to both the scene and the light.
  9232. * @param activeCamera The camera we are returning the max for
  9233. * @returns the depth max z
  9234. */
  9235. getDepthMaxZ(activeCamera: Camera): number;
  9236. }
  9237. /**
  9238. * Base implementation IShadowLight
  9239. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9240. */
  9241. export abstract class ShadowLight extends Light implements IShadowLight {
  9242. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9243. protected _position: Vector3;
  9244. protected _setPosition(value: Vector3): void;
  9245. /**
  9246. * Sets the position the shadow will be casted from. Also use as the light position for both
  9247. * point and spot lights.
  9248. */
  9249. get position(): Vector3;
  9250. /**
  9251. * Sets the position the shadow will be casted from. Also use as the light position for both
  9252. * point and spot lights.
  9253. */
  9254. set position(value: Vector3);
  9255. protected _direction: Vector3;
  9256. protected _setDirection(value: Vector3): void;
  9257. /**
  9258. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9259. * Also use as the light direction on spot and directional lights.
  9260. */
  9261. get direction(): Vector3;
  9262. /**
  9263. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9264. * Also use as the light direction on spot and directional lights.
  9265. */
  9266. set direction(value: Vector3);
  9267. protected _shadowMinZ: number;
  9268. /**
  9269. * Gets the shadow projection clipping minimum z value.
  9270. */
  9271. get shadowMinZ(): number;
  9272. /**
  9273. * Sets the shadow projection clipping minimum z value.
  9274. */
  9275. set shadowMinZ(value: number);
  9276. protected _shadowMaxZ: number;
  9277. /**
  9278. * Sets the shadow projection clipping maximum z value.
  9279. */
  9280. get shadowMaxZ(): number;
  9281. /**
  9282. * Gets the shadow projection clipping maximum z value.
  9283. */
  9284. set shadowMaxZ(value: number);
  9285. /**
  9286. * Callback defining a custom Projection Matrix Builder.
  9287. * This can be used to override the default projection matrix computation.
  9288. */
  9289. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9290. /**
  9291. * The transformed position. Position of the light in world space taking parenting in account.
  9292. */
  9293. transformedPosition: Vector3;
  9294. /**
  9295. * The transformed direction. Direction of the light in world space taking parenting in account.
  9296. */
  9297. transformedDirection: Vector3;
  9298. private _needProjectionMatrixCompute;
  9299. /**
  9300. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9301. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9302. */
  9303. computeTransformedInformation(): boolean;
  9304. /**
  9305. * Return the depth scale used for the shadow map.
  9306. * @returns the depth scale.
  9307. */
  9308. getDepthScale(): number;
  9309. /**
  9310. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9311. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9312. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9313. */
  9314. getShadowDirection(faceIndex?: number): Vector3;
  9315. /**
  9316. * Returns the ShadowLight absolute position in the World.
  9317. * @returns the position vector in world space
  9318. */
  9319. getAbsolutePosition(): Vector3;
  9320. /**
  9321. * Sets the ShadowLight direction toward the passed target.
  9322. * @param target The point to target in local space
  9323. * @returns the updated ShadowLight direction
  9324. */
  9325. setDirectionToTarget(target: Vector3): Vector3;
  9326. /**
  9327. * Returns the light rotation in euler definition.
  9328. * @returns the x y z rotation in local space.
  9329. */
  9330. getRotation(): Vector3;
  9331. /**
  9332. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9333. * @returns true if a cube texture needs to be use
  9334. */
  9335. needCube(): boolean;
  9336. /**
  9337. * Detects if the projection matrix requires to be recomputed this frame.
  9338. * @returns true if it requires to be recomputed otherwise, false.
  9339. */
  9340. needProjectionMatrixCompute(): boolean;
  9341. /**
  9342. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9343. */
  9344. forceProjectionMatrixCompute(): void;
  9345. /** @hidden */
  9346. _initCache(): void;
  9347. /** @hidden */
  9348. _isSynchronized(): boolean;
  9349. /**
  9350. * Computes the world matrix of the node
  9351. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9352. * @returns the world matrix
  9353. */
  9354. computeWorldMatrix(force?: boolean): Matrix;
  9355. /**
  9356. * Gets the minZ used for shadow according to both the scene and the light.
  9357. * @param activeCamera The camera we are returning the min for
  9358. * @returns the depth min z
  9359. */
  9360. getDepthMinZ(activeCamera: Camera): number;
  9361. /**
  9362. * Gets the maxZ used for shadow according to both the scene and the light.
  9363. * @param activeCamera The camera we are returning the max for
  9364. * @returns the depth max z
  9365. */
  9366. getDepthMaxZ(activeCamera: Camera): number;
  9367. /**
  9368. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9369. * @param matrix The materix to updated with the projection information
  9370. * @param viewMatrix The transform matrix of the light
  9371. * @param renderList The list of mesh to render in the map
  9372. * @returns The current light
  9373. */
  9374. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9375. }
  9376. }
  9377. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9378. /** @hidden */
  9379. export var packingFunctions: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9385. /** @hidden */
  9386. export var bayerDitherFunctions: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9392. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9393. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9394. /** @hidden */
  9395. export var shadowMapFragmentDeclaration: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9401. /** @hidden */
  9402. export var clipPlaneFragmentDeclaration: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9408. /** @hidden */
  9409. export var clipPlaneFragment: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9415. /** @hidden */
  9416. export var shadowMapFragment: {
  9417. name: string;
  9418. shader: string;
  9419. };
  9420. }
  9421. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9422. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9423. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9424. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9425. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9426. /** @hidden */
  9427. export var shadowMapPixelShader: {
  9428. name: string;
  9429. shader: string;
  9430. };
  9431. }
  9432. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9433. /** @hidden */
  9434. export var bonesDeclaration: {
  9435. name: string;
  9436. shader: string;
  9437. };
  9438. }
  9439. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9440. /** @hidden */
  9441. export var morphTargetsVertexGlobalDeclaration: {
  9442. name: string;
  9443. shader: string;
  9444. };
  9445. }
  9446. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9447. /** @hidden */
  9448. export var morphTargetsVertexDeclaration: {
  9449. name: string;
  9450. shader: string;
  9451. };
  9452. }
  9453. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9454. /** @hidden */
  9455. export var instancesDeclaration: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9461. /** @hidden */
  9462. export var helperFunctions: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9468. /** @hidden */
  9469. export var shadowMapVertexDeclaration: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9475. /** @hidden */
  9476. export var clipPlaneVertexDeclaration: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9482. /** @hidden */
  9483. export var morphTargetsVertex: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9489. /** @hidden */
  9490. export var instancesVertex: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9496. /** @hidden */
  9497. export var bonesVertex: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9503. /** @hidden */
  9504. export var shadowMapVertexNormalBias: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9510. /** @hidden */
  9511. export var shadowMapVertexMetric: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9517. /** @hidden */
  9518. export var clipPlaneVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9524. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9525. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9527. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9528. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9529. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9530. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9532. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9533. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9534. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9535. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9536. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9537. /** @hidden */
  9538. export var shadowMapVertexShader: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9544. /** @hidden */
  9545. export var depthBoxBlurPixelShader: {
  9546. name: string;
  9547. shader: string;
  9548. };
  9549. }
  9550. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9551. /** @hidden */
  9552. export var shadowMapFragmentSoftTransparentShadow: {
  9553. name: string;
  9554. shader: string;
  9555. };
  9556. }
  9557. declare module "babylonjs/Materials/effectFallbacks" {
  9558. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9559. import { Effect } from "babylonjs/Materials/effect";
  9560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9561. /**
  9562. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9563. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9564. */
  9565. export class EffectFallbacks implements IEffectFallbacks {
  9566. private _defines;
  9567. private _currentRank;
  9568. private _maxRank;
  9569. private _mesh;
  9570. /**
  9571. * Removes the fallback from the bound mesh.
  9572. */
  9573. unBindMesh(): void;
  9574. /**
  9575. * Adds a fallback on the specified property.
  9576. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9577. * @param define The name of the define in the shader
  9578. */
  9579. addFallback(rank: number, define: string): void;
  9580. /**
  9581. * Sets the mesh to use CPU skinning when needing to fallback.
  9582. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9583. * @param mesh The mesh to use the fallbacks.
  9584. */
  9585. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9586. /**
  9587. * Checks to see if more fallbacks are still availible.
  9588. */
  9589. get hasMoreFallbacks(): boolean;
  9590. /**
  9591. * Removes the defines that should be removed when falling back.
  9592. * @param currentDefines defines the current define statements for the shader.
  9593. * @param effect defines the current effect we try to compile
  9594. * @returns The resulting defines with defines of the current rank removed.
  9595. */
  9596. reduce(currentDefines: string, effect: Effect): string;
  9597. }
  9598. }
  9599. declare module "babylonjs/Actions/action" {
  9600. import { Observable } from "babylonjs/Misc/observable";
  9601. import { Condition } from "babylonjs/Actions/condition";
  9602. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9603. import { Nullable } from "babylonjs/types";
  9604. import { Scene } from "babylonjs/scene";
  9605. import { ActionManager } from "babylonjs/Actions/actionManager";
  9606. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9607. import { Node } from "babylonjs/node";
  9608. /**
  9609. * Interface used to define Action
  9610. */
  9611. export interface IAction {
  9612. /**
  9613. * Trigger for the action
  9614. */
  9615. trigger: number;
  9616. /** Options of the trigger */
  9617. triggerOptions: any;
  9618. /**
  9619. * Gets the trigger parameters
  9620. * @returns the trigger parameters
  9621. */
  9622. getTriggerParameter(): any;
  9623. /**
  9624. * Internal only - executes current action event
  9625. * @hidden
  9626. */
  9627. _executeCurrent(evt?: ActionEvent): void;
  9628. /**
  9629. * Serialize placeholder for child classes
  9630. * @param parent of child
  9631. * @returns the serialized object
  9632. */
  9633. serialize(parent: any): any;
  9634. /**
  9635. * Internal only
  9636. * @hidden
  9637. */
  9638. _prepare(): void;
  9639. /**
  9640. * Internal only - manager for action
  9641. * @hidden
  9642. */
  9643. _actionManager: Nullable<AbstractActionManager>;
  9644. /**
  9645. * Adds action to chain of actions, may be a DoNothingAction
  9646. * @param action defines the next action to execute
  9647. * @returns The action passed in
  9648. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9649. */
  9650. then(action: IAction): IAction;
  9651. }
  9652. /**
  9653. * The action to be carried out following a trigger
  9654. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9655. */
  9656. export class Action implements IAction {
  9657. /** the trigger, with or without parameters, for the action */
  9658. triggerOptions: any;
  9659. /**
  9660. * Trigger for the action
  9661. */
  9662. trigger: number;
  9663. /**
  9664. * Internal only - manager for action
  9665. * @hidden
  9666. */
  9667. _actionManager: ActionManager;
  9668. private _nextActiveAction;
  9669. private _child;
  9670. private _condition?;
  9671. private _triggerParameter;
  9672. /**
  9673. * An event triggered prior to action being executed.
  9674. */
  9675. onBeforeExecuteObservable: Observable<Action>;
  9676. /**
  9677. * Creates a new Action
  9678. * @param triggerOptions the trigger, with or without parameters, for the action
  9679. * @param condition an optional determinant of action
  9680. */
  9681. constructor(
  9682. /** the trigger, with or without parameters, for the action */
  9683. triggerOptions: any, condition?: Condition);
  9684. /**
  9685. * Internal only
  9686. * @hidden
  9687. */
  9688. _prepare(): void;
  9689. /**
  9690. * Gets the trigger parameters
  9691. * @returns the trigger parameters
  9692. */
  9693. getTriggerParameter(): any;
  9694. /**
  9695. * Internal only - executes current action event
  9696. * @hidden
  9697. */
  9698. _executeCurrent(evt?: ActionEvent): void;
  9699. /**
  9700. * Execute placeholder for child classes
  9701. * @param evt optional action event
  9702. */
  9703. execute(evt?: ActionEvent): void;
  9704. /**
  9705. * Skips to next active action
  9706. */
  9707. skipToNextActiveAction(): void;
  9708. /**
  9709. * Adds action to chain of actions, may be a DoNothingAction
  9710. * @param action defines the next action to execute
  9711. * @returns The action passed in
  9712. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9713. */
  9714. then(action: Action): Action;
  9715. /**
  9716. * Internal only
  9717. * @hidden
  9718. */
  9719. _getProperty(propertyPath: string): string;
  9720. /**
  9721. * Internal only
  9722. * @hidden
  9723. */
  9724. _getEffectiveTarget(target: any, propertyPath: string): any;
  9725. /**
  9726. * Serialize placeholder for child classes
  9727. * @param parent of child
  9728. * @returns the serialized object
  9729. */
  9730. serialize(parent: any): any;
  9731. /**
  9732. * Internal only called by serialize
  9733. * @hidden
  9734. */
  9735. protected _serialize(serializedAction: any, parent?: any): any;
  9736. /**
  9737. * Internal only
  9738. * @hidden
  9739. */
  9740. static _SerializeValueAsString: (value: any) => string;
  9741. /**
  9742. * Internal only
  9743. * @hidden
  9744. */
  9745. static _GetTargetProperty: (target: Scene | Node) => {
  9746. name: string;
  9747. targetType: string;
  9748. value: string;
  9749. };
  9750. }
  9751. }
  9752. declare module "babylonjs/Actions/condition" {
  9753. import { ActionManager } from "babylonjs/Actions/actionManager";
  9754. /**
  9755. * A Condition applied to an Action
  9756. */
  9757. export class Condition {
  9758. /**
  9759. * Internal only - manager for action
  9760. * @hidden
  9761. */
  9762. _actionManager: ActionManager;
  9763. /**
  9764. * Internal only
  9765. * @hidden
  9766. */
  9767. _evaluationId: number;
  9768. /**
  9769. * Internal only
  9770. * @hidden
  9771. */
  9772. _currentResult: boolean;
  9773. /**
  9774. * Creates a new Condition
  9775. * @param actionManager the manager of the action the condition is applied to
  9776. */
  9777. constructor(actionManager: ActionManager);
  9778. /**
  9779. * Check if the current condition is valid
  9780. * @returns a boolean
  9781. */
  9782. isValid(): boolean;
  9783. /**
  9784. * Internal only
  9785. * @hidden
  9786. */
  9787. _getProperty(propertyPath: string): string;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. _getEffectiveTarget(target: any, propertyPath: string): any;
  9793. /**
  9794. * Serialize placeholder for child classes
  9795. * @returns the serialized object
  9796. */
  9797. serialize(): any;
  9798. /**
  9799. * Internal only
  9800. * @hidden
  9801. */
  9802. protected _serialize(serializedCondition: any): any;
  9803. }
  9804. /**
  9805. * Defines specific conditional operators as extensions of Condition
  9806. */
  9807. export class ValueCondition extends Condition {
  9808. /** path to specify the property of the target the conditional operator uses */
  9809. propertyPath: string;
  9810. /** the value compared by the conditional operator against the current value of the property */
  9811. value: any;
  9812. /** the conditional operator, default ValueCondition.IsEqual */
  9813. operator: number;
  9814. /**
  9815. * Internal only
  9816. * @hidden
  9817. */
  9818. private static _IsEqual;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. private static _IsDifferent;
  9824. /**
  9825. * Internal only
  9826. * @hidden
  9827. */
  9828. private static _IsGreater;
  9829. /**
  9830. * Internal only
  9831. * @hidden
  9832. */
  9833. private static _IsLesser;
  9834. /**
  9835. * returns the number for IsEqual
  9836. */
  9837. static get IsEqual(): number;
  9838. /**
  9839. * Returns the number for IsDifferent
  9840. */
  9841. static get IsDifferent(): number;
  9842. /**
  9843. * Returns the number for IsGreater
  9844. */
  9845. static get IsGreater(): number;
  9846. /**
  9847. * Returns the number for IsLesser
  9848. */
  9849. static get IsLesser(): number;
  9850. /**
  9851. * Internal only The action manager for the condition
  9852. * @hidden
  9853. */
  9854. _actionManager: ActionManager;
  9855. /**
  9856. * Internal only
  9857. * @hidden
  9858. */
  9859. private _target;
  9860. /**
  9861. * Internal only
  9862. * @hidden
  9863. */
  9864. private _effectiveTarget;
  9865. /**
  9866. * Internal only
  9867. * @hidden
  9868. */
  9869. private _property;
  9870. /**
  9871. * Creates a new ValueCondition
  9872. * @param actionManager manager for the action the condition applies to
  9873. * @param target for the action
  9874. * @param propertyPath path to specify the property of the target the conditional operator uses
  9875. * @param value the value compared by the conditional operator against the current value of the property
  9876. * @param operator the conditional operator, default ValueCondition.IsEqual
  9877. */
  9878. constructor(actionManager: ActionManager, target: any,
  9879. /** path to specify the property of the target the conditional operator uses */
  9880. propertyPath: string,
  9881. /** the value compared by the conditional operator against the current value of the property */
  9882. value: any,
  9883. /** the conditional operator, default ValueCondition.IsEqual */
  9884. operator?: number);
  9885. /**
  9886. * Compares the given value with the property value for the specified conditional operator
  9887. * @returns the result of the comparison
  9888. */
  9889. isValid(): boolean;
  9890. /**
  9891. * Serialize the ValueCondition into a JSON compatible object
  9892. * @returns serialization object
  9893. */
  9894. serialize(): any;
  9895. /**
  9896. * Gets the name of the conditional operator for the ValueCondition
  9897. * @param operator the conditional operator
  9898. * @returns the name
  9899. */
  9900. static GetOperatorName(operator: number): string;
  9901. }
  9902. /**
  9903. * Defines a predicate condition as an extension of Condition
  9904. */
  9905. export class PredicateCondition extends Condition {
  9906. /** defines the predicate function used to validate the condition */
  9907. predicate: () => boolean;
  9908. /**
  9909. * Internal only - manager for action
  9910. * @hidden
  9911. */
  9912. _actionManager: ActionManager;
  9913. /**
  9914. * Creates a new PredicateCondition
  9915. * @param actionManager manager for the action the condition applies to
  9916. * @param predicate defines the predicate function used to validate the condition
  9917. */
  9918. constructor(actionManager: ActionManager,
  9919. /** defines the predicate function used to validate the condition */
  9920. predicate: () => boolean);
  9921. /**
  9922. * @returns the validity of the predicate condition
  9923. */
  9924. isValid(): boolean;
  9925. }
  9926. /**
  9927. * Defines a state condition as an extension of Condition
  9928. */
  9929. export class StateCondition extends Condition {
  9930. /** Value to compare with target state */
  9931. value: string;
  9932. /**
  9933. * Internal only - manager for action
  9934. * @hidden
  9935. */
  9936. _actionManager: ActionManager;
  9937. /**
  9938. * Internal only
  9939. * @hidden
  9940. */
  9941. private _target;
  9942. /**
  9943. * Creates a new StateCondition
  9944. * @param actionManager manager for the action the condition applies to
  9945. * @param target of the condition
  9946. * @param value to compare with target state
  9947. */
  9948. constructor(actionManager: ActionManager, target: any,
  9949. /** Value to compare with target state */
  9950. value: string);
  9951. /**
  9952. * Gets a boolean indicating if the current condition is met
  9953. * @returns the validity of the state
  9954. */
  9955. isValid(): boolean;
  9956. /**
  9957. * Serialize the StateCondition into a JSON compatible object
  9958. * @returns serialization object
  9959. */
  9960. serialize(): any;
  9961. }
  9962. }
  9963. declare module "babylonjs/Actions/directActions" {
  9964. import { Action } from "babylonjs/Actions/action";
  9965. import { Condition } from "babylonjs/Actions/condition";
  9966. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9967. /**
  9968. * This defines an action responsible to toggle a boolean once triggered.
  9969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9970. */
  9971. export class SwitchBooleanAction extends Action {
  9972. /**
  9973. * The path to the boolean property in the target object
  9974. */
  9975. propertyPath: string;
  9976. private _target;
  9977. private _effectiveTarget;
  9978. private _property;
  9979. /**
  9980. * Instantiate the action
  9981. * @param triggerOptions defines the trigger options
  9982. * @param target defines the object containing the boolean
  9983. * @param propertyPath defines the path to the boolean property in the target object
  9984. * @param condition defines the trigger related conditions
  9985. */
  9986. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9987. /** @hidden */
  9988. _prepare(): void;
  9989. /**
  9990. * Execute the action toggle the boolean value.
  9991. */
  9992. execute(): void;
  9993. /**
  9994. * Serializes the actions and its related information.
  9995. * @param parent defines the object to serialize in
  9996. * @returns the serialized object
  9997. */
  9998. serialize(parent: any): any;
  9999. }
  10000. /**
  10001. * This defines an action responsible to set a the state field of the target
  10002. * to a desired value once triggered.
  10003. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10004. */
  10005. export class SetStateAction extends Action {
  10006. /**
  10007. * The value to store in the state field.
  10008. */
  10009. value: string;
  10010. private _target;
  10011. /**
  10012. * Instantiate the action
  10013. * @param triggerOptions defines the trigger options
  10014. * @param target defines the object containing the state property
  10015. * @param value defines the value to store in the state field
  10016. * @param condition defines the trigger related conditions
  10017. */
  10018. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10019. /**
  10020. * Execute the action and store the value on the target state property.
  10021. */
  10022. execute(): void;
  10023. /**
  10024. * Serializes the actions and its related information.
  10025. * @param parent defines the object to serialize in
  10026. * @returns the serialized object
  10027. */
  10028. serialize(parent: any): any;
  10029. }
  10030. /**
  10031. * This defines an action responsible to set a property of the target
  10032. * to a desired value once triggered.
  10033. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10034. */
  10035. export class SetValueAction extends Action {
  10036. /**
  10037. * The path of the property to set in the target.
  10038. */
  10039. propertyPath: string;
  10040. /**
  10041. * The value to set in the property
  10042. */
  10043. value: any;
  10044. private _target;
  10045. private _effectiveTarget;
  10046. private _property;
  10047. /**
  10048. * Instantiate the action
  10049. * @param triggerOptions defines the trigger options
  10050. * @param target defines the object containing the property
  10051. * @param propertyPath defines the path of the property to set in the target
  10052. * @param value defines the value to set in the property
  10053. * @param condition defines the trigger related conditions
  10054. */
  10055. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10056. /** @hidden */
  10057. _prepare(): void;
  10058. /**
  10059. * Execute the action and set the targetted property to the desired value.
  10060. */
  10061. execute(): void;
  10062. /**
  10063. * Serializes the actions and its related information.
  10064. * @param parent defines the object to serialize in
  10065. * @returns the serialized object
  10066. */
  10067. serialize(parent: any): any;
  10068. }
  10069. /**
  10070. * This defines an action responsible to increment the target value
  10071. * to a desired value once triggered.
  10072. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10073. */
  10074. export class IncrementValueAction extends Action {
  10075. /**
  10076. * The path of the property to increment in the target.
  10077. */
  10078. propertyPath: string;
  10079. /**
  10080. * The value we should increment the property by.
  10081. */
  10082. value: any;
  10083. private _target;
  10084. private _effectiveTarget;
  10085. private _property;
  10086. /**
  10087. * Instantiate the action
  10088. * @param triggerOptions defines the trigger options
  10089. * @param target defines the object containing the property
  10090. * @param propertyPath defines the path of the property to increment in the target
  10091. * @param value defines the value value we should increment the property by
  10092. * @param condition defines the trigger related conditions
  10093. */
  10094. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10095. /** @hidden */
  10096. _prepare(): void;
  10097. /**
  10098. * Execute the action and increment the target of the value amount.
  10099. */
  10100. execute(): void;
  10101. /**
  10102. * Serializes the actions and its related information.
  10103. * @param parent defines the object to serialize in
  10104. * @returns the serialized object
  10105. */
  10106. serialize(parent: any): any;
  10107. }
  10108. /**
  10109. * This defines an action responsible to start an animation once triggered.
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10111. */
  10112. export class PlayAnimationAction extends Action {
  10113. /**
  10114. * Where the animation should start (animation frame)
  10115. */
  10116. from: number;
  10117. /**
  10118. * Where the animation should stop (animation frame)
  10119. */
  10120. to: number;
  10121. /**
  10122. * Define if the animation should loop or stop after the first play.
  10123. */
  10124. loop?: boolean;
  10125. private _target;
  10126. /**
  10127. * Instantiate the action
  10128. * @param triggerOptions defines the trigger options
  10129. * @param target defines the target animation or animation name
  10130. * @param from defines from where the animation should start (animation frame)
  10131. * @param end defines where the animation should stop (animation frame)
  10132. * @param loop defines if the animation should loop or stop after the first play
  10133. * @param condition defines the trigger related conditions
  10134. */
  10135. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10136. /** @hidden */
  10137. _prepare(): void;
  10138. /**
  10139. * Execute the action and play the animation.
  10140. */
  10141. execute(): void;
  10142. /**
  10143. * Serializes the actions and its related information.
  10144. * @param parent defines the object to serialize in
  10145. * @returns the serialized object
  10146. */
  10147. serialize(parent: any): any;
  10148. }
  10149. /**
  10150. * This defines an action responsible to stop an animation once triggered.
  10151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10152. */
  10153. export class StopAnimationAction extends Action {
  10154. private _target;
  10155. /**
  10156. * Instantiate the action
  10157. * @param triggerOptions defines the trigger options
  10158. * @param target defines the target animation or animation name
  10159. * @param condition defines the trigger related conditions
  10160. */
  10161. constructor(triggerOptions: any, target: any, condition?: Condition);
  10162. /** @hidden */
  10163. _prepare(): void;
  10164. /**
  10165. * Execute the action and stop the animation.
  10166. */
  10167. execute(): void;
  10168. /**
  10169. * Serializes the actions and its related information.
  10170. * @param parent defines the object to serialize in
  10171. * @returns the serialized object
  10172. */
  10173. serialize(parent: any): any;
  10174. }
  10175. /**
  10176. * This defines an action responsible that does nothing once triggered.
  10177. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10178. */
  10179. export class DoNothingAction extends Action {
  10180. /**
  10181. * Instantiate the action
  10182. * @param triggerOptions defines the trigger options
  10183. * @param condition defines the trigger related conditions
  10184. */
  10185. constructor(triggerOptions?: any, condition?: Condition);
  10186. /**
  10187. * Execute the action and do nothing.
  10188. */
  10189. execute(): void;
  10190. /**
  10191. * Serializes the actions and its related information.
  10192. * @param parent defines the object to serialize in
  10193. * @returns the serialized object
  10194. */
  10195. serialize(parent: any): any;
  10196. }
  10197. /**
  10198. * This defines an action responsible to trigger several actions once triggered.
  10199. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10200. */
  10201. export class CombineAction extends Action {
  10202. /**
  10203. * The list of aggregated animations to run.
  10204. */
  10205. children: Action[];
  10206. /**
  10207. * Instantiate the action
  10208. * @param triggerOptions defines the trigger options
  10209. * @param children defines the list of aggregated animations to run
  10210. * @param condition defines the trigger related conditions
  10211. */
  10212. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10213. /** @hidden */
  10214. _prepare(): void;
  10215. /**
  10216. * Execute the action and executes all the aggregated actions.
  10217. */
  10218. execute(evt: ActionEvent): void;
  10219. /**
  10220. * Serializes the actions and its related information.
  10221. * @param parent defines the object to serialize in
  10222. * @returns the serialized object
  10223. */
  10224. serialize(parent: any): any;
  10225. }
  10226. /**
  10227. * This defines an action responsible to run code (external event) once triggered.
  10228. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10229. */
  10230. export class ExecuteCodeAction extends Action {
  10231. /**
  10232. * The callback function to run.
  10233. */
  10234. func: (evt: ActionEvent) => void;
  10235. /**
  10236. * Instantiate the action
  10237. * @param triggerOptions defines the trigger options
  10238. * @param func defines the callback function to run
  10239. * @param condition defines the trigger related conditions
  10240. */
  10241. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10242. /**
  10243. * Execute the action and run the attached code.
  10244. */
  10245. execute(evt: ActionEvent): void;
  10246. }
  10247. /**
  10248. * This defines an action responsible to set the parent property of the target once triggered.
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10250. */
  10251. export class SetParentAction extends Action {
  10252. private _parent;
  10253. private _target;
  10254. /**
  10255. * Instantiate the action
  10256. * @param triggerOptions defines the trigger options
  10257. * @param target defines the target containing the parent property
  10258. * @param parent defines from where the animation should start (animation frame)
  10259. * @param condition defines the trigger related conditions
  10260. */
  10261. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10262. /** @hidden */
  10263. _prepare(): void;
  10264. /**
  10265. * Execute the action and set the parent property.
  10266. */
  10267. execute(): void;
  10268. /**
  10269. * Serializes the actions and its related information.
  10270. * @param parent defines the object to serialize in
  10271. * @returns the serialized object
  10272. */
  10273. serialize(parent: any): any;
  10274. }
  10275. }
  10276. declare module "babylonjs/Actions/actionManager" {
  10277. import { Nullable } from "babylonjs/types";
  10278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10279. import { Scene } from "babylonjs/scene";
  10280. import { IAction } from "babylonjs/Actions/action";
  10281. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10282. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10283. /**
  10284. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10285. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10286. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10287. */
  10288. export class ActionManager extends AbstractActionManager {
  10289. /**
  10290. * Nothing
  10291. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10292. */
  10293. static readonly NothingTrigger: number;
  10294. /**
  10295. * On pick
  10296. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10297. */
  10298. static readonly OnPickTrigger: number;
  10299. /**
  10300. * On left pick
  10301. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10302. */
  10303. static readonly OnLeftPickTrigger: number;
  10304. /**
  10305. * On right pick
  10306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10307. */
  10308. static readonly OnRightPickTrigger: number;
  10309. /**
  10310. * On center pick
  10311. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10312. */
  10313. static readonly OnCenterPickTrigger: number;
  10314. /**
  10315. * On pick down
  10316. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10317. */
  10318. static readonly OnPickDownTrigger: number;
  10319. /**
  10320. * On double pick
  10321. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10322. */
  10323. static readonly OnDoublePickTrigger: number;
  10324. /**
  10325. * On pick up
  10326. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10327. */
  10328. static readonly OnPickUpTrigger: number;
  10329. /**
  10330. * On pick out.
  10331. * This trigger will only be raised if you also declared a OnPickDown
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnPickOutTrigger: number;
  10335. /**
  10336. * On long press
  10337. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10338. */
  10339. static readonly OnLongPressTrigger: number;
  10340. /**
  10341. * On pointer over
  10342. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10343. */
  10344. static readonly OnPointerOverTrigger: number;
  10345. /**
  10346. * On pointer out
  10347. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10348. */
  10349. static readonly OnPointerOutTrigger: number;
  10350. /**
  10351. * On every frame
  10352. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10353. */
  10354. static readonly OnEveryFrameTrigger: number;
  10355. /**
  10356. * On intersection enter
  10357. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10358. */
  10359. static readonly OnIntersectionEnterTrigger: number;
  10360. /**
  10361. * On intersection exit
  10362. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10363. */
  10364. static readonly OnIntersectionExitTrigger: number;
  10365. /**
  10366. * On key down
  10367. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10368. */
  10369. static readonly OnKeyDownTrigger: number;
  10370. /**
  10371. * On key up
  10372. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10373. */
  10374. static readonly OnKeyUpTrigger: number;
  10375. private _scene;
  10376. /**
  10377. * Creates a new action manager
  10378. * @param scene defines the hosting scene
  10379. */
  10380. constructor(scene: Scene);
  10381. /**
  10382. * Releases all associated resources
  10383. */
  10384. dispose(): void;
  10385. /**
  10386. * Gets hosting scene
  10387. * @returns the hosting scene
  10388. */
  10389. getScene(): Scene;
  10390. /**
  10391. * Does this action manager handles actions of any of the given triggers
  10392. * @param triggers defines the triggers to be tested
  10393. * @return a boolean indicating whether one (or more) of the triggers is handled
  10394. */
  10395. hasSpecificTriggers(triggers: number[]): boolean;
  10396. /**
  10397. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10398. * speed.
  10399. * @param triggerA defines the trigger to be tested
  10400. * @param triggerB defines the trigger to be tested
  10401. * @return a boolean indicating whether one (or more) of the triggers is handled
  10402. */
  10403. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10404. /**
  10405. * Does this action manager handles actions of a given trigger
  10406. * @param trigger defines the trigger to be tested
  10407. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10408. * @return whether the trigger is handled
  10409. */
  10410. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10411. /**
  10412. * Does this action manager has pointer triggers
  10413. */
  10414. get hasPointerTriggers(): boolean;
  10415. /**
  10416. * Does this action manager has pick triggers
  10417. */
  10418. get hasPickTriggers(): boolean;
  10419. /**
  10420. * Registers an action to this action manager
  10421. * @param action defines the action to be registered
  10422. * @return the action amended (prepared) after registration
  10423. */
  10424. registerAction(action: IAction): Nullable<IAction>;
  10425. /**
  10426. * Unregisters an action to this action manager
  10427. * @param action defines the action to be unregistered
  10428. * @return a boolean indicating whether the action has been unregistered
  10429. */
  10430. unregisterAction(action: IAction): Boolean;
  10431. /**
  10432. * Process a specific trigger
  10433. * @param trigger defines the trigger to process
  10434. * @param evt defines the event details to be processed
  10435. */
  10436. processTrigger(trigger: number, evt?: IActionEvent): void;
  10437. /** @hidden */
  10438. _getEffectiveTarget(target: any, propertyPath: string): any;
  10439. /** @hidden */
  10440. _getProperty(propertyPath: string): string;
  10441. /**
  10442. * Serialize this manager to a JSON object
  10443. * @param name defines the property name to store this manager
  10444. * @returns a JSON representation of this manager
  10445. */
  10446. serialize(name: string): any;
  10447. /**
  10448. * Creates a new ActionManager from a JSON data
  10449. * @param parsedActions defines the JSON data to read from
  10450. * @param object defines the hosting mesh
  10451. * @param scene defines the hosting scene
  10452. */
  10453. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10454. /**
  10455. * Get a trigger name by index
  10456. * @param trigger defines the trigger index
  10457. * @returns a trigger name
  10458. */
  10459. static GetTriggerName(trigger: number): string;
  10460. }
  10461. }
  10462. declare module "babylonjs/Sprites/sprite" {
  10463. import { Vector3 } from "babylonjs/Maths/math.vector";
  10464. import { Nullable } from "babylonjs/types";
  10465. import { ActionManager } from "babylonjs/Actions/actionManager";
  10466. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10467. import { Color4 } from "babylonjs/Maths/math.color";
  10468. import { Observable } from "babylonjs/Misc/observable";
  10469. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10470. import { Animation } from "babylonjs/Animations/animation";
  10471. /**
  10472. * Class used to represent a sprite
  10473. * @see https://doc.babylonjs.com/babylon101/sprites
  10474. */
  10475. export class Sprite implements IAnimatable {
  10476. /** defines the name */
  10477. name: string;
  10478. /** Gets or sets the current world position */
  10479. position: Vector3;
  10480. /** Gets or sets the main color */
  10481. color: Color4;
  10482. /** Gets or sets the width */
  10483. width: number;
  10484. /** Gets or sets the height */
  10485. height: number;
  10486. /** Gets or sets rotation angle */
  10487. angle: number;
  10488. /** Gets or sets the cell index in the sprite sheet */
  10489. cellIndex: number;
  10490. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10491. cellRef: string;
  10492. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10493. invertU: boolean;
  10494. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10495. invertV: boolean;
  10496. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10497. disposeWhenFinishedAnimating: boolean;
  10498. /** Gets the list of attached animations */
  10499. animations: Nullable<Array<Animation>>;
  10500. /** Gets or sets a boolean indicating if the sprite can be picked */
  10501. isPickable: boolean;
  10502. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10503. useAlphaForPicking: boolean;
  10504. /** @hidden */
  10505. _xOffset: number;
  10506. /** @hidden */
  10507. _yOffset: number;
  10508. /** @hidden */
  10509. _xSize: number;
  10510. /** @hidden */
  10511. _ySize: number;
  10512. /**
  10513. * Gets or sets the associated action manager
  10514. */
  10515. actionManager: Nullable<ActionManager>;
  10516. /**
  10517. * An event triggered when the control has been disposed
  10518. */
  10519. onDisposeObservable: Observable<Sprite>;
  10520. private _animationStarted;
  10521. private _loopAnimation;
  10522. private _fromIndex;
  10523. private _toIndex;
  10524. private _delay;
  10525. private _direction;
  10526. private _manager;
  10527. private _time;
  10528. private _onAnimationEnd;
  10529. /**
  10530. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10531. */
  10532. isVisible: boolean;
  10533. /**
  10534. * Gets or sets the sprite size
  10535. */
  10536. get size(): number;
  10537. set size(value: number);
  10538. /**
  10539. * Returns a boolean indicating if the animation is started
  10540. */
  10541. get animationStarted(): boolean;
  10542. /**
  10543. * Gets or sets the unique id of the sprite
  10544. */
  10545. uniqueId: number;
  10546. /**
  10547. * Gets the manager of this sprite
  10548. */
  10549. get manager(): ISpriteManager;
  10550. /**
  10551. * Creates a new Sprite
  10552. * @param name defines the name
  10553. * @param manager defines the manager
  10554. */
  10555. constructor(
  10556. /** defines the name */
  10557. name: string, manager: ISpriteManager);
  10558. /**
  10559. * Returns the string "Sprite"
  10560. * @returns "Sprite"
  10561. */
  10562. getClassName(): string;
  10563. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10564. get fromIndex(): number;
  10565. set fromIndex(value: number);
  10566. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10567. get toIndex(): number;
  10568. set toIndex(value: number);
  10569. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10570. get loopAnimation(): boolean;
  10571. set loopAnimation(value: boolean);
  10572. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10573. get delay(): number;
  10574. set delay(value: number);
  10575. /**
  10576. * Starts an animation
  10577. * @param from defines the initial key
  10578. * @param to defines the end key
  10579. * @param loop defines if the animation must loop
  10580. * @param delay defines the start delay (in ms)
  10581. * @param onAnimationEnd defines a callback to call when animation ends
  10582. */
  10583. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10584. /** Stops current animation (if any) */
  10585. stopAnimation(): void;
  10586. /** @hidden */
  10587. _animate(deltaTime: number): void;
  10588. /** Release associated resources */
  10589. dispose(): void;
  10590. /**
  10591. * Serializes the sprite to a JSON object
  10592. * @returns the JSON object
  10593. */
  10594. serialize(): any;
  10595. /**
  10596. * Parses a JSON object to create a new sprite
  10597. * @param parsedSprite The JSON object to parse
  10598. * @param manager defines the hosting manager
  10599. * @returns the new sprite
  10600. */
  10601. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10602. }
  10603. }
  10604. declare module "babylonjs/Collisions/pickingInfo" {
  10605. import { Nullable } from "babylonjs/types";
  10606. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10608. import { Sprite } from "babylonjs/Sprites/sprite";
  10609. import { Ray } from "babylonjs/Culling/ray";
  10610. /**
  10611. * Information about the result of picking within a scene
  10612. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10613. */
  10614. export class PickingInfo {
  10615. /** @hidden */
  10616. _pickingUnavailable: boolean;
  10617. /**
  10618. * If the pick collided with an object
  10619. */
  10620. hit: boolean;
  10621. /**
  10622. * Distance away where the pick collided
  10623. */
  10624. distance: number;
  10625. /**
  10626. * The location of pick collision
  10627. */
  10628. pickedPoint: Nullable<Vector3>;
  10629. /**
  10630. * The mesh corresponding the the pick collision
  10631. */
  10632. pickedMesh: Nullable<AbstractMesh>;
  10633. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10634. bu: number;
  10635. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10636. bv: number;
  10637. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10638. faceId: number;
  10639. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10640. subMeshFaceId: number;
  10641. /** Id of the the submesh that was picked */
  10642. subMeshId: number;
  10643. /** If a sprite was picked, this will be the sprite the pick collided with */
  10644. pickedSprite: Nullable<Sprite>;
  10645. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10646. thinInstanceIndex: number;
  10647. /**
  10648. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10649. */
  10650. originMesh: Nullable<AbstractMesh>;
  10651. /**
  10652. * The ray that was used to perform the picking.
  10653. */
  10654. ray: Nullable<Ray>;
  10655. /**
  10656. * Gets the normal correspodning to the face the pick collided with
  10657. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10658. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10659. * @returns The normal correspodning to the face the pick collided with
  10660. */
  10661. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10662. /**
  10663. * Gets the texture coordinates of where the pick occured
  10664. * @returns the vector containing the coordnates of the texture
  10665. */
  10666. getTextureCoordinates(): Nullable<Vector2>;
  10667. }
  10668. }
  10669. declare module "babylonjs/Culling/ray" {
  10670. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10671. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10673. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10674. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10675. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10676. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10677. import { Plane } from "babylonjs/Maths/math.plane";
  10678. /**
  10679. * Class representing a ray with position and direction
  10680. */
  10681. export class Ray {
  10682. /** origin point */
  10683. origin: Vector3;
  10684. /** direction */
  10685. direction: Vector3;
  10686. /** length of the ray */
  10687. length: number;
  10688. private static readonly _TmpVector3;
  10689. private _tmpRay;
  10690. /**
  10691. * Creates a new ray
  10692. * @param origin origin point
  10693. * @param direction direction
  10694. * @param length length of the ray
  10695. */
  10696. constructor(
  10697. /** origin point */
  10698. origin: Vector3,
  10699. /** direction */
  10700. direction: Vector3,
  10701. /** length of the ray */
  10702. length?: number);
  10703. /**
  10704. * Checks if the ray intersects a box
  10705. * This does not account for the ray lenght by design to improve perfs.
  10706. * @param minimum bound of the box
  10707. * @param maximum bound of the box
  10708. * @param intersectionTreshold extra extend to be added to the box in all direction
  10709. * @returns if the box was hit
  10710. */
  10711. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10712. /**
  10713. * Checks if the ray intersects a box
  10714. * This does not account for the ray lenght by design to improve perfs.
  10715. * @param box the bounding box to check
  10716. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10717. * @returns if the box was hit
  10718. */
  10719. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10720. /**
  10721. * If the ray hits a sphere
  10722. * @param sphere the bounding sphere to check
  10723. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10724. * @returns true if it hits the sphere
  10725. */
  10726. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10727. /**
  10728. * If the ray hits a triange
  10729. * @param vertex0 triangle vertex
  10730. * @param vertex1 triangle vertex
  10731. * @param vertex2 triangle vertex
  10732. * @returns intersection information if hit
  10733. */
  10734. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10735. /**
  10736. * Checks if ray intersects a plane
  10737. * @param plane the plane to check
  10738. * @returns the distance away it was hit
  10739. */
  10740. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10741. /**
  10742. * Calculate the intercept of a ray on a given axis
  10743. * @param axis to check 'x' | 'y' | 'z'
  10744. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10745. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10746. */
  10747. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10748. /**
  10749. * Checks if ray intersects a mesh
  10750. * @param mesh the mesh to check
  10751. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10752. * @returns picking info of the intersecton
  10753. */
  10754. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10755. /**
  10756. * Checks if ray intersects a mesh
  10757. * @param meshes the meshes to check
  10758. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10759. * @param results array to store result in
  10760. * @returns Array of picking infos
  10761. */
  10762. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10763. private _comparePickingInfo;
  10764. private static smallnum;
  10765. private static rayl;
  10766. /**
  10767. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10768. * @param sega the first point of the segment to test the intersection against
  10769. * @param segb the second point of the segment to test the intersection against
  10770. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10771. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10772. */
  10773. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10774. /**
  10775. * Update the ray from viewport position
  10776. * @param x position
  10777. * @param y y position
  10778. * @param viewportWidth viewport width
  10779. * @param viewportHeight viewport height
  10780. * @param world world matrix
  10781. * @param view view matrix
  10782. * @param projection projection matrix
  10783. * @returns this ray updated
  10784. */
  10785. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10786. /**
  10787. * Creates a ray with origin and direction of 0,0,0
  10788. * @returns the new ray
  10789. */
  10790. static Zero(): Ray;
  10791. /**
  10792. * Creates a new ray from screen space and viewport
  10793. * @param x position
  10794. * @param y y position
  10795. * @param viewportWidth viewport width
  10796. * @param viewportHeight viewport height
  10797. * @param world world matrix
  10798. * @param view view matrix
  10799. * @param projection projection matrix
  10800. * @returns new ray
  10801. */
  10802. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10803. /**
  10804. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10805. * transformed to the given world matrix.
  10806. * @param origin The origin point
  10807. * @param end The end point
  10808. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10809. * @returns the new ray
  10810. */
  10811. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10812. /**
  10813. * Transforms a ray by a matrix
  10814. * @param ray ray to transform
  10815. * @param matrix matrix to apply
  10816. * @returns the resulting new ray
  10817. */
  10818. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10819. /**
  10820. * Transforms a ray by a matrix
  10821. * @param ray ray to transform
  10822. * @param matrix matrix to apply
  10823. * @param result ray to store result in
  10824. */
  10825. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10826. /**
  10827. * Unproject a ray from screen space to object space
  10828. * @param sourceX defines the screen space x coordinate to use
  10829. * @param sourceY defines the screen space y coordinate to use
  10830. * @param viewportWidth defines the current width of the viewport
  10831. * @param viewportHeight defines the current height of the viewport
  10832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10833. * @param view defines the view matrix to use
  10834. * @param projection defines the projection matrix to use
  10835. */
  10836. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10837. }
  10838. /**
  10839. * Type used to define predicate used to select faces when a mesh intersection is detected
  10840. */
  10841. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10842. module "babylonjs/scene" {
  10843. interface Scene {
  10844. /** @hidden */
  10845. _tempPickingRay: Nullable<Ray>;
  10846. /** @hidden */
  10847. _cachedRayForTransform: Ray;
  10848. /** @hidden */
  10849. _pickWithRayInverseMatrix: Matrix;
  10850. /** @hidden */
  10851. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10852. /** @hidden */
  10853. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10854. /** @hidden */
  10855. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10856. }
  10857. }
  10858. }
  10859. declare module "babylonjs/sceneComponent" {
  10860. import { Scene } from "babylonjs/scene";
  10861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10862. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10863. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10864. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10865. import { Nullable } from "babylonjs/types";
  10866. import { Camera } from "babylonjs/Cameras/camera";
  10867. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10868. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10869. import { AbstractScene } from "babylonjs/abstractScene";
  10870. import { Mesh } from "babylonjs/Meshes/mesh";
  10871. /**
  10872. * Groups all the scene component constants in one place to ease maintenance.
  10873. * @hidden
  10874. */
  10875. export class SceneComponentConstants {
  10876. static readonly NAME_EFFECTLAYER: string;
  10877. static readonly NAME_LAYER: string;
  10878. static readonly NAME_LENSFLARESYSTEM: string;
  10879. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10880. static readonly NAME_PARTICLESYSTEM: string;
  10881. static readonly NAME_GAMEPAD: string;
  10882. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10883. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10884. static readonly NAME_PREPASSRENDERER: string;
  10885. static readonly NAME_DEPTHRENDERER: string;
  10886. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10887. static readonly NAME_SPRITE: string;
  10888. static readonly NAME_SUBSURFACE: string;
  10889. static readonly NAME_OUTLINERENDERER: string;
  10890. static readonly NAME_PROCEDURALTEXTURE: string;
  10891. static readonly NAME_SHADOWGENERATOR: string;
  10892. static readonly NAME_OCTREE: string;
  10893. static readonly NAME_PHYSICSENGINE: string;
  10894. static readonly NAME_AUDIO: string;
  10895. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10896. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10897. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10898. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10899. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10900. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10901. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10902. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10903. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10904. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10905. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10906. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10907. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10908. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10909. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10910. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10911. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10912. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10913. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10914. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10915. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10916. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10917. static readonly STEP_AFTERRENDER_AUDIO: number;
  10918. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10919. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10920. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10921. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10922. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10923. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10924. static readonly STEP_POINTERMOVE_SPRITE: number;
  10925. static readonly STEP_POINTERDOWN_SPRITE: number;
  10926. static readonly STEP_POINTERUP_SPRITE: number;
  10927. }
  10928. /**
  10929. * This represents a scene component.
  10930. *
  10931. * This is used to decouple the dependency the scene is having on the different workloads like
  10932. * layers, post processes...
  10933. */
  10934. export interface ISceneComponent {
  10935. /**
  10936. * The name of the component. Each component must have a unique name.
  10937. */
  10938. name: string;
  10939. /**
  10940. * The scene the component belongs to.
  10941. */
  10942. scene: Scene;
  10943. /**
  10944. * Register the component to one instance of a scene.
  10945. */
  10946. register(): void;
  10947. /**
  10948. * Rebuilds the elements related to this component in case of
  10949. * context lost for instance.
  10950. */
  10951. rebuild(): void;
  10952. /**
  10953. * Disposes the component and the associated ressources.
  10954. */
  10955. dispose(): void;
  10956. }
  10957. /**
  10958. * This represents a SERIALIZABLE scene component.
  10959. *
  10960. * This extends Scene Component to add Serialization methods on top.
  10961. */
  10962. export interface ISceneSerializableComponent extends ISceneComponent {
  10963. /**
  10964. * Adds all the elements from the container to the scene
  10965. * @param container the container holding the elements
  10966. */
  10967. addFromContainer(container: AbstractScene): void;
  10968. /**
  10969. * Removes all the elements in the container from the scene
  10970. * @param container contains the elements to remove
  10971. * @param dispose if the removed element should be disposed (default: false)
  10972. */
  10973. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10974. /**
  10975. * Serializes the component data to the specified json object
  10976. * @param serializationObject The object to serialize to
  10977. */
  10978. serialize(serializationObject: any): void;
  10979. }
  10980. /**
  10981. * Strong typing of a Mesh related stage step action
  10982. */
  10983. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10984. /**
  10985. * Strong typing of a Evaluate Sub Mesh related stage step action
  10986. */
  10987. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10988. /**
  10989. * Strong typing of a Active Mesh related stage step action
  10990. */
  10991. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10992. /**
  10993. * Strong typing of a Camera related stage step action
  10994. */
  10995. export type CameraStageAction = (camera: Camera) => void;
  10996. /**
  10997. * Strong typing of a Camera Frame buffer related stage step action
  10998. */
  10999. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11000. /**
  11001. * Strong typing of a Render Target related stage step action
  11002. */
  11003. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11004. /**
  11005. * Strong typing of a RenderingGroup related stage step action
  11006. */
  11007. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11008. /**
  11009. * Strong typing of a Mesh Render related stage step action
  11010. */
  11011. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11012. /**
  11013. * Strong typing of a simple stage step action
  11014. */
  11015. export type SimpleStageAction = () => void;
  11016. /**
  11017. * Strong typing of a render target action.
  11018. */
  11019. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11020. /**
  11021. * Strong typing of a pointer move action.
  11022. */
  11023. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11024. /**
  11025. * Strong typing of a pointer up/down action.
  11026. */
  11027. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11028. /**
  11029. * Representation of a stage in the scene (Basically a list of ordered steps)
  11030. * @hidden
  11031. */
  11032. export class Stage<T extends Function> extends Array<{
  11033. index: number;
  11034. component: ISceneComponent;
  11035. action: T;
  11036. }> {
  11037. /**
  11038. * Hide ctor from the rest of the world.
  11039. * @param items The items to add.
  11040. */
  11041. private constructor();
  11042. /**
  11043. * Creates a new Stage.
  11044. * @returns A new instance of a Stage
  11045. */
  11046. static Create<T extends Function>(): Stage<T>;
  11047. /**
  11048. * Registers a step in an ordered way in the targeted stage.
  11049. * @param index Defines the position to register the step in
  11050. * @param component Defines the component attached to the step
  11051. * @param action Defines the action to launch during the step
  11052. */
  11053. registerStep(index: number, component: ISceneComponent, action: T): void;
  11054. /**
  11055. * Clears all the steps from the stage.
  11056. */
  11057. clear(): void;
  11058. }
  11059. }
  11060. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11061. import { Nullable } from "babylonjs/types";
  11062. import { Observable } from "babylonjs/Misc/observable";
  11063. import { Scene } from "babylonjs/scene";
  11064. import { Sprite } from "babylonjs/Sprites/sprite";
  11065. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11066. import { Ray } from "babylonjs/Culling/ray";
  11067. import { Camera } from "babylonjs/Cameras/camera";
  11068. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11069. import { ISceneComponent } from "babylonjs/sceneComponent";
  11070. module "babylonjs/scene" {
  11071. interface Scene {
  11072. /** @hidden */
  11073. _pointerOverSprite: Nullable<Sprite>;
  11074. /** @hidden */
  11075. _pickedDownSprite: Nullable<Sprite>;
  11076. /** @hidden */
  11077. _tempSpritePickingRay: Nullable<Ray>;
  11078. /**
  11079. * All of the sprite managers added to this scene
  11080. * @see https://doc.babylonjs.com/babylon101/sprites
  11081. */
  11082. spriteManagers: Array<ISpriteManager>;
  11083. /**
  11084. * An event triggered when sprites rendering is about to start
  11085. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11086. */
  11087. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11088. /**
  11089. * An event triggered when sprites rendering is done
  11090. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11091. */
  11092. onAfterSpritesRenderingObservable: Observable<Scene>;
  11093. /** @hidden */
  11094. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11095. /** Launch a ray to try to pick a sprite in the scene
  11096. * @param x position on screen
  11097. * @param y position on screen
  11098. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11099. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11100. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11101. * @returns a PickingInfo
  11102. */
  11103. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11104. /** Use the given ray to pick a sprite in the scene
  11105. * @param ray The ray (in world space) to use to pick meshes
  11106. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11107. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11108. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11109. * @returns a PickingInfo
  11110. */
  11111. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11112. /** @hidden */
  11113. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11114. /** Launch a ray to try to pick sprites in the scene
  11115. * @param x position on screen
  11116. * @param y position on screen
  11117. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11118. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11119. * @returns a PickingInfo array
  11120. */
  11121. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11122. /** Use the given ray to pick sprites in the scene
  11123. * @param ray The ray (in world space) to use to pick meshes
  11124. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11125. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11126. * @returns a PickingInfo array
  11127. */
  11128. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11129. /**
  11130. * Force the sprite under the pointer
  11131. * @param sprite defines the sprite to use
  11132. */
  11133. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11134. /**
  11135. * Gets the sprite under the pointer
  11136. * @returns a Sprite or null if no sprite is under the pointer
  11137. */
  11138. getPointerOverSprite(): Nullable<Sprite>;
  11139. }
  11140. }
  11141. /**
  11142. * Defines the sprite scene component responsible to manage sprites
  11143. * in a given scene.
  11144. */
  11145. export class SpriteSceneComponent implements ISceneComponent {
  11146. /**
  11147. * The component name helpfull to identify the component in the list of scene components.
  11148. */
  11149. readonly name: string;
  11150. /**
  11151. * The scene the component belongs to.
  11152. */
  11153. scene: Scene;
  11154. /** @hidden */
  11155. private _spritePredicate;
  11156. /**
  11157. * Creates a new instance of the component for the given scene
  11158. * @param scene Defines the scene to register the component in
  11159. */
  11160. constructor(scene: Scene);
  11161. /**
  11162. * Registers the component in a given scene
  11163. */
  11164. register(): void;
  11165. /**
  11166. * Rebuilds the elements related to this component in case of
  11167. * context lost for instance.
  11168. */
  11169. rebuild(): void;
  11170. /**
  11171. * Disposes the component and the associated ressources.
  11172. */
  11173. dispose(): void;
  11174. private _pickSpriteButKeepRay;
  11175. private _pointerMove;
  11176. private _pointerDown;
  11177. private _pointerUp;
  11178. }
  11179. }
  11180. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11181. /** @hidden */
  11182. export var fogFragmentDeclaration: {
  11183. name: string;
  11184. shader: string;
  11185. };
  11186. }
  11187. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11188. /** @hidden */
  11189. export var fogFragment: {
  11190. name: string;
  11191. shader: string;
  11192. };
  11193. }
  11194. declare module "babylonjs/Shaders/sprites.fragment" {
  11195. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11196. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11197. /** @hidden */
  11198. export var spritesPixelShader: {
  11199. name: string;
  11200. shader: string;
  11201. };
  11202. }
  11203. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11204. /** @hidden */
  11205. export var fogVertexDeclaration: {
  11206. name: string;
  11207. shader: string;
  11208. };
  11209. }
  11210. declare module "babylonjs/Shaders/sprites.vertex" {
  11211. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11212. /** @hidden */
  11213. export var spritesVertexShader: {
  11214. name: string;
  11215. shader: string;
  11216. };
  11217. }
  11218. declare module "babylonjs/Sprites/spriteManager" {
  11219. import { IDisposable, Scene } from "babylonjs/scene";
  11220. import { Nullable } from "babylonjs/types";
  11221. import { Observable } from "babylonjs/Misc/observable";
  11222. import { Sprite } from "babylonjs/Sprites/sprite";
  11223. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11224. import { Camera } from "babylonjs/Cameras/camera";
  11225. import { Texture } from "babylonjs/Materials/Textures/texture";
  11226. import "babylonjs/Shaders/sprites.fragment";
  11227. import "babylonjs/Shaders/sprites.vertex";
  11228. import { Ray } from "babylonjs/Culling/ray";
  11229. /**
  11230. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11231. */
  11232. export interface ISpriteManager extends IDisposable {
  11233. /**
  11234. * Gets manager's name
  11235. */
  11236. name: string;
  11237. /**
  11238. * Restricts the camera to viewing objects with the same layerMask.
  11239. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11240. */
  11241. layerMask: number;
  11242. /**
  11243. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11244. */
  11245. isPickable: boolean;
  11246. /**
  11247. * Gets the hosting scene
  11248. */
  11249. scene: Scene;
  11250. /**
  11251. * Specifies the rendering group id for this mesh (0 by default)
  11252. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11253. */
  11254. renderingGroupId: number;
  11255. /**
  11256. * Defines the list of sprites managed by the manager.
  11257. */
  11258. sprites: Array<Sprite>;
  11259. /**
  11260. * Gets or sets the spritesheet texture
  11261. */
  11262. texture: Texture;
  11263. /** Defines the default width of a cell in the spritesheet */
  11264. cellWidth: number;
  11265. /** Defines the default height of a cell in the spritesheet */
  11266. cellHeight: number;
  11267. /**
  11268. * Tests the intersection of a sprite with a specific ray.
  11269. * @param ray The ray we are sending to test the collision
  11270. * @param camera The camera space we are sending rays in
  11271. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11272. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11273. * @returns picking info or null.
  11274. */
  11275. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11276. /**
  11277. * Intersects the sprites with a ray
  11278. * @param ray defines the ray to intersect with
  11279. * @param camera defines the current active camera
  11280. * @param predicate defines a predicate used to select candidate sprites
  11281. * @returns null if no hit or a PickingInfo array
  11282. */
  11283. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11284. /**
  11285. * Renders the list of sprites on screen.
  11286. */
  11287. render(): void;
  11288. }
  11289. /**
  11290. * Class used to manage multiple sprites on the same spritesheet
  11291. * @see https://doc.babylonjs.com/babylon101/sprites
  11292. */
  11293. export class SpriteManager implements ISpriteManager {
  11294. /** defines the manager's name */
  11295. name: string;
  11296. /** Define the Url to load snippets */
  11297. static SnippetUrl: string;
  11298. /** Snippet ID if the manager was created from the snippet server */
  11299. snippetId: string;
  11300. /** Gets the list of sprites */
  11301. sprites: Sprite[];
  11302. /** Gets or sets the rendering group id (0 by default) */
  11303. renderingGroupId: number;
  11304. /** Gets or sets camera layer mask */
  11305. layerMask: number;
  11306. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11307. fogEnabled: boolean;
  11308. /** Gets or sets a boolean indicating if the sprites are pickable */
  11309. isPickable: boolean;
  11310. /** Defines the default width of a cell in the spritesheet */
  11311. cellWidth: number;
  11312. /** Defines the default height of a cell in the spritesheet */
  11313. cellHeight: number;
  11314. /** Associative array from JSON sprite data file */
  11315. private _cellData;
  11316. /** Array of sprite names from JSON sprite data file */
  11317. private _spriteMap;
  11318. /** True when packed cell data from JSON file is ready*/
  11319. private _packedAndReady;
  11320. private _textureContent;
  11321. private _useInstancing;
  11322. /**
  11323. * An event triggered when the manager is disposed.
  11324. */
  11325. onDisposeObservable: Observable<SpriteManager>;
  11326. private _onDisposeObserver;
  11327. /**
  11328. * Callback called when the manager is disposed
  11329. */
  11330. set onDispose(callback: () => void);
  11331. private _capacity;
  11332. private _fromPacked;
  11333. private _spriteTexture;
  11334. private _epsilon;
  11335. private _scene;
  11336. private _vertexData;
  11337. private _buffer;
  11338. private _vertexBuffers;
  11339. private _spriteBuffer;
  11340. private _indexBuffer;
  11341. private _effectBase;
  11342. private _effectFog;
  11343. private _vertexBufferSize;
  11344. /**
  11345. * Gets or sets the unique id of the sprite
  11346. */
  11347. uniqueId: number;
  11348. /**
  11349. * Gets the array of sprites
  11350. */
  11351. get children(): Sprite[];
  11352. /**
  11353. * Gets the hosting scene
  11354. */
  11355. get scene(): Scene;
  11356. /**
  11357. * Gets the capacity of the manager
  11358. */
  11359. get capacity(): number;
  11360. /**
  11361. * Gets or sets the spritesheet texture
  11362. */
  11363. get texture(): Texture;
  11364. set texture(value: Texture);
  11365. private _blendMode;
  11366. /**
  11367. * Blend mode use to render the particle, it can be any of
  11368. * the static Constants.ALPHA_x properties provided in this class.
  11369. * Default value is Constants.ALPHA_COMBINE
  11370. */
  11371. get blendMode(): number;
  11372. set blendMode(blendMode: number);
  11373. /** Disables writing to the depth buffer when rendering the sprites.
  11374. * It can be handy to disable depth writing when using textures without alpha channel
  11375. * and setting some specific blend modes.
  11376. */
  11377. disableDepthWrite: boolean;
  11378. /**
  11379. * Creates a new sprite manager
  11380. * @param name defines the manager's name
  11381. * @param imgUrl defines the sprite sheet url
  11382. * @param capacity defines the maximum allowed number of sprites
  11383. * @param cellSize defines the size of a sprite cell
  11384. * @param scene defines the hosting scene
  11385. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11386. * @param samplingMode defines the smapling mode to use with spritesheet
  11387. * @param fromPacked set to false; do not alter
  11388. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11389. */
  11390. constructor(
  11391. /** defines the manager's name */
  11392. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11393. /**
  11394. * Returns the string "SpriteManager"
  11395. * @returns "SpriteManager"
  11396. */
  11397. getClassName(): string;
  11398. private _makePacked;
  11399. private _appendSpriteVertex;
  11400. private _checkTextureAlpha;
  11401. /**
  11402. * Intersects the sprites with a ray
  11403. * @param ray defines the ray to intersect with
  11404. * @param camera defines the current active camera
  11405. * @param predicate defines a predicate used to select candidate sprites
  11406. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11407. * @returns null if no hit or a PickingInfo
  11408. */
  11409. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11410. /**
  11411. * Intersects the sprites with a ray
  11412. * @param ray defines the ray to intersect with
  11413. * @param camera defines the current active camera
  11414. * @param predicate defines a predicate used to select candidate sprites
  11415. * @returns null if no hit or a PickingInfo array
  11416. */
  11417. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11418. /**
  11419. * Render all child sprites
  11420. */
  11421. render(): void;
  11422. /**
  11423. * Release associated resources
  11424. */
  11425. dispose(): void;
  11426. /**
  11427. * Serializes the sprite manager to a JSON object
  11428. * @param serializeTexture defines if the texture must be serialized as well
  11429. * @returns the JSON object
  11430. */
  11431. serialize(serializeTexture?: boolean): any;
  11432. /**
  11433. * Parses a JSON object to create a new sprite manager.
  11434. * @param parsedManager The JSON object to parse
  11435. * @param scene The scene to create the sprite managerin
  11436. * @param rootUrl The root url to use to load external dependencies like texture
  11437. * @returns the new sprite manager
  11438. */
  11439. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11440. /**
  11441. * Creates a sprite manager from a snippet saved in a remote file
  11442. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11443. * @param url defines the url to load from
  11444. * @param scene defines the hosting scene
  11445. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11446. * @returns a promise that will resolve to the new sprite manager
  11447. */
  11448. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11449. /**
  11450. * Creates a sprite manager from a snippet saved by the sprite editor
  11451. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11452. * @param scene defines the hosting scene
  11453. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11454. * @returns a promise that will resolve to the new sprite manager
  11455. */
  11456. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11457. }
  11458. }
  11459. declare module "babylonjs/Misc/gradients" {
  11460. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11461. /** Interface used by value gradients (color, factor, ...) */
  11462. export interface IValueGradient {
  11463. /**
  11464. * Gets or sets the gradient value (between 0 and 1)
  11465. */
  11466. gradient: number;
  11467. }
  11468. /** Class used to store color4 gradient */
  11469. export class ColorGradient implements IValueGradient {
  11470. /**
  11471. * Gets or sets the gradient value (between 0 and 1)
  11472. */
  11473. gradient: number;
  11474. /**
  11475. * Gets or sets first associated color
  11476. */
  11477. color1: Color4;
  11478. /**
  11479. * Gets or sets second associated color
  11480. */
  11481. color2?: Color4 | undefined;
  11482. /**
  11483. * Creates a new color4 gradient
  11484. * @param gradient gets or sets the gradient value (between 0 and 1)
  11485. * @param color1 gets or sets first associated color
  11486. * @param color2 gets or sets first second color
  11487. */
  11488. constructor(
  11489. /**
  11490. * Gets or sets the gradient value (between 0 and 1)
  11491. */
  11492. gradient: number,
  11493. /**
  11494. * Gets or sets first associated color
  11495. */
  11496. color1: Color4,
  11497. /**
  11498. * Gets or sets second associated color
  11499. */
  11500. color2?: Color4 | undefined);
  11501. /**
  11502. * Will get a color picked randomly between color1 and color2.
  11503. * If color2 is undefined then color1 will be used
  11504. * @param result defines the target Color4 to store the result in
  11505. */
  11506. getColorToRef(result: Color4): void;
  11507. }
  11508. /** Class used to store color 3 gradient */
  11509. export class Color3Gradient implements IValueGradient {
  11510. /**
  11511. * Gets or sets the gradient value (between 0 and 1)
  11512. */
  11513. gradient: number;
  11514. /**
  11515. * Gets or sets the associated color
  11516. */
  11517. color: Color3;
  11518. /**
  11519. * Creates a new color3 gradient
  11520. * @param gradient gets or sets the gradient value (between 0 and 1)
  11521. * @param color gets or sets associated color
  11522. */
  11523. constructor(
  11524. /**
  11525. * Gets or sets the gradient value (between 0 and 1)
  11526. */
  11527. gradient: number,
  11528. /**
  11529. * Gets or sets the associated color
  11530. */
  11531. color: Color3);
  11532. }
  11533. /** Class used to store factor gradient */
  11534. export class FactorGradient implements IValueGradient {
  11535. /**
  11536. * Gets or sets the gradient value (between 0 and 1)
  11537. */
  11538. gradient: number;
  11539. /**
  11540. * Gets or sets first associated factor
  11541. */
  11542. factor1: number;
  11543. /**
  11544. * Gets or sets second associated factor
  11545. */
  11546. factor2?: number | undefined;
  11547. /**
  11548. * Creates a new factor gradient
  11549. * @param gradient gets or sets the gradient value (between 0 and 1)
  11550. * @param factor1 gets or sets first associated factor
  11551. * @param factor2 gets or sets second associated factor
  11552. */
  11553. constructor(
  11554. /**
  11555. * Gets or sets the gradient value (between 0 and 1)
  11556. */
  11557. gradient: number,
  11558. /**
  11559. * Gets or sets first associated factor
  11560. */
  11561. factor1: number,
  11562. /**
  11563. * Gets or sets second associated factor
  11564. */
  11565. factor2?: number | undefined);
  11566. /**
  11567. * Will get a number picked randomly between factor1 and factor2.
  11568. * If factor2 is undefined then factor1 will be used
  11569. * @returns the picked number
  11570. */
  11571. getFactor(): number;
  11572. }
  11573. /**
  11574. * Helper used to simplify some generic gradient tasks
  11575. */
  11576. export class GradientHelper {
  11577. /**
  11578. * Gets the current gradient from an array of IValueGradient
  11579. * @param ratio defines the current ratio to get
  11580. * @param gradients defines the array of IValueGradient
  11581. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11582. */
  11583. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11584. }
  11585. }
  11586. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11587. import { Nullable } from "babylonjs/types";
  11588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11589. import { Scene } from "babylonjs/scene";
  11590. module "babylonjs/Engines/thinEngine" {
  11591. interface ThinEngine {
  11592. /**
  11593. * Creates a raw texture
  11594. * @param data defines the data to store in the texture
  11595. * @param width defines the width of the texture
  11596. * @param height defines the height of the texture
  11597. * @param format defines the format of the data
  11598. * @param generateMipMaps defines if the engine should generate the mip levels
  11599. * @param invertY defines if data must be stored with Y axis inverted
  11600. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11601. * @param compression defines the compression used (null by default)
  11602. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11603. * @returns the raw texture inside an InternalTexture
  11604. */
  11605. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11606. /**
  11607. * Update a raw texture
  11608. * @param texture defines the texture to update
  11609. * @param data defines the data to store in the texture
  11610. * @param format defines the format of the data
  11611. * @param invertY defines if data must be stored with Y axis inverted
  11612. */
  11613. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11614. /**
  11615. * Update a raw texture
  11616. * @param texture defines the texture to update
  11617. * @param data defines the data to store in the texture
  11618. * @param format defines the format of the data
  11619. * @param invertY defines if data must be stored with Y axis inverted
  11620. * @param compression defines the compression used (null by default)
  11621. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11622. */
  11623. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11624. /**
  11625. * Creates a new raw cube texture
  11626. * @param data defines the array of data to use to create each face
  11627. * @param size defines the size of the textures
  11628. * @param format defines the format of the data
  11629. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11630. * @param generateMipMaps defines if the engine should generate the mip levels
  11631. * @param invertY defines if data must be stored with Y axis inverted
  11632. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11633. * @param compression defines the compression used (null by default)
  11634. * @returns the cube texture as an InternalTexture
  11635. */
  11636. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11637. /**
  11638. * Update a raw cube texture
  11639. * @param texture defines the texture to udpdate
  11640. * @param data defines the data to store
  11641. * @param format defines the data format
  11642. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11643. * @param invertY defines if data must be stored with Y axis inverted
  11644. */
  11645. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11646. /**
  11647. * Update a raw cube texture
  11648. * @param texture defines the texture to udpdate
  11649. * @param data defines the data to store
  11650. * @param format defines the data format
  11651. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11652. * @param invertY defines if data must be stored with Y axis inverted
  11653. * @param compression defines the compression used (null by default)
  11654. */
  11655. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11656. /**
  11657. * Update a raw cube texture
  11658. * @param texture defines the texture to udpdate
  11659. * @param data defines the data to store
  11660. * @param format defines the data format
  11661. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11662. * @param invertY defines if data must be stored with Y axis inverted
  11663. * @param compression defines the compression used (null by default)
  11664. * @param level defines which level of the texture to update
  11665. */
  11666. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11667. /**
  11668. * Creates a new raw cube texture from a specified url
  11669. * @param url defines the url where the data is located
  11670. * @param scene defines the current scene
  11671. * @param size defines the size of the textures
  11672. * @param format defines the format of the data
  11673. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11674. * @param noMipmap defines if the engine should avoid generating the mip levels
  11675. * @param callback defines a callback used to extract texture data from loaded data
  11676. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11677. * @param onLoad defines a callback called when texture is loaded
  11678. * @param onError defines a callback called if there is an error
  11679. * @returns the cube texture as an InternalTexture
  11680. */
  11681. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11682. /**
  11683. * Creates a new raw cube texture from a specified url
  11684. * @param url defines the url where the data is located
  11685. * @param scene defines the current scene
  11686. * @param size defines the size of the textures
  11687. * @param format defines the format of the data
  11688. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11689. * @param noMipmap defines if the engine should avoid generating the mip levels
  11690. * @param callback defines a callback used to extract texture data from loaded data
  11691. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11692. * @param onLoad defines a callback called when texture is loaded
  11693. * @param onError defines a callback called if there is an error
  11694. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11695. * @param invertY defines if data must be stored with Y axis inverted
  11696. * @returns the cube texture as an InternalTexture
  11697. */
  11698. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11699. /**
  11700. * Creates a new raw 3D texture
  11701. * @param data defines the data used to create the texture
  11702. * @param width defines the width of the texture
  11703. * @param height defines the height of the texture
  11704. * @param depth defines the depth of the texture
  11705. * @param format defines the format of the texture
  11706. * @param generateMipMaps defines if the engine must generate mip levels
  11707. * @param invertY defines if data must be stored with Y axis inverted
  11708. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11709. * @param compression defines the compressed used (can be null)
  11710. * @param textureType defines the compressed used (can be null)
  11711. * @returns a new raw 3D texture (stored in an InternalTexture)
  11712. */
  11713. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11714. /**
  11715. * Update a raw 3D texture
  11716. * @param texture defines the texture to update
  11717. * @param data defines the data to store
  11718. * @param format defines the data format
  11719. * @param invertY defines if data must be stored with Y axis inverted
  11720. */
  11721. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11722. /**
  11723. * Update a raw 3D texture
  11724. * @param texture defines the texture to update
  11725. * @param data defines the data to store
  11726. * @param format defines the data format
  11727. * @param invertY defines if data must be stored with Y axis inverted
  11728. * @param compression defines the used compression (can be null)
  11729. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11730. */
  11731. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11732. /**
  11733. * Creates a new raw 2D array texture
  11734. * @param data defines the data used to create the texture
  11735. * @param width defines the width of the texture
  11736. * @param height defines the height of the texture
  11737. * @param depth defines the number of layers of the texture
  11738. * @param format defines the format of the texture
  11739. * @param generateMipMaps defines if the engine must generate mip levels
  11740. * @param invertY defines if data must be stored with Y axis inverted
  11741. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11742. * @param compression defines the compressed used (can be null)
  11743. * @param textureType defines the compressed used (can be null)
  11744. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11745. */
  11746. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11747. /**
  11748. * Update a raw 2D array texture
  11749. * @param texture defines the texture to update
  11750. * @param data defines the data to store
  11751. * @param format defines the data format
  11752. * @param invertY defines if data must be stored with Y axis inverted
  11753. */
  11754. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11755. /**
  11756. * Update a raw 2D array texture
  11757. * @param texture defines the texture to update
  11758. * @param data defines the data to store
  11759. * @param format defines the data format
  11760. * @param invertY defines if data must be stored with Y axis inverted
  11761. * @param compression defines the used compression (can be null)
  11762. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11763. */
  11764. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11765. }
  11766. }
  11767. }
  11768. declare module "babylonjs/Materials/Textures/rawTexture" {
  11769. import { Texture } from "babylonjs/Materials/Textures/texture";
  11770. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11771. import { Nullable } from "babylonjs/types";
  11772. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11773. import { Scene } from "babylonjs/scene";
  11774. /**
  11775. * Raw texture can help creating a texture directly from an array of data.
  11776. * This can be super useful if you either get the data from an uncompressed source or
  11777. * if you wish to create your texture pixel by pixel.
  11778. */
  11779. export class RawTexture extends Texture {
  11780. /**
  11781. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11782. */
  11783. format: number;
  11784. /**
  11785. * Instantiates a new RawTexture.
  11786. * Raw texture can help creating a texture directly from an array of data.
  11787. * This can be super useful if you either get the data from an uncompressed source or
  11788. * if you wish to create your texture pixel by pixel.
  11789. * @param data define the array of data to use to create the texture
  11790. * @param width define the width of the texture
  11791. * @param height define the height of the texture
  11792. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11793. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11794. * @param generateMipMaps define whether mip maps should be generated or not
  11795. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11796. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11797. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11798. */
  11799. constructor(data: ArrayBufferView, width: number, height: number,
  11800. /**
  11801. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11802. */
  11803. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11804. /**
  11805. * Updates the texture underlying data.
  11806. * @param data Define the new data of the texture
  11807. */
  11808. update(data: ArrayBufferView): void;
  11809. /**
  11810. * Creates a luminance texture from some data.
  11811. * @param data Define the texture data
  11812. * @param width Define the width of the texture
  11813. * @param height Define the height of the texture
  11814. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11815. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11816. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11817. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11818. * @returns the luminance texture
  11819. */
  11820. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11821. /**
  11822. * Creates a luminance alpha texture from some data.
  11823. * @param data Define the texture data
  11824. * @param width Define the width of the texture
  11825. * @param height Define the height of the texture
  11826. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11827. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11828. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11829. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11830. * @returns the luminance alpha texture
  11831. */
  11832. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11833. /**
  11834. * Creates an alpha texture from some data.
  11835. * @param data Define the texture data
  11836. * @param width Define the width of the texture
  11837. * @param height Define the height of the texture
  11838. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11839. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11840. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11841. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11842. * @returns the alpha texture
  11843. */
  11844. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11845. /**
  11846. * Creates a RGB texture from some data.
  11847. * @param data Define the texture data
  11848. * @param width Define the width of the texture
  11849. * @param height Define the height of the texture
  11850. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11851. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11852. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11853. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11854. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11855. * @returns the RGB alpha texture
  11856. */
  11857. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11858. /**
  11859. * Creates a RGBA texture from some data.
  11860. * @param data Define the texture data
  11861. * @param width Define the width of the texture
  11862. * @param height Define the height of the texture
  11863. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11864. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11865. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11866. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11867. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11868. * @returns the RGBA texture
  11869. */
  11870. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11871. /**
  11872. * Creates a R texture from some data.
  11873. * @param data Define the texture data
  11874. * @param width Define the width of the texture
  11875. * @param height Define the height of the texture
  11876. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11877. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11878. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11879. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11880. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11881. * @returns the R texture
  11882. */
  11883. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11884. }
  11885. }
  11886. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11887. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11888. import { IndicesArray, DataArray } from "babylonjs/types";
  11889. module "babylonjs/Engines/thinEngine" {
  11890. interface ThinEngine {
  11891. /**
  11892. * Update a dynamic index buffer
  11893. * @param indexBuffer defines the target index buffer
  11894. * @param indices defines the data to update
  11895. * @param offset defines the offset in the target index buffer where update should start
  11896. */
  11897. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11898. /**
  11899. * Updates a dynamic vertex buffer.
  11900. * @param vertexBuffer the vertex buffer to update
  11901. * @param data the data used to update the vertex buffer
  11902. * @param byteOffset the byte offset of the data
  11903. * @param byteLength the byte length of the data
  11904. */
  11905. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11906. }
  11907. }
  11908. }
  11909. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11910. import { Scene } from "babylonjs/scene";
  11911. import { ISceneComponent } from "babylonjs/sceneComponent";
  11912. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11913. module "babylonjs/abstractScene" {
  11914. interface AbstractScene {
  11915. /**
  11916. * The list of procedural textures added to the scene
  11917. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11918. */
  11919. proceduralTextures: Array<ProceduralTexture>;
  11920. }
  11921. }
  11922. /**
  11923. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11924. * in a given scene.
  11925. */
  11926. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11927. /**
  11928. * The component name helpfull to identify the component in the list of scene components.
  11929. */
  11930. readonly name: string;
  11931. /**
  11932. * The scene the component belongs to.
  11933. */
  11934. scene: Scene;
  11935. /**
  11936. * Creates a new instance of the component for the given scene
  11937. * @param scene Defines the scene to register the component in
  11938. */
  11939. constructor(scene: Scene);
  11940. /**
  11941. * Registers the component in a given scene
  11942. */
  11943. register(): void;
  11944. /**
  11945. * Rebuilds the elements related to this component in case of
  11946. * context lost for instance.
  11947. */
  11948. rebuild(): void;
  11949. /**
  11950. * Disposes the component and the associated ressources.
  11951. */
  11952. dispose(): void;
  11953. private _beforeClear;
  11954. }
  11955. }
  11956. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11957. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11958. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11959. module "babylonjs/Engines/thinEngine" {
  11960. interface ThinEngine {
  11961. /**
  11962. * Creates a new render target cube texture
  11963. * @param size defines the size of the texture
  11964. * @param options defines the options used to create the texture
  11965. * @returns a new render target cube texture stored in an InternalTexture
  11966. */
  11967. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11968. }
  11969. }
  11970. }
  11971. declare module "babylonjs/Shaders/procedural.vertex" {
  11972. /** @hidden */
  11973. export var proceduralVertexShader: {
  11974. name: string;
  11975. shader: string;
  11976. };
  11977. }
  11978. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11979. import { Observable } from "babylonjs/Misc/observable";
  11980. import { Nullable } from "babylonjs/types";
  11981. import { Scene } from "babylonjs/scene";
  11982. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11983. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11984. import { Effect } from "babylonjs/Materials/effect";
  11985. import { Texture } from "babylonjs/Materials/Textures/texture";
  11986. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11987. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11988. import "babylonjs/Shaders/procedural.vertex";
  11989. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  11990. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  11991. /**
  11992. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11993. * This is the base class of any Procedural texture and contains most of the shareable code.
  11994. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11995. */
  11996. export class ProceduralTexture extends Texture {
  11997. /**
  11998. * Define if the texture is enabled or not (disabled texture will not render)
  11999. */
  12000. isEnabled: boolean;
  12001. /**
  12002. * Define if the texture must be cleared before rendering (default is true)
  12003. */
  12004. autoClear: boolean;
  12005. /**
  12006. * Callback called when the texture is generated
  12007. */
  12008. onGenerated: () => void;
  12009. /**
  12010. * Event raised when the texture is generated
  12011. */
  12012. onGeneratedObservable: Observable<ProceduralTexture>;
  12013. /**
  12014. * Event raised before the texture is generated
  12015. */
  12016. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12017. /**
  12018. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12019. */
  12020. nodeMaterialSource: Nullable<NodeMaterial>;
  12021. /** @hidden */
  12022. _generateMipMaps: boolean;
  12023. /** @hidden **/
  12024. _effect: Effect;
  12025. /** @hidden */
  12026. _textures: {
  12027. [key: string]: Texture;
  12028. };
  12029. /** @hidden */
  12030. protected _fallbackTexture: Nullable<Texture>;
  12031. private _size;
  12032. private _currentRefreshId;
  12033. private _frameId;
  12034. private _refreshRate;
  12035. private _vertexBuffers;
  12036. private _indexBuffer;
  12037. private _uniforms;
  12038. private _samplers;
  12039. private _fragment;
  12040. private _floats;
  12041. private _ints;
  12042. private _floatsArrays;
  12043. private _colors3;
  12044. private _colors4;
  12045. private _vectors2;
  12046. private _vectors3;
  12047. private _matrices;
  12048. private _fallbackTextureUsed;
  12049. private _fullEngine;
  12050. private _cachedDefines;
  12051. private _contentUpdateId;
  12052. private _contentData;
  12053. /**
  12054. * Instantiates a new procedural texture.
  12055. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  12056. * This is the base class of any Procedural texture and contains most of the shareable code.
  12057. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12058. * @param name Define the name of the texture
  12059. * @param size Define the size of the texture to create
  12060. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12061. * @param scene Define the scene the texture belongs to
  12062. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12063. * @param generateMipMaps Define if the texture should creates mip maps or not
  12064. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12065. * @param textureType The FBO internal texture type
  12066. */
  12067. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  12068. /**
  12069. * The effect that is created when initializing the post process.
  12070. * @returns The created effect corresponding the the postprocess.
  12071. */
  12072. getEffect(): Effect;
  12073. /**
  12074. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12075. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12076. */
  12077. getContent(): Nullable<ArrayBufferView>;
  12078. private _createIndexBuffer;
  12079. /** @hidden */
  12080. _rebuild(): void;
  12081. /**
  12082. * Resets the texture in order to recreate its associated resources.
  12083. * This can be called in case of context loss
  12084. */
  12085. reset(): void;
  12086. protected _getDefines(): string;
  12087. /**
  12088. * Is the texture ready to be used ? (rendered at least once)
  12089. * @returns true if ready, otherwise, false.
  12090. */
  12091. isReady(): boolean;
  12092. /**
  12093. * Resets the refresh counter of the texture and start bak from scratch.
  12094. * Could be useful to regenerate the texture if it is setup to render only once.
  12095. */
  12096. resetRefreshCounter(): void;
  12097. /**
  12098. * Set the fragment shader to use in order to render the texture.
  12099. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12100. */
  12101. setFragment(fragment: any): void;
  12102. /**
  12103. * Define the refresh rate of the texture or the rendering frequency.
  12104. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12105. */
  12106. get refreshRate(): number;
  12107. set refreshRate(value: number);
  12108. /** @hidden */
  12109. _shouldRender(): boolean;
  12110. /**
  12111. * Get the size the texture is rendering at.
  12112. * @returns the size (on cube texture it is always squared)
  12113. */
  12114. getRenderSize(): RenderTargetTextureSize;
  12115. /**
  12116. * Resize the texture to new value.
  12117. * @param size Define the new size the texture should have
  12118. * @param generateMipMaps Define whether the new texture should create mip maps
  12119. */
  12120. resize(size: number, generateMipMaps: boolean): void;
  12121. private _checkUniform;
  12122. /**
  12123. * Set a texture in the shader program used to render.
  12124. * @param name Define the name of the uniform samplers as defined in the shader
  12125. * @param texture Define the texture to bind to this sampler
  12126. * @return the texture itself allowing "fluent" like uniform updates
  12127. */
  12128. setTexture(name: string, texture: Texture): ProceduralTexture;
  12129. /**
  12130. * Set a float in the shader.
  12131. * @param name Define the name of the uniform as defined in the shader
  12132. * @param value Define the value to give to the uniform
  12133. * @return the texture itself allowing "fluent" like uniform updates
  12134. */
  12135. setFloat(name: string, value: number): ProceduralTexture;
  12136. /**
  12137. * Set a int in the shader.
  12138. * @param name Define the name of the uniform as defined in the shader
  12139. * @param value Define the value to give to the uniform
  12140. * @return the texture itself allowing "fluent" like uniform updates
  12141. */
  12142. setInt(name: string, value: number): ProceduralTexture;
  12143. /**
  12144. * Set an array of floats in the shader.
  12145. * @param name Define the name of the uniform as defined in the shader
  12146. * @param value Define the value to give to the uniform
  12147. * @return the texture itself allowing "fluent" like uniform updates
  12148. */
  12149. setFloats(name: string, value: number[]): ProceduralTexture;
  12150. /**
  12151. * Set a vec3 in the shader from a Color3.
  12152. * @param name Define the name of the uniform as defined in the shader
  12153. * @param value Define the value to give to the uniform
  12154. * @return the texture itself allowing "fluent" like uniform updates
  12155. */
  12156. setColor3(name: string, value: Color3): ProceduralTexture;
  12157. /**
  12158. * Set a vec4 in the shader from a Color4.
  12159. * @param name Define the name of the uniform as defined in the shader
  12160. * @param value Define the value to give to the uniform
  12161. * @return the texture itself allowing "fluent" like uniform updates
  12162. */
  12163. setColor4(name: string, value: Color4): ProceduralTexture;
  12164. /**
  12165. * Set a vec2 in the shader from a Vector2.
  12166. * @param name Define the name of the uniform as defined in the shader
  12167. * @param value Define the value to give to the uniform
  12168. * @return the texture itself allowing "fluent" like uniform updates
  12169. */
  12170. setVector2(name: string, value: Vector2): ProceduralTexture;
  12171. /**
  12172. * Set a vec3 in the shader from a Vector3.
  12173. * @param name Define the name of the uniform as defined in the shader
  12174. * @param value Define the value to give to the uniform
  12175. * @return the texture itself allowing "fluent" like uniform updates
  12176. */
  12177. setVector3(name: string, value: Vector3): ProceduralTexture;
  12178. /**
  12179. * Set a mat4 in the shader from a MAtrix.
  12180. * @param name Define the name of the uniform as defined in the shader
  12181. * @param value Define the value to give to the uniform
  12182. * @return the texture itself allowing "fluent" like uniform updates
  12183. */
  12184. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12185. /**
  12186. * Render the texture to its associated render target.
  12187. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12188. */
  12189. render(useCameraPostProcess?: boolean): void;
  12190. /**
  12191. * Clone the texture.
  12192. * @returns the cloned texture
  12193. */
  12194. clone(): ProceduralTexture;
  12195. /**
  12196. * Dispose the texture and release its asoociated resources.
  12197. */
  12198. dispose(): void;
  12199. }
  12200. }
  12201. declare module "babylonjs/Particles/baseParticleSystem" {
  12202. import { Nullable } from "babylonjs/types";
  12203. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12205. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12206. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12207. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12209. import { Color4 } from "babylonjs/Maths/math.color";
  12210. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12211. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12212. import { Animation } from "babylonjs/Animations/animation";
  12213. import { Scene } from "babylonjs/scene";
  12214. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12215. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12216. /**
  12217. * This represents the base class for particle system in Babylon.
  12218. * 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.
  12219. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12220. * @example https://doc.babylonjs.com/babylon101/particles
  12221. */
  12222. export class BaseParticleSystem {
  12223. /**
  12224. * Source color is added to the destination color without alpha affecting the result
  12225. */
  12226. static BLENDMODE_ONEONE: number;
  12227. /**
  12228. * Blend current color and particle color using particle’s alpha
  12229. */
  12230. static BLENDMODE_STANDARD: number;
  12231. /**
  12232. * Add current color and particle color multiplied by particle’s alpha
  12233. */
  12234. static BLENDMODE_ADD: number;
  12235. /**
  12236. * Multiply current color with particle color
  12237. */
  12238. static BLENDMODE_MULTIPLY: number;
  12239. /**
  12240. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12241. */
  12242. static BLENDMODE_MULTIPLYADD: number;
  12243. /**
  12244. * List of animations used by the particle system.
  12245. */
  12246. animations: Animation[];
  12247. /**
  12248. * Gets or sets the unique id of the particle system
  12249. */
  12250. uniqueId: number;
  12251. /**
  12252. * The id of the Particle system.
  12253. */
  12254. id: string;
  12255. /**
  12256. * The friendly name of the Particle system.
  12257. */
  12258. name: string;
  12259. /**
  12260. * Snippet ID if the particle system was created from the snippet server
  12261. */
  12262. snippetId: string;
  12263. /**
  12264. * The rendering group used by the Particle system to chose when to render.
  12265. */
  12266. renderingGroupId: number;
  12267. /**
  12268. * The emitter represents the Mesh or position we are attaching the particle system to.
  12269. */
  12270. emitter: Nullable<AbstractMesh | Vector3>;
  12271. /**
  12272. * The maximum number of particles to emit per frame
  12273. */
  12274. emitRate: number;
  12275. /**
  12276. * If you want to launch only a few particles at once, that can be done, as well.
  12277. */
  12278. manualEmitCount: number;
  12279. /**
  12280. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12281. */
  12282. updateSpeed: number;
  12283. /**
  12284. * The amount of time the particle system is running (depends of the overall update speed).
  12285. */
  12286. targetStopDuration: number;
  12287. /**
  12288. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12289. */
  12290. disposeOnStop: boolean;
  12291. /**
  12292. * Minimum power of emitting particles.
  12293. */
  12294. minEmitPower: number;
  12295. /**
  12296. * Maximum power of emitting particles.
  12297. */
  12298. maxEmitPower: number;
  12299. /**
  12300. * Minimum life time of emitting particles.
  12301. */
  12302. minLifeTime: number;
  12303. /**
  12304. * Maximum life time of emitting particles.
  12305. */
  12306. maxLifeTime: number;
  12307. /**
  12308. * Minimum Size of emitting particles.
  12309. */
  12310. minSize: number;
  12311. /**
  12312. * Maximum Size of emitting particles.
  12313. */
  12314. maxSize: number;
  12315. /**
  12316. * Minimum scale of emitting particles on X axis.
  12317. */
  12318. minScaleX: number;
  12319. /**
  12320. * Maximum scale of emitting particles on X axis.
  12321. */
  12322. maxScaleX: number;
  12323. /**
  12324. * Minimum scale of emitting particles on Y axis.
  12325. */
  12326. minScaleY: number;
  12327. /**
  12328. * Maximum scale of emitting particles on Y axis.
  12329. */
  12330. maxScaleY: number;
  12331. /**
  12332. * Gets or sets the minimal initial rotation in radians.
  12333. */
  12334. minInitialRotation: number;
  12335. /**
  12336. * Gets or sets the maximal initial rotation in radians.
  12337. */
  12338. maxInitialRotation: number;
  12339. /**
  12340. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12341. */
  12342. minAngularSpeed: number;
  12343. /**
  12344. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12345. */
  12346. maxAngularSpeed: number;
  12347. /**
  12348. * The texture used to render each particle. (this can be a spritesheet)
  12349. */
  12350. particleTexture: Nullable<BaseTexture>;
  12351. /**
  12352. * The layer mask we are rendering the particles through.
  12353. */
  12354. layerMask: number;
  12355. /**
  12356. * This can help using your own shader to render the particle system.
  12357. * The according effect will be created
  12358. */
  12359. customShader: any;
  12360. /**
  12361. * By default particle system starts as soon as they are created. This prevents the
  12362. * automatic start to happen and let you decide when to start emitting particles.
  12363. */
  12364. preventAutoStart: boolean;
  12365. private _noiseTexture;
  12366. /**
  12367. * Gets or sets a texture used to add random noise to particle positions
  12368. */
  12369. get noiseTexture(): Nullable<ProceduralTexture>;
  12370. set noiseTexture(value: Nullable<ProceduralTexture>);
  12371. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12372. noiseStrength: Vector3;
  12373. /**
  12374. * Callback triggered when the particle animation is ending.
  12375. */
  12376. onAnimationEnd: Nullable<() => void>;
  12377. /**
  12378. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12379. */
  12380. blendMode: number;
  12381. /**
  12382. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12383. * to override the particles.
  12384. */
  12385. forceDepthWrite: boolean;
  12386. /** 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 */
  12387. preWarmCycles: number;
  12388. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12389. preWarmStepOffset: number;
  12390. /**
  12391. * 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)
  12392. */
  12393. spriteCellChangeSpeed: number;
  12394. /**
  12395. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12396. */
  12397. startSpriteCellID: number;
  12398. /**
  12399. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12400. */
  12401. endSpriteCellID: number;
  12402. /**
  12403. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12404. */
  12405. spriteCellWidth: number;
  12406. /**
  12407. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12408. */
  12409. spriteCellHeight: number;
  12410. /**
  12411. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12412. */
  12413. spriteRandomStartCell: boolean;
  12414. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12415. translationPivot: Vector2;
  12416. /** @hidden */
  12417. protected _isAnimationSheetEnabled: boolean;
  12418. /**
  12419. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12420. */
  12421. beginAnimationOnStart: boolean;
  12422. /**
  12423. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12424. */
  12425. beginAnimationFrom: number;
  12426. /**
  12427. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12428. */
  12429. beginAnimationTo: number;
  12430. /**
  12431. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12432. */
  12433. beginAnimationLoop: boolean;
  12434. /**
  12435. * Gets or sets a world offset applied to all particles
  12436. */
  12437. worldOffset: Vector3;
  12438. /**
  12439. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12440. */
  12441. get isAnimationSheetEnabled(): boolean;
  12442. set isAnimationSheetEnabled(value: boolean);
  12443. /**
  12444. * Get hosting scene
  12445. * @returns the scene
  12446. */
  12447. getScene(): Nullable<Scene>;
  12448. /**
  12449. * You can use gravity if you want to give an orientation to your particles.
  12450. */
  12451. gravity: Vector3;
  12452. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12453. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12454. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12455. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12456. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12457. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12458. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12459. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12460. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12461. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12462. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12463. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12464. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12465. /**
  12466. * Defines the delay in milliseconds before starting the system (0 by default)
  12467. */
  12468. startDelay: number;
  12469. /**
  12470. * Gets the current list of drag gradients.
  12471. * You must use addDragGradient and removeDragGradient to udpate this list
  12472. * @returns the list of drag gradients
  12473. */
  12474. getDragGradients(): Nullable<Array<FactorGradient>>;
  12475. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12476. limitVelocityDamping: number;
  12477. /**
  12478. * Gets the current list of limit velocity gradients.
  12479. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12480. * @returns the list of limit velocity gradients
  12481. */
  12482. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12483. /**
  12484. * Gets the current list of color gradients.
  12485. * You must use addColorGradient and removeColorGradient to udpate this list
  12486. * @returns the list of color gradients
  12487. */
  12488. getColorGradients(): Nullable<Array<ColorGradient>>;
  12489. /**
  12490. * Gets the current list of size gradients.
  12491. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12492. * @returns the list of size gradients
  12493. */
  12494. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12495. /**
  12496. * Gets the current list of color remap gradients.
  12497. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12498. * @returns the list of color remap gradients
  12499. */
  12500. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12501. /**
  12502. * Gets the current list of alpha remap gradients.
  12503. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12504. * @returns the list of alpha remap gradients
  12505. */
  12506. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12507. /**
  12508. * Gets the current list of life time gradients.
  12509. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12510. * @returns the list of life time gradients
  12511. */
  12512. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12513. /**
  12514. * Gets the current list of angular speed gradients.
  12515. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12516. * @returns the list of angular speed gradients
  12517. */
  12518. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12519. /**
  12520. * Gets the current list of velocity gradients.
  12521. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12522. * @returns the list of velocity gradients
  12523. */
  12524. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12525. /**
  12526. * Gets the current list of start size gradients.
  12527. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12528. * @returns the list of start size gradients
  12529. */
  12530. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12531. /**
  12532. * Gets the current list of emit rate gradients.
  12533. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12534. * @returns the list of emit rate gradients
  12535. */
  12536. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12537. /**
  12538. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12539. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12540. */
  12541. get direction1(): Vector3;
  12542. set direction1(value: Vector3);
  12543. /**
  12544. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12545. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12546. */
  12547. get direction2(): Vector3;
  12548. set direction2(value: Vector3);
  12549. /**
  12550. * 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.
  12551. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12552. */
  12553. get minEmitBox(): Vector3;
  12554. set minEmitBox(value: Vector3);
  12555. /**
  12556. * 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.
  12557. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12558. */
  12559. get maxEmitBox(): Vector3;
  12560. set maxEmitBox(value: Vector3);
  12561. /**
  12562. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12563. */
  12564. color1: Color4;
  12565. /**
  12566. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12567. */
  12568. color2: Color4;
  12569. /**
  12570. * Color the particle will have at the end of its lifetime
  12571. */
  12572. colorDead: Color4;
  12573. /**
  12574. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12575. */
  12576. textureMask: Color4;
  12577. /**
  12578. * The particle emitter type defines the emitter used by the particle system.
  12579. * It can be for example box, sphere, or cone...
  12580. */
  12581. particleEmitterType: IParticleEmitterType;
  12582. /** @hidden */
  12583. _isSubEmitter: boolean;
  12584. /**
  12585. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12586. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12587. */
  12588. billboardMode: number;
  12589. protected _isBillboardBased: boolean;
  12590. /**
  12591. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12592. */
  12593. get isBillboardBased(): boolean;
  12594. set isBillboardBased(value: boolean);
  12595. /**
  12596. * The scene the particle system belongs to.
  12597. */
  12598. protected _scene: Nullable<Scene>;
  12599. /**
  12600. * The engine the particle system belongs to.
  12601. */
  12602. protected _engine: ThinEngine;
  12603. /**
  12604. * Local cache of defines for image processing.
  12605. */
  12606. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12607. /**
  12608. * Default configuration related to image processing available in the standard Material.
  12609. */
  12610. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12611. /**
  12612. * Gets the image processing configuration used either in this material.
  12613. */
  12614. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12615. /**
  12616. * Sets the Default image processing configuration used either in the this material.
  12617. *
  12618. * If sets to null, the scene one is in use.
  12619. */
  12620. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12621. /**
  12622. * Attaches a new image processing configuration to the Standard Material.
  12623. * @param configuration
  12624. */
  12625. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12626. /** @hidden */
  12627. protected _reset(): void;
  12628. /** @hidden */
  12629. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12630. /**
  12631. * Instantiates a particle system.
  12632. * 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.
  12633. * @param name The name of the particle system
  12634. */
  12635. constructor(name: string);
  12636. /**
  12637. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12638. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12639. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12640. * @returns the emitter
  12641. */
  12642. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12643. /**
  12644. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12645. * @param radius The radius of the hemisphere to emit from
  12646. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12647. * @returns the emitter
  12648. */
  12649. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12650. /**
  12651. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12652. * @param radius The radius of the sphere to emit from
  12653. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12654. * @returns the emitter
  12655. */
  12656. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12657. /**
  12658. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12659. * @param radius The radius of the sphere to emit from
  12660. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12661. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12662. * @returns the emitter
  12663. */
  12664. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12665. /**
  12666. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12667. * @param radius The radius of the emission cylinder
  12668. * @param height The height of the emission cylinder
  12669. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12670. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12671. * @returns the emitter
  12672. */
  12673. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12674. /**
  12675. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12676. * @param radius The radius of the cylinder to emit from
  12677. * @param height The height of the emission cylinder
  12678. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12679. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12680. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12681. * @returns the emitter
  12682. */
  12683. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12684. /**
  12685. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12686. * @param radius The radius of the cone to emit from
  12687. * @param angle The base angle of the cone
  12688. * @returns the emitter
  12689. */
  12690. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12691. /**
  12692. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12695. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12696. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12697. * @returns the emitter
  12698. */
  12699. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12700. }
  12701. }
  12702. declare module "babylonjs/Particles/subEmitter" {
  12703. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12704. import { Scene } from "babylonjs/scene";
  12705. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12706. /**
  12707. * Type of sub emitter
  12708. */
  12709. export enum SubEmitterType {
  12710. /**
  12711. * Attached to the particle over it's lifetime
  12712. */
  12713. ATTACHED = 0,
  12714. /**
  12715. * Created when the particle dies
  12716. */
  12717. END = 1
  12718. }
  12719. /**
  12720. * Sub emitter class used to emit particles from an existing particle
  12721. */
  12722. export class SubEmitter {
  12723. /**
  12724. * the particle system to be used by the sub emitter
  12725. */
  12726. particleSystem: ParticleSystem;
  12727. /**
  12728. * Type of the submitter (Default: END)
  12729. */
  12730. type: SubEmitterType;
  12731. /**
  12732. * 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)
  12733. * Note: This only is supported when using an emitter of type Mesh
  12734. */
  12735. inheritDirection: boolean;
  12736. /**
  12737. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12738. */
  12739. inheritedVelocityAmount: number;
  12740. /**
  12741. * Creates a sub emitter
  12742. * @param particleSystem the particle system to be used by the sub emitter
  12743. */
  12744. constructor(
  12745. /**
  12746. * the particle system to be used by the sub emitter
  12747. */
  12748. particleSystem: ParticleSystem);
  12749. /**
  12750. * Clones the sub emitter
  12751. * @returns the cloned sub emitter
  12752. */
  12753. clone(): SubEmitter;
  12754. /**
  12755. * Serialize current object to a JSON object
  12756. * @returns the serialized object
  12757. */
  12758. serialize(): any;
  12759. /** @hidden */
  12760. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12761. /**
  12762. * Creates a new SubEmitter from a serialized JSON version
  12763. * @param serializationObject defines the JSON object to read from
  12764. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12765. * @param rootUrl defines the rootUrl for data loading
  12766. * @returns a new SubEmitter
  12767. */
  12768. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12769. /** Release associated resources */
  12770. dispose(): void;
  12771. }
  12772. }
  12773. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12774. /** @hidden */
  12775. export var imageProcessingDeclaration: {
  12776. name: string;
  12777. shader: string;
  12778. };
  12779. }
  12780. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12781. /** @hidden */
  12782. export var imageProcessingFunctions: {
  12783. name: string;
  12784. shader: string;
  12785. };
  12786. }
  12787. declare module "babylonjs/Shaders/particles.fragment" {
  12788. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12789. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12790. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12791. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12792. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12793. /** @hidden */
  12794. export var particlesPixelShader: {
  12795. name: string;
  12796. shader: string;
  12797. };
  12798. }
  12799. declare module "babylonjs/Shaders/particles.vertex" {
  12800. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12801. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12802. /** @hidden */
  12803. export var particlesVertexShader: {
  12804. name: string;
  12805. shader: string;
  12806. };
  12807. }
  12808. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12809. import { Nullable } from "babylonjs/types";
  12810. import { Plane } from "babylonjs/Maths/math";
  12811. /**
  12812. * Interface used to define entities containing multiple clip planes
  12813. */
  12814. export interface IClipPlanesHolder {
  12815. /**
  12816. * Gets or sets the active clipplane 1
  12817. */
  12818. clipPlane: Nullable<Plane>;
  12819. /**
  12820. * Gets or sets the active clipplane 2
  12821. */
  12822. clipPlane2: Nullable<Plane>;
  12823. /**
  12824. * Gets or sets the active clipplane 3
  12825. */
  12826. clipPlane3: Nullable<Plane>;
  12827. /**
  12828. * Gets or sets the active clipplane 4
  12829. */
  12830. clipPlane4: Nullable<Plane>;
  12831. /**
  12832. * Gets or sets the active clipplane 5
  12833. */
  12834. clipPlane5: Nullable<Plane>;
  12835. /**
  12836. * Gets or sets the active clipplane 6
  12837. */
  12838. clipPlane6: Nullable<Plane>;
  12839. }
  12840. }
  12841. declare module "babylonjs/Materials/thinMaterialHelper" {
  12842. import { Effect } from "babylonjs/Materials/effect";
  12843. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12844. /**
  12845. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12846. *
  12847. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12848. *
  12849. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12850. */
  12851. export class ThinMaterialHelper {
  12852. /**
  12853. * Binds the clip plane information from the holder to the effect.
  12854. * @param effect The effect we are binding the data to
  12855. * @param holder The entity containing the clip plane information
  12856. */
  12857. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12858. }
  12859. }
  12860. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12861. module "babylonjs/Engines/thinEngine" {
  12862. interface ThinEngine {
  12863. /**
  12864. * Sets alpha constants used by some alpha blending modes
  12865. * @param r defines the red component
  12866. * @param g defines the green component
  12867. * @param b defines the blue component
  12868. * @param a defines the alpha component
  12869. */
  12870. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12871. /**
  12872. * Sets the current alpha mode
  12873. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12874. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12875. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12876. */
  12877. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12878. /**
  12879. * Gets the current alpha mode
  12880. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12881. * @returns the current alpha mode
  12882. */
  12883. getAlphaMode(): number;
  12884. /**
  12885. * Sets the current alpha equation
  12886. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12887. */
  12888. setAlphaEquation(equation: number): void;
  12889. /**
  12890. * Gets the current alpha equation.
  12891. * @returns the current alpha equation
  12892. */
  12893. getAlphaEquation(): number;
  12894. }
  12895. }
  12896. }
  12897. declare module "babylonjs/Particles/particleSystem" {
  12898. import { Nullable } from "babylonjs/types";
  12899. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12900. import { Observable } from "babylonjs/Misc/observable";
  12901. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12902. import { Effect } from "babylonjs/Materials/effect";
  12903. import { IDisposable } from "babylonjs/scene";
  12904. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12905. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12906. import { Particle } from "babylonjs/Particles/particle";
  12907. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12908. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12909. import "babylonjs/Shaders/particles.fragment";
  12910. import "babylonjs/Shaders/particles.vertex";
  12911. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12912. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12913. import "babylonjs/Engines/Extensions/engine.alpha";
  12914. import { Scene } from "babylonjs/scene";
  12915. /**
  12916. * This represents a particle system in Babylon.
  12917. * 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.
  12918. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12919. * @example https://doc.babylonjs.com/babylon101/particles
  12920. */
  12921. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12922. /**
  12923. * Billboard mode will only apply to Y axis
  12924. */
  12925. static readonly BILLBOARDMODE_Y: number;
  12926. /**
  12927. * Billboard mode will apply to all axes
  12928. */
  12929. static readonly BILLBOARDMODE_ALL: number;
  12930. /**
  12931. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12932. */
  12933. static readonly BILLBOARDMODE_STRETCHED: number;
  12934. /**
  12935. * This function can be defined to provide custom update for active particles.
  12936. * This function will be called instead of regular update (age, position, color, etc.).
  12937. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12938. */
  12939. updateFunction: (particles: Particle[]) => void;
  12940. private _emitterWorldMatrix;
  12941. /**
  12942. * This function can be defined to specify initial direction for every new particle.
  12943. * It by default use the emitterType defined function
  12944. */
  12945. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12946. /**
  12947. * This function can be defined to specify initial position for every new particle.
  12948. * It by default use the emitterType defined function
  12949. */
  12950. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12951. /**
  12952. * @hidden
  12953. */
  12954. _inheritedVelocityOffset: Vector3;
  12955. /**
  12956. * An event triggered when the system is disposed
  12957. */
  12958. onDisposeObservable: Observable<IParticleSystem>;
  12959. private _onDisposeObserver;
  12960. /**
  12961. * Sets a callback that will be triggered when the system is disposed
  12962. */
  12963. set onDispose(callback: () => void);
  12964. private _particles;
  12965. private _epsilon;
  12966. private _capacity;
  12967. private _stockParticles;
  12968. private _newPartsExcess;
  12969. private _vertexData;
  12970. private _vertexBuffer;
  12971. private _vertexBuffers;
  12972. private _spriteBuffer;
  12973. private _indexBuffer;
  12974. private _effect;
  12975. private _customEffect;
  12976. private _cachedDefines;
  12977. private _scaledColorStep;
  12978. private _colorDiff;
  12979. private _scaledDirection;
  12980. private _scaledGravity;
  12981. private _currentRenderId;
  12982. private _alive;
  12983. private _useInstancing;
  12984. private _started;
  12985. private _stopped;
  12986. private _actualFrame;
  12987. private _scaledUpdateSpeed;
  12988. private _vertexBufferSize;
  12989. /** @hidden */
  12990. _currentEmitRateGradient: Nullable<FactorGradient>;
  12991. /** @hidden */
  12992. _currentEmitRate1: number;
  12993. /** @hidden */
  12994. _currentEmitRate2: number;
  12995. /** @hidden */
  12996. _currentStartSizeGradient: Nullable<FactorGradient>;
  12997. /** @hidden */
  12998. _currentStartSize1: number;
  12999. /** @hidden */
  13000. _currentStartSize2: number;
  13001. private readonly _rawTextureWidth;
  13002. private _rampGradientsTexture;
  13003. private _useRampGradients;
  13004. /** Gets or sets a matrix to use to compute projection */
  13005. defaultProjectionMatrix: Matrix;
  13006. /** Gets or sets a matrix to use to compute view */
  13007. defaultViewMatrix: Matrix;
  13008. /** Gets or sets a boolean indicating that ramp gradients must be used
  13009. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13010. */
  13011. get useRampGradients(): boolean;
  13012. set useRampGradients(value: boolean);
  13013. /**
  13014. * 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.
  13015. * 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: [])
  13016. */
  13017. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13018. private _subEmitters;
  13019. /**
  13020. * @hidden
  13021. * If the particle systems emitter should be disposed when the particle system is disposed
  13022. */
  13023. _disposeEmitterOnDispose: boolean;
  13024. /**
  13025. * The current active Sub-systems, this property is used by the root particle system only.
  13026. */
  13027. activeSubSystems: Array<ParticleSystem>;
  13028. /**
  13029. * Specifies if the particles are updated in emitter local space or world space
  13030. */
  13031. isLocal: boolean;
  13032. private _rootParticleSystem;
  13033. /**
  13034. * Gets the current list of active particles
  13035. */
  13036. get particles(): Particle[];
  13037. /**
  13038. * Gets the number of particles active at the same time.
  13039. * @returns The number of active particles.
  13040. */
  13041. getActiveCount(): number;
  13042. /**
  13043. * Returns the string "ParticleSystem"
  13044. * @returns a string containing the class name
  13045. */
  13046. getClassName(): string;
  13047. /**
  13048. * Gets a boolean indicating that the system is stopping
  13049. * @returns true if the system is currently stopping
  13050. */
  13051. isStopping(): boolean;
  13052. /**
  13053. * Gets the custom effect used to render the particles
  13054. * @param blendMode Blend mode for which the effect should be retrieved
  13055. * @returns The effect
  13056. */
  13057. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13058. /**
  13059. * Sets the custom effect used to render the particles
  13060. * @param effect The effect to set
  13061. * @param blendMode Blend mode for which the effect should be set
  13062. */
  13063. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13064. /** @hidden */
  13065. private _onBeforeDrawParticlesObservable;
  13066. /**
  13067. * Observable that will be called just before the particles are drawn
  13068. */
  13069. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13070. /**
  13071. * Gets the name of the particle vertex shader
  13072. */
  13073. get vertexShaderName(): string;
  13074. /**
  13075. * Instantiates a particle system.
  13076. * 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.
  13077. * @param name The name of the particle system
  13078. * @param capacity The max number of particles alive at the same time
  13079. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13080. * @param customEffect a custom effect used to change the way particles are rendered by default
  13081. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13082. * @param epsilon Offset used to render the particles
  13083. */
  13084. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13085. private _addFactorGradient;
  13086. private _removeFactorGradient;
  13087. /**
  13088. * Adds a new life time gradient
  13089. * @param gradient defines the gradient to use (between 0 and 1)
  13090. * @param factor defines the life time factor to affect to the specified gradient
  13091. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13092. * @returns the current particle system
  13093. */
  13094. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13095. /**
  13096. * Remove a specific life time gradient
  13097. * @param gradient defines the gradient to remove
  13098. * @returns the current particle system
  13099. */
  13100. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13101. /**
  13102. * Adds a new size gradient
  13103. * @param gradient defines the gradient to use (between 0 and 1)
  13104. * @param factor defines the size factor to affect to the specified gradient
  13105. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13106. * @returns the current particle system
  13107. */
  13108. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13109. /**
  13110. * Remove a specific size gradient
  13111. * @param gradient defines the gradient to remove
  13112. * @returns the current particle system
  13113. */
  13114. removeSizeGradient(gradient: number): IParticleSystem;
  13115. /**
  13116. * Adds a new color remap gradient
  13117. * @param gradient defines the gradient to use (between 0 and 1)
  13118. * @param min defines the color remap minimal range
  13119. * @param max defines the color remap maximal range
  13120. * @returns the current particle system
  13121. */
  13122. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13123. /**
  13124. * Remove a specific color remap gradient
  13125. * @param gradient defines the gradient to remove
  13126. * @returns the current particle system
  13127. */
  13128. removeColorRemapGradient(gradient: number): IParticleSystem;
  13129. /**
  13130. * Adds a new alpha remap gradient
  13131. * @param gradient defines the gradient to use (between 0 and 1)
  13132. * @param min defines the alpha remap minimal range
  13133. * @param max defines the alpha remap maximal range
  13134. * @returns the current particle system
  13135. */
  13136. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13137. /**
  13138. * Remove a specific alpha remap gradient
  13139. * @param gradient defines the gradient to remove
  13140. * @returns the current particle system
  13141. */
  13142. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13143. /**
  13144. * Adds a new angular speed gradient
  13145. * @param gradient defines the gradient to use (between 0 and 1)
  13146. * @param factor defines the angular speed to affect to the specified gradient
  13147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13148. * @returns the current particle system
  13149. */
  13150. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13151. /**
  13152. * Remove a specific angular speed gradient
  13153. * @param gradient defines the gradient to remove
  13154. * @returns the current particle system
  13155. */
  13156. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13157. /**
  13158. * Adds a new velocity gradient
  13159. * @param gradient defines the gradient to use (between 0 and 1)
  13160. * @param factor defines the velocity to affect to the specified gradient
  13161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13162. * @returns the current particle system
  13163. */
  13164. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13165. /**
  13166. * Remove a specific velocity gradient
  13167. * @param gradient defines the gradient to remove
  13168. * @returns the current particle system
  13169. */
  13170. removeVelocityGradient(gradient: number): IParticleSystem;
  13171. /**
  13172. * Adds a new limit velocity gradient
  13173. * @param gradient defines the gradient to use (between 0 and 1)
  13174. * @param factor defines the limit velocity value to affect to the specified gradient
  13175. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13176. * @returns the current particle system
  13177. */
  13178. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13179. /**
  13180. * Remove a specific limit velocity gradient
  13181. * @param gradient defines the gradient to remove
  13182. * @returns the current particle system
  13183. */
  13184. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13185. /**
  13186. * Adds a new drag gradient
  13187. * @param gradient defines the gradient to use (between 0 and 1)
  13188. * @param factor defines the drag value to affect to the specified gradient
  13189. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13190. * @returns the current particle system
  13191. */
  13192. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13193. /**
  13194. * Remove a specific drag gradient
  13195. * @param gradient defines the gradient to remove
  13196. * @returns the current particle system
  13197. */
  13198. removeDragGradient(gradient: number): IParticleSystem;
  13199. /**
  13200. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13201. * @param gradient defines the gradient to use (between 0 and 1)
  13202. * @param factor defines the emit rate value to affect to the specified gradient
  13203. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13204. * @returns the current particle system
  13205. */
  13206. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13207. /**
  13208. * Remove a specific emit rate gradient
  13209. * @param gradient defines the gradient to remove
  13210. * @returns the current particle system
  13211. */
  13212. removeEmitRateGradient(gradient: number): IParticleSystem;
  13213. /**
  13214. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13215. * @param gradient defines the gradient to use (between 0 and 1)
  13216. * @param factor defines the start size value to affect to the specified gradient
  13217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13218. * @returns the current particle system
  13219. */
  13220. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13221. /**
  13222. * Remove a specific start size gradient
  13223. * @param gradient defines the gradient to remove
  13224. * @returns the current particle system
  13225. */
  13226. removeStartSizeGradient(gradient: number): IParticleSystem;
  13227. private _createRampGradientTexture;
  13228. /**
  13229. * Gets the current list of ramp gradients.
  13230. * You must use addRampGradient and removeRampGradient to udpate this list
  13231. * @returns the list of ramp gradients
  13232. */
  13233. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13234. /** Force the system to rebuild all gradients that need to be resync */
  13235. forceRefreshGradients(): void;
  13236. private _syncRampGradientTexture;
  13237. /**
  13238. * Adds a new ramp gradient used to remap particle colors
  13239. * @param gradient defines the gradient to use (between 0 and 1)
  13240. * @param color defines the color to affect to the specified gradient
  13241. * @returns the current particle system
  13242. */
  13243. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13244. /**
  13245. * Remove a specific ramp gradient
  13246. * @param gradient defines the gradient to remove
  13247. * @returns the current particle system
  13248. */
  13249. removeRampGradient(gradient: number): ParticleSystem;
  13250. /**
  13251. * Adds a new color gradient
  13252. * @param gradient defines the gradient to use (between 0 and 1)
  13253. * @param color1 defines the color to affect to the specified gradient
  13254. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13255. * @returns this particle system
  13256. */
  13257. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13258. /**
  13259. * Remove a specific color gradient
  13260. * @param gradient defines the gradient to remove
  13261. * @returns this particle system
  13262. */
  13263. removeColorGradient(gradient: number): IParticleSystem;
  13264. private _fetchR;
  13265. protected _reset(): void;
  13266. private _resetEffect;
  13267. private _createVertexBuffers;
  13268. private _createIndexBuffer;
  13269. /**
  13270. * Gets the maximum number of particles active at the same time.
  13271. * @returns The max number of active particles.
  13272. */
  13273. getCapacity(): number;
  13274. /**
  13275. * Gets whether there are still active particles in the system.
  13276. * @returns True if it is alive, otherwise false.
  13277. */
  13278. isAlive(): boolean;
  13279. /**
  13280. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13281. * @returns True if it has been started, otherwise false.
  13282. */
  13283. isStarted(): boolean;
  13284. private _prepareSubEmitterInternalArray;
  13285. /**
  13286. * Starts the particle system and begins to emit
  13287. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13288. */
  13289. start(delay?: number): void;
  13290. /**
  13291. * Stops the particle system.
  13292. * @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.
  13293. */
  13294. stop(stopSubEmitters?: boolean): void;
  13295. /**
  13296. * Remove all active particles
  13297. */
  13298. reset(): void;
  13299. /**
  13300. * @hidden (for internal use only)
  13301. */
  13302. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13303. /**
  13304. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13305. * Its lifetime will start back at 0.
  13306. */
  13307. recycleParticle: (particle: Particle) => void;
  13308. private _stopSubEmitters;
  13309. private _createParticle;
  13310. private _removeFromRoot;
  13311. private _emitFromParticle;
  13312. private _update;
  13313. /** @hidden */
  13314. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13315. /** @hidden */
  13316. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13317. /**
  13318. * Fill the defines array according to the current settings of the particle system
  13319. * @param defines Array to be updated
  13320. * @param blendMode blend mode to take into account when updating the array
  13321. */
  13322. fillDefines(defines: Array<string>, blendMode: number): void;
  13323. /**
  13324. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13325. * @param uniforms Uniforms array to fill
  13326. * @param attributes Attributes array to fill
  13327. * @param samplers Samplers array to fill
  13328. */
  13329. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13330. /** @hidden */
  13331. private _getEffect;
  13332. /**
  13333. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13334. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13335. */
  13336. animate(preWarmOnly?: boolean): void;
  13337. private _appendParticleVertices;
  13338. /**
  13339. * Rebuilds the particle system.
  13340. */
  13341. rebuild(): void;
  13342. /**
  13343. * Is this system ready to be used/rendered
  13344. * @return true if the system is ready
  13345. */
  13346. isReady(): boolean;
  13347. private _render;
  13348. /**
  13349. * Renders the particle system in its current state.
  13350. * @returns the current number of particles
  13351. */
  13352. render(): number;
  13353. /**
  13354. * Disposes the particle system and free the associated resources
  13355. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13356. */
  13357. dispose(disposeTexture?: boolean): void;
  13358. /**
  13359. * Clones the particle system.
  13360. * @param name The name of the cloned object
  13361. * @param newEmitter The new emitter to use
  13362. * @returns the cloned particle system
  13363. */
  13364. clone(name: string, newEmitter: any): ParticleSystem;
  13365. /**
  13366. * Serializes the particle system to a JSON object
  13367. * @param serializeTexture defines if the texture must be serialized as well
  13368. * @returns the JSON object
  13369. */
  13370. serialize(serializeTexture?: boolean): any;
  13371. /** @hidden */
  13372. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13373. /** @hidden */
  13374. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13375. /**
  13376. * Parses a JSON object to create a particle system.
  13377. * @param parsedParticleSystem The JSON object to parse
  13378. * @param sceneOrEngine The scene or the engine to create the particle system in
  13379. * @param rootUrl The root url to use to load external dependencies like texture
  13380. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13381. * @returns the Parsed particle system
  13382. */
  13383. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13384. }
  13385. }
  13386. declare module "babylonjs/Particles/particle" {
  13387. import { Nullable } from "babylonjs/types";
  13388. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13389. import { Color4 } from "babylonjs/Maths/math.color";
  13390. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13391. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13392. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13393. /**
  13394. * A particle represents one of the element emitted by a particle system.
  13395. * This is mainly define by its coordinates, direction, velocity and age.
  13396. */
  13397. export class Particle {
  13398. /**
  13399. * The particle system the particle belongs to.
  13400. */
  13401. particleSystem: ParticleSystem;
  13402. private static _Count;
  13403. /**
  13404. * Unique ID of the particle
  13405. */
  13406. id: number;
  13407. /**
  13408. * The world position of the particle in the scene.
  13409. */
  13410. position: Vector3;
  13411. /**
  13412. * The world direction of the particle in the scene.
  13413. */
  13414. direction: Vector3;
  13415. /**
  13416. * The color of the particle.
  13417. */
  13418. color: Color4;
  13419. /**
  13420. * The color change of the particle per step.
  13421. */
  13422. colorStep: Color4;
  13423. /**
  13424. * Defines how long will the life of the particle be.
  13425. */
  13426. lifeTime: number;
  13427. /**
  13428. * The current age of the particle.
  13429. */
  13430. age: number;
  13431. /**
  13432. * The current size of the particle.
  13433. */
  13434. size: number;
  13435. /**
  13436. * The current scale of the particle.
  13437. */
  13438. scale: Vector2;
  13439. /**
  13440. * The current angle of the particle.
  13441. */
  13442. angle: number;
  13443. /**
  13444. * Defines how fast is the angle changing.
  13445. */
  13446. angularSpeed: number;
  13447. /**
  13448. * Defines the cell index used by the particle to be rendered from a sprite.
  13449. */
  13450. cellIndex: number;
  13451. /**
  13452. * The information required to support color remapping
  13453. */
  13454. remapData: Vector4;
  13455. /** @hidden */
  13456. _randomCellOffset?: number;
  13457. /** @hidden */
  13458. _initialDirection: Nullable<Vector3>;
  13459. /** @hidden */
  13460. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13461. /** @hidden */
  13462. _initialStartSpriteCellID: number;
  13463. /** @hidden */
  13464. _initialEndSpriteCellID: number;
  13465. /** @hidden */
  13466. _currentColorGradient: Nullable<ColorGradient>;
  13467. /** @hidden */
  13468. _currentColor1: Color4;
  13469. /** @hidden */
  13470. _currentColor2: Color4;
  13471. /** @hidden */
  13472. _currentSizeGradient: Nullable<FactorGradient>;
  13473. /** @hidden */
  13474. _currentSize1: number;
  13475. /** @hidden */
  13476. _currentSize2: number;
  13477. /** @hidden */
  13478. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13479. /** @hidden */
  13480. _currentAngularSpeed1: number;
  13481. /** @hidden */
  13482. _currentAngularSpeed2: number;
  13483. /** @hidden */
  13484. _currentVelocityGradient: Nullable<FactorGradient>;
  13485. /** @hidden */
  13486. _currentVelocity1: number;
  13487. /** @hidden */
  13488. _currentVelocity2: number;
  13489. /** @hidden */
  13490. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13491. /** @hidden */
  13492. _currentLimitVelocity1: number;
  13493. /** @hidden */
  13494. _currentLimitVelocity2: number;
  13495. /** @hidden */
  13496. _currentDragGradient: Nullable<FactorGradient>;
  13497. /** @hidden */
  13498. _currentDrag1: number;
  13499. /** @hidden */
  13500. _currentDrag2: number;
  13501. /** @hidden */
  13502. _randomNoiseCoordinates1: Vector3;
  13503. /** @hidden */
  13504. _randomNoiseCoordinates2: Vector3;
  13505. /** @hidden */
  13506. _localPosition?: Vector3;
  13507. /**
  13508. * Creates a new instance Particle
  13509. * @param particleSystem the particle system the particle belongs to
  13510. */
  13511. constructor(
  13512. /**
  13513. * The particle system the particle belongs to.
  13514. */
  13515. particleSystem: ParticleSystem);
  13516. private updateCellInfoFromSystem;
  13517. /**
  13518. * Defines how the sprite cell index is updated for the particle
  13519. */
  13520. updateCellIndex(): void;
  13521. /** @hidden */
  13522. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13523. /** @hidden */
  13524. _inheritParticleInfoToSubEmitters(): void;
  13525. /** @hidden */
  13526. _reset(): void;
  13527. /**
  13528. * Copy the properties of particle to another one.
  13529. * @param other the particle to copy the information to.
  13530. */
  13531. copyTo(other: Particle): void;
  13532. }
  13533. }
  13534. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13535. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13536. import { Effect } from "babylonjs/Materials/effect";
  13537. import { Particle } from "babylonjs/Particles/particle";
  13538. import { Nullable } from "babylonjs/types";
  13539. import { Scene } from "babylonjs/scene";
  13540. /**
  13541. * Particle emitter represents a volume emitting particles.
  13542. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13543. */
  13544. export interface IParticleEmitterType {
  13545. /**
  13546. * Called by the particle System when the direction is computed for the created particle.
  13547. * @param worldMatrix is the world matrix of the particle system
  13548. * @param directionToUpdate is the direction vector to update with the result
  13549. * @param particle is the particle we are computed the direction for
  13550. * @param isLocal defines if the direction should be set in local space
  13551. */
  13552. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13553. /**
  13554. * Called by the particle System when the position is computed for the created particle.
  13555. * @param worldMatrix is the world matrix of the particle system
  13556. * @param positionToUpdate is the position vector to update with the result
  13557. * @param particle is the particle we are computed the position for
  13558. * @param isLocal defines if the position should be set in local space
  13559. */
  13560. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13561. /**
  13562. * Clones the current emitter and returns a copy of it
  13563. * @returns the new emitter
  13564. */
  13565. clone(): IParticleEmitterType;
  13566. /**
  13567. * Called by the GPUParticleSystem to setup the update shader
  13568. * @param effect defines the update shader
  13569. */
  13570. applyToShader(effect: Effect): void;
  13571. /**
  13572. * Returns a string to use to update the GPU particles update shader
  13573. * @returns the effect defines string
  13574. */
  13575. getEffectDefines(): string;
  13576. /**
  13577. * Returns a string representing the class name
  13578. * @returns a string containing the class name
  13579. */
  13580. getClassName(): string;
  13581. /**
  13582. * Serializes the particle system to a JSON object.
  13583. * @returns the JSON object
  13584. */
  13585. serialize(): any;
  13586. /**
  13587. * Parse properties from a JSON object
  13588. * @param serializationObject defines the JSON object
  13589. * @param scene defines the hosting scene
  13590. */
  13591. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13592. }
  13593. }
  13594. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13595. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13596. import { Effect } from "babylonjs/Materials/effect";
  13597. import { Particle } from "babylonjs/Particles/particle";
  13598. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13599. /**
  13600. * Particle emitter emitting particles from the inside of a box.
  13601. * It emits the particles randomly between 2 given directions.
  13602. */
  13603. export class BoxParticleEmitter implements IParticleEmitterType {
  13604. /**
  13605. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13606. */
  13607. direction1: Vector3;
  13608. /**
  13609. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13610. */
  13611. direction2: Vector3;
  13612. /**
  13613. * 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.
  13614. */
  13615. minEmitBox: Vector3;
  13616. /**
  13617. * 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.
  13618. */
  13619. maxEmitBox: Vector3;
  13620. /**
  13621. * Creates a new instance BoxParticleEmitter
  13622. */
  13623. constructor();
  13624. /**
  13625. * Called by the particle System when the direction is computed for the created particle.
  13626. * @param worldMatrix is the world matrix of the particle system
  13627. * @param directionToUpdate is the direction vector to update with the result
  13628. * @param particle is the particle we are computed the direction for
  13629. * @param isLocal defines if the direction should be set in local space
  13630. */
  13631. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13632. /**
  13633. * Called by the particle System when the position is computed for the created particle.
  13634. * @param worldMatrix is the world matrix of the particle system
  13635. * @param positionToUpdate is the position vector to update with the result
  13636. * @param particle is the particle we are computed the position for
  13637. * @param isLocal defines if the position should be set in local space
  13638. */
  13639. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13640. /**
  13641. * Clones the current emitter and returns a copy of it
  13642. * @returns the new emitter
  13643. */
  13644. clone(): BoxParticleEmitter;
  13645. /**
  13646. * Called by the GPUParticleSystem to setup the update shader
  13647. * @param effect defines the update shader
  13648. */
  13649. applyToShader(effect: Effect): void;
  13650. /**
  13651. * Returns a string to use to update the GPU particles update shader
  13652. * @returns a string containng the defines string
  13653. */
  13654. getEffectDefines(): string;
  13655. /**
  13656. * Returns the string "BoxParticleEmitter"
  13657. * @returns a string containing the class name
  13658. */
  13659. getClassName(): string;
  13660. /**
  13661. * Serializes the particle system to a JSON object.
  13662. * @returns the JSON object
  13663. */
  13664. serialize(): any;
  13665. /**
  13666. * Parse properties from a JSON object
  13667. * @param serializationObject defines the JSON object
  13668. */
  13669. parse(serializationObject: any): void;
  13670. }
  13671. }
  13672. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13673. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13674. import { Effect } from "babylonjs/Materials/effect";
  13675. import { Particle } from "babylonjs/Particles/particle";
  13676. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13677. /**
  13678. * Particle emitter emitting particles from the inside of a cone.
  13679. * It emits the particles alongside the cone volume from the base to the particle.
  13680. * The emission direction might be randomized.
  13681. */
  13682. export class ConeParticleEmitter implements IParticleEmitterType {
  13683. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13684. directionRandomizer: number;
  13685. private _radius;
  13686. private _angle;
  13687. private _height;
  13688. /**
  13689. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13690. */
  13691. radiusRange: number;
  13692. /**
  13693. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13694. */
  13695. heightRange: number;
  13696. /**
  13697. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13698. */
  13699. emitFromSpawnPointOnly: boolean;
  13700. /**
  13701. * Gets or sets the radius of the emission cone
  13702. */
  13703. get radius(): number;
  13704. set radius(value: number);
  13705. /**
  13706. * Gets or sets the angle of the emission cone
  13707. */
  13708. get angle(): number;
  13709. set angle(value: number);
  13710. private _buildHeight;
  13711. /**
  13712. * Creates a new instance ConeParticleEmitter
  13713. * @param radius the radius of the emission cone (1 by default)
  13714. * @param angle the cone base angle (PI by default)
  13715. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13716. */
  13717. constructor(radius?: number, angle?: number,
  13718. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13719. directionRandomizer?: number);
  13720. /**
  13721. * Called by the particle System when the direction is computed for the created particle.
  13722. * @param worldMatrix is the world matrix of the particle system
  13723. * @param directionToUpdate is the direction vector to update with the result
  13724. * @param particle is the particle we are computed the direction for
  13725. * @param isLocal defines if the direction should be set in local space
  13726. */
  13727. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13728. /**
  13729. * Called by the particle System when the position is computed for the created particle.
  13730. * @param worldMatrix is the world matrix of the particle system
  13731. * @param positionToUpdate is the position vector to update with the result
  13732. * @param particle is the particle we are computed the position for
  13733. * @param isLocal defines if the position should be set in local space
  13734. */
  13735. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13736. /**
  13737. * Clones the current emitter and returns a copy of it
  13738. * @returns the new emitter
  13739. */
  13740. clone(): ConeParticleEmitter;
  13741. /**
  13742. * Called by the GPUParticleSystem to setup the update shader
  13743. * @param effect defines the update shader
  13744. */
  13745. applyToShader(effect: Effect): void;
  13746. /**
  13747. * Returns a string to use to update the GPU particles update shader
  13748. * @returns a string containng the defines string
  13749. */
  13750. getEffectDefines(): string;
  13751. /**
  13752. * Returns the string "ConeParticleEmitter"
  13753. * @returns a string containing the class name
  13754. */
  13755. getClassName(): string;
  13756. /**
  13757. * Serializes the particle system to a JSON object.
  13758. * @returns the JSON object
  13759. */
  13760. serialize(): any;
  13761. /**
  13762. * Parse properties from a JSON object
  13763. * @param serializationObject defines the JSON object
  13764. */
  13765. parse(serializationObject: any): void;
  13766. }
  13767. }
  13768. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13769. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13770. import { Effect } from "babylonjs/Materials/effect";
  13771. import { Particle } from "babylonjs/Particles/particle";
  13772. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13773. /**
  13774. * Particle emitter emitting particles from the inside of a cylinder.
  13775. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13776. */
  13777. export class CylinderParticleEmitter implements IParticleEmitterType {
  13778. /**
  13779. * The radius of the emission cylinder.
  13780. */
  13781. radius: number;
  13782. /**
  13783. * The height of the emission cylinder.
  13784. */
  13785. height: number;
  13786. /**
  13787. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13788. */
  13789. radiusRange: number;
  13790. /**
  13791. * How much to randomize the particle direction [0-1].
  13792. */
  13793. directionRandomizer: number;
  13794. /**
  13795. * Creates a new instance CylinderParticleEmitter
  13796. * @param radius the radius of the emission cylinder (1 by default)
  13797. * @param height the height of the emission cylinder (1 by default)
  13798. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13799. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13800. */
  13801. constructor(
  13802. /**
  13803. * The radius of the emission cylinder.
  13804. */
  13805. radius?: number,
  13806. /**
  13807. * The height of the emission cylinder.
  13808. */
  13809. height?: number,
  13810. /**
  13811. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13812. */
  13813. radiusRange?: number,
  13814. /**
  13815. * How much to randomize the particle direction [0-1].
  13816. */
  13817. directionRandomizer?: number);
  13818. /**
  13819. * Called by the particle System when the direction is computed for the created particle.
  13820. * @param worldMatrix is the world matrix of the particle system
  13821. * @param directionToUpdate is the direction vector to update with the result
  13822. * @param particle is the particle we are computed the direction for
  13823. * @param isLocal defines if the direction should be set in local space
  13824. */
  13825. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13826. /**
  13827. * Called by the particle System when the position is computed for the created particle.
  13828. * @param worldMatrix is the world matrix of the particle system
  13829. * @param positionToUpdate is the position vector to update with the result
  13830. * @param particle is the particle we are computed the position for
  13831. * @param isLocal defines if the position should be set in local space
  13832. */
  13833. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13834. /**
  13835. * Clones the current emitter and returns a copy of it
  13836. * @returns the new emitter
  13837. */
  13838. clone(): CylinderParticleEmitter;
  13839. /**
  13840. * Called by the GPUParticleSystem to setup the update shader
  13841. * @param effect defines the update shader
  13842. */
  13843. applyToShader(effect: Effect): void;
  13844. /**
  13845. * Returns a string to use to update the GPU particles update shader
  13846. * @returns a string containng the defines string
  13847. */
  13848. getEffectDefines(): string;
  13849. /**
  13850. * Returns the string "CylinderParticleEmitter"
  13851. * @returns a string containing the class name
  13852. */
  13853. getClassName(): string;
  13854. /**
  13855. * Serializes the particle system to a JSON object.
  13856. * @returns the JSON object
  13857. */
  13858. serialize(): any;
  13859. /**
  13860. * Parse properties from a JSON object
  13861. * @param serializationObject defines the JSON object
  13862. */
  13863. parse(serializationObject: any): void;
  13864. }
  13865. /**
  13866. * Particle emitter emitting particles from the inside of a cylinder.
  13867. * It emits the particles randomly between two vectors.
  13868. */
  13869. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13870. /**
  13871. * The min limit of the emission direction.
  13872. */
  13873. direction1: Vector3;
  13874. /**
  13875. * The max limit of the emission direction.
  13876. */
  13877. direction2: Vector3;
  13878. /**
  13879. * Creates a new instance CylinderDirectedParticleEmitter
  13880. * @param radius the radius of the emission cylinder (1 by default)
  13881. * @param height the height of the emission cylinder (1 by default)
  13882. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13883. * @param direction1 the min limit of the emission direction (up vector by default)
  13884. * @param direction2 the max limit of the emission direction (up vector by default)
  13885. */
  13886. constructor(radius?: number, height?: number, radiusRange?: number,
  13887. /**
  13888. * The min limit of the emission direction.
  13889. */
  13890. direction1?: Vector3,
  13891. /**
  13892. * The max limit of the emission direction.
  13893. */
  13894. direction2?: Vector3);
  13895. /**
  13896. * Called by the particle System when the direction is computed for the created particle.
  13897. * @param worldMatrix is the world matrix of the particle system
  13898. * @param directionToUpdate is the direction vector to update with the result
  13899. * @param particle is the particle we are computed the direction for
  13900. */
  13901. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13902. /**
  13903. * Clones the current emitter and returns a copy of it
  13904. * @returns the new emitter
  13905. */
  13906. clone(): CylinderDirectedParticleEmitter;
  13907. /**
  13908. * Called by the GPUParticleSystem to setup the update shader
  13909. * @param effect defines the update shader
  13910. */
  13911. applyToShader(effect: Effect): void;
  13912. /**
  13913. * Returns a string to use to update the GPU particles update shader
  13914. * @returns a string containng the defines string
  13915. */
  13916. getEffectDefines(): string;
  13917. /**
  13918. * Returns the string "CylinderDirectedParticleEmitter"
  13919. * @returns a string containing the class name
  13920. */
  13921. getClassName(): string;
  13922. /**
  13923. * Serializes the particle system to a JSON object.
  13924. * @returns the JSON object
  13925. */
  13926. serialize(): any;
  13927. /**
  13928. * Parse properties from a JSON object
  13929. * @param serializationObject defines the JSON object
  13930. */
  13931. parse(serializationObject: any): void;
  13932. }
  13933. }
  13934. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13935. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13936. import { Effect } from "babylonjs/Materials/effect";
  13937. import { Particle } from "babylonjs/Particles/particle";
  13938. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13939. /**
  13940. * Particle emitter emitting particles from the inside of a hemisphere.
  13941. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13942. */
  13943. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13944. /**
  13945. * The radius of the emission hemisphere.
  13946. */
  13947. radius: number;
  13948. /**
  13949. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13950. */
  13951. radiusRange: number;
  13952. /**
  13953. * How much to randomize the particle direction [0-1].
  13954. */
  13955. directionRandomizer: number;
  13956. /**
  13957. * Creates a new instance HemisphericParticleEmitter
  13958. * @param radius the radius of the emission hemisphere (1 by default)
  13959. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13960. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13961. */
  13962. constructor(
  13963. /**
  13964. * The radius of the emission hemisphere.
  13965. */
  13966. radius?: number,
  13967. /**
  13968. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13969. */
  13970. radiusRange?: number,
  13971. /**
  13972. * How much to randomize the particle direction [0-1].
  13973. */
  13974. directionRandomizer?: number);
  13975. /**
  13976. * Called by the particle System when the direction is computed for the created particle.
  13977. * @param worldMatrix is the world matrix of the particle system
  13978. * @param directionToUpdate is the direction vector to update with the result
  13979. * @param particle is the particle we are computed the direction for
  13980. * @param isLocal defines if the direction should be set in local space
  13981. */
  13982. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13983. /**
  13984. * Called by the particle System when the position is computed for the created particle.
  13985. * @param worldMatrix is the world matrix of the particle system
  13986. * @param positionToUpdate is the position vector to update with the result
  13987. * @param particle is the particle we are computed the position for
  13988. * @param isLocal defines if the position should be set in local space
  13989. */
  13990. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13991. /**
  13992. * Clones the current emitter and returns a copy of it
  13993. * @returns the new emitter
  13994. */
  13995. clone(): HemisphericParticleEmitter;
  13996. /**
  13997. * Called by the GPUParticleSystem to setup the update shader
  13998. * @param effect defines the update shader
  13999. */
  14000. applyToShader(effect: Effect): void;
  14001. /**
  14002. * Returns a string to use to update the GPU particles update shader
  14003. * @returns a string containng the defines string
  14004. */
  14005. getEffectDefines(): string;
  14006. /**
  14007. * Returns the string "HemisphericParticleEmitter"
  14008. * @returns a string containing the class name
  14009. */
  14010. getClassName(): string;
  14011. /**
  14012. * Serializes the particle system to a JSON object.
  14013. * @returns the JSON object
  14014. */
  14015. serialize(): any;
  14016. /**
  14017. * Parse properties from a JSON object
  14018. * @param serializationObject defines the JSON object
  14019. */
  14020. parse(serializationObject: any): void;
  14021. }
  14022. }
  14023. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14024. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14025. import { Effect } from "babylonjs/Materials/effect";
  14026. import { Particle } from "babylonjs/Particles/particle";
  14027. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14028. /**
  14029. * Particle emitter emitting particles from a point.
  14030. * It emits the particles randomly between 2 given directions.
  14031. */
  14032. export class PointParticleEmitter implements IParticleEmitterType {
  14033. /**
  14034. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14035. */
  14036. direction1: Vector3;
  14037. /**
  14038. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14039. */
  14040. direction2: Vector3;
  14041. /**
  14042. * Creates a new instance PointParticleEmitter
  14043. */
  14044. constructor();
  14045. /**
  14046. * Called by the particle System when the direction is computed for the created particle.
  14047. * @param worldMatrix is the world matrix of the particle system
  14048. * @param directionToUpdate is the direction vector to update with the result
  14049. * @param particle is the particle we are computed the direction for
  14050. * @param isLocal defines if the direction should be set in local space
  14051. */
  14052. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14053. /**
  14054. * Called by the particle System when the position is computed for the created particle.
  14055. * @param worldMatrix is the world matrix of the particle system
  14056. * @param positionToUpdate is the position vector to update with the result
  14057. * @param particle is the particle we are computed the position for
  14058. * @param isLocal defines if the position should be set in local space
  14059. */
  14060. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14061. /**
  14062. * Clones the current emitter and returns a copy of it
  14063. * @returns the new emitter
  14064. */
  14065. clone(): PointParticleEmitter;
  14066. /**
  14067. * Called by the GPUParticleSystem to setup the update shader
  14068. * @param effect defines the update shader
  14069. */
  14070. applyToShader(effect: Effect): void;
  14071. /**
  14072. * Returns a string to use to update the GPU particles update shader
  14073. * @returns a string containng the defines string
  14074. */
  14075. getEffectDefines(): string;
  14076. /**
  14077. * Returns the string "PointParticleEmitter"
  14078. * @returns a string containing the class name
  14079. */
  14080. getClassName(): string;
  14081. /**
  14082. * Serializes the particle system to a JSON object.
  14083. * @returns the JSON object
  14084. */
  14085. serialize(): any;
  14086. /**
  14087. * Parse properties from a JSON object
  14088. * @param serializationObject defines the JSON object
  14089. */
  14090. parse(serializationObject: any): void;
  14091. }
  14092. }
  14093. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14094. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14095. import { Effect } from "babylonjs/Materials/effect";
  14096. import { Particle } from "babylonjs/Particles/particle";
  14097. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14098. /**
  14099. * Particle emitter emitting particles from the inside of a sphere.
  14100. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14101. */
  14102. export class SphereParticleEmitter implements IParticleEmitterType {
  14103. /**
  14104. * The radius of the emission sphere.
  14105. */
  14106. radius: number;
  14107. /**
  14108. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14109. */
  14110. radiusRange: number;
  14111. /**
  14112. * How much to randomize the particle direction [0-1].
  14113. */
  14114. directionRandomizer: number;
  14115. /**
  14116. * Creates a new instance SphereParticleEmitter
  14117. * @param radius the radius of the emission sphere (1 by default)
  14118. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14119. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14120. */
  14121. constructor(
  14122. /**
  14123. * The radius of the emission sphere.
  14124. */
  14125. radius?: number,
  14126. /**
  14127. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14128. */
  14129. radiusRange?: number,
  14130. /**
  14131. * How much to randomize the particle direction [0-1].
  14132. */
  14133. directionRandomizer?: number);
  14134. /**
  14135. * Called by the particle System when the direction is computed for the created particle.
  14136. * @param worldMatrix is the world matrix of the particle system
  14137. * @param directionToUpdate is the direction vector to update with the result
  14138. * @param particle is the particle we are computed the direction for
  14139. * @param isLocal defines if the direction should be set in local space
  14140. */
  14141. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14142. /**
  14143. * Called by the particle System when the position is computed for the created particle.
  14144. * @param worldMatrix is the world matrix of the particle system
  14145. * @param positionToUpdate is the position vector to update with the result
  14146. * @param particle is the particle we are computed the position for
  14147. * @param isLocal defines if the position should be set in local space
  14148. */
  14149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14150. /**
  14151. * Clones the current emitter and returns a copy of it
  14152. * @returns the new emitter
  14153. */
  14154. clone(): SphereParticleEmitter;
  14155. /**
  14156. * Called by the GPUParticleSystem to setup the update shader
  14157. * @param effect defines the update shader
  14158. */
  14159. applyToShader(effect: Effect): void;
  14160. /**
  14161. * Returns a string to use to update the GPU particles update shader
  14162. * @returns a string containng the defines string
  14163. */
  14164. getEffectDefines(): string;
  14165. /**
  14166. * Returns the string "SphereParticleEmitter"
  14167. * @returns a string containing the class name
  14168. */
  14169. getClassName(): string;
  14170. /**
  14171. * Serializes the particle system to a JSON object.
  14172. * @returns the JSON object
  14173. */
  14174. serialize(): any;
  14175. /**
  14176. * Parse properties from a JSON object
  14177. * @param serializationObject defines the JSON object
  14178. */
  14179. parse(serializationObject: any): void;
  14180. }
  14181. /**
  14182. * Particle emitter emitting particles from the inside of a sphere.
  14183. * It emits the particles randomly between two vectors.
  14184. */
  14185. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14186. /**
  14187. * The min limit of the emission direction.
  14188. */
  14189. direction1: Vector3;
  14190. /**
  14191. * The max limit of the emission direction.
  14192. */
  14193. direction2: Vector3;
  14194. /**
  14195. * Creates a new instance SphereDirectedParticleEmitter
  14196. * @param radius the radius of the emission sphere (1 by default)
  14197. * @param direction1 the min limit of the emission direction (up vector by default)
  14198. * @param direction2 the max limit of the emission direction (up vector by default)
  14199. */
  14200. constructor(radius?: number,
  14201. /**
  14202. * The min limit of the emission direction.
  14203. */
  14204. direction1?: Vector3,
  14205. /**
  14206. * The max limit of the emission direction.
  14207. */
  14208. direction2?: Vector3);
  14209. /**
  14210. * Called by the particle System when the direction is computed for the created particle.
  14211. * @param worldMatrix is the world matrix of the particle system
  14212. * @param directionToUpdate is the direction vector to update with the result
  14213. * @param particle is the particle we are computed the direction for
  14214. */
  14215. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14216. /**
  14217. * Clones the current emitter and returns a copy of it
  14218. * @returns the new emitter
  14219. */
  14220. clone(): SphereDirectedParticleEmitter;
  14221. /**
  14222. * Called by the GPUParticleSystem to setup the update shader
  14223. * @param effect defines the update shader
  14224. */
  14225. applyToShader(effect: Effect): void;
  14226. /**
  14227. * Returns a string to use to update the GPU particles update shader
  14228. * @returns a string containng the defines string
  14229. */
  14230. getEffectDefines(): string;
  14231. /**
  14232. * Returns the string "SphereDirectedParticleEmitter"
  14233. * @returns a string containing the class name
  14234. */
  14235. getClassName(): string;
  14236. /**
  14237. * Serializes the particle system to a JSON object.
  14238. * @returns the JSON object
  14239. */
  14240. serialize(): any;
  14241. /**
  14242. * Parse properties from a JSON object
  14243. * @param serializationObject defines the JSON object
  14244. */
  14245. parse(serializationObject: any): void;
  14246. }
  14247. }
  14248. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14249. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14250. import { Effect } from "babylonjs/Materials/effect";
  14251. import { Particle } from "babylonjs/Particles/particle";
  14252. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14253. import { Nullable } from "babylonjs/types";
  14254. /**
  14255. * Particle emitter emitting particles from a custom list of positions.
  14256. */
  14257. export class CustomParticleEmitter implements IParticleEmitterType {
  14258. /**
  14259. * Gets or sets the position generator that will create the inital position of each particle.
  14260. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14261. */
  14262. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14263. /**
  14264. * Gets or sets the destination generator that will create the final destination of each particle.
  14265. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14266. */
  14267. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14268. /**
  14269. * Creates a new instance CustomParticleEmitter
  14270. */
  14271. constructor();
  14272. /**
  14273. * Called by the particle System when the direction is computed for the created particle.
  14274. * @param worldMatrix is the world matrix of the particle system
  14275. * @param directionToUpdate is the direction vector to update with the result
  14276. * @param particle is the particle we are computed the direction for
  14277. * @param isLocal defines if the direction should be set in local space
  14278. */
  14279. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14280. /**
  14281. * Called by the particle System when the position is computed for the created particle.
  14282. * @param worldMatrix is the world matrix of the particle system
  14283. * @param positionToUpdate is the position vector to update with the result
  14284. * @param particle is the particle we are computed the position for
  14285. * @param isLocal defines if the position should be set in local space
  14286. */
  14287. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14288. /**
  14289. * Clones the current emitter and returns a copy of it
  14290. * @returns the new emitter
  14291. */
  14292. clone(): CustomParticleEmitter;
  14293. /**
  14294. * Called by the GPUParticleSystem to setup the update shader
  14295. * @param effect defines the update shader
  14296. */
  14297. applyToShader(effect: Effect): void;
  14298. /**
  14299. * Returns a string to use to update the GPU particles update shader
  14300. * @returns a string containng the defines string
  14301. */
  14302. getEffectDefines(): string;
  14303. /**
  14304. * Returns the string "PointParticleEmitter"
  14305. * @returns a string containing the class name
  14306. */
  14307. getClassName(): string;
  14308. /**
  14309. * Serializes the particle system to a JSON object.
  14310. * @returns the JSON object
  14311. */
  14312. serialize(): any;
  14313. /**
  14314. * Parse properties from a JSON object
  14315. * @param serializationObject defines the JSON object
  14316. */
  14317. parse(serializationObject: any): void;
  14318. }
  14319. }
  14320. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14321. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14322. import { Effect } from "babylonjs/Materials/effect";
  14323. import { Particle } from "babylonjs/Particles/particle";
  14324. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14325. import { Nullable } from "babylonjs/types";
  14326. import { Scene } from "babylonjs/scene";
  14327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14328. /**
  14329. * Particle emitter emitting particles from the inside of a box.
  14330. * It emits the particles randomly between 2 given directions.
  14331. */
  14332. export class MeshParticleEmitter implements IParticleEmitterType {
  14333. private _indices;
  14334. private _positions;
  14335. private _normals;
  14336. private _storedNormal;
  14337. private _mesh;
  14338. /**
  14339. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14340. */
  14341. direction1: Vector3;
  14342. /**
  14343. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14344. */
  14345. direction2: Vector3;
  14346. /**
  14347. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14348. */
  14349. useMeshNormalsForDirection: boolean;
  14350. /** Defines the mesh to use as source */
  14351. get mesh(): Nullable<AbstractMesh>;
  14352. set mesh(value: Nullable<AbstractMesh>);
  14353. /**
  14354. * Creates a new instance MeshParticleEmitter
  14355. * @param mesh defines the mesh to use as source
  14356. */
  14357. constructor(mesh?: Nullable<AbstractMesh>);
  14358. /**
  14359. * Called by the particle System when the direction is computed for the created particle.
  14360. * @param worldMatrix is the world matrix of the particle system
  14361. * @param directionToUpdate is the direction vector to update with the result
  14362. * @param particle is the particle we are computed the direction for
  14363. * @param isLocal defines if the direction should be set in local space
  14364. */
  14365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14366. /**
  14367. * Called by the particle System when the position is computed for the created particle.
  14368. * @param worldMatrix is the world matrix of the particle system
  14369. * @param positionToUpdate is the position vector to update with the result
  14370. * @param particle is the particle we are computed the position for
  14371. * @param isLocal defines if the position should be set in local space
  14372. */
  14373. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14374. /**
  14375. * Clones the current emitter and returns a copy of it
  14376. * @returns the new emitter
  14377. */
  14378. clone(): MeshParticleEmitter;
  14379. /**
  14380. * Called by the GPUParticleSystem to setup the update shader
  14381. * @param effect defines the update shader
  14382. */
  14383. applyToShader(effect: Effect): void;
  14384. /**
  14385. * Returns a string to use to update the GPU particles update shader
  14386. * @returns a string containng the defines string
  14387. */
  14388. getEffectDefines(): string;
  14389. /**
  14390. * Returns the string "BoxParticleEmitter"
  14391. * @returns a string containing the class name
  14392. */
  14393. getClassName(): string;
  14394. /**
  14395. * Serializes the particle system to a JSON object.
  14396. * @returns the JSON object
  14397. */
  14398. serialize(): any;
  14399. /**
  14400. * Parse properties from a JSON object
  14401. * @param serializationObject defines the JSON object
  14402. * @param scene defines the hosting scene
  14403. */
  14404. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14405. }
  14406. }
  14407. declare module "babylonjs/Particles/EmitterTypes/index" {
  14408. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14409. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14410. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14411. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14412. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14413. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14414. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14415. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14416. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14417. }
  14418. declare module "babylonjs/Particles/IParticleSystem" {
  14419. import { Nullable } from "babylonjs/types";
  14420. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14421. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14423. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14424. import { Scene } from "babylonjs/scene";
  14425. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14426. import { Effect } from "babylonjs/Materials/effect";
  14427. import { Observable } from "babylonjs/Misc/observable";
  14428. import { Animation } from "babylonjs/Animations/animation";
  14429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14430. /**
  14431. * Interface representing a particle system in Babylon.js.
  14432. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14433. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14434. */
  14435. export interface IParticleSystem {
  14436. /**
  14437. * List of animations used by the particle system.
  14438. */
  14439. animations: Animation[];
  14440. /**
  14441. * The id of the Particle system.
  14442. */
  14443. id: string;
  14444. /**
  14445. * The name of the Particle system.
  14446. */
  14447. name: string;
  14448. /**
  14449. * The emitter represents the Mesh or position we are attaching the particle system to.
  14450. */
  14451. emitter: Nullable<AbstractMesh | Vector3>;
  14452. /**
  14453. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14454. */
  14455. isBillboardBased: boolean;
  14456. /**
  14457. * The rendering group used by the Particle system to chose when to render.
  14458. */
  14459. renderingGroupId: number;
  14460. /**
  14461. * The layer mask we are rendering the particles through.
  14462. */
  14463. layerMask: number;
  14464. /**
  14465. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14466. */
  14467. updateSpeed: number;
  14468. /**
  14469. * The amount of time the particle system is running (depends of the overall update speed).
  14470. */
  14471. targetStopDuration: number;
  14472. /**
  14473. * The texture used to render each particle. (this can be a spritesheet)
  14474. */
  14475. particleTexture: Nullable<BaseTexture>;
  14476. /**
  14477. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14478. */
  14479. blendMode: number;
  14480. /**
  14481. * Minimum life time of emitting particles.
  14482. */
  14483. minLifeTime: number;
  14484. /**
  14485. * Maximum life time of emitting particles.
  14486. */
  14487. maxLifeTime: number;
  14488. /**
  14489. * Minimum Size of emitting particles.
  14490. */
  14491. minSize: number;
  14492. /**
  14493. * Maximum Size of emitting particles.
  14494. */
  14495. maxSize: number;
  14496. /**
  14497. * Minimum scale of emitting particles on X axis.
  14498. */
  14499. minScaleX: number;
  14500. /**
  14501. * Maximum scale of emitting particles on X axis.
  14502. */
  14503. maxScaleX: number;
  14504. /**
  14505. * Minimum scale of emitting particles on Y axis.
  14506. */
  14507. minScaleY: number;
  14508. /**
  14509. * Maximum scale of emitting particles on Y axis.
  14510. */
  14511. maxScaleY: number;
  14512. /**
  14513. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14514. */
  14515. color1: Color4;
  14516. /**
  14517. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14518. */
  14519. color2: Color4;
  14520. /**
  14521. * Color the particle will have at the end of its lifetime.
  14522. */
  14523. colorDead: Color4;
  14524. /**
  14525. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14526. */
  14527. emitRate: number;
  14528. /**
  14529. * You can use gravity if you want to give an orientation to your particles.
  14530. */
  14531. gravity: Vector3;
  14532. /**
  14533. * Minimum power of emitting particles.
  14534. */
  14535. minEmitPower: number;
  14536. /**
  14537. * Maximum power of emitting particles.
  14538. */
  14539. maxEmitPower: number;
  14540. /**
  14541. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14542. */
  14543. minAngularSpeed: number;
  14544. /**
  14545. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14546. */
  14547. maxAngularSpeed: number;
  14548. /**
  14549. * Gets or sets the minimal initial rotation in radians.
  14550. */
  14551. minInitialRotation: number;
  14552. /**
  14553. * Gets or sets the maximal initial rotation in radians.
  14554. */
  14555. maxInitialRotation: number;
  14556. /**
  14557. * The particle emitter type defines the emitter used by the particle system.
  14558. * It can be for example box, sphere, or cone...
  14559. */
  14560. particleEmitterType: Nullable<IParticleEmitterType>;
  14561. /**
  14562. * Defines the delay in milliseconds before starting the system (0 by default)
  14563. */
  14564. startDelay: number;
  14565. /**
  14566. * 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
  14567. */
  14568. preWarmCycles: number;
  14569. /**
  14570. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14571. */
  14572. preWarmStepOffset: number;
  14573. /**
  14574. * 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)
  14575. */
  14576. spriteCellChangeSpeed: number;
  14577. /**
  14578. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14579. */
  14580. startSpriteCellID: number;
  14581. /**
  14582. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14583. */
  14584. endSpriteCellID: number;
  14585. /**
  14586. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14587. */
  14588. spriteCellWidth: number;
  14589. /**
  14590. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14591. */
  14592. spriteCellHeight: number;
  14593. /**
  14594. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14595. */
  14596. spriteRandomStartCell: boolean;
  14597. /**
  14598. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14599. */
  14600. isAnimationSheetEnabled: boolean;
  14601. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14602. translationPivot: Vector2;
  14603. /**
  14604. * Gets or sets a texture used to add random noise to particle positions
  14605. */
  14606. noiseTexture: Nullable<BaseTexture>;
  14607. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14608. noiseStrength: Vector3;
  14609. /**
  14610. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14611. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14612. */
  14613. billboardMode: number;
  14614. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14615. limitVelocityDamping: number;
  14616. /**
  14617. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14618. */
  14619. beginAnimationOnStart: boolean;
  14620. /**
  14621. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14622. */
  14623. beginAnimationFrom: number;
  14624. /**
  14625. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14626. */
  14627. beginAnimationTo: number;
  14628. /**
  14629. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14630. */
  14631. beginAnimationLoop: boolean;
  14632. /**
  14633. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14634. */
  14635. disposeOnStop: boolean;
  14636. /**
  14637. * Specifies if the particles are updated in emitter local space or world space
  14638. */
  14639. isLocal: boolean;
  14640. /** Snippet ID if the particle system was created from the snippet server */
  14641. snippetId: string;
  14642. /** Gets or sets a matrix to use to compute projection */
  14643. defaultProjectionMatrix: Matrix;
  14644. /**
  14645. * Gets the maximum number of particles active at the same time.
  14646. * @returns The max number of active particles.
  14647. */
  14648. getCapacity(): number;
  14649. /**
  14650. * Gets the number of particles active at the same time.
  14651. * @returns The number of active particles.
  14652. */
  14653. getActiveCount(): number;
  14654. /**
  14655. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14656. * @returns True if it has been started, otherwise false.
  14657. */
  14658. isStarted(): boolean;
  14659. /**
  14660. * Animates the particle system for this frame.
  14661. */
  14662. animate(): void;
  14663. /**
  14664. * Renders the particle system in its current state.
  14665. * @returns the current number of particles
  14666. */
  14667. render(): number;
  14668. /**
  14669. * Dispose the particle system and frees its associated resources.
  14670. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14671. */
  14672. dispose(disposeTexture?: boolean): void;
  14673. /**
  14674. * An event triggered when the system is disposed
  14675. */
  14676. onDisposeObservable: Observable<IParticleSystem>;
  14677. /**
  14678. * Clones the particle system.
  14679. * @param name The name of the cloned object
  14680. * @param newEmitter The new emitter to use
  14681. * @returns the cloned particle system
  14682. */
  14683. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14684. /**
  14685. * Serializes the particle system to a JSON object
  14686. * @param serializeTexture defines if the texture must be serialized as well
  14687. * @returns the JSON object
  14688. */
  14689. serialize(serializeTexture: boolean): any;
  14690. /**
  14691. * Rebuild the particle system
  14692. */
  14693. rebuild(): void;
  14694. /** Force the system to rebuild all gradients that need to be resync */
  14695. forceRefreshGradients(): void;
  14696. /**
  14697. * Starts the particle system and begins to emit
  14698. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14699. */
  14700. start(delay?: number): void;
  14701. /**
  14702. * Stops the particle system.
  14703. */
  14704. stop(): void;
  14705. /**
  14706. * Remove all active particles
  14707. */
  14708. reset(): void;
  14709. /**
  14710. * Gets a boolean indicating that the system is stopping
  14711. * @returns true if the system is currently stopping
  14712. */
  14713. isStopping(): boolean;
  14714. /**
  14715. * Is this system ready to be used/rendered
  14716. * @return true if the system is ready
  14717. */
  14718. isReady(): boolean;
  14719. /**
  14720. * Returns the string "ParticleSystem"
  14721. * @returns a string containing the class name
  14722. */
  14723. getClassName(): string;
  14724. /**
  14725. * Gets the custom effect used to render the particles
  14726. * @param blendMode Blend mode for which the effect should be retrieved
  14727. * @returns The effect
  14728. */
  14729. getCustomEffect(blendMode: number): Nullable<Effect>;
  14730. /**
  14731. * Sets the custom effect used to render the particles
  14732. * @param effect The effect to set
  14733. * @param blendMode Blend mode for which the effect should be set
  14734. */
  14735. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14736. /**
  14737. * Fill the defines array according to the current settings of the particle system
  14738. * @param defines Array to be updated
  14739. * @param blendMode blend mode to take into account when updating the array
  14740. */
  14741. fillDefines(defines: Array<string>, blendMode: number): void;
  14742. /**
  14743. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14744. * @param uniforms Uniforms array to fill
  14745. * @param attributes Attributes array to fill
  14746. * @param samplers Samplers array to fill
  14747. */
  14748. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14749. /**
  14750. * Observable that will be called just before the particles are drawn
  14751. */
  14752. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14753. /**
  14754. * Gets the name of the particle vertex shader
  14755. */
  14756. vertexShaderName: string;
  14757. /**
  14758. * Adds a new color gradient
  14759. * @param gradient defines the gradient to use (between 0 and 1)
  14760. * @param color1 defines the color to affect to the specified gradient
  14761. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14762. * @returns the current particle system
  14763. */
  14764. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14765. /**
  14766. * Remove a specific color gradient
  14767. * @param gradient defines the gradient to remove
  14768. * @returns the current particle system
  14769. */
  14770. removeColorGradient(gradient: number): IParticleSystem;
  14771. /**
  14772. * Adds a new size gradient
  14773. * @param gradient defines the gradient to use (between 0 and 1)
  14774. * @param factor defines the size factor to affect to the specified gradient
  14775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14776. * @returns the current particle system
  14777. */
  14778. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14779. /**
  14780. * Remove a specific size gradient
  14781. * @param gradient defines the gradient to remove
  14782. * @returns the current particle system
  14783. */
  14784. removeSizeGradient(gradient: number): IParticleSystem;
  14785. /**
  14786. * Gets the current list of color gradients.
  14787. * You must use addColorGradient and removeColorGradient to udpate this list
  14788. * @returns the list of color gradients
  14789. */
  14790. getColorGradients(): Nullable<Array<ColorGradient>>;
  14791. /**
  14792. * Gets the current list of size gradients.
  14793. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14794. * @returns the list of size gradients
  14795. */
  14796. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14797. /**
  14798. * Gets the current list of angular speed gradients.
  14799. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14800. * @returns the list of angular speed gradients
  14801. */
  14802. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14803. /**
  14804. * Adds a new angular speed gradient
  14805. * @param gradient defines the gradient to use (between 0 and 1)
  14806. * @param factor defines the angular speed to affect to the specified gradient
  14807. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14808. * @returns the current particle system
  14809. */
  14810. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14811. /**
  14812. * Remove a specific angular speed gradient
  14813. * @param gradient defines the gradient to remove
  14814. * @returns the current particle system
  14815. */
  14816. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14817. /**
  14818. * Gets the current list of velocity gradients.
  14819. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14820. * @returns the list of velocity gradients
  14821. */
  14822. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14823. /**
  14824. * Adds a new velocity gradient
  14825. * @param gradient defines the gradient to use (between 0 and 1)
  14826. * @param factor defines the velocity to affect to the specified gradient
  14827. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14828. * @returns the current particle system
  14829. */
  14830. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14831. /**
  14832. * Remove a specific velocity gradient
  14833. * @param gradient defines the gradient to remove
  14834. * @returns the current particle system
  14835. */
  14836. removeVelocityGradient(gradient: number): IParticleSystem;
  14837. /**
  14838. * Gets the current list of limit velocity gradients.
  14839. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14840. * @returns the list of limit velocity gradients
  14841. */
  14842. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14843. /**
  14844. * Adds a new limit velocity gradient
  14845. * @param gradient defines the gradient to use (between 0 and 1)
  14846. * @param factor defines the limit velocity to affect to the specified gradient
  14847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14848. * @returns the current particle system
  14849. */
  14850. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14851. /**
  14852. * Remove a specific limit velocity gradient
  14853. * @param gradient defines the gradient to remove
  14854. * @returns the current particle system
  14855. */
  14856. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14857. /**
  14858. * Adds a new drag gradient
  14859. * @param gradient defines the gradient to use (between 0 and 1)
  14860. * @param factor defines the drag to affect to the specified gradient
  14861. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14862. * @returns the current particle system
  14863. */
  14864. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14865. /**
  14866. * Remove a specific drag gradient
  14867. * @param gradient defines the gradient to remove
  14868. * @returns the current particle system
  14869. */
  14870. removeDragGradient(gradient: number): IParticleSystem;
  14871. /**
  14872. * Gets the current list of drag gradients.
  14873. * You must use addDragGradient and removeDragGradient to udpate this list
  14874. * @returns the list of drag gradients
  14875. */
  14876. getDragGradients(): Nullable<Array<FactorGradient>>;
  14877. /**
  14878. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14879. * @param gradient defines the gradient to use (between 0 and 1)
  14880. * @param factor defines the emit rate to affect to the specified gradient
  14881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14882. * @returns the current particle system
  14883. */
  14884. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14885. /**
  14886. * Remove a specific emit rate gradient
  14887. * @param gradient defines the gradient to remove
  14888. * @returns the current particle system
  14889. */
  14890. removeEmitRateGradient(gradient: number): IParticleSystem;
  14891. /**
  14892. * Gets the current list of emit rate gradients.
  14893. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14894. * @returns the list of emit rate gradients
  14895. */
  14896. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14897. /**
  14898. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14899. * @param gradient defines the gradient to use (between 0 and 1)
  14900. * @param factor defines the start size to affect to the specified gradient
  14901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14902. * @returns the current particle system
  14903. */
  14904. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14905. /**
  14906. * Remove a specific start size gradient
  14907. * @param gradient defines the gradient to remove
  14908. * @returns the current particle system
  14909. */
  14910. removeStartSizeGradient(gradient: number): IParticleSystem;
  14911. /**
  14912. * Gets the current list of start size gradients.
  14913. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14914. * @returns the list of start size gradients
  14915. */
  14916. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14917. /**
  14918. * Adds a new life time gradient
  14919. * @param gradient defines the gradient to use (between 0 and 1)
  14920. * @param factor defines the life time factor to affect to the specified gradient
  14921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14922. * @returns the current particle system
  14923. */
  14924. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14925. /**
  14926. * Remove a specific life time gradient
  14927. * @param gradient defines the gradient to remove
  14928. * @returns the current particle system
  14929. */
  14930. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14931. /**
  14932. * Gets the current list of life time gradients.
  14933. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14934. * @returns the list of life time gradients
  14935. */
  14936. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14937. /**
  14938. * Gets the current list of color gradients.
  14939. * You must use addColorGradient and removeColorGradient to udpate this list
  14940. * @returns the list of color gradients
  14941. */
  14942. getColorGradients(): Nullable<Array<ColorGradient>>;
  14943. /**
  14944. * Adds a new ramp gradient used to remap particle colors
  14945. * @param gradient defines the gradient to use (between 0 and 1)
  14946. * @param color defines the color to affect to the specified gradient
  14947. * @returns the current particle system
  14948. */
  14949. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14950. /**
  14951. * Gets the current list of ramp gradients.
  14952. * You must use addRampGradient and removeRampGradient to udpate this list
  14953. * @returns the list of ramp gradients
  14954. */
  14955. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14956. /** Gets or sets a boolean indicating that ramp gradients must be used
  14957. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14958. */
  14959. useRampGradients: boolean;
  14960. /**
  14961. * Adds a new color remap gradient
  14962. * @param gradient defines the gradient to use (between 0 and 1)
  14963. * @param min defines the color remap minimal range
  14964. * @param max defines the color remap maximal range
  14965. * @returns the current particle system
  14966. */
  14967. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14968. /**
  14969. * Gets the current list of color remap gradients.
  14970. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14971. * @returns the list of color remap gradients
  14972. */
  14973. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14974. /**
  14975. * Adds a new alpha remap gradient
  14976. * @param gradient defines the gradient to use (between 0 and 1)
  14977. * @param min defines the alpha remap minimal range
  14978. * @param max defines the alpha remap maximal range
  14979. * @returns the current particle system
  14980. */
  14981. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14982. /**
  14983. * Gets the current list of alpha remap gradients.
  14984. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14985. * @returns the list of alpha remap gradients
  14986. */
  14987. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14988. /**
  14989. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14990. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14991. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14992. * @returns the emitter
  14993. */
  14994. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14995. /**
  14996. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14997. * @param radius The radius of the hemisphere to emit from
  14998. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14999. * @returns the emitter
  15000. */
  15001. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15002. /**
  15003. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15004. * @param radius The radius of the sphere to emit from
  15005. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15006. * @returns the emitter
  15007. */
  15008. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15009. /**
  15010. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15011. * @param radius The radius of the sphere to emit from
  15012. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15013. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15014. * @returns the emitter
  15015. */
  15016. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15017. /**
  15018. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15019. * @param radius The radius of the emission cylinder
  15020. * @param height The height of the emission cylinder
  15021. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15022. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15023. * @returns the emitter
  15024. */
  15025. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15026. /**
  15027. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15028. * @param radius The radius of the cylinder to emit from
  15029. * @param height The height of the emission cylinder
  15030. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15031. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15032. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15033. * @returns the emitter
  15034. */
  15035. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15036. /**
  15037. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15038. * @param radius The radius of the cone to emit from
  15039. * @param angle The base angle of the cone
  15040. * @returns the emitter
  15041. */
  15042. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15043. /**
  15044. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15045. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15046. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15047. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15048. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15049. * @returns the emitter
  15050. */
  15051. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15052. /**
  15053. * Get hosting scene
  15054. * @returns the scene
  15055. */
  15056. getScene(): Nullable<Scene>;
  15057. }
  15058. }
  15059. declare module "babylonjs/Meshes/transformNode" {
  15060. import { DeepImmutable } from "babylonjs/types";
  15061. import { Observable } from "babylonjs/Misc/observable";
  15062. import { Nullable } from "babylonjs/types";
  15063. import { Camera } from "babylonjs/Cameras/camera";
  15064. import { Scene } from "babylonjs/scene";
  15065. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15066. import { Node } from "babylonjs/node";
  15067. import { Bone } from "babylonjs/Bones/bone";
  15068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15069. import { Space } from "babylonjs/Maths/math.axis";
  15070. /**
  15071. * 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.
  15072. * @see https://doc.babylonjs.com/how_to/transformnode
  15073. */
  15074. export class TransformNode extends Node {
  15075. /**
  15076. * Object will not rotate to face the camera
  15077. */
  15078. static BILLBOARDMODE_NONE: number;
  15079. /**
  15080. * Object will rotate to face the camera but only on the x axis
  15081. */
  15082. static BILLBOARDMODE_X: number;
  15083. /**
  15084. * Object will rotate to face the camera but only on the y axis
  15085. */
  15086. static BILLBOARDMODE_Y: number;
  15087. /**
  15088. * Object will rotate to face the camera but only on the z axis
  15089. */
  15090. static BILLBOARDMODE_Z: number;
  15091. /**
  15092. * Object will rotate to face the camera
  15093. */
  15094. static BILLBOARDMODE_ALL: number;
  15095. /**
  15096. * Object will rotate to face the camera's position instead of orientation
  15097. */
  15098. static BILLBOARDMODE_USE_POSITION: number;
  15099. private static _TmpRotation;
  15100. private static _TmpScaling;
  15101. private static _TmpTranslation;
  15102. private _forward;
  15103. private _forwardInverted;
  15104. private _up;
  15105. private _right;
  15106. private _rightInverted;
  15107. private _position;
  15108. private _rotation;
  15109. private _rotationQuaternion;
  15110. protected _scaling: Vector3;
  15111. protected _isDirty: boolean;
  15112. private _transformToBoneReferal;
  15113. private _isAbsoluteSynced;
  15114. private _billboardMode;
  15115. /**
  15116. * Gets or sets the billboard mode. Default is 0.
  15117. *
  15118. * | Value | Type | Description |
  15119. * | --- | --- | --- |
  15120. * | 0 | BILLBOARDMODE_NONE | |
  15121. * | 1 | BILLBOARDMODE_X | |
  15122. * | 2 | BILLBOARDMODE_Y | |
  15123. * | 4 | BILLBOARDMODE_Z | |
  15124. * | 7 | BILLBOARDMODE_ALL | |
  15125. *
  15126. */
  15127. get billboardMode(): number;
  15128. set billboardMode(value: number);
  15129. private _preserveParentRotationForBillboard;
  15130. /**
  15131. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15132. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15133. */
  15134. get preserveParentRotationForBillboard(): boolean;
  15135. set preserveParentRotationForBillboard(value: boolean);
  15136. /**
  15137. * 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
  15138. */
  15139. scalingDeterminant: number;
  15140. private _infiniteDistance;
  15141. /**
  15142. * Gets or sets the distance of the object to max, often used by skybox
  15143. */
  15144. get infiniteDistance(): boolean;
  15145. set infiniteDistance(value: boolean);
  15146. /**
  15147. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15148. * By default the system will update normals to compensate
  15149. */
  15150. ignoreNonUniformScaling: boolean;
  15151. /**
  15152. * 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
  15153. */
  15154. reIntegrateRotationIntoRotationQuaternion: boolean;
  15155. /** @hidden */
  15156. _poseMatrix: Nullable<Matrix>;
  15157. /** @hidden */
  15158. _localMatrix: Matrix;
  15159. private _usePivotMatrix;
  15160. private _absolutePosition;
  15161. private _absoluteScaling;
  15162. private _absoluteRotationQuaternion;
  15163. private _pivotMatrix;
  15164. private _pivotMatrixInverse;
  15165. /** @hidden */
  15166. _postMultiplyPivotMatrix: boolean;
  15167. protected _isWorldMatrixFrozen: boolean;
  15168. /** @hidden */
  15169. _indexInSceneTransformNodesArray: number;
  15170. /**
  15171. * An event triggered after the world matrix is updated
  15172. */
  15173. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15174. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15175. /**
  15176. * Gets a string identifying the name of the class
  15177. * @returns "TransformNode" string
  15178. */
  15179. getClassName(): string;
  15180. /**
  15181. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15182. */
  15183. get position(): Vector3;
  15184. set position(newPosition: Vector3);
  15185. /**
  15186. * 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)).
  15187. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15188. */
  15189. get rotation(): Vector3;
  15190. set rotation(newRotation: Vector3);
  15191. /**
  15192. * 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)).
  15193. */
  15194. get scaling(): Vector3;
  15195. set scaling(newScaling: Vector3);
  15196. /**
  15197. * 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).
  15198. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15199. */
  15200. get rotationQuaternion(): Nullable<Quaternion>;
  15201. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15202. /**
  15203. * The forward direction of that transform in world space.
  15204. */
  15205. get forward(): Vector3;
  15206. /**
  15207. * The up direction of that transform in world space.
  15208. */
  15209. get up(): Vector3;
  15210. /**
  15211. * The right direction of that transform in world space.
  15212. */
  15213. get right(): Vector3;
  15214. /**
  15215. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15216. * @param matrix the matrix to copy the pose from
  15217. * @returns this TransformNode.
  15218. */
  15219. updatePoseMatrix(matrix: Matrix): TransformNode;
  15220. /**
  15221. * Returns the mesh Pose matrix.
  15222. * @returns the pose matrix
  15223. */
  15224. getPoseMatrix(): Matrix;
  15225. /** @hidden */
  15226. _isSynchronized(): boolean;
  15227. /** @hidden */
  15228. _initCache(): void;
  15229. /**
  15230. * Flag the transform node as dirty (Forcing it to update everything)
  15231. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15232. * @returns this transform node
  15233. */
  15234. markAsDirty(property: string): TransformNode;
  15235. /**
  15236. * Returns the current mesh absolute position.
  15237. * Returns a Vector3.
  15238. */
  15239. get absolutePosition(): Vector3;
  15240. /**
  15241. * Returns the current mesh absolute scaling.
  15242. * Returns a Vector3.
  15243. */
  15244. get absoluteScaling(): Vector3;
  15245. /**
  15246. * Returns the current mesh absolute rotation.
  15247. * Returns a Quaternion.
  15248. */
  15249. get absoluteRotationQuaternion(): Quaternion;
  15250. /**
  15251. * Sets a new matrix to apply before all other transformation
  15252. * @param matrix defines the transform matrix
  15253. * @returns the current TransformNode
  15254. */
  15255. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15256. /**
  15257. * Sets a new pivot matrix to the current node
  15258. * @param matrix defines the new pivot matrix to use
  15259. * @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
  15260. * @returns the current TransformNode
  15261. */
  15262. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15263. /**
  15264. * Returns the mesh pivot matrix.
  15265. * Default : Identity.
  15266. * @returns the matrix
  15267. */
  15268. getPivotMatrix(): Matrix;
  15269. /**
  15270. * Instantiate (when possible) or clone that node with its hierarchy
  15271. * @param newParent defines the new parent to use for the instance (or clone)
  15272. * @param options defines options to configure how copy is done
  15273. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15274. * @returns an instance (or a clone) of the current node with its hiearchy
  15275. */
  15276. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15277. doNotInstantiate: boolean;
  15278. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15279. /**
  15280. * Prevents the World matrix to be computed any longer
  15281. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15282. * @returns the TransformNode.
  15283. */
  15284. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15285. /**
  15286. * Allows back the World matrix computation.
  15287. * @returns the TransformNode.
  15288. */
  15289. unfreezeWorldMatrix(): this;
  15290. /**
  15291. * True if the World matrix has been frozen.
  15292. */
  15293. get isWorldMatrixFrozen(): boolean;
  15294. /**
  15295. * Retuns the mesh absolute position in the World.
  15296. * @returns a Vector3.
  15297. */
  15298. getAbsolutePosition(): Vector3;
  15299. /**
  15300. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15301. * @param absolutePosition the absolute position to set
  15302. * @returns the TransformNode.
  15303. */
  15304. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15305. /**
  15306. * Sets the mesh position in its local space.
  15307. * @param vector3 the position to set in localspace
  15308. * @returns the TransformNode.
  15309. */
  15310. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15311. /**
  15312. * Returns the mesh position in the local space from the current World matrix values.
  15313. * @returns a new Vector3.
  15314. */
  15315. getPositionExpressedInLocalSpace(): Vector3;
  15316. /**
  15317. * Translates the mesh along the passed Vector3 in its local space.
  15318. * @param vector3 the distance to translate in localspace
  15319. * @returns the TransformNode.
  15320. */
  15321. locallyTranslate(vector3: Vector3): TransformNode;
  15322. private static _lookAtVectorCache;
  15323. /**
  15324. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15325. * @param targetPoint the position (must be in same space as current mesh) to look at
  15326. * @param yawCor optional yaw (y-axis) correction in radians
  15327. * @param pitchCor optional pitch (x-axis) correction in radians
  15328. * @param rollCor optional roll (z-axis) correction in radians
  15329. * @param space the choosen space of the target
  15330. * @returns the TransformNode.
  15331. */
  15332. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15333. /**
  15334. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15335. * This Vector3 is expressed in the World space.
  15336. * @param localAxis axis to rotate
  15337. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15338. */
  15339. getDirection(localAxis: Vector3): Vector3;
  15340. /**
  15341. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15342. * localAxis is expressed in the mesh local space.
  15343. * result is computed in the Wordl space from the mesh World matrix.
  15344. * @param localAxis axis to rotate
  15345. * @param result the resulting transformnode
  15346. * @returns this TransformNode.
  15347. */
  15348. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15349. /**
  15350. * Sets this transform node rotation to the given local axis.
  15351. * @param localAxis the axis in local space
  15352. * @param yawCor optional yaw (y-axis) correction in radians
  15353. * @param pitchCor optional pitch (x-axis) correction in radians
  15354. * @param rollCor optional roll (z-axis) correction in radians
  15355. * @returns this TransformNode
  15356. */
  15357. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15358. /**
  15359. * Sets a new pivot point to the current node
  15360. * @param point defines the new pivot point to use
  15361. * @param space defines if the point is in world or local space (local by default)
  15362. * @returns the current TransformNode
  15363. */
  15364. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15365. /**
  15366. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15367. * @returns the pivot point
  15368. */
  15369. getPivotPoint(): Vector3;
  15370. /**
  15371. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15372. * @param result the vector3 to store the result
  15373. * @returns this TransformNode.
  15374. */
  15375. getPivotPointToRef(result: Vector3): TransformNode;
  15376. /**
  15377. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15378. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15379. */
  15380. getAbsolutePivotPoint(): Vector3;
  15381. /**
  15382. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15383. * @param result vector3 to store the result
  15384. * @returns this TransformNode.
  15385. */
  15386. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15387. /**
  15388. * Defines the passed node as the parent of the current node.
  15389. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15390. * @see https://doc.babylonjs.com/how_to/parenting
  15391. * @param node the node ot set as the parent
  15392. * @returns this TransformNode.
  15393. */
  15394. setParent(node: Nullable<Node>): TransformNode;
  15395. private _nonUniformScaling;
  15396. /**
  15397. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15398. */
  15399. get nonUniformScaling(): boolean;
  15400. /** @hidden */
  15401. _updateNonUniformScalingState(value: boolean): boolean;
  15402. /**
  15403. * Attach the current TransformNode to another TransformNode associated with a bone
  15404. * @param bone Bone affecting the TransformNode
  15405. * @param affectedTransformNode TransformNode associated with the bone
  15406. * @returns this object
  15407. */
  15408. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15409. /**
  15410. * Detach the transform node if its associated with a bone
  15411. * @returns this object
  15412. */
  15413. detachFromBone(): TransformNode;
  15414. private static _rotationAxisCache;
  15415. /**
  15416. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15417. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  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. * @param axis the axis to rotate around
  15421. * @param amount the amount to rotate in radians
  15422. * @param space Space to rotate in (Default: local)
  15423. * @returns the TransformNode.
  15424. */
  15425. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15426. /**
  15427. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15428. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15429. * The passed axis is also normalized. .
  15430. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15431. * @param point the point to rotate around
  15432. * @param axis the axis to rotate around
  15433. * @param amount the amount to rotate in radians
  15434. * @returns the TransformNode
  15435. */
  15436. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15437. /**
  15438. * Translates the mesh along the axis vector for the passed distance in the given space.
  15439. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15440. * @param axis the axis to translate in
  15441. * @param distance the distance to translate
  15442. * @param space Space to rotate in (Default: local)
  15443. * @returns the TransformNode.
  15444. */
  15445. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15446. /**
  15447. * Adds a rotation step to the mesh current rotation.
  15448. * x, y, z are Euler angles expressed in radians.
  15449. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15450. * This means this rotation is made in the mesh local space only.
  15451. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15452. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15453. * ```javascript
  15454. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15455. * ```
  15456. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15457. * 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.
  15458. * @param x Rotation to add
  15459. * @param y Rotation to add
  15460. * @param z Rotation to add
  15461. * @returns the TransformNode.
  15462. */
  15463. addRotation(x: number, y: number, z: number): TransformNode;
  15464. /**
  15465. * @hidden
  15466. */
  15467. protected _getEffectiveParent(): Nullable<Node>;
  15468. /**
  15469. * Computes the world matrix of the node
  15470. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15471. * @returns the world matrix
  15472. */
  15473. computeWorldMatrix(force?: boolean): Matrix;
  15474. /**
  15475. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15476. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15477. */
  15478. resetLocalMatrix(independentOfChildren?: boolean): void;
  15479. protected _afterComputeWorldMatrix(): void;
  15480. /**
  15481. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15482. * @param func callback function to add
  15483. *
  15484. * @returns the TransformNode.
  15485. */
  15486. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15487. /**
  15488. * Removes a registered callback function.
  15489. * @param func callback function to remove
  15490. * @returns the TransformNode.
  15491. */
  15492. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15493. /**
  15494. * Gets the position of the current mesh in camera space
  15495. * @param camera defines the camera to use
  15496. * @returns a position
  15497. */
  15498. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15499. /**
  15500. * Returns the distance from the mesh to the active camera
  15501. * @param camera defines the camera to use
  15502. * @returns the distance
  15503. */
  15504. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15505. /**
  15506. * Clone the current transform node
  15507. * @param name Name of the new clone
  15508. * @param newParent New parent for the clone
  15509. * @param doNotCloneChildren Do not clone children hierarchy
  15510. * @returns the new transform node
  15511. */
  15512. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15513. /**
  15514. * Serializes the objects information.
  15515. * @param currentSerializationObject defines the object to serialize in
  15516. * @returns the serialized object
  15517. */
  15518. serialize(currentSerializationObject?: any): any;
  15519. /**
  15520. * Returns a new TransformNode object parsed from the source provided.
  15521. * @param parsedTransformNode is the source.
  15522. * @param scene the scne the object belongs to
  15523. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15524. * @returns a new TransformNode object parsed from the source provided.
  15525. */
  15526. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15527. /**
  15528. * Get all child-transformNodes of this node
  15529. * @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
  15530. * @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
  15531. * @returns an array of TransformNode
  15532. */
  15533. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15534. /**
  15535. * Releases resources associated with this transform node.
  15536. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15537. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15538. */
  15539. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15540. /**
  15541. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15542. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15543. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15544. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15545. * @returns the current mesh
  15546. */
  15547. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15548. private _syncAbsoluteScalingAndRotation;
  15549. }
  15550. }
  15551. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15552. /**
  15553. * Class used to override all child animations of a given target
  15554. */
  15555. export class AnimationPropertiesOverride {
  15556. /**
  15557. * Gets or sets a value indicating if animation blending must be used
  15558. */
  15559. enableBlending: boolean;
  15560. /**
  15561. * Gets or sets the blending speed to use when enableBlending is true
  15562. */
  15563. blendingSpeed: number;
  15564. /**
  15565. * Gets or sets the default loop mode to use
  15566. */
  15567. loopMode: number;
  15568. }
  15569. }
  15570. declare module "babylonjs/Bones/bone" {
  15571. import { Skeleton } from "babylonjs/Bones/skeleton";
  15572. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15573. import { Nullable } from "babylonjs/types";
  15574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15575. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15576. import { Node } from "babylonjs/node";
  15577. import { Space } from "babylonjs/Maths/math.axis";
  15578. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15579. /**
  15580. * Class used to store bone information
  15581. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15582. */
  15583. export class Bone extends Node {
  15584. /**
  15585. * defines the bone name
  15586. */
  15587. name: string;
  15588. private static _tmpVecs;
  15589. private static _tmpQuat;
  15590. private static _tmpMats;
  15591. /**
  15592. * Gets the list of child bones
  15593. */
  15594. children: Bone[];
  15595. /** Gets the animations associated with this bone */
  15596. animations: import("babylonjs/Animations/animation").Animation[];
  15597. /**
  15598. * Gets or sets bone length
  15599. */
  15600. length: number;
  15601. /**
  15602. * @hidden Internal only
  15603. * Set this value to map this bone to a different index in the transform matrices
  15604. * Set this value to -1 to exclude the bone from the transform matrices
  15605. */
  15606. _index: Nullable<number>;
  15607. private _skeleton;
  15608. private _localMatrix;
  15609. private _restPose;
  15610. private _bindPose;
  15611. private _baseMatrix;
  15612. private _absoluteTransform;
  15613. private _invertedAbsoluteTransform;
  15614. private _parent;
  15615. private _scalingDeterminant;
  15616. private _worldTransform;
  15617. private _localScaling;
  15618. private _localRotation;
  15619. private _localPosition;
  15620. private _needToDecompose;
  15621. private _needToCompose;
  15622. /** @hidden */
  15623. _linkedTransformNode: Nullable<TransformNode>;
  15624. /** @hidden */
  15625. _waitingTransformNodeId: Nullable<string>;
  15626. /** @hidden */
  15627. get _matrix(): Matrix;
  15628. /** @hidden */
  15629. set _matrix(value: Matrix);
  15630. /**
  15631. * Create a new bone
  15632. * @param name defines the bone name
  15633. * @param skeleton defines the parent skeleton
  15634. * @param parentBone defines the parent (can be null if the bone is the root)
  15635. * @param localMatrix defines the local matrix
  15636. * @param restPose defines the rest pose matrix
  15637. * @param baseMatrix defines the base matrix
  15638. * @param index defines index of the bone in the hiearchy
  15639. */
  15640. constructor(
  15641. /**
  15642. * defines the bone name
  15643. */
  15644. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15645. /**
  15646. * Gets the current object class name.
  15647. * @return the class name
  15648. */
  15649. getClassName(): string;
  15650. /**
  15651. * Gets the parent skeleton
  15652. * @returns a skeleton
  15653. */
  15654. getSkeleton(): Skeleton;
  15655. /**
  15656. * Gets parent bone
  15657. * @returns a bone or null if the bone is the root of the bone hierarchy
  15658. */
  15659. getParent(): Nullable<Bone>;
  15660. /**
  15661. * Returns an array containing the root bones
  15662. * @returns an array containing the root bones
  15663. */
  15664. getChildren(): Array<Bone>;
  15665. /**
  15666. * Gets the node index in matrix array generated for rendering
  15667. * @returns the node index
  15668. */
  15669. getIndex(): number;
  15670. /**
  15671. * Sets the parent bone
  15672. * @param parent defines the parent (can be null if the bone is the root)
  15673. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15674. */
  15675. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15676. /**
  15677. * Gets the local matrix
  15678. * @returns a matrix
  15679. */
  15680. getLocalMatrix(): Matrix;
  15681. /**
  15682. * Gets the base matrix (initial matrix which remains unchanged)
  15683. * @returns a matrix
  15684. */
  15685. getBaseMatrix(): Matrix;
  15686. /**
  15687. * Gets the rest pose matrix
  15688. * @returns a matrix
  15689. */
  15690. getRestPose(): Matrix;
  15691. /**
  15692. * Sets the rest pose matrix
  15693. * @param matrix the local-space rest pose to set for this bone
  15694. */
  15695. setRestPose(matrix: Matrix): void;
  15696. /**
  15697. * Gets the bind pose matrix
  15698. * @returns the bind pose matrix
  15699. */
  15700. getBindPose(): Matrix;
  15701. /**
  15702. * Sets the bind pose matrix
  15703. * @param matrix the local-space bind pose to set for this bone
  15704. */
  15705. setBindPose(matrix: Matrix): void;
  15706. /**
  15707. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15708. */
  15709. getWorldMatrix(): Matrix;
  15710. /**
  15711. * Sets the local matrix to rest pose matrix
  15712. */
  15713. returnToRest(): void;
  15714. /**
  15715. * Gets the inverse of the absolute transform matrix.
  15716. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15717. * @returns a matrix
  15718. */
  15719. getInvertedAbsoluteTransform(): Matrix;
  15720. /**
  15721. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15722. * @returns a matrix
  15723. */
  15724. getAbsoluteTransform(): Matrix;
  15725. /**
  15726. * Links with the given transform node.
  15727. * The local matrix of this bone is copied from the transform node every frame.
  15728. * @param transformNode defines the transform node to link to
  15729. */
  15730. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15731. /**
  15732. * Gets the node used to drive the bone's transformation
  15733. * @returns a transform node or null
  15734. */
  15735. getTransformNode(): Nullable<TransformNode>;
  15736. /** Gets or sets current position (in local space) */
  15737. get position(): Vector3;
  15738. set position(newPosition: Vector3);
  15739. /** Gets or sets current rotation (in local space) */
  15740. get rotation(): Vector3;
  15741. set rotation(newRotation: Vector3);
  15742. /** Gets or sets current rotation quaternion (in local space) */
  15743. get rotationQuaternion(): Quaternion;
  15744. set rotationQuaternion(newRotation: Quaternion);
  15745. /** Gets or sets current scaling (in local space) */
  15746. get scaling(): Vector3;
  15747. set scaling(newScaling: Vector3);
  15748. /**
  15749. * Gets the animation properties override
  15750. */
  15751. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15752. private _decompose;
  15753. private _compose;
  15754. /**
  15755. * Update the base and local matrices
  15756. * @param matrix defines the new base or local matrix
  15757. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15758. * @param updateLocalMatrix defines if the local matrix should be updated
  15759. */
  15760. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15761. /** @hidden */
  15762. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15763. /**
  15764. * Flag the bone as dirty (Forcing it to update everything)
  15765. */
  15766. markAsDirty(): void;
  15767. /** @hidden */
  15768. _markAsDirtyAndCompose(): void;
  15769. private _markAsDirtyAndDecompose;
  15770. /**
  15771. * Translate the bone in local or world space
  15772. * @param vec The amount to translate the bone
  15773. * @param space The space that the translation is in
  15774. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15775. */
  15776. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15777. /**
  15778. * Set the postion of the bone in local or world space
  15779. * @param position The position to set the bone
  15780. * @param space The space that the position is in
  15781. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15782. */
  15783. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15784. /**
  15785. * Set the absolute position of the bone (world space)
  15786. * @param position The position to set the bone
  15787. * @param mesh The mesh that this bone is attached to
  15788. */
  15789. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15790. /**
  15791. * Scale the bone on the x, y and z axes (in local space)
  15792. * @param x The amount to scale the bone on the x axis
  15793. * @param y The amount to scale the bone on the y axis
  15794. * @param z The amount to scale the bone on the z axis
  15795. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15796. */
  15797. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15798. /**
  15799. * Set the bone scaling in local space
  15800. * @param scale defines the scaling vector
  15801. */
  15802. setScale(scale: Vector3): void;
  15803. /**
  15804. * Gets the current scaling in local space
  15805. * @returns the current scaling vector
  15806. */
  15807. getScale(): Vector3;
  15808. /**
  15809. * Gets the current scaling in local space and stores it in a target vector
  15810. * @param result defines the target vector
  15811. */
  15812. getScaleToRef(result: Vector3): void;
  15813. /**
  15814. * Set the yaw, pitch, and roll of the bone in local or world space
  15815. * @param yaw The rotation of the bone on the y axis
  15816. * @param pitch The rotation of the bone on the x axis
  15817. * @param roll The rotation of the bone on the z axis
  15818. * @param space The space that the axes of rotation are in
  15819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15820. */
  15821. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15822. /**
  15823. * Add a rotation to the bone on an axis in local or world space
  15824. * @param axis The axis to rotate the bone on
  15825. * @param amount The amount to rotate the bone
  15826. * @param space The space that the axis is in
  15827. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15828. */
  15829. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15830. /**
  15831. * Set the rotation of the bone to a particular axis angle in local or world space
  15832. * @param axis The axis to rotate the bone on
  15833. * @param angle The angle that the bone should be rotated to
  15834. * @param space The space that the axis is in
  15835. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15836. */
  15837. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15838. /**
  15839. * Set the euler rotation of the bone in local or world space
  15840. * @param rotation The euler rotation that the bone should be set to
  15841. * @param space The space that the rotation is in
  15842. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15843. */
  15844. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15845. /**
  15846. * Set the quaternion rotation of the bone in local or world space
  15847. * @param quat The quaternion rotation that the bone should be set to
  15848. * @param space The space that the rotation is in
  15849. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15850. */
  15851. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15852. /**
  15853. * Set the rotation matrix of the bone in local or world space
  15854. * @param rotMat The rotation matrix that the bone should be set to
  15855. * @param space The space that the rotation is in
  15856. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15857. */
  15858. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15859. private _rotateWithMatrix;
  15860. private _getNegativeRotationToRef;
  15861. /**
  15862. * Get the position of the bone in local or world space
  15863. * @param space The space that the returned position is in
  15864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15865. * @returns The position of the bone
  15866. */
  15867. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15868. /**
  15869. * Copy the position of the bone to a vector3 in local or world space
  15870. * @param space The space that the returned position is in
  15871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15872. * @param result The vector3 to copy the position to
  15873. */
  15874. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15875. /**
  15876. * Get the absolute position of the bone (world space)
  15877. * @param mesh The mesh that this bone is attached to
  15878. * @returns The absolute position of the bone
  15879. */
  15880. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15881. /**
  15882. * Copy the absolute position of the bone (world space) to the result param
  15883. * @param mesh The mesh that this bone is attached to
  15884. * @param result The vector3 to copy the absolute position to
  15885. */
  15886. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15887. /**
  15888. * Compute the absolute transforms of this bone and its children
  15889. */
  15890. computeAbsoluteTransforms(): void;
  15891. /**
  15892. * Get the world direction from an axis that is in the local space of the bone
  15893. * @param localAxis The local direction that is used to compute the world direction
  15894. * @param mesh The mesh that this bone is attached to
  15895. * @returns The world direction
  15896. */
  15897. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15898. /**
  15899. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15900. * @param localAxis The local direction that is used to compute the world direction
  15901. * @param mesh The mesh that this bone is attached to
  15902. * @param result The vector3 that the world direction will be copied to
  15903. */
  15904. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15905. /**
  15906. * Get the euler rotation of the bone in local or world space
  15907. * @param space The space that the rotation should be in
  15908. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15909. * @returns The euler rotation
  15910. */
  15911. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15912. /**
  15913. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15914. * @param space The space that the rotation should be in
  15915. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15916. * @param result The vector3 that the rotation should be copied to
  15917. */
  15918. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15919. /**
  15920. * Get the quaternion rotation of the bone in either local or world space
  15921. * @param space The space that the rotation should be in
  15922. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15923. * @returns The quaternion rotation
  15924. */
  15925. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15926. /**
  15927. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15928. * @param space The space that the rotation should be in
  15929. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15930. * @param result The quaternion that the rotation should be copied to
  15931. */
  15932. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15933. /**
  15934. * Get the rotation matrix of the bone in local or world space
  15935. * @param space The space that the rotation should be in
  15936. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15937. * @returns The rotation matrix
  15938. */
  15939. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15940. /**
  15941. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15942. * @param space The space that the rotation should be in
  15943. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15944. * @param result The quaternion that the rotation should be copied to
  15945. */
  15946. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15947. /**
  15948. * Get the world position of a point that is in the local space of the bone
  15949. * @param position The local position
  15950. * @param mesh The mesh that this bone is attached to
  15951. * @returns The world position
  15952. */
  15953. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15954. /**
  15955. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15956. * @param position The local position
  15957. * @param mesh The mesh that this bone is attached to
  15958. * @param result The vector3 that the world position should be copied to
  15959. */
  15960. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15961. /**
  15962. * Get the local position of a point that is in world space
  15963. * @param position The world position
  15964. * @param mesh The mesh that this bone is attached to
  15965. * @returns The local position
  15966. */
  15967. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15968. /**
  15969. * Get the local position of a point that is in world space and copy it to the result param
  15970. * @param position The world position
  15971. * @param mesh The mesh that this bone is attached to
  15972. * @param result The vector3 that the local position should be copied to
  15973. */
  15974. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15975. /**
  15976. * Set the current local matrix as the restPose for this bone.
  15977. */
  15978. setCurrentPoseAsRest(): void;
  15979. }
  15980. }
  15981. declare module "babylonjs/Animations/runtimeAnimation" {
  15982. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15983. import { Animatable } from "babylonjs/Animations/animatable";
  15984. import { Scene } from "babylonjs/scene";
  15985. /**
  15986. * Defines a runtime animation
  15987. */
  15988. export class RuntimeAnimation {
  15989. private _events;
  15990. /**
  15991. * The current frame of the runtime animation
  15992. */
  15993. private _currentFrame;
  15994. /**
  15995. * The animation used by the runtime animation
  15996. */
  15997. private _animation;
  15998. /**
  15999. * The target of the runtime animation
  16000. */
  16001. private _target;
  16002. /**
  16003. * The initiating animatable
  16004. */
  16005. private _host;
  16006. /**
  16007. * The original value of the runtime animation
  16008. */
  16009. private _originalValue;
  16010. /**
  16011. * The original blend value of the runtime animation
  16012. */
  16013. private _originalBlendValue;
  16014. /**
  16015. * The offsets cache of the runtime animation
  16016. */
  16017. private _offsetsCache;
  16018. /**
  16019. * The high limits cache of the runtime animation
  16020. */
  16021. private _highLimitsCache;
  16022. /**
  16023. * Specifies if the runtime animation has been stopped
  16024. */
  16025. private _stopped;
  16026. /**
  16027. * The blending factor of the runtime animation
  16028. */
  16029. private _blendingFactor;
  16030. /**
  16031. * The BabylonJS scene
  16032. */
  16033. private _scene;
  16034. /**
  16035. * The current value of the runtime animation
  16036. */
  16037. private _currentValue;
  16038. /** @hidden */
  16039. _animationState: _IAnimationState;
  16040. /**
  16041. * The active target of the runtime animation
  16042. */
  16043. private _activeTargets;
  16044. private _currentActiveTarget;
  16045. private _directTarget;
  16046. /**
  16047. * The target path of the runtime animation
  16048. */
  16049. private _targetPath;
  16050. /**
  16051. * The weight of the runtime animation
  16052. */
  16053. private _weight;
  16054. /**
  16055. * The ratio offset of the runtime animation
  16056. */
  16057. private _ratioOffset;
  16058. /**
  16059. * The previous delay of the runtime animation
  16060. */
  16061. private _previousDelay;
  16062. /**
  16063. * The previous ratio of the runtime animation
  16064. */
  16065. private _previousRatio;
  16066. private _enableBlending;
  16067. private _keys;
  16068. private _minFrame;
  16069. private _maxFrame;
  16070. private _minValue;
  16071. private _maxValue;
  16072. private _targetIsArray;
  16073. /**
  16074. * Gets the current frame of the runtime animation
  16075. */
  16076. get currentFrame(): number;
  16077. /**
  16078. * Gets the weight of the runtime animation
  16079. */
  16080. get weight(): number;
  16081. /**
  16082. * Gets the current value of the runtime animation
  16083. */
  16084. get currentValue(): any;
  16085. /**
  16086. * Gets the target path of the runtime animation
  16087. */
  16088. get targetPath(): string;
  16089. /**
  16090. * Gets the actual target of the runtime animation
  16091. */
  16092. get target(): any;
  16093. /**
  16094. * Gets the additive state of the runtime animation
  16095. */
  16096. get isAdditive(): boolean;
  16097. /** @hidden */
  16098. _onLoop: () => void;
  16099. /**
  16100. * Create a new RuntimeAnimation object
  16101. * @param target defines the target of the animation
  16102. * @param animation defines the source animation object
  16103. * @param scene defines the hosting scene
  16104. * @param host defines the initiating Animatable
  16105. */
  16106. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16107. private _preparePath;
  16108. /**
  16109. * Gets the animation from the runtime animation
  16110. */
  16111. get animation(): Animation;
  16112. /**
  16113. * Resets the runtime animation to the beginning
  16114. * @param restoreOriginal defines whether to restore the target property to the original value
  16115. */
  16116. reset(restoreOriginal?: boolean): void;
  16117. /**
  16118. * Specifies if the runtime animation is stopped
  16119. * @returns Boolean specifying if the runtime animation is stopped
  16120. */
  16121. isStopped(): boolean;
  16122. /**
  16123. * Disposes of the runtime animation
  16124. */
  16125. dispose(): void;
  16126. /**
  16127. * Apply the interpolated value to the target
  16128. * @param currentValue defines the value computed by the animation
  16129. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16130. */
  16131. setValue(currentValue: any, weight: number): void;
  16132. private _getOriginalValues;
  16133. private _setValue;
  16134. /**
  16135. * Gets the loop pmode of the runtime animation
  16136. * @returns Loop Mode
  16137. */
  16138. private _getCorrectLoopMode;
  16139. /**
  16140. * Move the current animation to a given frame
  16141. * @param frame defines the frame to move to
  16142. */
  16143. goToFrame(frame: number): void;
  16144. /**
  16145. * @hidden Internal use only
  16146. */
  16147. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16148. /**
  16149. * Execute the current animation
  16150. * @param delay defines the delay to add to the current frame
  16151. * @param from defines the lower bound of the animation range
  16152. * @param to defines the upper bound of the animation range
  16153. * @param loop defines if the current animation must loop
  16154. * @param speedRatio defines the current speed ratio
  16155. * @param weight defines the weight of the animation (default is -1 so no weight)
  16156. * @param onLoop optional callback called when animation loops
  16157. * @returns a boolean indicating if the animation is running
  16158. */
  16159. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16160. }
  16161. }
  16162. declare module "babylonjs/Animations/animatable" {
  16163. import { Animation } from "babylonjs/Animations/animation";
  16164. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16165. import { Nullable } from "babylonjs/types";
  16166. import { Observable } from "babylonjs/Misc/observable";
  16167. import { Scene } from "babylonjs/scene";
  16168. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16169. import { Node } from "babylonjs/node";
  16170. /**
  16171. * Class used to store an actual running animation
  16172. */
  16173. export class Animatable {
  16174. /** defines the target object */
  16175. target: any;
  16176. /** defines the starting frame number (default is 0) */
  16177. fromFrame: number;
  16178. /** defines the ending frame number (default is 100) */
  16179. toFrame: number;
  16180. /** defines if the animation must loop (default is false) */
  16181. loopAnimation: boolean;
  16182. /** defines a callback to call when animation ends if it is not looping */
  16183. onAnimationEnd?: (() => void) | null | undefined;
  16184. /** defines a callback to call when animation loops */
  16185. onAnimationLoop?: (() => void) | null | undefined;
  16186. /** defines whether the animation should be evaluated additively */
  16187. isAdditive: boolean;
  16188. private _localDelayOffset;
  16189. private _pausedDelay;
  16190. private _runtimeAnimations;
  16191. private _paused;
  16192. private _scene;
  16193. private _speedRatio;
  16194. private _weight;
  16195. private _syncRoot;
  16196. /**
  16197. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16198. * This will only apply for non looping animation (default is true)
  16199. */
  16200. disposeOnEnd: boolean;
  16201. /**
  16202. * Gets a boolean indicating if the animation has started
  16203. */
  16204. animationStarted: boolean;
  16205. /**
  16206. * Observer raised when the animation ends
  16207. */
  16208. onAnimationEndObservable: Observable<Animatable>;
  16209. /**
  16210. * Observer raised when the animation loops
  16211. */
  16212. onAnimationLoopObservable: Observable<Animatable>;
  16213. /**
  16214. * Gets the root Animatable used to synchronize and normalize animations
  16215. */
  16216. get syncRoot(): Nullable<Animatable>;
  16217. /**
  16218. * Gets the current frame of the first RuntimeAnimation
  16219. * Used to synchronize Animatables
  16220. */
  16221. get masterFrame(): number;
  16222. /**
  16223. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16224. */
  16225. get weight(): number;
  16226. set weight(value: number);
  16227. /**
  16228. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16229. */
  16230. get speedRatio(): number;
  16231. set speedRatio(value: number);
  16232. /**
  16233. * Creates a new Animatable
  16234. * @param scene defines the hosting scene
  16235. * @param target defines the target object
  16236. * @param fromFrame defines the starting frame number (default is 0)
  16237. * @param toFrame defines the ending frame number (default is 100)
  16238. * @param loopAnimation defines if the animation must loop (default is false)
  16239. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16240. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16241. * @param animations defines a group of animation to add to the new Animatable
  16242. * @param onAnimationLoop defines a callback to call when animation loops
  16243. * @param isAdditive defines whether the animation should be evaluated additively
  16244. */
  16245. constructor(scene: Scene,
  16246. /** defines the target object */
  16247. target: any,
  16248. /** defines the starting frame number (default is 0) */
  16249. fromFrame?: number,
  16250. /** defines the ending frame number (default is 100) */
  16251. toFrame?: number,
  16252. /** defines if the animation must loop (default is false) */
  16253. loopAnimation?: boolean, speedRatio?: number,
  16254. /** defines a callback to call when animation ends if it is not looping */
  16255. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16256. /** defines a callback to call when animation loops */
  16257. onAnimationLoop?: (() => void) | null | undefined,
  16258. /** defines whether the animation should be evaluated additively */
  16259. isAdditive?: boolean);
  16260. /**
  16261. * Synchronize and normalize current Animatable with a source Animatable
  16262. * This is useful when using animation weights and when animations are not of the same length
  16263. * @param root defines the root Animatable to synchronize with
  16264. * @returns the current Animatable
  16265. */
  16266. syncWith(root: Animatable): Animatable;
  16267. /**
  16268. * Gets the list of runtime animations
  16269. * @returns an array of RuntimeAnimation
  16270. */
  16271. getAnimations(): RuntimeAnimation[];
  16272. /**
  16273. * Adds more animations to the current animatable
  16274. * @param target defines the target of the animations
  16275. * @param animations defines the new animations to add
  16276. */
  16277. appendAnimations(target: any, animations: Animation[]): void;
  16278. /**
  16279. * Gets the source animation for a specific property
  16280. * @param property defines the propertyu to look for
  16281. * @returns null or the source animation for the given property
  16282. */
  16283. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16284. /**
  16285. * Gets the runtime animation for a specific property
  16286. * @param property defines the propertyu to look for
  16287. * @returns null or the runtime animation for the given property
  16288. */
  16289. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16290. /**
  16291. * Resets the animatable to its original state
  16292. */
  16293. reset(): void;
  16294. /**
  16295. * Allows the animatable to blend with current running animations
  16296. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16297. * @param blendingSpeed defines the blending speed to use
  16298. */
  16299. enableBlending(blendingSpeed: number): void;
  16300. /**
  16301. * Disable animation blending
  16302. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16303. */
  16304. disableBlending(): void;
  16305. /**
  16306. * Jump directly to a given frame
  16307. * @param frame defines the frame to jump to
  16308. */
  16309. goToFrame(frame: number): void;
  16310. /**
  16311. * Pause the animation
  16312. */
  16313. pause(): void;
  16314. /**
  16315. * Restart the animation
  16316. */
  16317. restart(): void;
  16318. private _raiseOnAnimationEnd;
  16319. /**
  16320. * Stop and delete the current animation
  16321. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16322. * @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)
  16323. */
  16324. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16325. /**
  16326. * Wait asynchronously for the animation to end
  16327. * @returns a promise which will be fullfilled when the animation ends
  16328. */
  16329. waitAsync(): Promise<Animatable>;
  16330. /** @hidden */
  16331. _animate(delay: number): boolean;
  16332. }
  16333. module "babylonjs/scene" {
  16334. interface Scene {
  16335. /** @hidden */
  16336. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16337. /** @hidden */
  16338. _processLateAnimationBindingsForMatrices(holder: {
  16339. totalWeight: number;
  16340. totalAdditiveWeight: number;
  16341. animations: RuntimeAnimation[];
  16342. additiveAnimations: RuntimeAnimation[];
  16343. originalValue: Matrix;
  16344. }): any;
  16345. /** @hidden */
  16346. _processLateAnimationBindingsForQuaternions(holder: {
  16347. totalWeight: number;
  16348. totalAdditiveWeight: number;
  16349. animations: RuntimeAnimation[];
  16350. additiveAnimations: RuntimeAnimation[];
  16351. originalValue: Quaternion;
  16352. }, refQuaternion: Quaternion): Quaternion;
  16353. /** @hidden */
  16354. _processLateAnimationBindings(): void;
  16355. /**
  16356. * Will start the animation sequence of a given target
  16357. * @param target defines the target
  16358. * @param from defines from which frame should animation start
  16359. * @param to defines until which frame should animation run.
  16360. * @param weight defines the weight to apply to the animation (1.0 by default)
  16361. * @param loop defines if the animation loops
  16362. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16363. * @param onAnimationEnd defines the function to be executed when the animation ends
  16364. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16365. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16366. * @param onAnimationLoop defines the callback to call when an animation loops
  16367. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16368. * @returns the animatable object created for this animation
  16369. */
  16370. 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;
  16371. /**
  16372. * Will start the animation sequence of a given target
  16373. * @param target defines the target
  16374. * @param from defines from which frame should animation start
  16375. * @param to defines until which frame should animation run.
  16376. * @param loop defines if the animation loops
  16377. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16378. * @param onAnimationEnd defines the function to be executed when the animation ends
  16379. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16380. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16381. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16382. * @param onAnimationLoop defines the callback to call when an animation loops
  16383. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16384. * @returns the animatable object created for this animation
  16385. */
  16386. 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;
  16387. /**
  16388. * Will start the animation sequence of a given target and its hierarchy
  16389. * @param target defines the target
  16390. * @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.
  16391. * @param from defines from which frame should animation start
  16392. * @param to defines until which frame should animation run.
  16393. * @param loop defines if the animation loops
  16394. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16395. * @param onAnimationEnd defines the function to be executed when the animation ends
  16396. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16397. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16398. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16399. * @param onAnimationLoop defines the callback to call when an animation loops
  16400. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16401. * @returns the list of created animatables
  16402. */
  16403. 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[];
  16404. /**
  16405. * Begin a new animation on a given node
  16406. * @param target defines the target where the animation will take place
  16407. * @param animations defines the list of animations to start
  16408. * @param from defines the initial value
  16409. * @param to defines the final value
  16410. * @param loop defines if you want animation to loop (off by default)
  16411. * @param speedRatio defines the speed ratio to apply to all animations
  16412. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16413. * @param onAnimationLoop defines the callback to call when an animation loops
  16414. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16415. * @returns the list of created animatables
  16416. */
  16417. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16418. /**
  16419. * Begin a new animation on a given node and its hierarchy
  16420. * @param target defines the root node where the animation will take place
  16421. * @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.
  16422. * @param animations defines the list of animations to start
  16423. * @param from defines the initial value
  16424. * @param to defines the final value
  16425. * @param loop defines if you want animation to loop (off by default)
  16426. * @param speedRatio defines the speed ratio to apply to all animations
  16427. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16428. * @param onAnimationLoop defines the callback to call when an animation loops
  16429. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16430. * @returns the list of animatables created for all nodes
  16431. */
  16432. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16433. /**
  16434. * Gets the animatable associated with a specific target
  16435. * @param target defines the target of the animatable
  16436. * @returns the required animatable if found
  16437. */
  16438. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16439. /**
  16440. * Gets all animatables associated with a given target
  16441. * @param target defines the target to look animatables for
  16442. * @returns an array of Animatables
  16443. */
  16444. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16445. /**
  16446. * Stops and removes all animations that have been applied to the scene
  16447. */
  16448. stopAllAnimations(): void;
  16449. /**
  16450. * Gets the current delta time used by animation engine
  16451. */
  16452. deltaTime: number;
  16453. }
  16454. }
  16455. module "babylonjs/Bones/bone" {
  16456. interface Bone {
  16457. /**
  16458. * Copy an animation range from another bone
  16459. * @param source defines the source bone
  16460. * @param rangeName defines the range name to copy
  16461. * @param frameOffset defines the frame offset
  16462. * @param rescaleAsRequired defines if rescaling must be applied if required
  16463. * @param skelDimensionsRatio defines the scaling ratio
  16464. * @returns true if operation was successful
  16465. */
  16466. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16467. }
  16468. }
  16469. }
  16470. declare module "babylonjs/Bones/skeleton" {
  16471. import { Bone } from "babylonjs/Bones/bone";
  16472. import { Observable } from "babylonjs/Misc/observable";
  16473. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16474. import { Scene } from "babylonjs/scene";
  16475. import { Nullable } from "babylonjs/types";
  16476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16477. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16478. import { Animatable } from "babylonjs/Animations/animatable";
  16479. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16480. import { Animation } from "babylonjs/Animations/animation";
  16481. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16482. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16483. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16484. /**
  16485. * Class used to handle skinning animations
  16486. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16487. */
  16488. export class Skeleton implements IAnimatable {
  16489. /** defines the skeleton name */
  16490. name: string;
  16491. /** defines the skeleton Id */
  16492. id: string;
  16493. /**
  16494. * Defines the list of child bones
  16495. */
  16496. bones: Bone[];
  16497. /**
  16498. * Defines an estimate of the dimension of the skeleton at rest
  16499. */
  16500. dimensionsAtRest: Vector3;
  16501. /**
  16502. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16503. */
  16504. needInitialSkinMatrix: boolean;
  16505. /**
  16506. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16507. */
  16508. overrideMesh: Nullable<AbstractMesh>;
  16509. /**
  16510. * Gets the list of animations attached to this skeleton
  16511. */
  16512. animations: Array<Animation>;
  16513. private _scene;
  16514. private _isDirty;
  16515. private _transformMatrices;
  16516. private _transformMatrixTexture;
  16517. private _meshesWithPoseMatrix;
  16518. private _animatables;
  16519. private _identity;
  16520. private _synchronizedWithMesh;
  16521. private _ranges;
  16522. private _lastAbsoluteTransformsUpdateId;
  16523. private _canUseTextureForBones;
  16524. private _uniqueId;
  16525. /** @hidden */
  16526. _numBonesWithLinkedTransformNode: number;
  16527. /** @hidden */
  16528. _hasWaitingData: Nullable<boolean>;
  16529. /** @hidden */
  16530. _waitingOverrideMeshId: Nullable<string>;
  16531. /**
  16532. * Specifies if the skeleton should be serialized
  16533. */
  16534. doNotSerialize: boolean;
  16535. private _useTextureToStoreBoneMatrices;
  16536. /**
  16537. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16538. * Please note that this option is not available if the hardware does not support it
  16539. */
  16540. get useTextureToStoreBoneMatrices(): boolean;
  16541. set useTextureToStoreBoneMatrices(value: boolean);
  16542. private _animationPropertiesOverride;
  16543. /**
  16544. * Gets or sets the animation properties override
  16545. */
  16546. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16547. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16548. /**
  16549. * List of inspectable custom properties (used by the Inspector)
  16550. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16551. */
  16552. inspectableCustomProperties: IInspectable[];
  16553. /**
  16554. * An observable triggered before computing the skeleton's matrices
  16555. */
  16556. onBeforeComputeObservable: Observable<Skeleton>;
  16557. /**
  16558. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16559. */
  16560. get isUsingTextureForMatrices(): boolean;
  16561. /**
  16562. * Gets the unique ID of this skeleton
  16563. */
  16564. get uniqueId(): number;
  16565. /**
  16566. * Creates a new skeleton
  16567. * @param name defines the skeleton name
  16568. * @param id defines the skeleton Id
  16569. * @param scene defines the hosting scene
  16570. */
  16571. constructor(
  16572. /** defines the skeleton name */
  16573. name: string,
  16574. /** defines the skeleton Id */
  16575. id: string, scene: Scene);
  16576. /**
  16577. * Gets the current object class name.
  16578. * @return the class name
  16579. */
  16580. getClassName(): string;
  16581. /**
  16582. * Returns an array containing the root bones
  16583. * @returns an array containing the root bones
  16584. */
  16585. getChildren(): Array<Bone>;
  16586. /**
  16587. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16588. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16589. * @returns a Float32Array containing matrices data
  16590. */
  16591. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16592. /**
  16593. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16594. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16595. * @returns a raw texture containing the data
  16596. */
  16597. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16598. /**
  16599. * Gets the current hosting scene
  16600. * @returns a scene object
  16601. */
  16602. getScene(): Scene;
  16603. /**
  16604. * Gets a string representing the current skeleton data
  16605. * @param fullDetails defines a boolean indicating if we want a verbose version
  16606. * @returns a string representing the current skeleton data
  16607. */
  16608. toString(fullDetails?: boolean): string;
  16609. /**
  16610. * Get bone's index searching by name
  16611. * @param name defines bone's name to search for
  16612. * @return the indice of the bone. Returns -1 if not found
  16613. */
  16614. getBoneIndexByName(name: string): number;
  16615. /**
  16616. * Creater a new animation range
  16617. * @param name defines the name of the range
  16618. * @param from defines the start key
  16619. * @param to defines the end key
  16620. */
  16621. createAnimationRange(name: string, from: number, to: number): void;
  16622. /**
  16623. * Delete a specific animation range
  16624. * @param name defines the name of the range
  16625. * @param deleteFrames defines if frames must be removed as well
  16626. */
  16627. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16628. /**
  16629. * Gets a specific animation range
  16630. * @param name defines the name of the range to look for
  16631. * @returns the requested animation range or null if not found
  16632. */
  16633. getAnimationRange(name: string): Nullable<AnimationRange>;
  16634. /**
  16635. * Gets the list of all animation ranges defined on this skeleton
  16636. * @returns an array
  16637. */
  16638. getAnimationRanges(): Nullable<AnimationRange>[];
  16639. /**
  16640. * Copy animation range from a source skeleton.
  16641. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16642. * @param source defines the source skeleton
  16643. * @param name defines the name of the range to copy
  16644. * @param rescaleAsRequired defines if rescaling must be applied if required
  16645. * @returns true if operation was successful
  16646. */
  16647. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16648. /**
  16649. * Forces the skeleton to go to rest pose
  16650. */
  16651. returnToRest(): void;
  16652. private _getHighestAnimationFrame;
  16653. /**
  16654. * Begin a specific animation range
  16655. * @param name defines the name of the range to start
  16656. * @param loop defines if looping must be turned on (false by default)
  16657. * @param speedRatio defines the speed ratio to apply (1 by default)
  16658. * @param onAnimationEnd defines a callback which will be called when animation will end
  16659. * @returns a new animatable
  16660. */
  16661. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16662. /**
  16663. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16664. * @param skeleton defines the Skeleton containing the animation range to convert
  16665. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16666. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16667. * @returns the original skeleton
  16668. */
  16669. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16670. /** @hidden */
  16671. _markAsDirty(): void;
  16672. /** @hidden */
  16673. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16674. /** @hidden */
  16675. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16676. private _computeTransformMatrices;
  16677. /**
  16678. * Build all resources required to render a skeleton
  16679. */
  16680. prepare(): void;
  16681. /**
  16682. * Gets the list of animatables currently running for this skeleton
  16683. * @returns an array of animatables
  16684. */
  16685. getAnimatables(): IAnimatable[];
  16686. /**
  16687. * Clone the current skeleton
  16688. * @param name defines the name of the new skeleton
  16689. * @param id defines the id of the new skeleton
  16690. * @returns the new skeleton
  16691. */
  16692. clone(name: string, id?: string): Skeleton;
  16693. /**
  16694. * Enable animation blending for this skeleton
  16695. * @param blendingSpeed defines the blending speed to apply
  16696. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16697. */
  16698. enableBlending(blendingSpeed?: number): void;
  16699. /**
  16700. * Releases all resources associated with the current skeleton
  16701. */
  16702. dispose(): void;
  16703. /**
  16704. * Serialize the skeleton in a JSON object
  16705. * @returns a JSON object
  16706. */
  16707. serialize(): any;
  16708. /**
  16709. * Creates a new skeleton from serialized data
  16710. * @param parsedSkeleton defines the serialized data
  16711. * @param scene defines the hosting scene
  16712. * @returns a new skeleton
  16713. */
  16714. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16715. /**
  16716. * Compute all node absolute transforms
  16717. * @param forceUpdate defines if computation must be done even if cache is up to date
  16718. */
  16719. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16720. /**
  16721. * Gets the root pose matrix
  16722. * @returns a matrix
  16723. */
  16724. getPoseMatrix(): Nullable<Matrix>;
  16725. /**
  16726. * Sorts bones per internal index
  16727. */
  16728. sortBones(): void;
  16729. private _sortBones;
  16730. /**
  16731. * Set the current local matrix as the restPose for all bones in the skeleton.
  16732. */
  16733. setCurrentPoseAsRest(): void;
  16734. }
  16735. }
  16736. declare module "babylonjs/Meshes/instancedMesh" {
  16737. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16738. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16739. import { Camera } from "babylonjs/Cameras/camera";
  16740. import { Node } from "babylonjs/node";
  16741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16742. import { Mesh } from "babylonjs/Meshes/mesh";
  16743. import { Material } from "babylonjs/Materials/material";
  16744. import { Skeleton } from "babylonjs/Bones/skeleton";
  16745. import { Light } from "babylonjs/Lights/light";
  16746. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16747. /**
  16748. * Creates an instance based on a source mesh.
  16749. */
  16750. export class InstancedMesh extends AbstractMesh {
  16751. private _sourceMesh;
  16752. private _currentLOD;
  16753. /** @hidden */
  16754. _indexInSourceMeshInstanceArray: number;
  16755. constructor(name: string, source: Mesh);
  16756. /**
  16757. * Returns the string "InstancedMesh".
  16758. */
  16759. getClassName(): string;
  16760. /** Gets the list of lights affecting that mesh */
  16761. get lightSources(): Light[];
  16762. _resyncLightSources(): void;
  16763. _resyncLightSource(light: Light): void;
  16764. _removeLightSource(light: Light, dispose: boolean): void;
  16765. /**
  16766. * If the source mesh receives shadows
  16767. */
  16768. get receiveShadows(): boolean;
  16769. /**
  16770. * The material of the source mesh
  16771. */
  16772. get material(): Nullable<Material>;
  16773. /**
  16774. * Visibility of the source mesh
  16775. */
  16776. get visibility(): number;
  16777. /**
  16778. * Skeleton of the source mesh
  16779. */
  16780. get skeleton(): Nullable<Skeleton>;
  16781. /**
  16782. * Rendering ground id of the source mesh
  16783. */
  16784. get renderingGroupId(): number;
  16785. set renderingGroupId(value: number);
  16786. /**
  16787. * Returns the total number of vertices (integer).
  16788. */
  16789. getTotalVertices(): number;
  16790. /**
  16791. * Returns a positive integer : the total number of indices in this mesh geometry.
  16792. * @returns the numner of indices or zero if the mesh has no geometry.
  16793. */
  16794. getTotalIndices(): number;
  16795. /**
  16796. * The source mesh of the instance
  16797. */
  16798. get sourceMesh(): Mesh;
  16799. /**
  16800. * Creates a new InstancedMesh object from the mesh model.
  16801. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16802. * @param name defines the name of the new instance
  16803. * @returns a new InstancedMesh
  16804. */
  16805. createInstance(name: string): InstancedMesh;
  16806. /**
  16807. * Is this node ready to be used/rendered
  16808. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16809. * @return {boolean} is it ready
  16810. */
  16811. isReady(completeCheck?: boolean): boolean;
  16812. /**
  16813. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16814. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16815. * @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.
  16816. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16817. */
  16818. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16819. /**
  16820. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16821. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16822. * The `data` are either a numeric array either a Float32Array.
  16823. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16824. * 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).
  16825. * Note that a new underlying VertexBuffer object is created each call.
  16826. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16827. *
  16828. * Possible `kind` values :
  16829. * - VertexBuffer.PositionKind
  16830. * - VertexBuffer.UVKind
  16831. * - VertexBuffer.UV2Kind
  16832. * - VertexBuffer.UV3Kind
  16833. * - VertexBuffer.UV4Kind
  16834. * - VertexBuffer.UV5Kind
  16835. * - VertexBuffer.UV6Kind
  16836. * - VertexBuffer.ColorKind
  16837. * - VertexBuffer.MatricesIndicesKind
  16838. * - VertexBuffer.MatricesIndicesExtraKind
  16839. * - VertexBuffer.MatricesWeightsKind
  16840. * - VertexBuffer.MatricesWeightsExtraKind
  16841. *
  16842. * Returns the Mesh.
  16843. */
  16844. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16845. /**
  16846. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16847. * If the mesh has no geometry, it is simply returned as it is.
  16848. * The `data` are either a numeric array either a Float32Array.
  16849. * No new underlying VertexBuffer object is created.
  16850. * 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.
  16851. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16852. *
  16853. * Possible `kind` values :
  16854. * - VertexBuffer.PositionKind
  16855. * - VertexBuffer.UVKind
  16856. * - VertexBuffer.UV2Kind
  16857. * - VertexBuffer.UV3Kind
  16858. * - VertexBuffer.UV4Kind
  16859. * - VertexBuffer.UV5Kind
  16860. * - VertexBuffer.UV6Kind
  16861. * - VertexBuffer.ColorKind
  16862. * - VertexBuffer.MatricesIndicesKind
  16863. * - VertexBuffer.MatricesIndicesExtraKind
  16864. * - VertexBuffer.MatricesWeightsKind
  16865. * - VertexBuffer.MatricesWeightsExtraKind
  16866. *
  16867. * Returns the Mesh.
  16868. */
  16869. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16870. /**
  16871. * Sets the mesh indices.
  16872. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16873. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16874. * This method creates a new index buffer each call.
  16875. * Returns the Mesh.
  16876. */
  16877. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16878. /**
  16879. * Boolean : True if the mesh owns the requested kind of data.
  16880. */
  16881. isVerticesDataPresent(kind: string): boolean;
  16882. /**
  16883. * Returns an array of indices (IndicesArray).
  16884. */
  16885. getIndices(): Nullable<IndicesArray>;
  16886. get _positions(): Nullable<Vector3[]>;
  16887. /**
  16888. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16889. * This means the mesh underlying bounding box and sphere are recomputed.
  16890. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16891. * @returns the current mesh
  16892. */
  16893. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16894. /** @hidden */
  16895. _preActivate(): InstancedMesh;
  16896. /** @hidden */
  16897. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16898. /** @hidden */
  16899. _postActivate(): void;
  16900. getWorldMatrix(): Matrix;
  16901. get isAnInstance(): boolean;
  16902. /**
  16903. * Returns the current associated LOD AbstractMesh.
  16904. */
  16905. getLOD(camera: Camera): AbstractMesh;
  16906. /** @hidden */
  16907. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16908. /** @hidden */
  16909. _syncSubMeshes(): InstancedMesh;
  16910. /** @hidden */
  16911. _generatePointsArray(): boolean;
  16912. /** @hidden */
  16913. _updateBoundingInfo(): AbstractMesh;
  16914. /**
  16915. * Creates a new InstancedMesh from the current mesh.
  16916. * - name (string) : the cloned mesh name
  16917. * - newParent (optional Node) : the optional Node to parent the clone to.
  16918. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16919. *
  16920. * Returns the clone.
  16921. */
  16922. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16923. /**
  16924. * Disposes the InstancedMesh.
  16925. * Returns nothing.
  16926. */
  16927. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16928. }
  16929. module "babylonjs/Meshes/mesh" {
  16930. interface Mesh {
  16931. /**
  16932. * Register a custom buffer that will be instanced
  16933. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16934. * @param kind defines the buffer kind
  16935. * @param stride defines the stride in floats
  16936. */
  16937. registerInstancedBuffer(kind: string, stride: number): void;
  16938. /**
  16939. * true to use the edge renderer for all instances of this mesh
  16940. */
  16941. edgesShareWithInstances: boolean;
  16942. /** @hidden */
  16943. _userInstancedBuffersStorage: {
  16944. data: {
  16945. [key: string]: Float32Array;
  16946. };
  16947. sizes: {
  16948. [key: string]: number;
  16949. };
  16950. vertexBuffers: {
  16951. [key: string]: Nullable<VertexBuffer>;
  16952. };
  16953. strides: {
  16954. [key: string]: number;
  16955. };
  16956. };
  16957. }
  16958. }
  16959. module "babylonjs/Meshes/abstractMesh" {
  16960. interface AbstractMesh {
  16961. /**
  16962. * Object used to store instanced buffers defined by user
  16963. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16964. */
  16965. instancedBuffers: {
  16966. [key: string]: any;
  16967. };
  16968. }
  16969. }
  16970. }
  16971. declare module "babylonjs/Materials/shaderMaterial" {
  16972. import { Nullable } from "babylonjs/types";
  16973. import { Scene } from "babylonjs/scene";
  16974. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16976. import { Mesh } from "babylonjs/Meshes/mesh";
  16977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16979. import { Effect } from "babylonjs/Materials/effect";
  16980. import { Material } from "babylonjs/Materials/material";
  16981. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16982. /**
  16983. * Defines the options associated with the creation of a shader material.
  16984. */
  16985. export interface IShaderMaterialOptions {
  16986. /**
  16987. * Does the material work in alpha blend mode
  16988. */
  16989. needAlphaBlending: boolean;
  16990. /**
  16991. * Does the material work in alpha test mode
  16992. */
  16993. needAlphaTesting: boolean;
  16994. /**
  16995. * The list of attribute names used in the shader
  16996. */
  16997. attributes: string[];
  16998. /**
  16999. * The list of unifrom names used in the shader
  17000. */
  17001. uniforms: string[];
  17002. /**
  17003. * The list of UBO names used in the shader
  17004. */
  17005. uniformBuffers: string[];
  17006. /**
  17007. * The list of sampler names used in the shader
  17008. */
  17009. samplers: string[];
  17010. /**
  17011. * The list of defines used in the shader
  17012. */
  17013. defines: string[];
  17014. }
  17015. /**
  17016. * 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.
  17017. *
  17018. * This returned material effects how the mesh will look based on the code in the shaders.
  17019. *
  17020. * @see https://doc.babylonjs.com/how_to/shader_material
  17021. */
  17022. export class ShaderMaterial extends Material {
  17023. private _shaderPath;
  17024. private _options;
  17025. private _textures;
  17026. private _textureArrays;
  17027. private _floats;
  17028. private _ints;
  17029. private _floatsArrays;
  17030. private _colors3;
  17031. private _colors3Arrays;
  17032. private _colors4;
  17033. private _colors4Arrays;
  17034. private _vectors2;
  17035. private _vectors3;
  17036. private _vectors4;
  17037. private _matrices;
  17038. private _matrixArrays;
  17039. private _matrices3x3;
  17040. private _matrices2x2;
  17041. private _vectors2Arrays;
  17042. private _vectors3Arrays;
  17043. private _vectors4Arrays;
  17044. private _cachedWorldViewMatrix;
  17045. private _cachedWorldViewProjectionMatrix;
  17046. private _renderId;
  17047. private _multiview;
  17048. private _cachedDefines;
  17049. /** Define the Url to load snippets */
  17050. static SnippetUrl: string;
  17051. /** Snippet ID if the material was created from the snippet server */
  17052. snippetId: string;
  17053. /**
  17054. * Instantiate a new shader material.
  17055. * 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.
  17056. * This returned material effects how the mesh will look based on the code in the shaders.
  17057. * @see https://doc.babylonjs.com/how_to/shader_material
  17058. * @param name Define the name of the material in the scene
  17059. * @param scene Define the scene the material belongs to
  17060. * @param shaderPath Defines the route to the shader code in one of three ways:
  17061. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17062. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17063. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17064. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17065. * @param options Define the options used to create the shader
  17066. */
  17067. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17068. /**
  17069. * Gets the shader path used to define the shader code
  17070. * It can be modified to trigger a new compilation
  17071. */
  17072. get shaderPath(): any;
  17073. /**
  17074. * Sets the shader path used to define the shader code
  17075. * It can be modified to trigger a new compilation
  17076. */
  17077. set shaderPath(shaderPath: any);
  17078. /**
  17079. * Gets the options used to compile the shader.
  17080. * They can be modified to trigger a new compilation
  17081. */
  17082. get options(): IShaderMaterialOptions;
  17083. /**
  17084. * Gets the current class name of the material e.g. "ShaderMaterial"
  17085. * Mainly use in serialization.
  17086. * @returns the class name
  17087. */
  17088. getClassName(): string;
  17089. /**
  17090. * Specifies if the material will require alpha blending
  17091. * @returns a boolean specifying if alpha blending is needed
  17092. */
  17093. needAlphaBlending(): boolean;
  17094. /**
  17095. * Specifies if this material should be rendered in alpha test mode
  17096. * @returns a boolean specifying if an alpha test is needed.
  17097. */
  17098. needAlphaTesting(): boolean;
  17099. private _checkUniform;
  17100. /**
  17101. * Set a texture in the shader.
  17102. * @param name Define the name of the uniform samplers as defined in the shader
  17103. * @param texture Define the texture to bind to this sampler
  17104. * @return the material itself allowing "fluent" like uniform updates
  17105. */
  17106. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17107. /**
  17108. * Set a texture array in the shader.
  17109. * @param name Define the name of the uniform sampler array as defined in the shader
  17110. * @param textures Define the list of textures to bind to this sampler
  17111. * @return the material itself allowing "fluent" like uniform updates
  17112. */
  17113. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17114. /**
  17115. * Set a float in the shader.
  17116. * @param name Define the name of the uniform as defined in the shader
  17117. * @param value Define the value to give to the uniform
  17118. * @return the material itself allowing "fluent" like uniform updates
  17119. */
  17120. setFloat(name: string, value: number): ShaderMaterial;
  17121. /**
  17122. * Set a int in the shader.
  17123. * @param name Define the name of the uniform as defined in the shader
  17124. * @param value Define the value to give to the uniform
  17125. * @return the material itself allowing "fluent" like uniform updates
  17126. */
  17127. setInt(name: string, value: number): ShaderMaterial;
  17128. /**
  17129. * Set an array of floats in the shader.
  17130. * @param name Define the name of the uniform as defined in the shader
  17131. * @param value Define the value to give to the uniform
  17132. * @return the material itself allowing "fluent" like uniform updates
  17133. */
  17134. setFloats(name: string, value: number[]): ShaderMaterial;
  17135. /**
  17136. * Set a vec3 in the shader from a Color3.
  17137. * @param name Define the name of the uniform as defined in the shader
  17138. * @param value Define the value to give to the uniform
  17139. * @return the material itself allowing "fluent" like uniform updates
  17140. */
  17141. setColor3(name: string, value: Color3): ShaderMaterial;
  17142. /**
  17143. * Set a vec3 array in the shader from a Color3 array.
  17144. * @param name Define the name of the uniform as defined in the shader
  17145. * @param value Define the value to give to the uniform
  17146. * @return the material itself allowing "fluent" like uniform updates
  17147. */
  17148. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17149. /**
  17150. * Set a vec4 in the shader from a Color4.
  17151. * @param name Define the name of the uniform as defined in the shader
  17152. * @param value Define the value to give to the uniform
  17153. * @return the material itself allowing "fluent" like uniform updates
  17154. */
  17155. setColor4(name: string, value: Color4): ShaderMaterial;
  17156. /**
  17157. * Set a vec4 array in the shader from a Color4 array.
  17158. * @param name Define the name of the uniform as defined in the shader
  17159. * @param value Define the value to give to the uniform
  17160. * @return the material itself allowing "fluent" like uniform updates
  17161. */
  17162. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17163. /**
  17164. * Set a vec2 in the shader from a Vector2.
  17165. * @param name Define the name of the uniform as defined in the shader
  17166. * @param value Define the value to give to the uniform
  17167. * @return the material itself allowing "fluent" like uniform updates
  17168. */
  17169. setVector2(name: string, value: Vector2): ShaderMaterial;
  17170. /**
  17171. * Set a vec3 in the shader from a Vector3.
  17172. * @param name Define the name of the uniform as defined in the shader
  17173. * @param value Define the value to give to the uniform
  17174. * @return the material itself allowing "fluent" like uniform updates
  17175. */
  17176. setVector3(name: string, value: Vector3): ShaderMaterial;
  17177. /**
  17178. * Set a vec4 in the shader from a Vector4.
  17179. * @param name Define the name of the uniform as defined in the shader
  17180. * @param value Define the value to give to the uniform
  17181. * @return the material itself allowing "fluent" like uniform updates
  17182. */
  17183. setVector4(name: string, value: Vector4): ShaderMaterial;
  17184. /**
  17185. * Set a mat4 in the shader from a Matrix.
  17186. * @param name Define the name of the uniform as defined in the shader
  17187. * @param value Define the value to give to the uniform
  17188. * @return the material itself allowing "fluent" like uniform updates
  17189. */
  17190. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17191. /**
  17192. * Set a float32Array in the shader from a matrix array.
  17193. * @param name Define the name of the uniform as defined in the shader
  17194. * @param value Define the value to give to the uniform
  17195. * @return the material itself allowing "fluent" like uniform updates
  17196. */
  17197. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17198. /**
  17199. * Set a mat3 in the shader from a Float32Array.
  17200. * @param name Define the name of the uniform as defined in the shader
  17201. * @param value Define the value to give to the uniform
  17202. * @return the material itself allowing "fluent" like uniform updates
  17203. */
  17204. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17205. /**
  17206. * Set a mat2 in the shader from a Float32Array.
  17207. * @param name Define the name of the uniform as defined in the shader
  17208. * @param value Define the value to give to the uniform
  17209. * @return the material itself allowing "fluent" like uniform updates
  17210. */
  17211. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17212. /**
  17213. * Set a vec2 array in the shader from a number array.
  17214. * @param name Define the name of the uniform as defined in the shader
  17215. * @param value Define the value to give to the uniform
  17216. * @return the material itself allowing "fluent" like uniform updates
  17217. */
  17218. setArray2(name: string, value: number[]): ShaderMaterial;
  17219. /**
  17220. * Set a vec3 array in the shader from a number array.
  17221. * @param name Define the name of the uniform as defined in the shader
  17222. * @param value Define the value to give to the uniform
  17223. * @return the material itself allowing "fluent" like uniform updates
  17224. */
  17225. setArray3(name: string, value: number[]): ShaderMaterial;
  17226. /**
  17227. * Set a vec4 array in the shader from a number array.
  17228. * @param name Define the name of the uniform as defined in the shader
  17229. * @param value Define the value to give to the uniform
  17230. * @return the material itself allowing "fluent" like uniform updates
  17231. */
  17232. setArray4(name: string, value: number[]): ShaderMaterial;
  17233. private _checkCache;
  17234. /**
  17235. * Specifies that the submesh is ready to be used
  17236. * @param mesh defines the mesh to check
  17237. * @param subMesh defines which submesh to check
  17238. * @param useInstances specifies that instances should be used
  17239. * @returns a boolean indicating that the submesh is ready or not
  17240. */
  17241. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17242. /**
  17243. * Checks if the material is ready to render the requested mesh
  17244. * @param mesh Define the mesh to render
  17245. * @param useInstances Define whether or not the material is used with instances
  17246. * @returns true if ready, otherwise false
  17247. */
  17248. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17249. /**
  17250. * Binds the world matrix to the material
  17251. * @param world defines the world transformation matrix
  17252. * @param effectOverride - If provided, use this effect instead of internal effect
  17253. */
  17254. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17255. /**
  17256. * Binds the submesh to this material by preparing the effect and shader to draw
  17257. * @param world defines the world transformation matrix
  17258. * @param mesh defines the mesh containing the submesh
  17259. * @param subMesh defines the submesh to bind the material to
  17260. */
  17261. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17262. /**
  17263. * Binds the material to the mesh
  17264. * @param world defines the world transformation matrix
  17265. * @param mesh defines the mesh to bind the material to
  17266. * @param effectOverride - If provided, use this effect instead of internal effect
  17267. */
  17268. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17269. protected _afterBind(mesh?: Mesh): void;
  17270. /**
  17271. * Gets the active textures from the material
  17272. * @returns an array of textures
  17273. */
  17274. getActiveTextures(): BaseTexture[];
  17275. /**
  17276. * Specifies if the material uses a texture
  17277. * @param texture defines the texture to check against the material
  17278. * @returns a boolean specifying if the material uses the texture
  17279. */
  17280. hasTexture(texture: BaseTexture): boolean;
  17281. /**
  17282. * Makes a duplicate of the material, and gives it a new name
  17283. * @param name defines the new name for the duplicated material
  17284. * @returns the cloned material
  17285. */
  17286. clone(name: string): ShaderMaterial;
  17287. /**
  17288. * Disposes the material
  17289. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17290. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17291. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17292. */
  17293. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17294. /**
  17295. * Serializes this material in a JSON representation
  17296. * @returns the serialized material object
  17297. */
  17298. serialize(): any;
  17299. /**
  17300. * Creates a shader material from parsed shader material data
  17301. * @param source defines the JSON represnetation of the material
  17302. * @param scene defines the hosting scene
  17303. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17304. * @returns a new material
  17305. */
  17306. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17307. /**
  17308. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17309. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17310. * @param url defines the url to load from
  17311. * @param scene defines the hosting scene
  17312. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17313. * @returns a promise that will resolve to the new ShaderMaterial
  17314. */
  17315. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17316. /**
  17317. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17318. * @param snippetId defines the snippet to load
  17319. * @param scene defines the hosting scene
  17320. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17321. * @returns a promise that will resolve to the new ShaderMaterial
  17322. */
  17323. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17324. }
  17325. }
  17326. declare module "babylonjs/Shaders/color.fragment" {
  17327. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17328. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17329. /** @hidden */
  17330. export var colorPixelShader: {
  17331. name: string;
  17332. shader: string;
  17333. };
  17334. }
  17335. declare module "babylonjs/Shaders/color.vertex" {
  17336. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17337. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17338. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17339. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17340. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17341. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17342. /** @hidden */
  17343. export var colorVertexShader: {
  17344. name: string;
  17345. shader: string;
  17346. };
  17347. }
  17348. declare module "babylonjs/Meshes/linesMesh" {
  17349. import { Nullable } from "babylonjs/types";
  17350. import { Scene } from "babylonjs/scene";
  17351. import { Color3 } from "babylonjs/Maths/math.color";
  17352. import { Node } from "babylonjs/node";
  17353. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17354. import { Mesh } from "babylonjs/Meshes/mesh";
  17355. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17356. import { Effect } from "babylonjs/Materials/effect";
  17357. import { Material } from "babylonjs/Materials/material";
  17358. import "babylonjs/Shaders/color.fragment";
  17359. import "babylonjs/Shaders/color.vertex";
  17360. /**
  17361. * Line mesh
  17362. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17363. */
  17364. export class LinesMesh extends Mesh {
  17365. /**
  17366. * If vertex color should be applied to the mesh
  17367. */
  17368. readonly useVertexColor?: boolean | undefined;
  17369. /**
  17370. * If vertex alpha should be applied to the mesh
  17371. */
  17372. readonly useVertexAlpha?: boolean | undefined;
  17373. /**
  17374. * Color of the line (Default: White)
  17375. */
  17376. color: Color3;
  17377. /**
  17378. * Alpha of the line (Default: 1)
  17379. */
  17380. alpha: number;
  17381. /**
  17382. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17383. * This margin is expressed in world space coordinates, so its value may vary.
  17384. * Default value is 0.1
  17385. */
  17386. intersectionThreshold: number;
  17387. private _colorShader;
  17388. private color4;
  17389. /**
  17390. * Creates a new LinesMesh
  17391. * @param name defines the name
  17392. * @param scene defines the hosting scene
  17393. * @param parent defines the parent mesh if any
  17394. * @param source defines the optional source LinesMesh used to clone data from
  17395. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17396. * When false, achieved by calling a clone(), also passing False.
  17397. * This will make creation of children, recursive.
  17398. * @param useVertexColor defines if this LinesMesh supports vertex color
  17399. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17400. */
  17401. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17402. /**
  17403. * If vertex color should be applied to the mesh
  17404. */
  17405. useVertexColor?: boolean | undefined,
  17406. /**
  17407. * If vertex alpha should be applied to the mesh
  17408. */
  17409. useVertexAlpha?: boolean | undefined);
  17410. private _addClipPlaneDefine;
  17411. private _removeClipPlaneDefine;
  17412. isReady(): boolean;
  17413. /**
  17414. * Returns the string "LineMesh"
  17415. */
  17416. getClassName(): string;
  17417. /**
  17418. * @hidden
  17419. */
  17420. get material(): Material;
  17421. /**
  17422. * @hidden
  17423. */
  17424. set material(value: Material);
  17425. /**
  17426. * @hidden
  17427. */
  17428. get checkCollisions(): boolean;
  17429. /** @hidden */
  17430. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17431. /** @hidden */
  17432. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17433. /**
  17434. * Disposes of the line mesh
  17435. * @param doNotRecurse If children should be disposed
  17436. */
  17437. dispose(doNotRecurse?: boolean): void;
  17438. /**
  17439. * Returns a new LineMesh object cloned from the current one.
  17440. */
  17441. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17442. /**
  17443. * Creates a new InstancedLinesMesh object from the mesh model.
  17444. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17445. * @param name defines the name of the new instance
  17446. * @returns a new InstancedLinesMesh
  17447. */
  17448. createInstance(name: string): InstancedLinesMesh;
  17449. }
  17450. /**
  17451. * Creates an instance based on a source LinesMesh
  17452. */
  17453. export class InstancedLinesMesh extends InstancedMesh {
  17454. /**
  17455. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17456. * This margin is expressed in world space coordinates, so its value may vary.
  17457. * Initilized with the intersectionThreshold value of the source LinesMesh
  17458. */
  17459. intersectionThreshold: number;
  17460. constructor(name: string, source: LinesMesh);
  17461. /**
  17462. * Returns the string "InstancedLinesMesh".
  17463. */
  17464. getClassName(): string;
  17465. }
  17466. }
  17467. declare module "babylonjs/Shaders/line.fragment" {
  17468. /** @hidden */
  17469. export var linePixelShader: {
  17470. name: string;
  17471. shader: string;
  17472. };
  17473. }
  17474. declare module "babylonjs/Shaders/line.vertex" {
  17475. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17476. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17477. /** @hidden */
  17478. export var lineVertexShader: {
  17479. name: string;
  17480. shader: string;
  17481. };
  17482. }
  17483. declare module "babylonjs/Rendering/edgesRenderer" {
  17484. import { Nullable } from "babylonjs/types";
  17485. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17487. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17488. import { IDisposable } from "babylonjs/scene";
  17489. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17490. import "babylonjs/Shaders/line.fragment";
  17491. import "babylonjs/Shaders/line.vertex";
  17492. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17493. import { SmartArray } from "babylonjs/Misc/smartArray";
  17494. module "babylonjs/scene" {
  17495. interface Scene {
  17496. /** @hidden */
  17497. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17498. }
  17499. }
  17500. module "babylonjs/Meshes/abstractMesh" {
  17501. interface AbstractMesh {
  17502. /**
  17503. * Gets the edgesRenderer associated with the mesh
  17504. */
  17505. edgesRenderer: Nullable<EdgesRenderer>;
  17506. }
  17507. }
  17508. module "babylonjs/Meshes/linesMesh" {
  17509. interface LinesMesh {
  17510. /**
  17511. * Enables the edge rendering mode on the mesh.
  17512. * This mode makes the mesh edges visible
  17513. * @param epsilon defines the maximal distance between two angles to detect a face
  17514. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17515. * @returns the currentAbstractMesh
  17516. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17517. */
  17518. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17519. }
  17520. }
  17521. module "babylonjs/Meshes/linesMesh" {
  17522. interface InstancedLinesMesh {
  17523. /**
  17524. * Enables the edge rendering mode on the mesh.
  17525. * This mode makes the mesh edges visible
  17526. * @param epsilon defines the maximal distance between two angles to detect a face
  17527. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17528. * @returns the current InstancedLinesMesh
  17529. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17530. */
  17531. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17532. }
  17533. }
  17534. /**
  17535. * Defines the minimum contract an Edges renderer should follow.
  17536. */
  17537. export interface IEdgesRenderer extends IDisposable {
  17538. /**
  17539. * Gets or sets a boolean indicating if the edgesRenderer is active
  17540. */
  17541. isEnabled: boolean;
  17542. /**
  17543. * Renders the edges of the attached mesh,
  17544. */
  17545. render(): void;
  17546. /**
  17547. * Checks wether or not the edges renderer is ready to render.
  17548. * @return true if ready, otherwise false.
  17549. */
  17550. isReady(): boolean;
  17551. /**
  17552. * List of instances to render in case the source mesh has instances
  17553. */
  17554. customInstances: SmartArray<Matrix>;
  17555. }
  17556. /**
  17557. * Defines the additional options of the edges renderer
  17558. */
  17559. export interface IEdgesRendererOptions {
  17560. /**
  17561. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17562. * If not defined, the default value is true
  17563. */
  17564. useAlternateEdgeFinder?: boolean;
  17565. /**
  17566. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17567. * If not defined, the default value is true.
  17568. * 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)
  17569. * This option is used only if useAlternateEdgeFinder = true
  17570. */
  17571. useFastVertexMerger?: boolean;
  17572. /**
  17573. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17574. * The default value is 1e-6
  17575. * This option is used only if useAlternateEdgeFinder = true
  17576. */
  17577. epsilonVertexMerge?: number;
  17578. /**
  17579. * 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
  17580. * 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.
  17581. * This option is used only if useAlternateEdgeFinder = true
  17582. */
  17583. applyTessellation?: boolean;
  17584. /**
  17585. * 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
  17586. * The default value is 1e-6
  17587. * This option is used only if useAlternateEdgeFinder = true
  17588. */
  17589. epsilonVertexAligned?: number;
  17590. }
  17591. /**
  17592. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17593. */
  17594. export class EdgesRenderer implements IEdgesRenderer {
  17595. /**
  17596. * Define the size of the edges with an orthographic camera
  17597. */
  17598. edgesWidthScalerForOrthographic: number;
  17599. /**
  17600. * Define the size of the edges with a perspective camera
  17601. */
  17602. edgesWidthScalerForPerspective: number;
  17603. protected _source: AbstractMesh;
  17604. protected _linesPositions: number[];
  17605. protected _linesNormals: number[];
  17606. protected _linesIndices: number[];
  17607. protected _epsilon: number;
  17608. protected _indicesCount: number;
  17609. protected _lineShader: ShaderMaterial;
  17610. protected _ib: DataBuffer;
  17611. protected _buffers: {
  17612. [key: string]: Nullable<VertexBuffer>;
  17613. };
  17614. protected _buffersForInstances: {
  17615. [key: string]: Nullable<VertexBuffer>;
  17616. };
  17617. protected _checkVerticesInsteadOfIndices: boolean;
  17618. protected _options: Nullable<IEdgesRendererOptions>;
  17619. private _meshRebuildObserver;
  17620. private _meshDisposeObserver;
  17621. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17622. isEnabled: boolean;
  17623. /**
  17624. * List of instances to render in case the source mesh has instances
  17625. */
  17626. customInstances: SmartArray<Matrix>;
  17627. private static GetShader;
  17628. /**
  17629. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17630. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17631. * @param source Mesh used to create edges
  17632. * @param epsilon sum of angles in adjacency to check for edge
  17633. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17634. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17635. * @param options The options to apply when generating the edges
  17636. */
  17637. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17638. protected _prepareRessources(): void;
  17639. /** @hidden */
  17640. _rebuild(): void;
  17641. /**
  17642. * Releases the required resources for the edges renderer
  17643. */
  17644. dispose(): void;
  17645. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17646. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17647. /**
  17648. * Checks if the pair of p0 and p1 is en edge
  17649. * @param faceIndex
  17650. * @param edge
  17651. * @param faceNormals
  17652. * @param p0
  17653. * @param p1
  17654. * @private
  17655. */
  17656. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17657. /**
  17658. * push line into the position, normal and index buffer
  17659. * @protected
  17660. */
  17661. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17662. /**
  17663. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17664. */
  17665. private _tessellateTriangle;
  17666. private _generateEdgesLinesAlternate;
  17667. /**
  17668. * Generates lines edges from adjacencjes
  17669. * @private
  17670. */
  17671. _generateEdgesLines(): void;
  17672. /**
  17673. * Checks wether or not the edges renderer is ready to render.
  17674. * @return true if ready, otherwise false.
  17675. */
  17676. isReady(): boolean;
  17677. /**
  17678. * Renders the edges of the attached mesh,
  17679. */
  17680. render(): void;
  17681. }
  17682. /**
  17683. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17684. */
  17685. export class LineEdgesRenderer extends EdgesRenderer {
  17686. /**
  17687. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17688. * @param source LineMesh used to generate edges
  17689. * @param epsilon not important (specified angle for edge detection)
  17690. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17691. */
  17692. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17693. /**
  17694. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17695. */
  17696. _generateEdgesLines(): void;
  17697. }
  17698. }
  17699. declare module "babylonjs/Rendering/renderingGroup" {
  17700. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17701. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17703. import { Nullable } from "babylonjs/types";
  17704. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17705. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17706. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17707. import { Material } from "babylonjs/Materials/material";
  17708. import { Scene } from "babylonjs/scene";
  17709. /**
  17710. * This represents the object necessary to create a rendering group.
  17711. * This is exclusively used and created by the rendering manager.
  17712. * To modify the behavior, you use the available helpers in your scene or meshes.
  17713. * @hidden
  17714. */
  17715. export class RenderingGroup {
  17716. index: number;
  17717. private static _zeroVector;
  17718. private _scene;
  17719. private _opaqueSubMeshes;
  17720. private _transparentSubMeshes;
  17721. private _alphaTestSubMeshes;
  17722. private _depthOnlySubMeshes;
  17723. private _particleSystems;
  17724. private _spriteManagers;
  17725. private _opaqueSortCompareFn;
  17726. private _alphaTestSortCompareFn;
  17727. private _transparentSortCompareFn;
  17728. private _renderOpaque;
  17729. private _renderAlphaTest;
  17730. private _renderTransparent;
  17731. /** @hidden */
  17732. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17733. onBeforeTransparentRendering: () => void;
  17734. /**
  17735. * Set the opaque sort comparison function.
  17736. * If null the sub meshes will be render in the order they were created
  17737. */
  17738. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17739. /**
  17740. * Set the alpha test sort comparison function.
  17741. * If null the sub meshes will be render in the order they were created
  17742. */
  17743. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17744. /**
  17745. * Set the transparent sort comparison function.
  17746. * If null the sub meshes will be render in the order they were created
  17747. */
  17748. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17749. /**
  17750. * Creates a new rendering group.
  17751. * @param index The rendering group index
  17752. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17753. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17754. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17755. */
  17756. 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>);
  17757. /**
  17758. * Render all the sub meshes contained in the group.
  17759. * @param customRenderFunction Used to override the default render behaviour of the group.
  17760. * @returns true if rendered some submeshes.
  17761. */
  17762. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17763. /**
  17764. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17765. * @param subMeshes The submeshes to render
  17766. */
  17767. private renderOpaqueSorted;
  17768. /**
  17769. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17770. * @param subMeshes The submeshes to render
  17771. */
  17772. private renderAlphaTestSorted;
  17773. /**
  17774. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17775. * @param subMeshes The submeshes to render
  17776. */
  17777. private renderTransparentSorted;
  17778. /**
  17779. * Renders the submeshes in a specified order.
  17780. * @param subMeshes The submeshes to sort before render
  17781. * @param sortCompareFn The comparison function use to sort
  17782. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17783. * @param transparent Specifies to activate blending if true
  17784. */
  17785. private static renderSorted;
  17786. /**
  17787. * Renders the submeshes in the order they were dispatched (no sort applied).
  17788. * @param subMeshes The submeshes to render
  17789. */
  17790. private static renderUnsorted;
  17791. /**
  17792. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17793. * are rendered back to front if in the same alpha index.
  17794. *
  17795. * @param a The first submesh
  17796. * @param b The second submesh
  17797. * @returns The result of the comparison
  17798. */
  17799. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17800. /**
  17801. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17802. * are rendered back to front.
  17803. *
  17804. * @param a The first submesh
  17805. * @param b The second submesh
  17806. * @returns The result of the comparison
  17807. */
  17808. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17809. /**
  17810. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17811. * are rendered front to back (prevent overdraw).
  17812. *
  17813. * @param a The first submesh
  17814. * @param b The second submesh
  17815. * @returns The result of the comparison
  17816. */
  17817. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17818. /**
  17819. * Resets the different lists of submeshes to prepare a new frame.
  17820. */
  17821. prepare(): void;
  17822. dispose(): void;
  17823. /**
  17824. * Inserts the submesh in its correct queue depending on its material.
  17825. * @param subMesh The submesh to dispatch
  17826. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17827. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17828. */
  17829. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17830. dispatchSprites(spriteManager: ISpriteManager): void;
  17831. dispatchParticles(particleSystem: IParticleSystem): void;
  17832. private _renderParticles;
  17833. private _renderSprites;
  17834. }
  17835. }
  17836. declare module "babylonjs/Rendering/renderingManager" {
  17837. import { Nullable } from "babylonjs/types";
  17838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17839. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17840. import { SmartArray } from "babylonjs/Misc/smartArray";
  17841. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17842. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17843. import { Material } from "babylonjs/Materials/material";
  17844. import { Scene } from "babylonjs/scene";
  17845. import { Camera } from "babylonjs/Cameras/camera";
  17846. /**
  17847. * Interface describing the different options available in the rendering manager
  17848. * regarding Auto Clear between groups.
  17849. */
  17850. export interface IRenderingManagerAutoClearSetup {
  17851. /**
  17852. * Defines whether or not autoclear is enable.
  17853. */
  17854. autoClear: boolean;
  17855. /**
  17856. * Defines whether or not to autoclear the depth buffer.
  17857. */
  17858. depth: boolean;
  17859. /**
  17860. * Defines whether or not to autoclear the stencil buffer.
  17861. */
  17862. stencil: boolean;
  17863. }
  17864. /**
  17865. * This class is used by the onRenderingGroupObservable
  17866. */
  17867. export class RenderingGroupInfo {
  17868. /**
  17869. * The Scene that being rendered
  17870. */
  17871. scene: Scene;
  17872. /**
  17873. * The camera currently used for the rendering pass
  17874. */
  17875. camera: Nullable<Camera>;
  17876. /**
  17877. * The ID of the renderingGroup being processed
  17878. */
  17879. renderingGroupId: number;
  17880. }
  17881. /**
  17882. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17883. * It is enable to manage the different groups as well as the different necessary sort functions.
  17884. * This should not be used directly aside of the few static configurations
  17885. */
  17886. export class RenderingManager {
  17887. /**
  17888. * The max id used for rendering groups (not included)
  17889. */
  17890. static MAX_RENDERINGGROUPS: number;
  17891. /**
  17892. * The min id used for rendering groups (included)
  17893. */
  17894. static MIN_RENDERINGGROUPS: number;
  17895. /**
  17896. * Used to globally prevent autoclearing scenes.
  17897. */
  17898. static AUTOCLEAR: boolean;
  17899. /**
  17900. * @hidden
  17901. */
  17902. _useSceneAutoClearSetup: boolean;
  17903. private _scene;
  17904. private _renderingGroups;
  17905. private _depthStencilBufferAlreadyCleaned;
  17906. private _autoClearDepthStencil;
  17907. private _customOpaqueSortCompareFn;
  17908. private _customAlphaTestSortCompareFn;
  17909. private _customTransparentSortCompareFn;
  17910. private _renderingGroupInfo;
  17911. /**
  17912. * Instantiates a new rendering group for a particular scene
  17913. * @param scene Defines the scene the groups belongs to
  17914. */
  17915. constructor(scene: Scene);
  17916. private _clearDepthStencilBuffer;
  17917. /**
  17918. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17919. * @hidden
  17920. */
  17921. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17922. /**
  17923. * Resets the different information of the group to prepare a new frame
  17924. * @hidden
  17925. */
  17926. reset(): void;
  17927. /**
  17928. * Dispose and release the group and its associated resources.
  17929. * @hidden
  17930. */
  17931. dispose(): void;
  17932. /**
  17933. * Clear the info related to rendering groups preventing retention points during dispose.
  17934. */
  17935. freeRenderingGroups(): void;
  17936. private _prepareRenderingGroup;
  17937. /**
  17938. * Add a sprite manager to the rendering manager in order to render it this frame.
  17939. * @param spriteManager Define the sprite manager to render
  17940. */
  17941. dispatchSprites(spriteManager: ISpriteManager): void;
  17942. /**
  17943. * Add a particle system to the rendering manager in order to render it this frame.
  17944. * @param particleSystem Define the particle system to render
  17945. */
  17946. dispatchParticles(particleSystem: IParticleSystem): void;
  17947. /**
  17948. * Add a submesh to the manager in order to render it this frame
  17949. * @param subMesh The submesh to dispatch
  17950. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17951. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17952. */
  17953. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17954. /**
  17955. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17956. * This allowed control for front to back rendering or reversly depending of the special needs.
  17957. *
  17958. * @param renderingGroupId The rendering group id corresponding to its index
  17959. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17960. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17961. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17962. */
  17963. 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;
  17964. /**
  17965. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17966. *
  17967. * @param renderingGroupId The rendering group id corresponding to its index
  17968. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17969. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17970. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17971. */
  17972. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17973. /**
  17974. * Gets the current auto clear configuration for one rendering group of the rendering
  17975. * manager.
  17976. * @param index the rendering group index to get the information for
  17977. * @returns The auto clear setup for the requested rendering group
  17978. */
  17979. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17980. }
  17981. }
  17982. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17983. import { SmartArray } from "babylonjs/Misc/smartArray";
  17984. import { Nullable } from "babylonjs/types";
  17985. import { Scene } from "babylonjs/scene";
  17986. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17987. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17989. import { Mesh } from "babylonjs/Meshes/mesh";
  17990. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17991. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17992. import { Effect } from "babylonjs/Materials/effect";
  17993. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17994. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17995. import "babylonjs/Shaders/shadowMap.fragment";
  17996. import "babylonjs/Shaders/shadowMap.vertex";
  17997. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17998. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17999. import { Observable } from "babylonjs/Misc/observable";
  18000. /**
  18001. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18002. */
  18003. export interface ICustomShaderOptions {
  18004. /**
  18005. * Gets or sets the custom shader name to use
  18006. */
  18007. shaderName: string;
  18008. /**
  18009. * The list of attribute names used in the shader
  18010. */
  18011. attributes?: string[];
  18012. /**
  18013. * The list of unifrom names used in the shader
  18014. */
  18015. uniforms?: string[];
  18016. /**
  18017. * The list of sampler names used in the shader
  18018. */
  18019. samplers?: string[];
  18020. /**
  18021. * The list of defines used in the shader
  18022. */
  18023. defines?: string[];
  18024. }
  18025. /**
  18026. * Interface to implement to create a shadow generator compatible with BJS.
  18027. */
  18028. export interface IShadowGenerator {
  18029. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18030. id: string;
  18031. /**
  18032. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18033. * @returns The render target texture if present otherwise, null
  18034. */
  18035. getShadowMap(): Nullable<RenderTargetTexture>;
  18036. /**
  18037. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18038. * @param subMesh The submesh we want to render in the shadow map
  18039. * @param useInstances Defines wether will draw in the map using instances
  18040. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18041. * @returns true if ready otherwise, false
  18042. */
  18043. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18044. /**
  18045. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18046. * @param defines Defines of the material we want to update
  18047. * @param lightIndex Index of the light in the enabled light list of the material
  18048. */
  18049. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18050. /**
  18051. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18052. * defined in the generator but impacting the effect).
  18053. * It implies the unifroms available on the materials are the standard BJS ones.
  18054. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18055. * @param effect The effect we are binfing the information for
  18056. */
  18057. bindShadowLight(lightIndex: string, effect: Effect): void;
  18058. /**
  18059. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18060. * (eq to shadow prjection matrix * light transform matrix)
  18061. * @returns The transform matrix used to create the shadow map
  18062. */
  18063. getTransformMatrix(): Matrix;
  18064. /**
  18065. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18066. * Cube and 2D textures for instance.
  18067. */
  18068. recreateShadowMap(): void;
  18069. /**
  18070. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18071. * @param onCompiled Callback triggered at the and of the effects compilation
  18072. * @param options Sets of optional options forcing the compilation with different modes
  18073. */
  18074. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18075. useInstances: boolean;
  18076. }>): void;
  18077. /**
  18078. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18079. * @param options Sets of optional options forcing the compilation with different modes
  18080. * @returns A promise that resolves when the compilation completes
  18081. */
  18082. forceCompilationAsync(options?: Partial<{
  18083. useInstances: boolean;
  18084. }>): Promise<void>;
  18085. /**
  18086. * Serializes the shadow generator setup to a json object.
  18087. * @returns The serialized JSON object
  18088. */
  18089. serialize(): any;
  18090. /**
  18091. * Disposes the Shadow map and related Textures and effects.
  18092. */
  18093. dispose(): void;
  18094. }
  18095. /**
  18096. * Default implementation IShadowGenerator.
  18097. * This is the main object responsible of generating shadows in the framework.
  18098. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18099. */
  18100. export class ShadowGenerator implements IShadowGenerator {
  18101. /**
  18102. * Name of the shadow generator class
  18103. */
  18104. static CLASSNAME: string;
  18105. /**
  18106. * Shadow generator mode None: no filtering applied.
  18107. */
  18108. static readonly FILTER_NONE: number;
  18109. /**
  18110. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18111. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18112. */
  18113. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18114. /**
  18115. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18116. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18117. */
  18118. static readonly FILTER_POISSONSAMPLING: number;
  18119. /**
  18120. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18121. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18122. */
  18123. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18124. /**
  18125. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18126. * edge artifacts on steep falloff.
  18127. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18128. */
  18129. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18130. /**
  18131. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18132. * edge artifacts on steep falloff.
  18133. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18134. */
  18135. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18136. /**
  18137. * Shadow generator mode PCF: Percentage Closer Filtering
  18138. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18139. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18140. */
  18141. static readonly FILTER_PCF: number;
  18142. /**
  18143. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18144. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18145. * Contact Hardening
  18146. */
  18147. static readonly FILTER_PCSS: number;
  18148. /**
  18149. * Reserved for PCF and PCSS
  18150. * Highest Quality.
  18151. *
  18152. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18153. *
  18154. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18155. */
  18156. static readonly QUALITY_HIGH: number;
  18157. /**
  18158. * Reserved for PCF and PCSS
  18159. * Good tradeoff for quality/perf cross devices
  18160. *
  18161. * Execute PCF on a 3*3 kernel.
  18162. *
  18163. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18164. */
  18165. static readonly QUALITY_MEDIUM: number;
  18166. /**
  18167. * Reserved for PCF and PCSS
  18168. * The lowest quality but the fastest.
  18169. *
  18170. * Execute PCF on a 1*1 kernel.
  18171. *
  18172. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18173. */
  18174. static readonly QUALITY_LOW: number;
  18175. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18176. id: string;
  18177. /** Gets or sets the custom shader name to use */
  18178. customShaderOptions: ICustomShaderOptions;
  18179. /**
  18180. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18181. */
  18182. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18183. /**
  18184. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18185. */
  18186. onAfterShadowMapRenderObservable: Observable<Effect>;
  18187. /**
  18188. * Observable triggered before a mesh is rendered in the shadow map.
  18189. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18190. */
  18191. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18192. /**
  18193. * Observable triggered after a mesh is rendered in the shadow map.
  18194. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18195. */
  18196. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18197. protected _bias: number;
  18198. /**
  18199. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18200. */
  18201. get bias(): number;
  18202. /**
  18203. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18204. */
  18205. set bias(bias: number);
  18206. protected _normalBias: number;
  18207. /**
  18208. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18209. */
  18210. get normalBias(): number;
  18211. /**
  18212. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18213. */
  18214. set normalBias(normalBias: number);
  18215. protected _blurBoxOffset: number;
  18216. /**
  18217. * Gets the blur box offset: offset applied during the blur pass.
  18218. * Only useful if useKernelBlur = false
  18219. */
  18220. get blurBoxOffset(): number;
  18221. /**
  18222. * Sets the blur box offset: offset applied during the blur pass.
  18223. * Only useful if useKernelBlur = false
  18224. */
  18225. set blurBoxOffset(value: number);
  18226. protected _blurScale: number;
  18227. /**
  18228. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18229. * 2 means half of the size.
  18230. */
  18231. get blurScale(): number;
  18232. /**
  18233. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18234. * 2 means half of the size.
  18235. */
  18236. set blurScale(value: number);
  18237. protected _blurKernel: number;
  18238. /**
  18239. * Gets the blur kernel: kernel size of the blur pass.
  18240. * Only useful if useKernelBlur = true
  18241. */
  18242. get blurKernel(): number;
  18243. /**
  18244. * Sets the blur kernel: kernel size of the blur pass.
  18245. * Only useful if useKernelBlur = true
  18246. */
  18247. set blurKernel(value: number);
  18248. protected _useKernelBlur: boolean;
  18249. /**
  18250. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18251. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18252. */
  18253. get useKernelBlur(): boolean;
  18254. /**
  18255. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18256. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18257. */
  18258. set useKernelBlur(value: boolean);
  18259. protected _depthScale: number;
  18260. /**
  18261. * Gets the depth scale used in ESM mode.
  18262. */
  18263. get depthScale(): number;
  18264. /**
  18265. * Sets the depth scale used in ESM mode.
  18266. * This can override the scale stored on the light.
  18267. */
  18268. set depthScale(value: number);
  18269. protected _validateFilter(filter: number): number;
  18270. protected _filter: number;
  18271. /**
  18272. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18273. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18274. */
  18275. get filter(): number;
  18276. /**
  18277. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18278. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18279. */
  18280. set filter(value: number);
  18281. /**
  18282. * Gets if the current filter is set to Poisson Sampling.
  18283. */
  18284. get usePoissonSampling(): boolean;
  18285. /**
  18286. * Sets the current filter to Poisson Sampling.
  18287. */
  18288. set usePoissonSampling(value: boolean);
  18289. /**
  18290. * Gets if the current filter is set to ESM.
  18291. */
  18292. get useExponentialShadowMap(): boolean;
  18293. /**
  18294. * Sets the current filter is to ESM.
  18295. */
  18296. set useExponentialShadowMap(value: boolean);
  18297. /**
  18298. * Gets if the current filter is set to filtered ESM.
  18299. */
  18300. get useBlurExponentialShadowMap(): boolean;
  18301. /**
  18302. * Gets if the current filter is set to filtered ESM.
  18303. */
  18304. set useBlurExponentialShadowMap(value: boolean);
  18305. /**
  18306. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18307. * exponential to prevent steep falloff artifacts).
  18308. */
  18309. get useCloseExponentialShadowMap(): boolean;
  18310. /**
  18311. * Sets the current filter to "close ESM" (using the inverse of the
  18312. * exponential to prevent steep falloff artifacts).
  18313. */
  18314. set useCloseExponentialShadowMap(value: boolean);
  18315. /**
  18316. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18317. * exponential to prevent steep falloff artifacts).
  18318. */
  18319. get useBlurCloseExponentialShadowMap(): boolean;
  18320. /**
  18321. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18322. * exponential to prevent steep falloff artifacts).
  18323. */
  18324. set useBlurCloseExponentialShadowMap(value: boolean);
  18325. /**
  18326. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18327. */
  18328. get usePercentageCloserFiltering(): boolean;
  18329. /**
  18330. * Sets the current filter to "PCF" (percentage closer filtering).
  18331. */
  18332. set usePercentageCloserFiltering(value: boolean);
  18333. protected _filteringQuality: number;
  18334. /**
  18335. * Gets the PCF or PCSS Quality.
  18336. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18337. */
  18338. get filteringQuality(): number;
  18339. /**
  18340. * Sets the PCF or PCSS Quality.
  18341. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18342. */
  18343. set filteringQuality(filteringQuality: number);
  18344. /**
  18345. * Gets if the current filter is set to "PCSS" (contact hardening).
  18346. */
  18347. get useContactHardeningShadow(): boolean;
  18348. /**
  18349. * Sets the current filter to "PCSS" (contact hardening).
  18350. */
  18351. set useContactHardeningShadow(value: boolean);
  18352. protected _contactHardeningLightSizeUVRatio: number;
  18353. /**
  18354. * Gets 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. get contactHardeningLightSizeUVRatio(): number;
  18363. /**
  18364. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18365. * Using a ratio helps keeping shape stability independently of the map size.
  18366. *
  18367. * It does not account for the light projection as it was having too much
  18368. * instability during the light setup or during light position changes.
  18369. *
  18370. * Only valid if useContactHardeningShadow is true.
  18371. */
  18372. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18373. protected _darkness: number;
  18374. /** Gets or sets the actual darkness of a shadow */
  18375. get darkness(): number;
  18376. set darkness(value: number);
  18377. /**
  18378. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18379. * 0 means strongest and 1 would means no shadow.
  18380. * @returns the darkness.
  18381. */
  18382. getDarkness(): number;
  18383. /**
  18384. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18385. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18386. * @returns the shadow generator allowing fluent coding.
  18387. */
  18388. setDarkness(darkness: number): ShadowGenerator;
  18389. protected _transparencyShadow: boolean;
  18390. /** Gets or sets the ability to have transparent shadow */
  18391. get transparencyShadow(): boolean;
  18392. set transparencyShadow(value: boolean);
  18393. /**
  18394. * Sets the ability to have transparent shadow (boolean).
  18395. * @param transparent True if transparent else False
  18396. * @returns the shadow generator allowing fluent coding
  18397. */
  18398. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18399. /**
  18400. * Enables or disables shadows with varying strength based on the transparency
  18401. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18402. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18403. * mesh.visibility * alphaTexture.a
  18404. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18405. */
  18406. enableSoftTransparentShadow: boolean;
  18407. protected _shadowMap: Nullable<RenderTargetTexture>;
  18408. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18409. /**
  18410. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18411. * @returns The render target texture if present otherwise, null
  18412. */
  18413. getShadowMap(): Nullable<RenderTargetTexture>;
  18414. /**
  18415. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18416. * @returns The render target texture if the shadow map is present otherwise, null
  18417. */
  18418. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18419. /**
  18420. * Gets the class name of that object
  18421. * @returns "ShadowGenerator"
  18422. */
  18423. getClassName(): string;
  18424. /**
  18425. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18426. * @param mesh Mesh to add
  18427. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18428. * @returns the Shadow Generator itself
  18429. */
  18430. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18431. /**
  18432. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18433. * @param mesh Mesh to remove
  18434. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18435. * @returns the Shadow Generator itself
  18436. */
  18437. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18438. /**
  18439. * Controls the extent to which the shadows fade out at the edge of the frustum
  18440. */
  18441. frustumEdgeFalloff: number;
  18442. protected _light: IShadowLight;
  18443. /**
  18444. * Returns the associated light object.
  18445. * @returns the light generating the shadow
  18446. */
  18447. getLight(): IShadowLight;
  18448. /**
  18449. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18450. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18451. * It might on the other hand introduce peter panning.
  18452. */
  18453. forceBackFacesOnly: boolean;
  18454. protected _scene: Scene;
  18455. protected _lightDirection: Vector3;
  18456. protected _effect: Effect;
  18457. protected _viewMatrix: Matrix;
  18458. protected _projectionMatrix: Matrix;
  18459. protected _transformMatrix: Matrix;
  18460. protected _cachedPosition: Vector3;
  18461. protected _cachedDirection: Vector3;
  18462. protected _cachedDefines: string;
  18463. protected _currentRenderID: number;
  18464. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18465. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18466. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18467. protected _blurPostProcesses: PostProcess[];
  18468. protected _mapSize: number;
  18469. protected _currentFaceIndex: number;
  18470. protected _currentFaceIndexCache: number;
  18471. protected _textureType: number;
  18472. protected _defaultTextureMatrix: Matrix;
  18473. protected _storedUniqueId: Nullable<number>;
  18474. /** @hidden */
  18475. static _SceneComponentInitialization: (scene: Scene) => void;
  18476. /**
  18477. * Creates a ShadowGenerator object.
  18478. * A ShadowGenerator is the required tool to use the shadows.
  18479. * Each light casting shadows needs to use its own ShadowGenerator.
  18480. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18481. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18482. * @param light The light object generating the shadows.
  18483. * @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.
  18484. */
  18485. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18486. protected _initializeGenerator(): void;
  18487. protected _createTargetRenderTexture(): void;
  18488. protected _initializeShadowMap(): void;
  18489. protected _initializeBlurRTTAndPostProcesses(): void;
  18490. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18491. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18492. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18493. protected _applyFilterValues(): void;
  18494. /**
  18495. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18496. * @param onCompiled Callback triggered at the and of the effects compilation
  18497. * @param options Sets of optional options forcing the compilation with different modes
  18498. */
  18499. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18500. useInstances: boolean;
  18501. }>): void;
  18502. /**
  18503. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18504. * @param options Sets of optional options forcing the compilation with different modes
  18505. * @returns A promise that resolves when the compilation completes
  18506. */
  18507. forceCompilationAsync(options?: Partial<{
  18508. useInstances: boolean;
  18509. }>): Promise<void>;
  18510. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18511. private _prepareShadowDefines;
  18512. /**
  18513. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18514. * @param subMesh The submesh we want to render in the shadow map
  18515. * @param useInstances Defines wether will draw in the map using instances
  18516. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18517. * @returns true if ready otherwise, false
  18518. */
  18519. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18520. /**
  18521. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18522. * @param defines Defines of the material we want to update
  18523. * @param lightIndex Index of the light in the enabled light list of the material
  18524. */
  18525. prepareDefines(defines: any, lightIndex: number): void;
  18526. /**
  18527. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18528. * defined in the generator but impacting the effect).
  18529. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18530. * @param effect The effect we are binfing the information for
  18531. */
  18532. bindShadowLight(lightIndex: string, effect: Effect): void;
  18533. /**
  18534. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18535. * (eq to shadow prjection matrix * light transform matrix)
  18536. * @returns The transform matrix used to create the shadow map
  18537. */
  18538. getTransformMatrix(): Matrix;
  18539. /**
  18540. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18541. * Cube and 2D textures for instance.
  18542. */
  18543. recreateShadowMap(): void;
  18544. protected _disposeBlurPostProcesses(): void;
  18545. protected _disposeRTTandPostProcesses(): void;
  18546. /**
  18547. * Disposes the ShadowGenerator.
  18548. * Returns nothing.
  18549. */
  18550. dispose(): void;
  18551. /**
  18552. * Serializes the shadow generator setup to a json object.
  18553. * @returns The serialized JSON object
  18554. */
  18555. serialize(): any;
  18556. /**
  18557. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18558. * @param parsedShadowGenerator The JSON object to parse
  18559. * @param scene The scene to create the shadow map for
  18560. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18561. * @returns The parsed shadow generator
  18562. */
  18563. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18564. }
  18565. }
  18566. declare module "babylonjs/Lights/light" {
  18567. import { Nullable } from "babylonjs/types";
  18568. import { Scene } from "babylonjs/scene";
  18569. import { Vector3 } from "babylonjs/Maths/math.vector";
  18570. import { Color3 } from "babylonjs/Maths/math.color";
  18571. import { Node } from "babylonjs/node";
  18572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18573. import { Effect } from "babylonjs/Materials/effect";
  18574. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18575. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18576. /**
  18577. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18578. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18579. * 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.
  18580. */
  18581. export abstract class Light extends Node {
  18582. /**
  18583. * Falloff Default: light is falling off following the material specification:
  18584. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18585. */
  18586. static readonly FALLOFF_DEFAULT: number;
  18587. /**
  18588. * Falloff Physical: light is falling off following the inverse squared distance law.
  18589. */
  18590. static readonly FALLOFF_PHYSICAL: number;
  18591. /**
  18592. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18593. * to enhance interoperability with other engines.
  18594. */
  18595. static readonly FALLOFF_GLTF: number;
  18596. /**
  18597. * Falloff Standard: light is falling off like in the standard material
  18598. * to enhance interoperability with other materials.
  18599. */
  18600. static readonly FALLOFF_STANDARD: number;
  18601. /**
  18602. * If every light affecting the material is in this lightmapMode,
  18603. * material.lightmapTexture adds or multiplies
  18604. * (depends on material.useLightmapAsShadowmap)
  18605. * after every other light calculations.
  18606. */
  18607. static readonly LIGHTMAP_DEFAULT: number;
  18608. /**
  18609. * material.lightmapTexture as only diffuse lighting from this light
  18610. * adds only specular lighting from this light
  18611. * adds dynamic shadows
  18612. */
  18613. static readonly LIGHTMAP_SPECULAR: number;
  18614. /**
  18615. * material.lightmapTexture as only lighting
  18616. * no light calculation from this light
  18617. * only adds dynamic shadows from this light
  18618. */
  18619. static readonly LIGHTMAP_SHADOWSONLY: number;
  18620. /**
  18621. * Each light type uses the default quantity according to its type:
  18622. * point/spot lights use luminous intensity
  18623. * directional lights use illuminance
  18624. */
  18625. static readonly INTENSITYMODE_AUTOMATIC: number;
  18626. /**
  18627. * lumen (lm)
  18628. */
  18629. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18630. /**
  18631. * candela (lm/sr)
  18632. */
  18633. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18634. /**
  18635. * lux (lm/m^2)
  18636. */
  18637. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18638. /**
  18639. * nit (cd/m^2)
  18640. */
  18641. static readonly INTENSITYMODE_LUMINANCE: number;
  18642. /**
  18643. * Light type const id of the point light.
  18644. */
  18645. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18646. /**
  18647. * Light type const id of the directional light.
  18648. */
  18649. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18650. /**
  18651. * Light type const id of the spot light.
  18652. */
  18653. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18654. /**
  18655. * Light type const id of the hemispheric light.
  18656. */
  18657. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18658. /**
  18659. * Diffuse gives the basic color to an object.
  18660. */
  18661. diffuse: Color3;
  18662. /**
  18663. * Specular produces a highlight color on an object.
  18664. * Note: This is note affecting PBR materials.
  18665. */
  18666. specular: Color3;
  18667. /**
  18668. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18669. * falling off base on range or angle.
  18670. * This can be set to any values in Light.FALLOFF_x.
  18671. *
  18672. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18673. * other types of materials.
  18674. */
  18675. falloffType: number;
  18676. /**
  18677. * Strength of the light.
  18678. * Note: By default it is define in the framework own unit.
  18679. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18680. */
  18681. intensity: number;
  18682. private _range;
  18683. protected _inverseSquaredRange: number;
  18684. /**
  18685. * Defines how far from the source the light is impacting in scene units.
  18686. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18687. */
  18688. get range(): number;
  18689. /**
  18690. * Defines how far from the source the light is impacting in scene units.
  18691. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18692. */
  18693. set range(value: number);
  18694. /**
  18695. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18696. * of light.
  18697. */
  18698. private _photometricScale;
  18699. private _intensityMode;
  18700. /**
  18701. * Gets the photometric scale used to interpret the intensity.
  18702. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18703. */
  18704. get intensityMode(): number;
  18705. /**
  18706. * Sets the photometric scale used to interpret the intensity.
  18707. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18708. */
  18709. set intensityMode(value: number);
  18710. private _radius;
  18711. /**
  18712. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18713. */
  18714. get radius(): number;
  18715. /**
  18716. * sets the light radius used by PBR Materials to simulate soft area lights.
  18717. */
  18718. set radius(value: number);
  18719. private _renderPriority;
  18720. /**
  18721. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18722. * exceeding the number allowed of the materials.
  18723. */
  18724. renderPriority: number;
  18725. private _shadowEnabled;
  18726. /**
  18727. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18728. * the current shadow generator.
  18729. */
  18730. get shadowEnabled(): boolean;
  18731. /**
  18732. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18733. * the current shadow generator.
  18734. */
  18735. set shadowEnabled(value: boolean);
  18736. private _includedOnlyMeshes;
  18737. /**
  18738. * Gets the only meshes impacted by this light.
  18739. */
  18740. get includedOnlyMeshes(): AbstractMesh[];
  18741. /**
  18742. * Sets the only meshes impacted by this light.
  18743. */
  18744. set includedOnlyMeshes(value: AbstractMesh[]);
  18745. private _excludedMeshes;
  18746. /**
  18747. * Gets the meshes not impacted by this light.
  18748. */
  18749. get excludedMeshes(): AbstractMesh[];
  18750. /**
  18751. * Sets the meshes not impacted by this light.
  18752. */
  18753. set excludedMeshes(value: AbstractMesh[]);
  18754. private _excludeWithLayerMask;
  18755. /**
  18756. * Gets the layer id use to find what meshes are not impacted by the light.
  18757. * Inactive if 0
  18758. */
  18759. get excludeWithLayerMask(): number;
  18760. /**
  18761. * Sets the layer id use to find what meshes are not impacted by the light.
  18762. * Inactive if 0
  18763. */
  18764. set excludeWithLayerMask(value: number);
  18765. private _includeOnlyWithLayerMask;
  18766. /**
  18767. * Gets the layer id use to find what meshes are impacted by the light.
  18768. * Inactive if 0
  18769. */
  18770. get includeOnlyWithLayerMask(): number;
  18771. /**
  18772. * Sets the layer id use to find what meshes are impacted by the light.
  18773. * Inactive if 0
  18774. */
  18775. set includeOnlyWithLayerMask(value: number);
  18776. private _lightmapMode;
  18777. /**
  18778. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18779. */
  18780. get lightmapMode(): number;
  18781. /**
  18782. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18783. */
  18784. set lightmapMode(value: number);
  18785. /**
  18786. * Shadow generator associted to the light.
  18787. * @hidden Internal use only.
  18788. */
  18789. _shadowGenerator: Nullable<IShadowGenerator>;
  18790. /**
  18791. * @hidden Internal use only.
  18792. */
  18793. _excludedMeshesIds: string[];
  18794. /**
  18795. * @hidden Internal use only.
  18796. */
  18797. _includedOnlyMeshesIds: string[];
  18798. /**
  18799. * The current light unifom buffer.
  18800. * @hidden Internal use only.
  18801. */
  18802. _uniformBuffer: UniformBuffer;
  18803. /** @hidden */
  18804. _renderId: number;
  18805. /**
  18806. * Creates a Light object in the scene.
  18807. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18808. * @param name The firendly name of the light
  18809. * @param scene The scene the light belongs too
  18810. */
  18811. constructor(name: string, scene: Scene);
  18812. protected abstract _buildUniformLayout(): void;
  18813. /**
  18814. * Sets the passed Effect "effect" with the Light information.
  18815. * @param effect The effect to update
  18816. * @param lightIndex The index of the light in the effect to update
  18817. * @returns The light
  18818. */
  18819. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18820. /**
  18821. * Sets the passed Effect "effect" with the Light textures.
  18822. * @param effect The effect to update
  18823. * @param lightIndex The index of the light in the effect to update
  18824. * @returns The light
  18825. */
  18826. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18827. /**
  18828. * Binds the lights information from the scene to the effect for the given mesh.
  18829. * @param lightIndex Light index
  18830. * @param scene The scene where the light belongs to
  18831. * @param effect The effect we are binding the data to
  18832. * @param useSpecular Defines if specular is supported
  18833. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18834. */
  18835. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18836. /**
  18837. * Sets the passed Effect "effect" with the Light information.
  18838. * @param effect The effect to update
  18839. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18840. * @returns The light
  18841. */
  18842. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18843. /**
  18844. * Returns the string "Light".
  18845. * @returns the class name
  18846. */
  18847. getClassName(): string;
  18848. /** @hidden */
  18849. readonly _isLight: boolean;
  18850. /**
  18851. * Converts the light information to a readable string for debug purpose.
  18852. * @param fullDetails Supports for multiple levels of logging within scene loading
  18853. * @returns the human readable light info
  18854. */
  18855. toString(fullDetails?: boolean): string;
  18856. /** @hidden */
  18857. protected _syncParentEnabledState(): void;
  18858. /**
  18859. * Set the enabled state of this node.
  18860. * @param value - the new enabled state
  18861. */
  18862. setEnabled(value: boolean): void;
  18863. /**
  18864. * Returns the Light associated shadow generator if any.
  18865. * @return the associated shadow generator.
  18866. */
  18867. getShadowGenerator(): Nullable<IShadowGenerator>;
  18868. /**
  18869. * Returns a Vector3, the absolute light position in the World.
  18870. * @returns the world space position of the light
  18871. */
  18872. getAbsolutePosition(): Vector3;
  18873. /**
  18874. * Specifies if the light will affect the passed mesh.
  18875. * @param mesh The mesh to test against the light
  18876. * @return true the mesh is affected otherwise, false.
  18877. */
  18878. canAffectMesh(mesh: AbstractMesh): boolean;
  18879. /**
  18880. * Sort function to order lights for rendering.
  18881. * @param a First Light object to compare to second.
  18882. * @param b Second Light object to compare first.
  18883. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18884. */
  18885. static CompareLightsPriority(a: Light, b: Light): number;
  18886. /**
  18887. * Releases resources associated with this node.
  18888. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18889. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18890. */
  18891. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18892. /**
  18893. * Returns the light type ID (integer).
  18894. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18895. */
  18896. getTypeID(): number;
  18897. /**
  18898. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18899. * @returns the scaled intensity in intensity mode unit
  18900. */
  18901. getScaledIntensity(): number;
  18902. /**
  18903. * Returns a new Light object, named "name", from the current one.
  18904. * @param name The name of the cloned light
  18905. * @param newParent The parent of this light, if it has one
  18906. * @returns the new created light
  18907. */
  18908. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18909. /**
  18910. * Serializes the current light into a Serialization object.
  18911. * @returns the serialized object.
  18912. */
  18913. serialize(): any;
  18914. /**
  18915. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18916. * This new light is named "name" and added to the passed scene.
  18917. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18918. * @param name The friendly name of the light
  18919. * @param scene The scene the new light will belong to
  18920. * @returns the constructor function
  18921. */
  18922. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18923. /**
  18924. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18925. * @param parsedLight The JSON representation of the light
  18926. * @param scene The scene to create the parsed light in
  18927. * @returns the created light after parsing
  18928. */
  18929. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18930. private _hookArrayForExcluded;
  18931. private _hookArrayForIncludedOnly;
  18932. private _resyncMeshes;
  18933. /**
  18934. * Forces the meshes to update their light related information in their rendering used effects
  18935. * @hidden Internal Use Only
  18936. */
  18937. _markMeshesAsLightDirty(): void;
  18938. /**
  18939. * Recomputes the cached photometric scale if needed.
  18940. */
  18941. private _computePhotometricScale;
  18942. /**
  18943. * Returns the Photometric Scale according to the light type and intensity mode.
  18944. */
  18945. private _getPhotometricScale;
  18946. /**
  18947. * Reorder the light in the scene according to their defined priority.
  18948. * @hidden Internal Use Only
  18949. */
  18950. _reorderLightsInScene(): void;
  18951. /**
  18952. * Prepares the list of defines specific to the light type.
  18953. * @param defines the list of defines
  18954. * @param lightIndex defines the index of the light for the effect
  18955. */
  18956. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18957. }
  18958. }
  18959. declare module "babylonjs/Materials/prePassConfiguration" {
  18960. import { Matrix } from "babylonjs/Maths/math.vector";
  18961. import { Mesh } from "babylonjs/Meshes/mesh";
  18962. import { Scene } from "babylonjs/scene";
  18963. import { Effect } from "babylonjs/Materials/effect";
  18964. /**
  18965. * Configuration needed for prepass-capable materials
  18966. */
  18967. export class PrePassConfiguration {
  18968. /**
  18969. * Previous world matrices of meshes carrying this material
  18970. * Used for computing velocity
  18971. */
  18972. previousWorldMatrices: {
  18973. [index: number]: Matrix;
  18974. };
  18975. /**
  18976. * Previous view project matrix
  18977. * Used for computing velocity
  18978. */
  18979. previousViewProjection: Matrix;
  18980. /**
  18981. * Previous bones of meshes carrying this material
  18982. * Used for computing velocity
  18983. */
  18984. previousBones: {
  18985. [index: number]: Float32Array;
  18986. };
  18987. /**
  18988. * Add the required uniforms to the current list.
  18989. * @param uniforms defines the current uniform list.
  18990. */
  18991. static AddUniforms(uniforms: string[]): void;
  18992. /**
  18993. * Add the required samplers to the current list.
  18994. * @param samplers defines the current sampler list.
  18995. */
  18996. static AddSamplers(samplers: string[]): void;
  18997. /**
  18998. * Binds the material data.
  18999. * @param effect defines the effect to update
  19000. * @param scene defines the scene the material belongs to.
  19001. * @param mesh The mesh
  19002. * @param world World matrix of this mesh
  19003. * @param isFrozen Is the material frozen
  19004. */
  19005. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19006. }
  19007. }
  19008. declare module "babylonjs/Cameras/targetCamera" {
  19009. import { Nullable } from "babylonjs/types";
  19010. import { Camera } from "babylonjs/Cameras/camera";
  19011. import { Scene } from "babylonjs/scene";
  19012. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19013. /**
  19014. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19015. * This is the base of the follow, arc rotate cameras and Free camera
  19016. * @see https://doc.babylonjs.com/features/cameras
  19017. */
  19018. export class TargetCamera extends Camera {
  19019. private static _RigCamTransformMatrix;
  19020. private static _TargetTransformMatrix;
  19021. private static _TargetFocalPoint;
  19022. private _tmpUpVector;
  19023. private _tmpTargetVector;
  19024. /**
  19025. * Define the current direction the camera is moving to
  19026. */
  19027. cameraDirection: Vector3;
  19028. /**
  19029. * Define the current rotation the camera is rotating to
  19030. */
  19031. cameraRotation: Vector2;
  19032. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19033. ignoreParentScaling: boolean;
  19034. /**
  19035. * When set, the up vector of the camera will be updated by the rotation of the camera
  19036. */
  19037. updateUpVectorFromRotation: boolean;
  19038. private _tmpQuaternion;
  19039. /**
  19040. * Define the current rotation of the camera
  19041. */
  19042. rotation: Vector3;
  19043. /**
  19044. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19045. */
  19046. rotationQuaternion: Quaternion;
  19047. /**
  19048. * Define the current speed of the camera
  19049. */
  19050. speed: number;
  19051. /**
  19052. * Add constraint to the camera to prevent it to move freely in all directions and
  19053. * around all axis.
  19054. */
  19055. noRotationConstraint: boolean;
  19056. /**
  19057. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19058. * panning
  19059. */
  19060. invertRotation: boolean;
  19061. /**
  19062. * Speed multiplier for inverse camera panning
  19063. */
  19064. inverseRotationSpeed: number;
  19065. /**
  19066. * Define the current target of the camera as an object or a position.
  19067. */
  19068. lockedTarget: any;
  19069. /** @hidden */
  19070. _currentTarget: Vector3;
  19071. /** @hidden */
  19072. _initialFocalDistance: number;
  19073. /** @hidden */
  19074. _viewMatrix: Matrix;
  19075. /** @hidden */
  19076. _camMatrix: Matrix;
  19077. /** @hidden */
  19078. _cameraTransformMatrix: Matrix;
  19079. /** @hidden */
  19080. _cameraRotationMatrix: Matrix;
  19081. /** @hidden */
  19082. _referencePoint: Vector3;
  19083. /** @hidden */
  19084. _transformedReferencePoint: Vector3;
  19085. /** @hidden */
  19086. _reset: () => void;
  19087. private _defaultUp;
  19088. /**
  19089. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19090. * This is the base of the follow, arc rotate cameras and Free camera
  19091. * @see https://doc.babylonjs.com/features/cameras
  19092. * @param name Defines the name of the camera in the scene
  19093. * @param position Defines the start position of the camera in the scene
  19094. * @param scene Defines the scene the camera belongs to
  19095. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19096. */
  19097. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19098. /**
  19099. * Gets the position in front of the camera at a given distance.
  19100. * @param distance The distance from the camera we want the position to be
  19101. * @returns the position
  19102. */
  19103. getFrontPosition(distance: number): Vector3;
  19104. /** @hidden */
  19105. _getLockedTargetPosition(): Nullable<Vector3>;
  19106. private _storedPosition;
  19107. private _storedRotation;
  19108. private _storedRotationQuaternion;
  19109. /**
  19110. * Store current camera state of the camera (fov, position, rotation, etc..)
  19111. * @returns the camera
  19112. */
  19113. storeState(): Camera;
  19114. /**
  19115. * Restored camera state. You must call storeState() first
  19116. * @returns whether it was successful or not
  19117. * @hidden
  19118. */
  19119. _restoreStateValues(): boolean;
  19120. /** @hidden */
  19121. _initCache(): void;
  19122. /** @hidden */
  19123. _updateCache(ignoreParentClass?: boolean): void;
  19124. /** @hidden */
  19125. _isSynchronizedViewMatrix(): boolean;
  19126. /** @hidden */
  19127. _computeLocalCameraSpeed(): number;
  19128. /**
  19129. * Defines the target the camera should look at.
  19130. * @param target Defines the new target as a Vector or a mesh
  19131. */
  19132. setTarget(target: Vector3): void;
  19133. /**
  19134. * Defines the target point of the camera.
  19135. * The camera looks towards it form the radius distance.
  19136. */
  19137. get target(): Vector3;
  19138. set target(value: Vector3);
  19139. /**
  19140. * Return the current target position of the camera. This value is expressed in local space.
  19141. * @returns the target position
  19142. */
  19143. getTarget(): Vector3;
  19144. /** @hidden */
  19145. _decideIfNeedsToMove(): boolean;
  19146. /** @hidden */
  19147. _updatePosition(): void;
  19148. /** @hidden */
  19149. _checkInputs(): void;
  19150. protected _updateCameraRotationMatrix(): void;
  19151. /**
  19152. * 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)
  19153. * @returns the current camera
  19154. */
  19155. private _rotateUpVectorWithCameraRotationMatrix;
  19156. private _cachedRotationZ;
  19157. private _cachedQuaternionRotationZ;
  19158. /** @hidden */
  19159. _getViewMatrix(): Matrix;
  19160. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19161. /**
  19162. * @hidden
  19163. */
  19164. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19165. /**
  19166. * @hidden
  19167. */
  19168. _updateRigCameras(): void;
  19169. private _getRigCamPositionAndTarget;
  19170. /**
  19171. * Gets the current object class name.
  19172. * @return the class name
  19173. */
  19174. getClassName(): string;
  19175. }
  19176. }
  19177. declare module "babylonjs/Events/keyboardEvents" {
  19178. /**
  19179. * Gather the list of keyboard event types as constants.
  19180. */
  19181. export class KeyboardEventTypes {
  19182. /**
  19183. * The keydown event is fired when a key becomes active (pressed).
  19184. */
  19185. static readonly KEYDOWN: number;
  19186. /**
  19187. * The keyup event is fired when a key has been released.
  19188. */
  19189. static readonly KEYUP: number;
  19190. }
  19191. /**
  19192. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19193. */
  19194. export class KeyboardInfo {
  19195. /**
  19196. * Defines the type of event (KeyboardEventTypes)
  19197. */
  19198. type: number;
  19199. /**
  19200. * Defines the related dom event
  19201. */
  19202. event: KeyboardEvent;
  19203. /**
  19204. * Instantiates a new keyboard info.
  19205. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19206. * @param type Defines the type of event (KeyboardEventTypes)
  19207. * @param event Defines the related dom event
  19208. */
  19209. constructor(
  19210. /**
  19211. * Defines the type of event (KeyboardEventTypes)
  19212. */
  19213. type: number,
  19214. /**
  19215. * Defines the related dom event
  19216. */
  19217. event: KeyboardEvent);
  19218. }
  19219. /**
  19220. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19221. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19222. */
  19223. export class KeyboardInfoPre extends KeyboardInfo {
  19224. /**
  19225. * Defines the type of event (KeyboardEventTypes)
  19226. */
  19227. type: number;
  19228. /**
  19229. * Defines the related dom event
  19230. */
  19231. event: KeyboardEvent;
  19232. /**
  19233. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19234. */
  19235. skipOnPointerObservable: boolean;
  19236. /**
  19237. * Instantiates a new keyboard pre info.
  19238. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19239. * @param type Defines the type of event (KeyboardEventTypes)
  19240. * @param event Defines the related dom event
  19241. */
  19242. constructor(
  19243. /**
  19244. * Defines the type of event (KeyboardEventTypes)
  19245. */
  19246. type: number,
  19247. /**
  19248. * Defines the related dom event
  19249. */
  19250. event: KeyboardEvent);
  19251. }
  19252. }
  19253. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19254. import { Nullable } from "babylonjs/types";
  19255. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19256. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19257. /**
  19258. * Manage the keyboard inputs to control the movement of a free camera.
  19259. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19260. */
  19261. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19262. /**
  19263. * Defines the camera the input is attached to.
  19264. */
  19265. camera: FreeCamera;
  19266. /**
  19267. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19268. */
  19269. keysUp: number[];
  19270. /**
  19271. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19272. */
  19273. keysUpward: number[];
  19274. /**
  19275. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19276. */
  19277. keysDown: number[];
  19278. /**
  19279. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19280. */
  19281. keysDownward: number[];
  19282. /**
  19283. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19284. */
  19285. keysLeft: number[];
  19286. /**
  19287. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19288. */
  19289. keysRight: number[];
  19290. private _keys;
  19291. private _onCanvasBlurObserver;
  19292. private _onKeyboardObserver;
  19293. private _engine;
  19294. private _scene;
  19295. /**
  19296. * Attach the input controls to a specific dom element to get the input from.
  19297. * @param element Defines the element the controls should be listened from
  19298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19299. */
  19300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19301. /**
  19302. * Detach the current controls from the specified dom element.
  19303. * @param element Defines the element to stop listening the inputs from
  19304. */
  19305. detachControl(element: Nullable<HTMLElement>): void;
  19306. /**
  19307. * Update the current camera state depending on the inputs that have been used this frame.
  19308. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19309. */
  19310. checkInputs(): void;
  19311. /**
  19312. * Gets the class name of the current intput.
  19313. * @returns the class name
  19314. */
  19315. getClassName(): string;
  19316. /** @hidden */
  19317. _onLostFocus(): void;
  19318. /**
  19319. * Get the friendly name associated with the input class.
  19320. * @returns the input friendly name
  19321. */
  19322. getSimpleName(): string;
  19323. }
  19324. }
  19325. declare module "babylonjs/Events/pointerEvents" {
  19326. import { Nullable } from "babylonjs/types";
  19327. import { Vector2 } from "babylonjs/Maths/math.vector";
  19328. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19329. import { Ray } from "babylonjs/Culling/ray";
  19330. /**
  19331. * Gather the list of pointer event types as constants.
  19332. */
  19333. export class PointerEventTypes {
  19334. /**
  19335. * 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.
  19336. */
  19337. static readonly POINTERDOWN: number;
  19338. /**
  19339. * The pointerup event is fired when a pointer is no longer active.
  19340. */
  19341. static readonly POINTERUP: number;
  19342. /**
  19343. * The pointermove event is fired when a pointer changes coordinates.
  19344. */
  19345. static readonly POINTERMOVE: number;
  19346. /**
  19347. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19348. */
  19349. static readonly POINTERWHEEL: number;
  19350. /**
  19351. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19352. */
  19353. static readonly POINTERPICK: number;
  19354. /**
  19355. * The pointertap event is fired when a the object has been touched and released without drag.
  19356. */
  19357. static readonly POINTERTAP: number;
  19358. /**
  19359. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19360. */
  19361. static readonly POINTERDOUBLETAP: number;
  19362. }
  19363. /**
  19364. * Base class of pointer info types.
  19365. */
  19366. export class PointerInfoBase {
  19367. /**
  19368. * Defines the type of event (PointerEventTypes)
  19369. */
  19370. type: number;
  19371. /**
  19372. * Defines the related dom event
  19373. */
  19374. event: PointerEvent | MouseWheelEvent;
  19375. /**
  19376. * Instantiates the base class of pointers info.
  19377. * @param type Defines the type of event (PointerEventTypes)
  19378. * @param event Defines the related dom event
  19379. */
  19380. constructor(
  19381. /**
  19382. * Defines the type of event (PointerEventTypes)
  19383. */
  19384. type: number,
  19385. /**
  19386. * Defines the related dom event
  19387. */
  19388. event: PointerEvent | MouseWheelEvent);
  19389. }
  19390. /**
  19391. * This class is used to store pointer related info for the onPrePointerObservable event.
  19392. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19393. */
  19394. export class PointerInfoPre extends PointerInfoBase {
  19395. /**
  19396. * Ray from a pointer if availible (eg. 6dof controller)
  19397. */
  19398. ray: Nullable<Ray>;
  19399. /**
  19400. * Defines the local position of the pointer on the canvas.
  19401. */
  19402. localPosition: Vector2;
  19403. /**
  19404. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19405. */
  19406. skipOnPointerObservable: boolean;
  19407. /**
  19408. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19409. * @param type Defines the type of event (PointerEventTypes)
  19410. * @param event Defines the related dom event
  19411. * @param localX Defines the local x coordinates of the pointer when the event occured
  19412. * @param localY Defines the local y coordinates of the pointer when the event occured
  19413. */
  19414. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19415. }
  19416. /**
  19417. * This type contains all the data related to a pointer event in Babylon.js.
  19418. * 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.
  19419. */
  19420. export class PointerInfo extends PointerInfoBase {
  19421. /**
  19422. * Defines the picking info associated to the info (if any)\
  19423. */
  19424. pickInfo: Nullable<PickingInfo>;
  19425. /**
  19426. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19427. * @param type Defines the type of event (PointerEventTypes)
  19428. * @param event Defines the related dom event
  19429. * @param pickInfo Defines the picking info associated to the info (if any)\
  19430. */
  19431. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19432. /**
  19433. * Defines the picking info associated to the info (if any)\
  19434. */
  19435. pickInfo: Nullable<PickingInfo>);
  19436. }
  19437. /**
  19438. * Data relating to a touch event on the screen.
  19439. */
  19440. export interface PointerTouch {
  19441. /**
  19442. * X coordinate of touch.
  19443. */
  19444. x: number;
  19445. /**
  19446. * Y coordinate of touch.
  19447. */
  19448. y: number;
  19449. /**
  19450. * Id of touch. Unique for each finger.
  19451. */
  19452. pointerId: number;
  19453. /**
  19454. * Event type passed from DOM.
  19455. */
  19456. type: any;
  19457. }
  19458. }
  19459. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19460. import { Observable } from "babylonjs/Misc/observable";
  19461. import { Nullable } from "babylonjs/types";
  19462. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19463. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19464. /**
  19465. * Manage the mouse inputs to control the movement of a free camera.
  19466. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19467. */
  19468. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19469. /**
  19470. * Define if touch is enabled in the mouse input
  19471. */
  19472. touchEnabled: boolean;
  19473. /**
  19474. * Defines the camera the input is attached to.
  19475. */
  19476. camera: FreeCamera;
  19477. /**
  19478. * Defines the buttons associated with the input to handle camera move.
  19479. */
  19480. buttons: number[];
  19481. /**
  19482. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19483. */
  19484. angularSensibility: number;
  19485. private _pointerInput;
  19486. private _onMouseMove;
  19487. private _observer;
  19488. private previousPosition;
  19489. /**
  19490. * Observable for when a pointer move event occurs containing the move offset
  19491. */
  19492. onPointerMovedObservable: Observable<{
  19493. offsetX: number;
  19494. offsetY: number;
  19495. }>;
  19496. /**
  19497. * @hidden
  19498. * If the camera should be rotated automatically based on pointer movement
  19499. */
  19500. _allowCameraRotation: boolean;
  19501. /**
  19502. * Manage the mouse inputs to control the movement of a free camera.
  19503. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19504. * @param touchEnabled Defines if touch is enabled or not
  19505. */
  19506. constructor(
  19507. /**
  19508. * Define if touch is enabled in the mouse input
  19509. */
  19510. touchEnabled?: boolean);
  19511. /**
  19512. * Attach the input controls to a specific dom element to get the input from.
  19513. * @param element Defines the element the controls should be listened from
  19514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19515. */
  19516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19517. /**
  19518. * Called on JS contextmenu event.
  19519. * Override this method to provide functionality.
  19520. */
  19521. protected onContextMenu(evt: PointerEvent): void;
  19522. /**
  19523. * Detach the current controls from the specified dom element.
  19524. * @param element Defines the element to stop listening the inputs from
  19525. */
  19526. detachControl(element: Nullable<HTMLElement>): void;
  19527. /**
  19528. * Gets the class name of the current intput.
  19529. * @returns the class name
  19530. */
  19531. getClassName(): string;
  19532. /**
  19533. * Get the friendly name associated with the input class.
  19534. * @returns the input friendly name
  19535. */
  19536. getSimpleName(): string;
  19537. }
  19538. }
  19539. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19540. import { Nullable } from "babylonjs/types";
  19541. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19542. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19543. /**
  19544. * Manage the touch inputs to control the movement of a free camera.
  19545. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19546. */
  19547. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19548. /**
  19549. * Define if mouse events can be treated as touch events
  19550. */
  19551. allowMouse: boolean;
  19552. /**
  19553. * Defines the camera the input is attached to.
  19554. */
  19555. camera: FreeCamera;
  19556. /**
  19557. * Defines the touch sensibility for rotation.
  19558. * The higher the faster.
  19559. */
  19560. touchAngularSensibility: number;
  19561. /**
  19562. * Defines the touch sensibility for move.
  19563. * The higher the faster.
  19564. */
  19565. touchMoveSensibility: number;
  19566. private _offsetX;
  19567. private _offsetY;
  19568. private _pointerPressed;
  19569. private _pointerInput;
  19570. private _observer;
  19571. private _onLostFocus;
  19572. /**
  19573. * Manage the touch inputs to control the movement of a free camera.
  19574. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19575. * @param allowMouse Defines if mouse events can be treated as touch events
  19576. */
  19577. constructor(
  19578. /**
  19579. * Define if mouse events can be treated as touch events
  19580. */
  19581. allowMouse?: boolean);
  19582. /**
  19583. * Attach the input controls to a specific dom element to get the input from.
  19584. * @param element Defines the element the controls should be listened from
  19585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19586. */
  19587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19588. /**
  19589. * Detach the current controls from the specified dom element.
  19590. * @param element Defines the element to stop listening the inputs from
  19591. */
  19592. detachControl(element: Nullable<HTMLElement>): void;
  19593. /**
  19594. * Update the current camera state depending on the inputs that have been used this frame.
  19595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19596. */
  19597. checkInputs(): void;
  19598. /**
  19599. * Gets the class name of the current intput.
  19600. * @returns the class name
  19601. */
  19602. getClassName(): string;
  19603. /**
  19604. * Get the friendly name associated with the input class.
  19605. * @returns the input friendly name
  19606. */
  19607. getSimpleName(): string;
  19608. }
  19609. }
  19610. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19611. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19612. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19613. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19614. import { Nullable } from "babylonjs/types";
  19615. /**
  19616. * Default Inputs manager for the FreeCamera.
  19617. * It groups all the default supported inputs for ease of use.
  19618. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19619. */
  19620. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19621. /**
  19622. * @hidden
  19623. */
  19624. _mouseInput: Nullable<FreeCameraMouseInput>;
  19625. /**
  19626. * Instantiates a new FreeCameraInputsManager.
  19627. * @param camera Defines the camera the inputs belong to
  19628. */
  19629. constructor(camera: FreeCamera);
  19630. /**
  19631. * Add keyboard input support to the input manager.
  19632. * @returns the current input manager
  19633. */
  19634. addKeyboard(): FreeCameraInputsManager;
  19635. /**
  19636. * Add mouse input support to the input manager.
  19637. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19638. * @returns the current input manager
  19639. */
  19640. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19641. /**
  19642. * Removes the mouse input support from the manager
  19643. * @returns the current input manager
  19644. */
  19645. removeMouse(): FreeCameraInputsManager;
  19646. /**
  19647. * Add touch input support to the input manager.
  19648. * @returns the current input manager
  19649. */
  19650. addTouch(): FreeCameraInputsManager;
  19651. /**
  19652. * Remove all attached input methods from a camera
  19653. */
  19654. clear(): void;
  19655. }
  19656. }
  19657. declare module "babylonjs/Cameras/freeCamera" {
  19658. import { Vector3 } from "babylonjs/Maths/math.vector";
  19659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19660. import { Scene } from "babylonjs/scene";
  19661. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19662. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19663. /**
  19664. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19665. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19666. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19667. */
  19668. export class FreeCamera extends TargetCamera {
  19669. /**
  19670. * Define the collision ellipsoid of the camera.
  19671. * This is helpful to simulate a camera body like the player body around the camera
  19672. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19673. */
  19674. ellipsoid: Vector3;
  19675. /**
  19676. * Define an offset for the position of the ellipsoid around the camera.
  19677. * This can be helpful to determine the center of the body near the gravity center of the body
  19678. * instead of its head.
  19679. */
  19680. ellipsoidOffset: Vector3;
  19681. /**
  19682. * Enable or disable collisions of the camera with the rest of the scene objects.
  19683. */
  19684. checkCollisions: boolean;
  19685. /**
  19686. * Enable or disable gravity on the camera.
  19687. */
  19688. applyGravity: boolean;
  19689. /**
  19690. * Define the input manager associated to the camera.
  19691. */
  19692. inputs: FreeCameraInputsManager;
  19693. /**
  19694. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19695. * Higher values reduce sensitivity.
  19696. */
  19697. get angularSensibility(): number;
  19698. /**
  19699. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19700. * Higher values reduce sensitivity.
  19701. */
  19702. set angularSensibility(value: number);
  19703. /**
  19704. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19705. */
  19706. get keysUp(): number[];
  19707. set keysUp(value: number[]);
  19708. /**
  19709. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19710. */
  19711. get keysUpward(): number[];
  19712. set keysUpward(value: number[]);
  19713. /**
  19714. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19715. */
  19716. get keysDown(): number[];
  19717. set keysDown(value: number[]);
  19718. /**
  19719. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19720. */
  19721. get keysDownward(): number[];
  19722. set keysDownward(value: number[]);
  19723. /**
  19724. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19725. */
  19726. get keysLeft(): number[];
  19727. set keysLeft(value: number[]);
  19728. /**
  19729. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19730. */
  19731. get keysRight(): number[];
  19732. set keysRight(value: number[]);
  19733. /**
  19734. * Event raised when the camera collide with a mesh in the scene.
  19735. */
  19736. onCollide: (collidedMesh: AbstractMesh) => void;
  19737. private _collider;
  19738. private _needMoveForGravity;
  19739. private _oldPosition;
  19740. private _diffPosition;
  19741. private _newPosition;
  19742. /** @hidden */
  19743. _localDirection: Vector3;
  19744. /** @hidden */
  19745. _transformedDirection: Vector3;
  19746. /**
  19747. * Instantiates a Free Camera.
  19748. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19749. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19750. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19751. * @param name Define the name of the camera in the scene
  19752. * @param position Define the start position of the camera in the scene
  19753. * @param scene Define the scene the camera belongs to
  19754. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19755. */
  19756. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19757. /**
  19758. * Attached controls to the current camera.
  19759. * @param element Defines the element the controls should be listened from
  19760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19761. */
  19762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19763. /**
  19764. * Detach the current controls from the camera.
  19765. * The camera will stop reacting to inputs.
  19766. * @param element Defines the element to stop listening the inputs from
  19767. */
  19768. detachControl(element: HTMLElement): void;
  19769. private _collisionMask;
  19770. /**
  19771. * Define a collision mask to limit the list of object the camera can collide with
  19772. */
  19773. get collisionMask(): number;
  19774. set collisionMask(mask: number);
  19775. /** @hidden */
  19776. _collideWithWorld(displacement: Vector3): void;
  19777. private _onCollisionPositionChange;
  19778. /** @hidden */
  19779. _checkInputs(): void;
  19780. /** @hidden */
  19781. _decideIfNeedsToMove(): boolean;
  19782. /** @hidden */
  19783. _updatePosition(): void;
  19784. /**
  19785. * Destroy the camera and release the current resources hold by it.
  19786. */
  19787. dispose(): void;
  19788. /**
  19789. * Gets the current object class name.
  19790. * @return the class name
  19791. */
  19792. getClassName(): string;
  19793. }
  19794. }
  19795. declare module "babylonjs/Gamepads/gamepad" {
  19796. import { Observable } from "babylonjs/Misc/observable";
  19797. /**
  19798. * Represents a gamepad control stick position
  19799. */
  19800. export class StickValues {
  19801. /**
  19802. * The x component of the control stick
  19803. */
  19804. x: number;
  19805. /**
  19806. * The y component of the control stick
  19807. */
  19808. y: number;
  19809. /**
  19810. * Initializes the gamepad x and y control stick values
  19811. * @param x The x component of the gamepad control stick value
  19812. * @param y The y component of the gamepad control stick value
  19813. */
  19814. constructor(
  19815. /**
  19816. * The x component of the control stick
  19817. */
  19818. x: number,
  19819. /**
  19820. * The y component of the control stick
  19821. */
  19822. y: number);
  19823. }
  19824. /**
  19825. * An interface which manages callbacks for gamepad button changes
  19826. */
  19827. export interface GamepadButtonChanges {
  19828. /**
  19829. * Called when a gamepad has been changed
  19830. */
  19831. changed: boolean;
  19832. /**
  19833. * Called when a gamepad press event has been triggered
  19834. */
  19835. pressChanged: boolean;
  19836. /**
  19837. * Called when a touch event has been triggered
  19838. */
  19839. touchChanged: boolean;
  19840. /**
  19841. * Called when a value has changed
  19842. */
  19843. valueChanged: boolean;
  19844. }
  19845. /**
  19846. * Represents a gamepad
  19847. */
  19848. export class Gamepad {
  19849. /**
  19850. * The id of the gamepad
  19851. */
  19852. id: string;
  19853. /**
  19854. * The index of the gamepad
  19855. */
  19856. index: number;
  19857. /**
  19858. * The browser gamepad
  19859. */
  19860. browserGamepad: any;
  19861. /**
  19862. * Specifies what type of gamepad this represents
  19863. */
  19864. type: number;
  19865. private _leftStick;
  19866. private _rightStick;
  19867. /** @hidden */
  19868. _isConnected: boolean;
  19869. private _leftStickAxisX;
  19870. private _leftStickAxisY;
  19871. private _rightStickAxisX;
  19872. private _rightStickAxisY;
  19873. /**
  19874. * Triggered when the left control stick has been changed
  19875. */
  19876. private _onleftstickchanged;
  19877. /**
  19878. * Triggered when the right control stick has been changed
  19879. */
  19880. private _onrightstickchanged;
  19881. /**
  19882. * Represents a gamepad controller
  19883. */
  19884. static GAMEPAD: number;
  19885. /**
  19886. * Represents a generic controller
  19887. */
  19888. static GENERIC: number;
  19889. /**
  19890. * Represents an XBox controller
  19891. */
  19892. static XBOX: number;
  19893. /**
  19894. * Represents a pose-enabled controller
  19895. */
  19896. static POSE_ENABLED: number;
  19897. /**
  19898. * Represents an Dual Shock controller
  19899. */
  19900. static DUALSHOCK: number;
  19901. /**
  19902. * Specifies whether the left control stick should be Y-inverted
  19903. */
  19904. protected _invertLeftStickY: boolean;
  19905. /**
  19906. * Specifies if the gamepad has been connected
  19907. */
  19908. get isConnected(): boolean;
  19909. /**
  19910. * Initializes the gamepad
  19911. * @param id The id of the gamepad
  19912. * @param index The index of the gamepad
  19913. * @param browserGamepad The browser gamepad
  19914. * @param leftStickX The x component of the left joystick
  19915. * @param leftStickY The y component of the left joystick
  19916. * @param rightStickX The x component of the right joystick
  19917. * @param rightStickY The y component of the right joystick
  19918. */
  19919. constructor(
  19920. /**
  19921. * The id of the gamepad
  19922. */
  19923. id: string,
  19924. /**
  19925. * The index of the gamepad
  19926. */
  19927. index: number,
  19928. /**
  19929. * The browser gamepad
  19930. */
  19931. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19932. /**
  19933. * Callback triggered when the left joystick has changed
  19934. * @param callback
  19935. */
  19936. onleftstickchanged(callback: (values: StickValues) => void): void;
  19937. /**
  19938. * Callback triggered when the right joystick has changed
  19939. * @param callback
  19940. */
  19941. onrightstickchanged(callback: (values: StickValues) => void): void;
  19942. /**
  19943. * Gets the left joystick
  19944. */
  19945. get leftStick(): StickValues;
  19946. /**
  19947. * Sets the left joystick values
  19948. */
  19949. set leftStick(newValues: StickValues);
  19950. /**
  19951. * Gets the right joystick
  19952. */
  19953. get rightStick(): StickValues;
  19954. /**
  19955. * Sets the right joystick value
  19956. */
  19957. set rightStick(newValues: StickValues);
  19958. /**
  19959. * Updates the gamepad joystick positions
  19960. */
  19961. update(): void;
  19962. /**
  19963. * Disposes the gamepad
  19964. */
  19965. dispose(): void;
  19966. }
  19967. /**
  19968. * Represents a generic gamepad
  19969. */
  19970. export class GenericPad extends Gamepad {
  19971. private _buttons;
  19972. private _onbuttondown;
  19973. private _onbuttonup;
  19974. /**
  19975. * Observable triggered when a button has been pressed
  19976. */
  19977. onButtonDownObservable: Observable<number>;
  19978. /**
  19979. * Observable triggered when a button has been released
  19980. */
  19981. onButtonUpObservable: Observable<number>;
  19982. /**
  19983. * Callback triggered when a button has been pressed
  19984. * @param callback Called when a button has been pressed
  19985. */
  19986. onbuttondown(callback: (buttonPressed: number) => void): void;
  19987. /**
  19988. * Callback triggered when a button has been released
  19989. * @param callback Called when a button has been released
  19990. */
  19991. onbuttonup(callback: (buttonReleased: number) => void): void;
  19992. /**
  19993. * Initializes the generic gamepad
  19994. * @param id The id of the generic gamepad
  19995. * @param index The index of the generic gamepad
  19996. * @param browserGamepad The browser gamepad
  19997. */
  19998. constructor(id: string, index: number, browserGamepad: any);
  19999. private _setButtonValue;
  20000. /**
  20001. * Updates the generic gamepad
  20002. */
  20003. update(): void;
  20004. /**
  20005. * Disposes the generic gamepad
  20006. */
  20007. dispose(): void;
  20008. }
  20009. }
  20010. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20011. import { Observable } from "babylonjs/Misc/observable";
  20012. import { Nullable } from "babylonjs/types";
  20013. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20014. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20016. import { Ray } from "babylonjs/Culling/ray";
  20017. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20018. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20019. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20020. /**
  20021. * Defines the types of pose enabled controllers that are supported
  20022. */
  20023. export enum PoseEnabledControllerType {
  20024. /**
  20025. * HTC Vive
  20026. */
  20027. VIVE = 0,
  20028. /**
  20029. * Oculus Rift
  20030. */
  20031. OCULUS = 1,
  20032. /**
  20033. * Windows mixed reality
  20034. */
  20035. WINDOWS = 2,
  20036. /**
  20037. * Samsung gear VR
  20038. */
  20039. GEAR_VR = 3,
  20040. /**
  20041. * Google Daydream
  20042. */
  20043. DAYDREAM = 4,
  20044. /**
  20045. * Generic
  20046. */
  20047. GENERIC = 5
  20048. }
  20049. /**
  20050. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20051. */
  20052. export interface MutableGamepadButton {
  20053. /**
  20054. * Value of the button/trigger
  20055. */
  20056. value: number;
  20057. /**
  20058. * If the button/trigger is currently touched
  20059. */
  20060. touched: boolean;
  20061. /**
  20062. * If the button/trigger is currently pressed
  20063. */
  20064. pressed: boolean;
  20065. }
  20066. /**
  20067. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20068. * @hidden
  20069. */
  20070. export interface ExtendedGamepadButton extends GamepadButton {
  20071. /**
  20072. * If the button/trigger is currently pressed
  20073. */
  20074. readonly pressed: boolean;
  20075. /**
  20076. * If the button/trigger is currently touched
  20077. */
  20078. readonly touched: boolean;
  20079. /**
  20080. * Value of the button/trigger
  20081. */
  20082. readonly value: number;
  20083. }
  20084. /** @hidden */
  20085. export interface _GamePadFactory {
  20086. /**
  20087. * Returns whether or not the current gamepad can be created for this type of controller.
  20088. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20089. * @returns true if it can be created, otherwise false
  20090. */
  20091. canCreate(gamepadInfo: any): boolean;
  20092. /**
  20093. * Creates a new instance of the Gamepad.
  20094. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20095. * @returns the new gamepad instance
  20096. */
  20097. create(gamepadInfo: any): Gamepad;
  20098. }
  20099. /**
  20100. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20101. */
  20102. export class PoseEnabledControllerHelper {
  20103. /** @hidden */
  20104. static _ControllerFactories: _GamePadFactory[];
  20105. /** @hidden */
  20106. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20107. /**
  20108. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20109. * @param vrGamepad the gamepad to initialized
  20110. * @returns a vr controller of the type the gamepad identified as
  20111. */
  20112. static InitiateController(vrGamepad: any): Gamepad;
  20113. }
  20114. /**
  20115. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20116. */
  20117. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20118. /**
  20119. * If the controller is used in a webXR session
  20120. */
  20121. isXR: boolean;
  20122. private _deviceRoomPosition;
  20123. private _deviceRoomRotationQuaternion;
  20124. /**
  20125. * The device position in babylon space
  20126. */
  20127. devicePosition: Vector3;
  20128. /**
  20129. * The device rotation in babylon space
  20130. */
  20131. deviceRotationQuaternion: Quaternion;
  20132. /**
  20133. * The scale factor of the device in babylon space
  20134. */
  20135. deviceScaleFactor: number;
  20136. /**
  20137. * (Likely devicePosition should be used instead) The device position in its room space
  20138. */
  20139. position: Vector3;
  20140. /**
  20141. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20142. */
  20143. rotationQuaternion: Quaternion;
  20144. /**
  20145. * The type of controller (Eg. Windows mixed reality)
  20146. */
  20147. controllerType: PoseEnabledControllerType;
  20148. protected _calculatedPosition: Vector3;
  20149. private _calculatedRotation;
  20150. /**
  20151. * The raw pose from the device
  20152. */
  20153. rawPose: DevicePose;
  20154. private _trackPosition;
  20155. private _maxRotationDistFromHeadset;
  20156. private _draggedRoomRotation;
  20157. /**
  20158. * @hidden
  20159. */
  20160. _disableTrackPosition(fixedPosition: Vector3): void;
  20161. /**
  20162. * Internal, the mesh attached to the controller
  20163. * @hidden
  20164. */
  20165. _mesh: Nullable<AbstractMesh>;
  20166. private _poseControlledCamera;
  20167. private _leftHandSystemQuaternion;
  20168. /**
  20169. * Internal, matrix used to convert room space to babylon space
  20170. * @hidden
  20171. */
  20172. _deviceToWorld: Matrix;
  20173. /**
  20174. * Node to be used when casting a ray from the controller
  20175. * @hidden
  20176. */
  20177. _pointingPoseNode: Nullable<TransformNode>;
  20178. /**
  20179. * Name of the child mesh that can be used to cast a ray from the controller
  20180. */
  20181. static readonly POINTING_POSE: string;
  20182. /**
  20183. * Creates a new PoseEnabledController from a gamepad
  20184. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20185. */
  20186. constructor(browserGamepad: any);
  20187. private _workingMatrix;
  20188. /**
  20189. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20190. */
  20191. update(): void;
  20192. /**
  20193. * Updates only the pose device and mesh without doing any button event checking
  20194. */
  20195. protected _updatePoseAndMesh(): void;
  20196. /**
  20197. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20198. * @param poseData raw pose fromthe device
  20199. */
  20200. updateFromDevice(poseData: DevicePose): void;
  20201. /**
  20202. * @hidden
  20203. */
  20204. _meshAttachedObservable: Observable<AbstractMesh>;
  20205. /**
  20206. * Attaches a mesh to the controller
  20207. * @param mesh the mesh to be attached
  20208. */
  20209. attachToMesh(mesh: AbstractMesh): void;
  20210. /**
  20211. * Attaches the controllers mesh to a camera
  20212. * @param camera the camera the mesh should be attached to
  20213. */
  20214. attachToPoseControlledCamera(camera: TargetCamera): void;
  20215. /**
  20216. * Disposes of the controller
  20217. */
  20218. dispose(): void;
  20219. /**
  20220. * The mesh that is attached to the controller
  20221. */
  20222. get mesh(): Nullable<AbstractMesh>;
  20223. /**
  20224. * Gets the ray of the controller in the direction the controller is pointing
  20225. * @param length the length the resulting ray should be
  20226. * @returns a ray in the direction the controller is pointing
  20227. */
  20228. getForwardRay(length?: number): Ray;
  20229. }
  20230. }
  20231. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20232. import { Observable } from "babylonjs/Misc/observable";
  20233. import { Scene } from "babylonjs/scene";
  20234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20235. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20236. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20237. import { Nullable } from "babylonjs/types";
  20238. /**
  20239. * Defines the WebVRController object that represents controllers tracked in 3D space
  20240. */
  20241. export abstract class WebVRController extends PoseEnabledController {
  20242. /**
  20243. * Internal, the default controller model for the controller
  20244. */
  20245. protected _defaultModel: Nullable<AbstractMesh>;
  20246. /**
  20247. * Fired when the trigger state has changed
  20248. */
  20249. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20250. /**
  20251. * Fired when the main button state has changed
  20252. */
  20253. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20254. /**
  20255. * Fired when the secondary button state has changed
  20256. */
  20257. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20258. /**
  20259. * Fired when the pad state has changed
  20260. */
  20261. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20262. /**
  20263. * Fired when controllers stick values have changed
  20264. */
  20265. onPadValuesChangedObservable: Observable<StickValues>;
  20266. /**
  20267. * Array of button availible on the controller
  20268. */
  20269. protected _buttons: Array<MutableGamepadButton>;
  20270. private _onButtonStateChange;
  20271. /**
  20272. * Fired when a controller button's state has changed
  20273. * @param callback the callback containing the button that was modified
  20274. */
  20275. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20276. /**
  20277. * X and Y axis corresponding to the controllers joystick
  20278. */
  20279. pad: StickValues;
  20280. /**
  20281. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20282. */
  20283. hand: string;
  20284. /**
  20285. * The default controller model for the controller
  20286. */
  20287. get defaultModel(): Nullable<AbstractMesh>;
  20288. /**
  20289. * Creates a new WebVRController from a gamepad
  20290. * @param vrGamepad the gamepad that the WebVRController should be created from
  20291. */
  20292. constructor(vrGamepad: any);
  20293. /**
  20294. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20295. */
  20296. update(): void;
  20297. /**
  20298. * Function to be called when a button is modified
  20299. */
  20300. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20301. /**
  20302. * Loads a mesh and attaches it to the controller
  20303. * @param scene the scene the mesh should be added to
  20304. * @param meshLoaded callback for when the mesh has been loaded
  20305. */
  20306. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20307. private _setButtonValue;
  20308. private _changes;
  20309. private _checkChanges;
  20310. /**
  20311. * Disposes of th webVRCOntroller
  20312. */
  20313. dispose(): void;
  20314. }
  20315. }
  20316. declare module "babylonjs/Lights/hemisphericLight" {
  20317. import { Nullable } from "babylonjs/types";
  20318. import { Scene } from "babylonjs/scene";
  20319. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20320. import { Color3 } from "babylonjs/Maths/math.color";
  20321. import { Effect } from "babylonjs/Materials/effect";
  20322. import { Light } from "babylonjs/Lights/light";
  20323. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20324. /**
  20325. * The HemisphericLight simulates the ambient environment light,
  20326. * so the passed direction is the light reflection direction, not the incoming direction.
  20327. */
  20328. export class HemisphericLight extends Light {
  20329. /**
  20330. * The groundColor is the light in the opposite direction to the one specified during creation.
  20331. * 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.
  20332. */
  20333. groundColor: Color3;
  20334. /**
  20335. * The light reflection direction, not the incoming direction.
  20336. */
  20337. direction: Vector3;
  20338. /**
  20339. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20340. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20341. * The HemisphericLight can't cast shadows.
  20342. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20343. * @param name The friendly name of the light
  20344. * @param direction The direction of the light reflection
  20345. * @param scene The scene the light belongs to
  20346. */
  20347. constructor(name: string, direction: Vector3, scene: Scene);
  20348. protected _buildUniformLayout(): void;
  20349. /**
  20350. * Returns the string "HemisphericLight".
  20351. * @return The class name
  20352. */
  20353. getClassName(): string;
  20354. /**
  20355. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20356. * Returns the updated direction.
  20357. * @param target The target the direction should point to
  20358. * @return The computed direction
  20359. */
  20360. setDirectionToTarget(target: Vector3): Vector3;
  20361. /**
  20362. * Returns the shadow generator associated to the light.
  20363. * @returns Always null for hemispheric lights because it does not support shadows.
  20364. */
  20365. getShadowGenerator(): Nullable<IShadowGenerator>;
  20366. /**
  20367. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20368. * @param effect The effect to update
  20369. * @param lightIndex The index of the light in the effect to update
  20370. * @returns The hemispheric light
  20371. */
  20372. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20373. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20374. /**
  20375. * Computes the world matrix of the node
  20376. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20377. * @param useWasUpdatedFlag defines a reserved property
  20378. * @returns the world matrix
  20379. */
  20380. computeWorldMatrix(): Matrix;
  20381. /**
  20382. * Returns the integer 3.
  20383. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20384. */
  20385. getTypeID(): number;
  20386. /**
  20387. * Prepares the list of defines specific to the light type.
  20388. * @param defines the list of defines
  20389. * @param lightIndex defines the index of the light for the effect
  20390. */
  20391. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20392. }
  20393. }
  20394. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20395. /** @hidden */
  20396. export var vrMultiviewToSingleviewPixelShader: {
  20397. name: string;
  20398. shader: string;
  20399. };
  20400. }
  20401. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20402. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20403. import { Scene } from "babylonjs/scene";
  20404. /**
  20405. * Renders to multiple views with a single draw call
  20406. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20407. */
  20408. export class MultiviewRenderTarget extends RenderTargetTexture {
  20409. /**
  20410. * Creates a multiview render target
  20411. * @param scene scene used with the render target
  20412. * @param size the size of the render target (used for each view)
  20413. */
  20414. constructor(scene: Scene, size?: number | {
  20415. width: number;
  20416. height: number;
  20417. } | {
  20418. ratio: number;
  20419. });
  20420. /**
  20421. * @hidden
  20422. * @param faceIndex the face index, if its a cube texture
  20423. */
  20424. _bindFrameBuffer(faceIndex?: number): void;
  20425. /**
  20426. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20427. * @returns the view count
  20428. */
  20429. getViewCount(): number;
  20430. }
  20431. }
  20432. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20433. import { Camera } from "babylonjs/Cameras/camera";
  20434. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20435. import { Nullable } from "babylonjs/types";
  20436. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20437. import { Matrix } from "babylonjs/Maths/math.vector";
  20438. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20439. module "babylonjs/Engines/engine" {
  20440. interface Engine {
  20441. /**
  20442. * Creates a new multiview render target
  20443. * @param width defines the width of the texture
  20444. * @param height defines the height of the texture
  20445. * @returns the created multiview texture
  20446. */
  20447. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20448. /**
  20449. * Binds a multiview framebuffer to be drawn to
  20450. * @param multiviewTexture texture to bind
  20451. */
  20452. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20453. }
  20454. }
  20455. module "babylonjs/Cameras/camera" {
  20456. interface Camera {
  20457. /**
  20458. * @hidden
  20459. * 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)
  20460. */
  20461. _useMultiviewToSingleView: boolean;
  20462. /**
  20463. * @hidden
  20464. * 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)
  20465. */
  20466. _multiviewTexture: Nullable<RenderTargetTexture>;
  20467. /**
  20468. * @hidden
  20469. * ensures the multiview texture of the camera exists and has the specified width/height
  20470. * @param width height to set on the multiview texture
  20471. * @param height width to set on the multiview texture
  20472. */
  20473. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20474. }
  20475. }
  20476. module "babylonjs/scene" {
  20477. interface Scene {
  20478. /** @hidden */
  20479. _transformMatrixR: Matrix;
  20480. /** @hidden */
  20481. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20482. /** @hidden */
  20483. _createMultiviewUbo(): void;
  20484. /** @hidden */
  20485. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20486. /** @hidden */
  20487. _renderMultiviewToSingleView(camera: Camera): void;
  20488. }
  20489. }
  20490. }
  20491. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20492. import { Camera } from "babylonjs/Cameras/camera";
  20493. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20494. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20495. import "babylonjs/Engines/Extensions/engine.multiview";
  20496. /**
  20497. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20498. * This will not be used for webXR as it supports displaying texture arrays directly
  20499. */
  20500. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20501. /**
  20502. * Gets a string identifying the name of the class
  20503. * @returns "VRMultiviewToSingleviewPostProcess" string
  20504. */
  20505. getClassName(): string;
  20506. /**
  20507. * Initializes a VRMultiviewToSingleview
  20508. * @param name name of the post process
  20509. * @param camera camera to be applied to
  20510. * @param scaleFactor scaling factor to the size of the output texture
  20511. */
  20512. constructor(name: string, camera: Camera, scaleFactor: number);
  20513. }
  20514. }
  20515. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20516. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20517. import { Nullable } from "babylonjs/types";
  20518. import { Size } from "babylonjs/Maths/math.size";
  20519. import { Observable } from "babylonjs/Misc/observable";
  20520. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20521. /**
  20522. * Interface used to define additional presentation attributes
  20523. */
  20524. export interface IVRPresentationAttributes {
  20525. /**
  20526. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20527. */
  20528. highRefreshRate: boolean;
  20529. /**
  20530. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20531. */
  20532. foveationLevel: number;
  20533. }
  20534. module "babylonjs/Engines/engine" {
  20535. interface Engine {
  20536. /** @hidden */
  20537. _vrDisplay: any;
  20538. /** @hidden */
  20539. _vrSupported: boolean;
  20540. /** @hidden */
  20541. _oldSize: Size;
  20542. /** @hidden */
  20543. _oldHardwareScaleFactor: number;
  20544. /** @hidden */
  20545. _vrExclusivePointerMode: boolean;
  20546. /** @hidden */
  20547. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20548. /** @hidden */
  20549. _onVRDisplayPointerRestricted: () => void;
  20550. /** @hidden */
  20551. _onVRDisplayPointerUnrestricted: () => void;
  20552. /** @hidden */
  20553. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20554. /** @hidden */
  20555. _onVrDisplayDisconnect: Nullable<() => void>;
  20556. /** @hidden */
  20557. _onVrDisplayPresentChange: Nullable<() => void>;
  20558. /**
  20559. * Observable signaled when VR display mode changes
  20560. */
  20561. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20562. /**
  20563. * Observable signaled when VR request present is complete
  20564. */
  20565. onVRRequestPresentComplete: Observable<boolean>;
  20566. /**
  20567. * Observable signaled when VR request present starts
  20568. */
  20569. onVRRequestPresentStart: Observable<Engine>;
  20570. /**
  20571. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20572. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20573. */
  20574. isInVRExclusivePointerMode: boolean;
  20575. /**
  20576. * Gets a boolean indicating if a webVR device was detected
  20577. * @returns true if a webVR device was detected
  20578. */
  20579. isVRDevicePresent(): boolean;
  20580. /**
  20581. * Gets the current webVR device
  20582. * @returns the current webVR device (or null)
  20583. */
  20584. getVRDevice(): any;
  20585. /**
  20586. * Initializes a webVR display and starts listening to display change events
  20587. * The onVRDisplayChangedObservable will be notified upon these changes
  20588. * @returns A promise containing a VRDisplay and if vr is supported
  20589. */
  20590. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20591. /** @hidden */
  20592. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20593. /**
  20594. * Gets or sets the presentation attributes used to configure VR rendering
  20595. */
  20596. vrPresentationAttributes?: IVRPresentationAttributes;
  20597. /**
  20598. * Call this function to switch to webVR mode
  20599. * Will do nothing if webVR is not supported or if there is no webVR device
  20600. * @param options the webvr options provided to the camera. mainly used for multiview
  20601. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20602. */
  20603. enableVR(options: WebVROptions): void;
  20604. /** @hidden */
  20605. _onVRFullScreenTriggered(): void;
  20606. }
  20607. }
  20608. }
  20609. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20610. import { Nullable } from "babylonjs/types";
  20611. import { Observable } from "babylonjs/Misc/observable";
  20612. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20613. import { Scene } from "babylonjs/scene";
  20614. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20615. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20616. import { Node } from "babylonjs/node";
  20617. import { Ray } from "babylonjs/Culling/ray";
  20618. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20619. import "babylonjs/Engines/Extensions/engine.webVR";
  20620. /**
  20621. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20622. * IMPORTANT!! The data is right-hand data.
  20623. * @export
  20624. * @interface DevicePose
  20625. */
  20626. export interface DevicePose {
  20627. /**
  20628. * The position of the device, values in array are [x,y,z].
  20629. */
  20630. readonly position: Nullable<Float32Array>;
  20631. /**
  20632. * The linearVelocity of the device, values in array are [x,y,z].
  20633. */
  20634. readonly linearVelocity: Nullable<Float32Array>;
  20635. /**
  20636. * The linearAcceleration of the device, values in array are [x,y,z].
  20637. */
  20638. readonly linearAcceleration: Nullable<Float32Array>;
  20639. /**
  20640. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20641. */
  20642. readonly orientation: Nullable<Float32Array>;
  20643. /**
  20644. * The angularVelocity of the device, values in array are [x,y,z].
  20645. */
  20646. readonly angularVelocity: Nullable<Float32Array>;
  20647. /**
  20648. * The angularAcceleration of the device, values in array are [x,y,z].
  20649. */
  20650. readonly angularAcceleration: Nullable<Float32Array>;
  20651. }
  20652. /**
  20653. * Interface representing a pose controlled object in Babylon.
  20654. * A pose controlled object has both regular pose values as well as pose values
  20655. * from an external device such as a VR head mounted display
  20656. */
  20657. export interface PoseControlled {
  20658. /**
  20659. * The position of the object in babylon space.
  20660. */
  20661. position: Vector3;
  20662. /**
  20663. * The rotation quaternion of the object in babylon space.
  20664. */
  20665. rotationQuaternion: Quaternion;
  20666. /**
  20667. * The position of the device in babylon space.
  20668. */
  20669. devicePosition?: Vector3;
  20670. /**
  20671. * The rotation quaternion of the device in babylon space.
  20672. */
  20673. deviceRotationQuaternion: Quaternion;
  20674. /**
  20675. * The raw pose coming from the device.
  20676. */
  20677. rawPose: Nullable<DevicePose>;
  20678. /**
  20679. * The scale of the device to be used when translating from device space to babylon space.
  20680. */
  20681. deviceScaleFactor: number;
  20682. /**
  20683. * Updates the poseControlled values based on the input device pose.
  20684. * @param poseData the pose data to update the object with
  20685. */
  20686. updateFromDevice(poseData: DevicePose): void;
  20687. }
  20688. /**
  20689. * Set of options to customize the webVRCamera
  20690. */
  20691. export interface WebVROptions {
  20692. /**
  20693. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20694. */
  20695. trackPosition?: boolean;
  20696. /**
  20697. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20698. */
  20699. positionScale?: number;
  20700. /**
  20701. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20702. */
  20703. displayName?: string;
  20704. /**
  20705. * Should the native controller meshes be initialized. (default: true)
  20706. */
  20707. controllerMeshes?: boolean;
  20708. /**
  20709. * Creating a default HemiLight only on controllers. (default: true)
  20710. */
  20711. defaultLightingOnControllers?: boolean;
  20712. /**
  20713. * If you don't want to use the default VR button of the helper. (default: false)
  20714. */
  20715. useCustomVRButton?: boolean;
  20716. /**
  20717. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20718. */
  20719. customVRButton?: HTMLButtonElement;
  20720. /**
  20721. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20722. */
  20723. rayLength?: number;
  20724. /**
  20725. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20726. */
  20727. defaultHeight?: number;
  20728. /**
  20729. * If multiview should be used if availible (default: false)
  20730. */
  20731. useMultiview?: boolean;
  20732. }
  20733. /**
  20734. * This represents a WebVR camera.
  20735. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20736. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20737. */
  20738. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20739. private webVROptions;
  20740. /**
  20741. * @hidden
  20742. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20743. */
  20744. _vrDevice: any;
  20745. /**
  20746. * The rawPose of the vrDevice.
  20747. */
  20748. rawPose: Nullable<DevicePose>;
  20749. private _onVREnabled;
  20750. private _specsVersion;
  20751. private _attached;
  20752. private _frameData;
  20753. protected _descendants: Array<Node>;
  20754. private _deviceRoomPosition;
  20755. /** @hidden */
  20756. _deviceRoomRotationQuaternion: Quaternion;
  20757. private _standingMatrix;
  20758. /**
  20759. * Represents device position in babylon space.
  20760. */
  20761. devicePosition: Vector3;
  20762. /**
  20763. * Represents device rotation in babylon space.
  20764. */
  20765. deviceRotationQuaternion: Quaternion;
  20766. /**
  20767. * The scale of the device to be used when translating from device space to babylon space.
  20768. */
  20769. deviceScaleFactor: number;
  20770. private _deviceToWorld;
  20771. private _worldToDevice;
  20772. /**
  20773. * References to the webVR controllers for the vrDevice.
  20774. */
  20775. controllers: Array<WebVRController>;
  20776. /**
  20777. * Emits an event when a controller is attached.
  20778. */
  20779. onControllersAttachedObservable: Observable<WebVRController[]>;
  20780. /**
  20781. * Emits an event when a controller's mesh has been loaded;
  20782. */
  20783. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20784. /**
  20785. * Emits an event when the HMD's pose has been updated.
  20786. */
  20787. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20788. private _poseSet;
  20789. /**
  20790. * If the rig cameras be used as parent instead of this camera.
  20791. */
  20792. rigParenting: boolean;
  20793. private _lightOnControllers;
  20794. private _defaultHeight?;
  20795. /**
  20796. * Instantiates a WebVRFreeCamera.
  20797. * @param name The name of the WebVRFreeCamera
  20798. * @param position The starting anchor position for the camera
  20799. * @param scene The scene the camera belongs to
  20800. * @param webVROptions a set of customizable options for the webVRCamera
  20801. */
  20802. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20803. /**
  20804. * Gets the device distance from the ground in meters.
  20805. * @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.
  20806. */
  20807. deviceDistanceToRoomGround(): number;
  20808. /**
  20809. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20810. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20811. */
  20812. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20813. /**
  20814. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20815. * @returns A promise with a boolean set to if the standing matrix is supported.
  20816. */
  20817. useStandingMatrixAsync(): Promise<boolean>;
  20818. /**
  20819. * Disposes the camera
  20820. */
  20821. dispose(): void;
  20822. /**
  20823. * Gets a vrController by name.
  20824. * @param name The name of the controller to retreive
  20825. * @returns the controller matching the name specified or null if not found
  20826. */
  20827. getControllerByName(name: string): Nullable<WebVRController>;
  20828. private _leftController;
  20829. /**
  20830. * The controller corresponding to the users left hand.
  20831. */
  20832. get leftController(): Nullable<WebVRController>;
  20833. private _rightController;
  20834. /**
  20835. * The controller corresponding to the users right hand.
  20836. */
  20837. get rightController(): Nullable<WebVRController>;
  20838. /**
  20839. * Casts a ray forward from the vrCamera's gaze.
  20840. * @param length Length of the ray (default: 100)
  20841. * @returns the ray corresponding to the gaze
  20842. */
  20843. getForwardRay(length?: number): Ray;
  20844. /**
  20845. * @hidden
  20846. * Updates the camera based on device's frame data
  20847. */
  20848. _checkInputs(): void;
  20849. /**
  20850. * Updates the poseControlled values based on the input device pose.
  20851. * @param poseData Pose coming from the device
  20852. */
  20853. updateFromDevice(poseData: DevicePose): void;
  20854. private _htmlElementAttached;
  20855. private _detachIfAttached;
  20856. /**
  20857. * WebVR's attach control will start broadcasting frames to the device.
  20858. * Note that in certain browsers (chrome for example) this function must be called
  20859. * within a user-interaction callback. Example:
  20860. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20861. *
  20862. * @param element html element to attach the vrDevice to
  20863. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20864. */
  20865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20866. /**
  20867. * Detaches the camera from the html element and disables VR
  20868. *
  20869. * @param element html element to detach from
  20870. */
  20871. detachControl(element: HTMLElement): void;
  20872. /**
  20873. * @returns the name of this class
  20874. */
  20875. getClassName(): string;
  20876. /**
  20877. * Calls resetPose on the vrDisplay
  20878. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20879. */
  20880. resetToCurrentRotation(): void;
  20881. /**
  20882. * @hidden
  20883. * Updates the rig cameras (left and right eye)
  20884. */
  20885. _updateRigCameras(): void;
  20886. private _workingVector;
  20887. private _oneVector;
  20888. private _workingMatrix;
  20889. private updateCacheCalled;
  20890. private _correctPositionIfNotTrackPosition;
  20891. /**
  20892. * @hidden
  20893. * Updates the cached values of the camera
  20894. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20895. */
  20896. _updateCache(ignoreParentClass?: boolean): void;
  20897. /**
  20898. * @hidden
  20899. * Get current device position in babylon world
  20900. */
  20901. _computeDevicePosition(): void;
  20902. /**
  20903. * Updates the current device position and rotation in the babylon world
  20904. */
  20905. update(): void;
  20906. /**
  20907. * @hidden
  20908. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20909. * @returns an identity matrix
  20910. */
  20911. _getViewMatrix(): Matrix;
  20912. private _tmpMatrix;
  20913. /**
  20914. * This function is called by the two RIG cameras.
  20915. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20916. * @hidden
  20917. */
  20918. _getWebVRViewMatrix(): Matrix;
  20919. /** @hidden */
  20920. _getWebVRProjectionMatrix(): Matrix;
  20921. private _onGamepadConnectedObserver;
  20922. private _onGamepadDisconnectedObserver;
  20923. private _updateCacheWhenTrackingDisabledObserver;
  20924. /**
  20925. * Initializes the controllers and their meshes
  20926. */
  20927. initControllers(): void;
  20928. }
  20929. }
  20930. declare module "babylonjs/Materials/materialHelper" {
  20931. import { Nullable } from "babylonjs/types";
  20932. import { Scene } from "babylonjs/scene";
  20933. import { Engine } from "babylonjs/Engines/engine";
  20934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20935. import { Light } from "babylonjs/Lights/light";
  20936. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  20937. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20938. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20940. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20941. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20942. /**
  20943. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20944. *
  20945. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20946. *
  20947. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20948. */
  20949. export class MaterialHelper {
  20950. /**
  20951. * Bind the current view position to an effect.
  20952. * @param effect The effect to be bound
  20953. * @param scene The scene the eyes position is used from
  20954. * @param variableName name of the shader variable that will hold the eye position
  20955. */
  20956. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20957. /**
  20958. * Helps preparing the defines values about the UVs in used in the effect.
  20959. * UVs are shared as much as we can accross channels in the shaders.
  20960. * @param texture The texture we are preparing the UVs for
  20961. * @param defines The defines to update
  20962. * @param key The channel key "diffuse", "specular"... used in the shader
  20963. */
  20964. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20965. /**
  20966. * Binds a texture matrix value to its corrsponding uniform
  20967. * @param texture The texture to bind the matrix for
  20968. * @param uniformBuffer The uniform buffer receivin the data
  20969. * @param key The channel key "diffuse", "specular"... used in the shader
  20970. */
  20971. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20972. /**
  20973. * Gets the current status of the fog (should it be enabled?)
  20974. * @param mesh defines the mesh to evaluate for fog support
  20975. * @param scene defines the hosting scene
  20976. * @returns true if fog must be enabled
  20977. */
  20978. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20979. /**
  20980. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20981. * @param mesh defines the current mesh
  20982. * @param scene defines the current scene
  20983. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20984. * @param pointsCloud defines if point cloud rendering has to be turned on
  20985. * @param fogEnabled defines if fog has to be turned on
  20986. * @param alphaTest defines if alpha testing has to be turned on
  20987. * @param defines defines the current list of defines
  20988. */
  20989. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20990. /**
  20991. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20992. * @param scene defines the current scene
  20993. * @param engine defines the current engine
  20994. * @param defines specifies the list of active defines
  20995. * @param useInstances defines if instances have to be turned on
  20996. * @param useClipPlane defines if clip plane have to be turned on
  20997. * @param useInstances defines if instances have to be turned on
  20998. * @param useThinInstances defines if thin instances have to be turned on
  20999. */
  21000. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21001. /**
  21002. * Prepares the defines for bones
  21003. * @param mesh The mesh containing the geometry data we will draw
  21004. * @param defines The defines to update
  21005. */
  21006. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21007. /**
  21008. * Prepares the defines for morph targets
  21009. * @param mesh The mesh containing the geometry data we will draw
  21010. * @param defines The defines to update
  21011. */
  21012. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21013. /**
  21014. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21015. * @param mesh The mesh containing the geometry data we will draw
  21016. * @param defines The defines to update
  21017. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21018. * @param useBones Precise whether bones should be used or not (override mesh info)
  21019. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21020. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21021. * @returns false if defines are considered not dirty and have not been checked
  21022. */
  21023. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21024. /**
  21025. * Prepares the defines related to multiview
  21026. * @param scene The scene we are intending to draw
  21027. * @param defines The defines to update
  21028. */
  21029. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21030. /**
  21031. * Prepares the defines related to the prepass
  21032. * @param scene The scene we are intending to draw
  21033. * @param defines The defines to update
  21034. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21035. */
  21036. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21037. /**
  21038. * Prepares the defines related to the light information passed in parameter
  21039. * @param scene The scene we are intending to draw
  21040. * @param mesh The mesh the effect is compiling for
  21041. * @param light The light the effect is compiling for
  21042. * @param lightIndex The index of the light
  21043. * @param defines The defines to update
  21044. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21045. * @param state Defines the current state regarding what is needed (normals, etc...)
  21046. */
  21047. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21048. needNormals: boolean;
  21049. needRebuild: boolean;
  21050. shadowEnabled: boolean;
  21051. specularEnabled: boolean;
  21052. lightmapMode: boolean;
  21053. }): void;
  21054. /**
  21055. * Prepares the defines related to the light information passed in parameter
  21056. * @param scene The scene we are intending to draw
  21057. * @param mesh The mesh the effect is compiling for
  21058. * @param defines The defines to update
  21059. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21060. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21061. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21062. * @returns true if normals will be required for the rest of the effect
  21063. */
  21064. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21065. /**
  21066. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21067. * @param lightIndex defines the light index
  21068. * @param uniformsList The uniform list
  21069. * @param samplersList The sampler list
  21070. * @param projectedLightTexture defines if projected texture must be used
  21071. * @param uniformBuffersList defines an optional list of uniform buffers
  21072. */
  21073. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21074. /**
  21075. * Prepares the uniforms and samplers list to be used in the effect
  21076. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21077. * @param samplersList The sampler list
  21078. * @param defines The defines helping in the list generation
  21079. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21080. */
  21081. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21082. /**
  21083. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21084. * @param defines The defines to update while falling back
  21085. * @param fallbacks The authorized effect fallbacks
  21086. * @param maxSimultaneousLights The maximum number of lights allowed
  21087. * @param rank the current rank of the Effect
  21088. * @returns The newly affected rank
  21089. */
  21090. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21091. private static _TmpMorphInfluencers;
  21092. /**
  21093. * Prepares the list of attributes required for morph targets according to the effect defines.
  21094. * @param attribs The current list of supported attribs
  21095. * @param mesh The mesh to prepare the morph targets attributes for
  21096. * @param influencers The number of influencers
  21097. */
  21098. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21099. /**
  21100. * Prepares the list of attributes required for morph targets according to the effect defines.
  21101. * @param attribs The current list of supported attribs
  21102. * @param mesh The mesh to prepare the morph targets attributes for
  21103. * @param defines The current Defines of the effect
  21104. */
  21105. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21106. /**
  21107. * Prepares the list of attributes required for bones according to the effect defines.
  21108. * @param attribs The current list of supported attribs
  21109. * @param mesh The mesh to prepare the bones attributes for
  21110. * @param defines The current Defines of the effect
  21111. * @param fallbacks The current efffect fallback strategy
  21112. */
  21113. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21114. /**
  21115. * Check and prepare the list of attributes required for instances according to the effect defines.
  21116. * @param attribs The current list of supported attribs
  21117. * @param defines The current MaterialDefines of the effect
  21118. */
  21119. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21120. /**
  21121. * Add the list of attributes required for instances to the attribs array.
  21122. * @param attribs The current list of supported attribs
  21123. */
  21124. static PushAttributesForInstances(attribs: string[]): void;
  21125. /**
  21126. * Binds the light information to the effect.
  21127. * @param light The light containing the generator
  21128. * @param effect The effect we are binding the data to
  21129. * @param lightIndex The light index in the effect used to render
  21130. */
  21131. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21132. /**
  21133. * Binds the lights information from the scene to the effect for the given mesh.
  21134. * @param light Light to bind
  21135. * @param lightIndex Light index
  21136. * @param scene The scene where the light belongs to
  21137. * @param effect The effect we are binding the data to
  21138. * @param useSpecular Defines if specular is supported
  21139. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21140. */
  21141. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21142. /**
  21143. * Binds the lights information from the scene to the effect for the given mesh.
  21144. * @param scene The scene the lights belongs to
  21145. * @param mesh The mesh we are binding the information to render
  21146. * @param effect The effect we are binding the data to
  21147. * @param defines The generated defines for the effect
  21148. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21149. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21150. */
  21151. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21152. private static _tempFogColor;
  21153. /**
  21154. * Binds the fog information from the scene to the effect for the given mesh.
  21155. * @param scene The scene the lights belongs to
  21156. * @param mesh The mesh we are binding the information to render
  21157. * @param effect The effect we are binding the data to
  21158. * @param linearSpace Defines if the fog effect is applied in linear space
  21159. */
  21160. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21161. /**
  21162. * Binds the bones information from the mesh to the effect.
  21163. * @param mesh The mesh we are binding the information to render
  21164. * @param effect The effect we are binding the data to
  21165. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21166. */
  21167. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21168. private static _CopyBonesTransformationMatrices;
  21169. /**
  21170. * Binds the morph targets information from the mesh to the effect.
  21171. * @param abstractMesh The mesh we are binding the information to render
  21172. * @param effect The effect we are binding the data to
  21173. */
  21174. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21175. /**
  21176. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21177. * @param defines The generated defines used in the effect
  21178. * @param effect The effect we are binding the data to
  21179. * @param scene The scene we are willing to render with logarithmic scale for
  21180. */
  21181. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21182. /**
  21183. * Binds the clip plane information from the scene to the effect.
  21184. * @param scene The scene the clip plane information are extracted from
  21185. * @param effect The effect we are binding the data to
  21186. */
  21187. static BindClipPlane(effect: Effect, scene: Scene): void;
  21188. }
  21189. }
  21190. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21191. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21192. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21193. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21194. import { Nullable } from "babylonjs/types";
  21195. import { Effect } from "babylonjs/Materials/effect";
  21196. import { Matrix } from "babylonjs/Maths/math.vector";
  21197. import { Scene } from "babylonjs/scene";
  21198. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21200. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21201. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21202. import { Observable } from "babylonjs/Misc/observable";
  21203. /**
  21204. * Block used to expose an input value
  21205. */
  21206. export class InputBlock extends NodeMaterialBlock {
  21207. private _mode;
  21208. private _associatedVariableName;
  21209. private _storedValue;
  21210. private _valueCallback;
  21211. private _type;
  21212. private _animationType;
  21213. /** Gets or set a value used to limit the range of float values */
  21214. min: number;
  21215. /** Gets or set a value used to limit the range of float values */
  21216. max: number;
  21217. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21218. isBoolean: boolean;
  21219. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21220. matrixMode: number;
  21221. /** @hidden */
  21222. _systemValue: Nullable<NodeMaterialSystemValues>;
  21223. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21224. isConstant: boolean;
  21225. /** Gets or sets the group to use to display this block in the Inspector */
  21226. groupInInspector: string;
  21227. /** Gets an observable raised when the value is changed */
  21228. onValueChangedObservable: Observable<InputBlock>;
  21229. /**
  21230. * Gets or sets the connection point type (default is float)
  21231. */
  21232. get type(): NodeMaterialBlockConnectionPointTypes;
  21233. /**
  21234. * Creates a new InputBlock
  21235. * @param name defines the block name
  21236. * @param target defines the target of that block (Vertex by default)
  21237. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21238. */
  21239. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21240. /**
  21241. * Validates if a name is a reserve word.
  21242. * @param newName the new name to be given to the node.
  21243. * @returns false if the name is a reserve word, else true.
  21244. */
  21245. validateBlockName(newName: string): boolean;
  21246. /**
  21247. * Gets the output component
  21248. */
  21249. get output(): NodeMaterialConnectionPoint;
  21250. /**
  21251. * Set the source of this connection point to a vertex attribute
  21252. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21253. * @returns the current connection point
  21254. */
  21255. setAsAttribute(attributeName?: string): InputBlock;
  21256. /**
  21257. * Set the source of this connection point to a system value
  21258. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21259. * @returns the current connection point
  21260. */
  21261. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21262. /**
  21263. * Gets or sets the value of that point.
  21264. * Please note that this value will be ignored if valueCallback is defined
  21265. */
  21266. get value(): any;
  21267. set value(value: any);
  21268. /**
  21269. * Gets or sets a callback used to get the value of that point.
  21270. * Please note that setting this value will force the connection point to ignore the value property
  21271. */
  21272. get valueCallback(): () => any;
  21273. set valueCallback(value: () => any);
  21274. /**
  21275. * Gets or sets the associated variable name in the shader
  21276. */
  21277. get associatedVariableName(): string;
  21278. set associatedVariableName(value: string);
  21279. /** Gets or sets the type of animation applied to the input */
  21280. get animationType(): AnimatedInputBlockTypes;
  21281. set animationType(value: AnimatedInputBlockTypes);
  21282. /**
  21283. * Gets a boolean indicating that this connection point not defined yet
  21284. */
  21285. get isUndefined(): boolean;
  21286. /**
  21287. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21288. * In this case the connection point name must be the name of the uniform to use.
  21289. * Can only be set on inputs
  21290. */
  21291. get isUniform(): boolean;
  21292. set isUniform(value: boolean);
  21293. /**
  21294. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21295. * In this case the connection point name must be the name of the attribute to use
  21296. * Can only be set on inputs
  21297. */
  21298. get isAttribute(): boolean;
  21299. set isAttribute(value: boolean);
  21300. /**
  21301. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21302. * Can only be set on exit points
  21303. */
  21304. get isVarying(): boolean;
  21305. set isVarying(value: boolean);
  21306. /**
  21307. * Gets a boolean indicating that the current connection point is a system value
  21308. */
  21309. get isSystemValue(): boolean;
  21310. /**
  21311. * Gets or sets the current well known value or null if not defined as a system value
  21312. */
  21313. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21314. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21315. /**
  21316. * Gets the current class name
  21317. * @returns the class name
  21318. */
  21319. getClassName(): string;
  21320. /**
  21321. * Animate the input if animationType !== None
  21322. * @param scene defines the rendering scene
  21323. */
  21324. animate(scene: Scene): void;
  21325. private _emitDefine;
  21326. initialize(state: NodeMaterialBuildState): void;
  21327. /**
  21328. * Set the input block to its default value (based on its type)
  21329. */
  21330. setDefaultValue(): void;
  21331. private _emitConstant;
  21332. /** @hidden */
  21333. get _noContextSwitch(): boolean;
  21334. private _emit;
  21335. /** @hidden */
  21336. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21337. /** @hidden */
  21338. _transmit(effect: Effect, scene: Scene): void;
  21339. protected _buildBlock(state: NodeMaterialBuildState): void;
  21340. protected _dumpPropertiesCode(): string;
  21341. dispose(): void;
  21342. serialize(): any;
  21343. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21344. }
  21345. }
  21346. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21347. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21348. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21349. import { Nullable } from "babylonjs/types";
  21350. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21351. import { Observable } from "babylonjs/Misc/observable";
  21352. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21353. /**
  21354. * Enum used to define the compatibility state between two connection points
  21355. */
  21356. export enum NodeMaterialConnectionPointCompatibilityStates {
  21357. /** Points are compatibles */
  21358. Compatible = 0,
  21359. /** Points are incompatible because of their types */
  21360. TypeIncompatible = 1,
  21361. /** Points are incompatible because of their targets (vertex vs fragment) */
  21362. TargetIncompatible = 2
  21363. }
  21364. /**
  21365. * Defines the direction of a connection point
  21366. */
  21367. export enum NodeMaterialConnectionPointDirection {
  21368. /** Input */
  21369. Input = 0,
  21370. /** Output */
  21371. Output = 1
  21372. }
  21373. /**
  21374. * Defines a connection point for a block
  21375. */
  21376. export class NodeMaterialConnectionPoint {
  21377. /** @hidden */
  21378. _ownerBlock: NodeMaterialBlock;
  21379. /** @hidden */
  21380. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21381. private _endpoints;
  21382. private _associatedVariableName;
  21383. private _direction;
  21384. /** @hidden */
  21385. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21386. /** @hidden */
  21387. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21388. private _type;
  21389. /** @hidden */
  21390. _enforceAssociatedVariableName: boolean;
  21391. /** Gets the direction of the point */
  21392. get direction(): NodeMaterialConnectionPointDirection;
  21393. /** Indicates that this connection point needs dual validation before being connected to another point */
  21394. needDualDirectionValidation: boolean;
  21395. /**
  21396. * Gets or sets the additional types supported by this connection point
  21397. */
  21398. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21399. /**
  21400. * Gets or sets the additional types excluded by this connection point
  21401. */
  21402. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21403. /**
  21404. * Observable triggered when this point is connected
  21405. */
  21406. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21407. /**
  21408. * Gets or sets the associated variable name in the shader
  21409. */
  21410. get associatedVariableName(): string;
  21411. set associatedVariableName(value: string);
  21412. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21413. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21414. /**
  21415. * Gets or sets the connection point type (default is float)
  21416. */
  21417. get type(): NodeMaterialBlockConnectionPointTypes;
  21418. set type(value: NodeMaterialBlockConnectionPointTypes);
  21419. /**
  21420. * Gets or sets the connection point name
  21421. */
  21422. name: string;
  21423. /**
  21424. * Gets or sets the connection point name
  21425. */
  21426. displayName: string;
  21427. /**
  21428. * Gets or sets a boolean indicating that this connection point can be omitted
  21429. */
  21430. isOptional: boolean;
  21431. /**
  21432. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21433. */
  21434. isExposedOnFrame: boolean;
  21435. /**
  21436. * Gets or sets number indicating the position that the port is exposed to on a frame
  21437. */
  21438. exposedPortPosition: number;
  21439. /**
  21440. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21441. */
  21442. define: string;
  21443. /** @hidden */
  21444. _prioritizeVertex: boolean;
  21445. private _target;
  21446. /** Gets or sets the target of that connection point */
  21447. get target(): NodeMaterialBlockTargets;
  21448. set target(value: NodeMaterialBlockTargets);
  21449. /**
  21450. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21451. */
  21452. get isConnected(): boolean;
  21453. /**
  21454. * Gets a boolean indicating that the current point is connected to an input block
  21455. */
  21456. get isConnectedToInputBlock(): boolean;
  21457. /**
  21458. * Gets a the connected input block (if any)
  21459. */
  21460. get connectInputBlock(): Nullable<InputBlock>;
  21461. /** Get the other side of the connection (if any) */
  21462. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21463. /** Get the block that owns this connection point */
  21464. get ownerBlock(): NodeMaterialBlock;
  21465. /** Get the block connected on the other side of this connection (if any) */
  21466. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21467. /** Get the block connected on the endpoints of this connection (if any) */
  21468. get connectedBlocks(): Array<NodeMaterialBlock>;
  21469. /** Gets the list of connected endpoints */
  21470. get endpoints(): NodeMaterialConnectionPoint[];
  21471. /** Gets a boolean indicating if that output point is connected to at least one input */
  21472. get hasEndpoints(): boolean;
  21473. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21474. get isConnectedInVertexShader(): boolean;
  21475. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21476. get isConnectedInFragmentShader(): boolean;
  21477. /**
  21478. * Creates a block suitable to be used as an input for this input point.
  21479. * If null is returned, a block based on the point type will be created.
  21480. * @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
  21481. */
  21482. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21483. /**
  21484. * Creates a new connection point
  21485. * @param name defines the connection point name
  21486. * @param ownerBlock defines the block hosting this connection point
  21487. * @param direction defines the direction of the connection point
  21488. */
  21489. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21490. /**
  21491. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21492. * @returns the class name
  21493. */
  21494. getClassName(): string;
  21495. /**
  21496. * Gets a boolean indicating if the current point can be connected to another point
  21497. * @param connectionPoint defines the other connection point
  21498. * @returns a boolean
  21499. */
  21500. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21501. /**
  21502. * Gets a number indicating if the current point can be connected to another point
  21503. * @param connectionPoint defines the other connection point
  21504. * @returns a number defining the compatibility state
  21505. */
  21506. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21507. /**
  21508. * Connect this point to another connection point
  21509. * @param connectionPoint defines the other connection point
  21510. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21511. * @returns the current connection point
  21512. */
  21513. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21514. /**
  21515. * Disconnect this point from one of his endpoint
  21516. * @param endpoint defines the other connection point
  21517. * @returns the current connection point
  21518. */
  21519. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21520. /**
  21521. * Serializes this point in a JSON representation
  21522. * @param isInput defines if the connection point is an input (default is true)
  21523. * @returns the serialized point object
  21524. */
  21525. serialize(isInput?: boolean): any;
  21526. /**
  21527. * Release resources
  21528. */
  21529. dispose(): void;
  21530. }
  21531. }
  21532. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21533. /**
  21534. * Enum used to define the material modes
  21535. */
  21536. export enum NodeMaterialModes {
  21537. /** Regular material */
  21538. Material = 0,
  21539. /** For post process */
  21540. PostProcess = 1,
  21541. /** For particle system */
  21542. Particle = 2,
  21543. /** For procedural texture */
  21544. ProceduralTexture = 3
  21545. }
  21546. }
  21547. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21550. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21551. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21553. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21554. import { Effect } from "babylonjs/Materials/effect";
  21555. import { Mesh } from "babylonjs/Meshes/mesh";
  21556. import { Nullable } from "babylonjs/types";
  21557. import { Texture } from "babylonjs/Materials/Textures/texture";
  21558. import { Scene } from "babylonjs/scene";
  21559. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21560. /**
  21561. * Block used to read a texture from a sampler
  21562. */
  21563. export class TextureBlock extends NodeMaterialBlock {
  21564. private _defineName;
  21565. private _linearDefineName;
  21566. private _gammaDefineName;
  21567. private _tempTextureRead;
  21568. private _samplerName;
  21569. private _transformedUVName;
  21570. private _textureTransformName;
  21571. private _textureInfoName;
  21572. private _mainUVName;
  21573. private _mainUVDefineName;
  21574. private _fragmentOnly;
  21575. /**
  21576. * Gets or sets the texture associated with the node
  21577. */
  21578. texture: Nullable<Texture>;
  21579. /**
  21580. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21581. */
  21582. convertToGammaSpace: boolean;
  21583. /**
  21584. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21585. */
  21586. convertToLinearSpace: boolean;
  21587. /**
  21588. * Create a new TextureBlock
  21589. * @param name defines the block name
  21590. */
  21591. constructor(name: string, fragmentOnly?: boolean);
  21592. /**
  21593. * Gets the current class name
  21594. * @returns the class name
  21595. */
  21596. getClassName(): string;
  21597. /**
  21598. * Gets the uv input component
  21599. */
  21600. get uv(): NodeMaterialConnectionPoint;
  21601. /**
  21602. * Gets the rgba output component
  21603. */
  21604. get rgba(): NodeMaterialConnectionPoint;
  21605. /**
  21606. * Gets the rgb output component
  21607. */
  21608. get rgb(): NodeMaterialConnectionPoint;
  21609. /**
  21610. * Gets the r output component
  21611. */
  21612. get r(): NodeMaterialConnectionPoint;
  21613. /**
  21614. * Gets the g output component
  21615. */
  21616. get g(): NodeMaterialConnectionPoint;
  21617. /**
  21618. * Gets the b output component
  21619. */
  21620. get b(): NodeMaterialConnectionPoint;
  21621. /**
  21622. * Gets the a output component
  21623. */
  21624. get a(): NodeMaterialConnectionPoint;
  21625. get target(): NodeMaterialBlockTargets;
  21626. autoConfigure(material: NodeMaterial): void;
  21627. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21628. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21629. isReady(): boolean;
  21630. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21631. private get _isMixed();
  21632. private _injectVertexCode;
  21633. private _writeTextureRead;
  21634. private _writeOutput;
  21635. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21636. protected _dumpPropertiesCode(): string;
  21637. serialize(): any;
  21638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21639. }
  21640. }
  21641. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21642. /** @hidden */
  21643. export var reflectionFunction: {
  21644. name: string;
  21645. shader: string;
  21646. };
  21647. }
  21648. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21649. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21652. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21654. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21655. import { Effect } from "babylonjs/Materials/effect";
  21656. import { Mesh } from "babylonjs/Meshes/mesh";
  21657. import { Nullable } from "babylonjs/types";
  21658. import { Scene } from "babylonjs/scene";
  21659. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21660. /**
  21661. * Base block used to read a reflection texture from a sampler
  21662. */
  21663. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21664. /** @hidden */
  21665. _define3DName: string;
  21666. /** @hidden */
  21667. _defineCubicName: string;
  21668. /** @hidden */
  21669. _defineExplicitName: string;
  21670. /** @hidden */
  21671. _defineProjectionName: string;
  21672. /** @hidden */
  21673. _defineLocalCubicName: string;
  21674. /** @hidden */
  21675. _defineSphericalName: string;
  21676. /** @hidden */
  21677. _definePlanarName: string;
  21678. /** @hidden */
  21679. _defineEquirectangularName: string;
  21680. /** @hidden */
  21681. _defineMirroredEquirectangularFixedName: string;
  21682. /** @hidden */
  21683. _defineEquirectangularFixedName: string;
  21684. /** @hidden */
  21685. _defineSkyboxName: string;
  21686. /** @hidden */
  21687. _defineOppositeZ: string;
  21688. /** @hidden */
  21689. _cubeSamplerName: string;
  21690. /** @hidden */
  21691. _2DSamplerName: string;
  21692. protected _positionUVWName: string;
  21693. protected _directionWName: string;
  21694. protected _reflectionVectorName: string;
  21695. /** @hidden */
  21696. _reflectionCoordsName: string;
  21697. /** @hidden */
  21698. _reflectionMatrixName: string;
  21699. protected _reflectionColorName: string;
  21700. /**
  21701. * Gets or sets the texture associated with the node
  21702. */
  21703. texture: Nullable<BaseTexture>;
  21704. /**
  21705. * Create a new ReflectionTextureBaseBlock
  21706. * @param name defines the block name
  21707. */
  21708. constructor(name: string);
  21709. /**
  21710. * Gets the current class name
  21711. * @returns the class name
  21712. */
  21713. getClassName(): string;
  21714. /**
  21715. * Gets the world position input component
  21716. */
  21717. abstract get position(): NodeMaterialConnectionPoint;
  21718. /**
  21719. * Gets the world position input component
  21720. */
  21721. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21722. /**
  21723. * Gets the world normal input component
  21724. */
  21725. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21726. /**
  21727. * Gets the world input component
  21728. */
  21729. abstract get world(): NodeMaterialConnectionPoint;
  21730. /**
  21731. * Gets the camera (or eye) position component
  21732. */
  21733. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21734. /**
  21735. * Gets the view input component
  21736. */
  21737. abstract get view(): NodeMaterialConnectionPoint;
  21738. protected _getTexture(): Nullable<BaseTexture>;
  21739. autoConfigure(material: NodeMaterial): void;
  21740. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21741. isReady(): boolean;
  21742. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21743. /**
  21744. * Gets the code to inject in the vertex shader
  21745. * @param state current state of the node material building
  21746. * @returns the shader code
  21747. */
  21748. handleVertexSide(state: NodeMaterialBuildState): string;
  21749. /**
  21750. * Handles the inits for the fragment code path
  21751. * @param state node material build state
  21752. */
  21753. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21754. /**
  21755. * Generates the reflection coords code for the fragment code path
  21756. * @param worldNormalVarName name of the world normal variable
  21757. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21758. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21759. * @returns the shader code
  21760. */
  21761. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21762. /**
  21763. * Generates the reflection color code for the fragment code path
  21764. * @param lodVarName name of the lod variable
  21765. * @param swizzleLookupTexture swizzle to use for the final color variable
  21766. * @returns the shader code
  21767. */
  21768. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21769. /**
  21770. * Generates the code corresponding to the connected output points
  21771. * @param state node material build state
  21772. * @param varName name of the variable to output
  21773. * @returns the shader code
  21774. */
  21775. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21776. protected _buildBlock(state: NodeMaterialBuildState): this;
  21777. protected _dumpPropertiesCode(): string;
  21778. serialize(): any;
  21779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21780. }
  21781. }
  21782. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21783. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21784. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21785. import { Nullable } from "babylonjs/types";
  21786. /**
  21787. * Defines a connection point to be used for points with a custom object type
  21788. */
  21789. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21790. private _blockType;
  21791. private _blockName;
  21792. private _nameForCheking?;
  21793. /**
  21794. * Creates a new connection point
  21795. * @param name defines the connection point name
  21796. * @param ownerBlock defines the block hosting this connection point
  21797. * @param direction defines the direction of the connection point
  21798. */
  21799. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21800. /**
  21801. * Gets a number indicating if the current point can be connected to another point
  21802. * @param connectionPoint defines the other connection point
  21803. * @returns a number defining the compatibility state
  21804. */
  21805. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21806. /**
  21807. * Creates a block suitable to be used as an input for this input point.
  21808. * If null is returned, a block based on the point type will be created.
  21809. * @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
  21810. */
  21811. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21812. }
  21813. }
  21814. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21815. /**
  21816. * Enum defining the type of properties that can be edited in the property pages in the NME
  21817. */
  21818. export enum PropertyTypeForEdition {
  21819. /** property is a boolean */
  21820. Boolean = 0,
  21821. /** property is a float */
  21822. Float = 1,
  21823. /** property is a Vector2 */
  21824. Vector2 = 2,
  21825. /** property is a list of values */
  21826. List = 3
  21827. }
  21828. /**
  21829. * Interface that defines an option in a variable of type list
  21830. */
  21831. export interface IEditablePropertyListOption {
  21832. /** label of the option */
  21833. "label": string;
  21834. /** value of the option */
  21835. "value": number;
  21836. }
  21837. /**
  21838. * Interface that defines the options available for an editable property
  21839. */
  21840. export interface IEditablePropertyOption {
  21841. /** min value */
  21842. "min"?: number;
  21843. /** max value */
  21844. "max"?: number;
  21845. /** notifiers: indicates which actions to take when the property is changed */
  21846. "notifiers"?: {
  21847. /** the material should be rebuilt */
  21848. "rebuild"?: boolean;
  21849. /** the preview should be updated */
  21850. "update"?: boolean;
  21851. };
  21852. /** list of the options for a variable of type list */
  21853. "options"?: IEditablePropertyListOption[];
  21854. }
  21855. /**
  21856. * Interface that describes an editable property
  21857. */
  21858. export interface IPropertyDescriptionForEdition {
  21859. /** name of the property */
  21860. "propertyName": string;
  21861. /** display name of the property */
  21862. "displayName": string;
  21863. /** type of the property */
  21864. "type": PropertyTypeForEdition;
  21865. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21866. "groupName": string;
  21867. /** options for the property */
  21868. "options": IEditablePropertyOption;
  21869. }
  21870. /**
  21871. * Decorator that flags a property in a node material block as being editable
  21872. */
  21873. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21874. }
  21875. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21877. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21878. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21880. import { Nullable } from "babylonjs/types";
  21881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21882. import { Mesh } from "babylonjs/Meshes/mesh";
  21883. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21884. import { Effect } from "babylonjs/Materials/effect";
  21885. import { Scene } from "babylonjs/scene";
  21886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21887. /**
  21888. * Block used to implement the refraction part of the sub surface module of the PBR material
  21889. */
  21890. export class RefractionBlock extends NodeMaterialBlock {
  21891. /** @hidden */
  21892. _define3DName: string;
  21893. /** @hidden */
  21894. _refractionMatrixName: string;
  21895. /** @hidden */
  21896. _defineLODRefractionAlpha: string;
  21897. /** @hidden */
  21898. _defineLinearSpecularRefraction: string;
  21899. /** @hidden */
  21900. _defineOppositeZ: string;
  21901. /** @hidden */
  21902. _cubeSamplerName: string;
  21903. /** @hidden */
  21904. _2DSamplerName: string;
  21905. /** @hidden */
  21906. _vRefractionMicrosurfaceInfosName: string;
  21907. /** @hidden */
  21908. _vRefractionInfosName: string;
  21909. private _scene;
  21910. /**
  21911. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21912. * Materials half opaque for instance using refraction could benefit from this control.
  21913. */
  21914. linkRefractionWithTransparency: boolean;
  21915. /**
  21916. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21917. */
  21918. invertRefractionY: boolean;
  21919. /**
  21920. * Gets or sets the texture associated with the node
  21921. */
  21922. texture: Nullable<BaseTexture>;
  21923. /**
  21924. * Create a new RefractionBlock
  21925. * @param name defines the block name
  21926. */
  21927. constructor(name: string);
  21928. /**
  21929. * Gets the current class name
  21930. * @returns the class name
  21931. */
  21932. getClassName(): string;
  21933. /**
  21934. * Gets the intensity input component
  21935. */
  21936. get intensity(): NodeMaterialConnectionPoint;
  21937. /**
  21938. * Gets the index of refraction input component
  21939. */
  21940. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21941. /**
  21942. * Gets the tint at distance input component
  21943. */
  21944. get tintAtDistance(): NodeMaterialConnectionPoint;
  21945. /**
  21946. * Gets the view input component
  21947. */
  21948. get view(): NodeMaterialConnectionPoint;
  21949. /**
  21950. * Gets the refraction object output component
  21951. */
  21952. get refraction(): NodeMaterialConnectionPoint;
  21953. /**
  21954. * Returns true if the block has a texture
  21955. */
  21956. get hasTexture(): boolean;
  21957. protected _getTexture(): Nullable<BaseTexture>;
  21958. autoConfigure(material: NodeMaterial): void;
  21959. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21960. isReady(): boolean;
  21961. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21962. /**
  21963. * Gets the main code of the block (fragment side)
  21964. * @param state current state of the node material building
  21965. * @returns the shader code
  21966. */
  21967. getCode(state: NodeMaterialBuildState): string;
  21968. protected _buildBlock(state: NodeMaterialBuildState): this;
  21969. protected _dumpPropertiesCode(): string;
  21970. serialize(): any;
  21971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21972. }
  21973. }
  21974. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21975. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21976. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21977. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21980. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21981. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21982. import { Nullable } from "babylonjs/types";
  21983. import { Scene } from "babylonjs/scene";
  21984. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21985. /**
  21986. * Base block used as input for post process
  21987. */
  21988. export class CurrentScreenBlock extends NodeMaterialBlock {
  21989. private _samplerName;
  21990. private _linearDefineName;
  21991. private _gammaDefineName;
  21992. private _mainUVName;
  21993. private _tempTextureRead;
  21994. /**
  21995. * Gets or sets the texture associated with the node
  21996. */
  21997. texture: Nullable<BaseTexture>;
  21998. /**
  21999. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22000. */
  22001. convertToGammaSpace: boolean;
  22002. /**
  22003. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22004. */
  22005. convertToLinearSpace: boolean;
  22006. /**
  22007. * Create a new CurrentScreenBlock
  22008. * @param name defines the block name
  22009. */
  22010. constructor(name: string);
  22011. /**
  22012. * Gets the current class name
  22013. * @returns the class name
  22014. */
  22015. getClassName(): string;
  22016. /**
  22017. * Gets the uv input component
  22018. */
  22019. get uv(): NodeMaterialConnectionPoint;
  22020. /**
  22021. * Gets the rgba output component
  22022. */
  22023. get rgba(): NodeMaterialConnectionPoint;
  22024. /**
  22025. * Gets the rgb output component
  22026. */
  22027. get rgb(): NodeMaterialConnectionPoint;
  22028. /**
  22029. * Gets the r output component
  22030. */
  22031. get r(): NodeMaterialConnectionPoint;
  22032. /**
  22033. * Gets the g output component
  22034. */
  22035. get g(): NodeMaterialConnectionPoint;
  22036. /**
  22037. * Gets the b output component
  22038. */
  22039. get b(): NodeMaterialConnectionPoint;
  22040. /**
  22041. * Gets the a output component
  22042. */
  22043. get a(): NodeMaterialConnectionPoint;
  22044. /**
  22045. * Initialize the block and prepare the context for build
  22046. * @param state defines the state that will be used for the build
  22047. */
  22048. initialize(state: NodeMaterialBuildState): void;
  22049. get target(): NodeMaterialBlockTargets;
  22050. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22051. isReady(): boolean;
  22052. private _injectVertexCode;
  22053. private _writeTextureRead;
  22054. private _writeOutput;
  22055. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22056. serialize(): any;
  22057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22058. }
  22059. }
  22060. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22065. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22066. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22067. import { Nullable } from "babylonjs/types";
  22068. import { Scene } from "babylonjs/scene";
  22069. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22070. /**
  22071. * Base block used for the particle texture
  22072. */
  22073. export class ParticleTextureBlock extends NodeMaterialBlock {
  22074. private _samplerName;
  22075. private _linearDefineName;
  22076. private _gammaDefineName;
  22077. private _tempTextureRead;
  22078. /**
  22079. * Gets or sets the texture associated with the node
  22080. */
  22081. texture: Nullable<BaseTexture>;
  22082. /**
  22083. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22084. */
  22085. convertToGammaSpace: boolean;
  22086. /**
  22087. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22088. */
  22089. convertToLinearSpace: boolean;
  22090. /**
  22091. * Create a new ParticleTextureBlock
  22092. * @param name defines the block name
  22093. */
  22094. constructor(name: string);
  22095. /**
  22096. * Gets the current class name
  22097. * @returns the class name
  22098. */
  22099. getClassName(): string;
  22100. /**
  22101. * Gets the uv input component
  22102. */
  22103. get uv(): NodeMaterialConnectionPoint;
  22104. /**
  22105. * Gets the rgba output component
  22106. */
  22107. get rgba(): NodeMaterialConnectionPoint;
  22108. /**
  22109. * Gets the rgb output component
  22110. */
  22111. get rgb(): NodeMaterialConnectionPoint;
  22112. /**
  22113. * Gets the r output component
  22114. */
  22115. get r(): NodeMaterialConnectionPoint;
  22116. /**
  22117. * Gets the g output component
  22118. */
  22119. get g(): NodeMaterialConnectionPoint;
  22120. /**
  22121. * Gets the b output component
  22122. */
  22123. get b(): NodeMaterialConnectionPoint;
  22124. /**
  22125. * Gets the a output component
  22126. */
  22127. get a(): NodeMaterialConnectionPoint;
  22128. /**
  22129. * Initialize the block and prepare the context for build
  22130. * @param state defines the state that will be used for the build
  22131. */
  22132. initialize(state: NodeMaterialBuildState): void;
  22133. autoConfigure(material: NodeMaterial): void;
  22134. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22135. isReady(): boolean;
  22136. private _writeOutput;
  22137. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22138. serialize(): any;
  22139. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22140. }
  22141. }
  22142. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22143. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22145. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22146. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22147. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22148. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22149. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22150. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22151. import { Scene } from "babylonjs/scene";
  22152. /**
  22153. * Class used to store shared data between 2 NodeMaterialBuildState
  22154. */
  22155. export class NodeMaterialBuildStateSharedData {
  22156. /**
  22157. * Gets the list of emitted varyings
  22158. */
  22159. temps: string[];
  22160. /**
  22161. * Gets the list of emitted varyings
  22162. */
  22163. varyings: string[];
  22164. /**
  22165. * Gets the varying declaration string
  22166. */
  22167. varyingDeclaration: string;
  22168. /**
  22169. * Input blocks
  22170. */
  22171. inputBlocks: InputBlock[];
  22172. /**
  22173. * Input blocks
  22174. */
  22175. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22176. /**
  22177. * Bindable blocks (Blocks that need to set data to the effect)
  22178. */
  22179. bindableBlocks: NodeMaterialBlock[];
  22180. /**
  22181. * List of blocks that can provide a compilation fallback
  22182. */
  22183. blocksWithFallbacks: NodeMaterialBlock[];
  22184. /**
  22185. * List of blocks that can provide a define update
  22186. */
  22187. blocksWithDefines: NodeMaterialBlock[];
  22188. /**
  22189. * List of blocks that can provide a repeatable content
  22190. */
  22191. repeatableContentBlocks: NodeMaterialBlock[];
  22192. /**
  22193. * List of blocks that can provide a dynamic list of uniforms
  22194. */
  22195. dynamicUniformBlocks: NodeMaterialBlock[];
  22196. /**
  22197. * List of blocks that can block the isReady function for the material
  22198. */
  22199. blockingBlocks: NodeMaterialBlock[];
  22200. /**
  22201. * Gets the list of animated inputs
  22202. */
  22203. animatedInputs: InputBlock[];
  22204. /**
  22205. * Build Id used to avoid multiple recompilations
  22206. */
  22207. buildId: number;
  22208. /** List of emitted variables */
  22209. variableNames: {
  22210. [key: string]: number;
  22211. };
  22212. /** List of emitted defines */
  22213. defineNames: {
  22214. [key: string]: number;
  22215. };
  22216. /** Should emit comments? */
  22217. emitComments: boolean;
  22218. /** Emit build activity */
  22219. verbose: boolean;
  22220. /** Gets or sets the hosting scene */
  22221. scene: Scene;
  22222. /**
  22223. * Gets the compilation hints emitted at compilation time
  22224. */
  22225. hints: {
  22226. needWorldViewMatrix: boolean;
  22227. needWorldViewProjectionMatrix: boolean;
  22228. needAlphaBlending: boolean;
  22229. needAlphaTesting: boolean;
  22230. };
  22231. /**
  22232. * List of compilation checks
  22233. */
  22234. checks: {
  22235. emitVertex: boolean;
  22236. emitFragment: boolean;
  22237. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22238. };
  22239. /**
  22240. * Is vertex program allowed to be empty?
  22241. */
  22242. allowEmptyVertexProgram: boolean;
  22243. /** Creates a new shared data */
  22244. constructor();
  22245. /**
  22246. * Emits console errors and exceptions if there is a failing check
  22247. */
  22248. emitErrors(): void;
  22249. }
  22250. }
  22251. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22252. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22253. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22254. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22255. /**
  22256. * Class used to store node based material build state
  22257. */
  22258. export class NodeMaterialBuildState {
  22259. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22260. supportUniformBuffers: boolean;
  22261. /**
  22262. * Gets the list of emitted attributes
  22263. */
  22264. attributes: string[];
  22265. /**
  22266. * Gets the list of emitted uniforms
  22267. */
  22268. uniforms: string[];
  22269. /**
  22270. * Gets the list of emitted constants
  22271. */
  22272. constants: string[];
  22273. /**
  22274. * Gets the list of emitted samplers
  22275. */
  22276. samplers: string[];
  22277. /**
  22278. * Gets the list of emitted functions
  22279. */
  22280. functions: {
  22281. [key: string]: string;
  22282. };
  22283. /**
  22284. * Gets the list of emitted extensions
  22285. */
  22286. extensions: {
  22287. [key: string]: string;
  22288. };
  22289. /**
  22290. * Gets the target of the compilation state
  22291. */
  22292. target: NodeMaterialBlockTargets;
  22293. /**
  22294. * Gets the list of emitted counters
  22295. */
  22296. counters: {
  22297. [key: string]: number;
  22298. };
  22299. /**
  22300. * Shared data between multiple NodeMaterialBuildState instances
  22301. */
  22302. sharedData: NodeMaterialBuildStateSharedData;
  22303. /** @hidden */
  22304. _vertexState: NodeMaterialBuildState;
  22305. /** @hidden */
  22306. _attributeDeclaration: string;
  22307. /** @hidden */
  22308. _uniformDeclaration: string;
  22309. /** @hidden */
  22310. _constantDeclaration: string;
  22311. /** @hidden */
  22312. _samplerDeclaration: string;
  22313. /** @hidden */
  22314. _varyingTransfer: string;
  22315. /** @hidden */
  22316. _injectAtEnd: string;
  22317. private _repeatableContentAnchorIndex;
  22318. /** @hidden */
  22319. _builtCompilationString: string;
  22320. /**
  22321. * Gets the emitted compilation strings
  22322. */
  22323. compilationString: string;
  22324. /**
  22325. * Finalize the compilation strings
  22326. * @param state defines the current compilation state
  22327. */
  22328. finalize(state: NodeMaterialBuildState): void;
  22329. /** @hidden */
  22330. get _repeatableContentAnchor(): string;
  22331. /** @hidden */
  22332. _getFreeVariableName(prefix: string): string;
  22333. /** @hidden */
  22334. _getFreeDefineName(prefix: string): string;
  22335. /** @hidden */
  22336. _excludeVariableName(name: string): void;
  22337. /** @hidden */
  22338. _emit2DSampler(name: string): void;
  22339. /** @hidden */
  22340. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22341. /** @hidden */
  22342. _emitExtension(name: string, extension: string, define?: string): void;
  22343. /** @hidden */
  22344. _emitFunction(name: string, code: string, comments: string): void;
  22345. /** @hidden */
  22346. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22347. replaceStrings?: {
  22348. search: RegExp;
  22349. replace: string;
  22350. }[];
  22351. repeatKey?: string;
  22352. }): string;
  22353. /** @hidden */
  22354. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22355. repeatKey?: string;
  22356. removeAttributes?: boolean;
  22357. removeUniforms?: boolean;
  22358. removeVaryings?: boolean;
  22359. removeIfDef?: boolean;
  22360. replaceStrings?: {
  22361. search: RegExp;
  22362. replace: string;
  22363. }[];
  22364. }, storeKey?: string): void;
  22365. /** @hidden */
  22366. _registerTempVariable(name: string): boolean;
  22367. /** @hidden */
  22368. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22369. /** @hidden */
  22370. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22371. /** @hidden */
  22372. _emitFloat(value: number): string;
  22373. }
  22374. }
  22375. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22376. /**
  22377. * Helper class used to generate session unique ID
  22378. */
  22379. export class UniqueIdGenerator {
  22380. private static _UniqueIdCounter;
  22381. /**
  22382. * Gets an unique (relatively to the current scene) Id
  22383. */
  22384. static get UniqueId(): number;
  22385. }
  22386. }
  22387. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22388. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22389. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22390. import { Nullable } from "babylonjs/types";
  22391. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22392. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22393. import { Effect } from "babylonjs/Materials/effect";
  22394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22395. import { Mesh } from "babylonjs/Meshes/mesh";
  22396. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22397. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22398. import { Scene } from "babylonjs/scene";
  22399. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22400. /**
  22401. * Defines a block that can be used inside a node based material
  22402. */
  22403. export class NodeMaterialBlock {
  22404. private _buildId;
  22405. private _buildTarget;
  22406. private _target;
  22407. private _isFinalMerger;
  22408. private _isInput;
  22409. private _name;
  22410. protected _isUnique: boolean;
  22411. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22412. inputsAreExclusive: boolean;
  22413. /** @hidden */
  22414. _codeVariableName: string;
  22415. /** @hidden */
  22416. _inputs: NodeMaterialConnectionPoint[];
  22417. /** @hidden */
  22418. _outputs: NodeMaterialConnectionPoint[];
  22419. /** @hidden */
  22420. _preparationId: number;
  22421. /**
  22422. * Gets the name of the block
  22423. */
  22424. get name(): string;
  22425. /**
  22426. * Sets the name of the block. Will check if the name is valid.
  22427. */
  22428. set name(newName: string);
  22429. /**
  22430. * Gets or sets the unique id of the node
  22431. */
  22432. uniqueId: number;
  22433. /**
  22434. * Gets or sets the comments associated with this block
  22435. */
  22436. comments: string;
  22437. /**
  22438. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22439. */
  22440. get isUnique(): boolean;
  22441. /**
  22442. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22443. */
  22444. get isFinalMerger(): boolean;
  22445. /**
  22446. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22447. */
  22448. get isInput(): boolean;
  22449. /**
  22450. * Gets or sets the build Id
  22451. */
  22452. get buildId(): number;
  22453. set buildId(value: number);
  22454. /**
  22455. * Gets or sets the target of the block
  22456. */
  22457. get target(): NodeMaterialBlockTargets;
  22458. set target(value: NodeMaterialBlockTargets);
  22459. /**
  22460. * Gets the list of input points
  22461. */
  22462. get inputs(): NodeMaterialConnectionPoint[];
  22463. /** Gets the list of output points */
  22464. get outputs(): NodeMaterialConnectionPoint[];
  22465. /**
  22466. * Find an input by its name
  22467. * @param name defines the name of the input to look for
  22468. * @returns the input or null if not found
  22469. */
  22470. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22471. /**
  22472. * Find an output by its name
  22473. * @param name defines the name of the outputto look for
  22474. * @returns the output or null if not found
  22475. */
  22476. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22477. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22478. visibleInInspector: boolean;
  22479. /**
  22480. * Creates a new NodeMaterialBlock
  22481. * @param name defines the block name
  22482. * @param target defines the target of that block (Vertex by default)
  22483. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22484. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22485. */
  22486. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22487. /**
  22488. * Initialize the block and prepare the context for build
  22489. * @param state defines the state that will be used for the build
  22490. */
  22491. initialize(state: NodeMaterialBuildState): void;
  22492. /**
  22493. * Bind data to effect. Will only be called for blocks with isBindable === true
  22494. * @param effect defines the effect to bind data to
  22495. * @param nodeMaterial defines the hosting NodeMaterial
  22496. * @param mesh defines the mesh that will be rendered
  22497. * @param subMesh defines the submesh that will be rendered
  22498. */
  22499. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22500. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22501. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22502. protected _writeFloat(value: number): string;
  22503. /**
  22504. * Gets the current class name e.g. "NodeMaterialBlock"
  22505. * @returns the class name
  22506. */
  22507. getClassName(): string;
  22508. /**
  22509. * Register a new input. Must be called inside a block constructor
  22510. * @param name defines the connection point name
  22511. * @param type defines the connection point type
  22512. * @param isOptional defines a boolean indicating that this input can be omitted
  22513. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22514. * @param point an already created connection point. If not provided, create a new one
  22515. * @returns the current block
  22516. */
  22517. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22518. /**
  22519. * Register a new output. Must be called inside a block constructor
  22520. * @param name defines the connection point name
  22521. * @param type defines the connection point type
  22522. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22523. * @param point an already created connection point. If not provided, create a new one
  22524. * @returns the current block
  22525. */
  22526. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22527. /**
  22528. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22529. * @param forOutput defines an optional connection point to check compatibility with
  22530. * @returns the first available input or null
  22531. */
  22532. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22533. /**
  22534. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22535. * @param forBlock defines an optional block to check compatibility with
  22536. * @returns the first available input or null
  22537. */
  22538. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22539. /**
  22540. * Gets the sibling of the given output
  22541. * @param current defines the current output
  22542. * @returns the next output in the list or null
  22543. */
  22544. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22545. /**
  22546. * Connect current block with another block
  22547. * @param other defines the block to connect with
  22548. * @param options define the various options to help pick the right connections
  22549. * @returns the current block
  22550. */
  22551. connectTo(other: NodeMaterialBlock, options?: {
  22552. input?: string;
  22553. output?: string;
  22554. outputSwizzle?: string;
  22555. }): this | undefined;
  22556. protected _buildBlock(state: NodeMaterialBuildState): void;
  22557. /**
  22558. * Add uniforms, samplers and uniform buffers at compilation time
  22559. * @param state defines the state to update
  22560. * @param nodeMaterial defines the node material requesting the update
  22561. * @param defines defines the material defines to update
  22562. * @param uniformBuffers defines the list of uniform buffer names
  22563. */
  22564. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22565. /**
  22566. * Add potential fallbacks if shader compilation fails
  22567. * @param mesh defines the mesh to be rendered
  22568. * @param fallbacks defines the current prioritized list of fallbacks
  22569. */
  22570. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22571. /**
  22572. * Initialize defines for shader compilation
  22573. * @param mesh defines the mesh to be rendered
  22574. * @param nodeMaterial defines the node material requesting the update
  22575. * @param defines defines the material defines to update
  22576. * @param useInstances specifies that instances should be used
  22577. */
  22578. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22579. /**
  22580. * Update defines for shader compilation
  22581. * @param mesh defines the mesh to be rendered
  22582. * @param nodeMaterial defines the node material requesting the update
  22583. * @param defines defines the material defines to update
  22584. * @param useInstances specifies that instances should be used
  22585. * @param subMesh defines which submesh to render
  22586. */
  22587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22588. /**
  22589. * Lets the block try to connect some inputs automatically
  22590. * @param material defines the hosting NodeMaterial
  22591. */
  22592. autoConfigure(material: NodeMaterial): void;
  22593. /**
  22594. * Function called when a block is declared as repeatable content generator
  22595. * @param vertexShaderState defines the current compilation state for the vertex shader
  22596. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22597. * @param mesh defines the mesh to be rendered
  22598. * @param defines defines the material defines to update
  22599. */
  22600. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22601. /**
  22602. * Checks if the block is ready
  22603. * @param mesh defines the mesh to be rendered
  22604. * @param nodeMaterial defines the node material requesting the update
  22605. * @param defines defines the material defines to update
  22606. * @param useInstances specifies that instances should be used
  22607. * @returns true if the block is ready
  22608. */
  22609. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22610. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22611. private _processBuild;
  22612. /**
  22613. * Validates the new name for the block node.
  22614. * @param newName the new name to be given to the node.
  22615. * @returns false if the name is a reserve word, else true.
  22616. */
  22617. validateBlockName(newName: string): boolean;
  22618. /**
  22619. * Compile the current node and generate the shader code
  22620. * @param state defines the current compilation state (uniforms, samplers, current string)
  22621. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22622. * @returns true if already built
  22623. */
  22624. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22625. protected _inputRename(name: string): string;
  22626. protected _outputRename(name: string): string;
  22627. protected _dumpPropertiesCode(): string;
  22628. /** @hidden */
  22629. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22630. /** @hidden */
  22631. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22632. /**
  22633. * Clone the current block to a new identical block
  22634. * @param scene defines the hosting scene
  22635. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22636. * @returns a copy of the current block
  22637. */
  22638. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22639. /**
  22640. * Serializes this block in a JSON representation
  22641. * @returns the serialized block object
  22642. */
  22643. serialize(): any;
  22644. /** @hidden */
  22645. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22646. private _deserializePortDisplayNamesAndExposedOnFrame;
  22647. /**
  22648. * Release resources
  22649. */
  22650. dispose(): void;
  22651. }
  22652. }
  22653. declare module "babylonjs/Materials/pushMaterial" {
  22654. import { Nullable } from "babylonjs/types";
  22655. import { Scene } from "babylonjs/scene";
  22656. import { Matrix } from "babylonjs/Maths/math.vector";
  22657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22658. import { Mesh } from "babylonjs/Meshes/mesh";
  22659. import { Material } from "babylonjs/Materials/material";
  22660. import { Effect } from "babylonjs/Materials/effect";
  22661. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22662. /**
  22663. * Base class of materials working in push mode in babylon JS
  22664. * @hidden
  22665. */
  22666. export class PushMaterial extends Material {
  22667. protected _activeEffect: Effect;
  22668. protected _normalMatrix: Matrix;
  22669. constructor(name: string, scene: Scene);
  22670. getEffect(): Effect;
  22671. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22672. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22673. /**
  22674. * Binds the given world matrix to the active effect
  22675. *
  22676. * @param world the matrix to bind
  22677. */
  22678. bindOnlyWorldMatrix(world: Matrix): void;
  22679. /**
  22680. * Binds the given normal matrix to the active effect
  22681. *
  22682. * @param normalMatrix the matrix to bind
  22683. */
  22684. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22685. bind(world: Matrix, mesh?: Mesh): void;
  22686. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22687. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22688. }
  22689. }
  22690. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22691. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22692. /**
  22693. * Root class for all node material optimizers
  22694. */
  22695. export class NodeMaterialOptimizer {
  22696. /**
  22697. * Function used to optimize a NodeMaterial graph
  22698. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22699. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22700. */
  22701. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22702. }
  22703. }
  22704. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22705. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22708. import { Scene } from "babylonjs/scene";
  22709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22710. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22711. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22712. /**
  22713. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22714. */
  22715. export class TransformBlock extends NodeMaterialBlock {
  22716. /**
  22717. * Defines the value to use to complement W value to transform it to a Vector4
  22718. */
  22719. complementW: number;
  22720. /**
  22721. * Defines the value to use to complement z value to transform it to a Vector4
  22722. */
  22723. complementZ: number;
  22724. /**
  22725. * Creates a new TransformBlock
  22726. * @param name defines the block name
  22727. */
  22728. constructor(name: string);
  22729. /**
  22730. * Gets the current class name
  22731. * @returns the class name
  22732. */
  22733. getClassName(): string;
  22734. /**
  22735. * Gets the vector input
  22736. */
  22737. get vector(): NodeMaterialConnectionPoint;
  22738. /**
  22739. * Gets the output component
  22740. */
  22741. get output(): NodeMaterialConnectionPoint;
  22742. /**
  22743. * Gets the xyz output component
  22744. */
  22745. get xyz(): NodeMaterialConnectionPoint;
  22746. /**
  22747. * Gets the matrix transform input
  22748. */
  22749. get transform(): NodeMaterialConnectionPoint;
  22750. protected _buildBlock(state: NodeMaterialBuildState): this;
  22751. /**
  22752. * Update defines for shader compilation
  22753. * @param mesh defines the mesh to be rendered
  22754. * @param nodeMaterial defines the node material requesting the update
  22755. * @param defines defines the material defines to update
  22756. * @param useInstances specifies that instances should be used
  22757. * @param subMesh defines which submesh to render
  22758. */
  22759. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22760. serialize(): any;
  22761. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22762. protected _dumpPropertiesCode(): string;
  22763. }
  22764. }
  22765. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22766. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22767. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22768. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22769. /**
  22770. * Block used to output the vertex position
  22771. */
  22772. export class VertexOutputBlock extends NodeMaterialBlock {
  22773. /**
  22774. * Creates a new VertexOutputBlock
  22775. * @param name defines the block name
  22776. */
  22777. constructor(name: string);
  22778. /**
  22779. * Gets the current class name
  22780. * @returns the class name
  22781. */
  22782. getClassName(): string;
  22783. /**
  22784. * Gets the vector input component
  22785. */
  22786. get vector(): NodeMaterialConnectionPoint;
  22787. protected _buildBlock(state: NodeMaterialBuildState): this;
  22788. }
  22789. }
  22790. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22794. /**
  22795. * Block used to output the final color
  22796. */
  22797. export class FragmentOutputBlock extends NodeMaterialBlock {
  22798. /**
  22799. * Create a new FragmentOutputBlock
  22800. * @param name defines the block name
  22801. */
  22802. constructor(name: string);
  22803. /**
  22804. * Gets the current class name
  22805. * @returns the class name
  22806. */
  22807. getClassName(): string;
  22808. /**
  22809. * Gets the rgba input component
  22810. */
  22811. get rgba(): NodeMaterialConnectionPoint;
  22812. /**
  22813. * Gets the rgb input component
  22814. */
  22815. get rgb(): NodeMaterialConnectionPoint;
  22816. /**
  22817. * Gets the a input component
  22818. */
  22819. get a(): NodeMaterialConnectionPoint;
  22820. protected _buildBlock(state: NodeMaterialBuildState): this;
  22821. }
  22822. }
  22823. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22824. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22825. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22826. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22827. /**
  22828. * Block used for the particle ramp gradient section
  22829. */
  22830. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22831. /**
  22832. * Create a new ParticleRampGradientBlock
  22833. * @param name defines the block name
  22834. */
  22835. constructor(name: string);
  22836. /**
  22837. * Gets the current class name
  22838. * @returns the class name
  22839. */
  22840. getClassName(): string;
  22841. /**
  22842. * Gets the color input component
  22843. */
  22844. get color(): NodeMaterialConnectionPoint;
  22845. /**
  22846. * Gets the rampColor output component
  22847. */
  22848. get rampColor(): NodeMaterialConnectionPoint;
  22849. /**
  22850. * Initialize the block and prepare the context for build
  22851. * @param state defines the state that will be used for the build
  22852. */
  22853. initialize(state: NodeMaterialBuildState): void;
  22854. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22855. }
  22856. }
  22857. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22858. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22859. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22860. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22861. /**
  22862. * Block used for the particle blend multiply section
  22863. */
  22864. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22865. /**
  22866. * Create a new ParticleBlendMultiplyBlock
  22867. * @param name defines the block name
  22868. */
  22869. constructor(name: string);
  22870. /**
  22871. * Gets the current class name
  22872. * @returns the class name
  22873. */
  22874. getClassName(): string;
  22875. /**
  22876. * Gets the color input component
  22877. */
  22878. get color(): NodeMaterialConnectionPoint;
  22879. /**
  22880. * Gets the alphaTexture input component
  22881. */
  22882. get alphaTexture(): NodeMaterialConnectionPoint;
  22883. /**
  22884. * Gets the alphaColor input component
  22885. */
  22886. get alphaColor(): NodeMaterialConnectionPoint;
  22887. /**
  22888. * Gets the blendColor output component
  22889. */
  22890. get blendColor(): NodeMaterialConnectionPoint;
  22891. /**
  22892. * Initialize the block and prepare the context for build
  22893. * @param state defines the state that will be used for the build
  22894. */
  22895. initialize(state: NodeMaterialBuildState): void;
  22896. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22897. }
  22898. }
  22899. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22903. /**
  22904. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22905. */
  22906. export class VectorMergerBlock extends NodeMaterialBlock {
  22907. /**
  22908. * Create a new VectorMergerBlock
  22909. * @param name defines the block name
  22910. */
  22911. constructor(name: string);
  22912. /**
  22913. * Gets the current class name
  22914. * @returns the class name
  22915. */
  22916. getClassName(): string;
  22917. /**
  22918. * Gets the xyz component (input)
  22919. */
  22920. get xyzIn(): NodeMaterialConnectionPoint;
  22921. /**
  22922. * Gets the xy component (input)
  22923. */
  22924. get xyIn(): NodeMaterialConnectionPoint;
  22925. /**
  22926. * Gets the x component (input)
  22927. */
  22928. get x(): NodeMaterialConnectionPoint;
  22929. /**
  22930. * Gets the y component (input)
  22931. */
  22932. get y(): NodeMaterialConnectionPoint;
  22933. /**
  22934. * Gets the z component (input)
  22935. */
  22936. get z(): NodeMaterialConnectionPoint;
  22937. /**
  22938. * Gets the w component (input)
  22939. */
  22940. get w(): NodeMaterialConnectionPoint;
  22941. /**
  22942. * Gets the xyzw component (output)
  22943. */
  22944. get xyzw(): NodeMaterialConnectionPoint;
  22945. /**
  22946. * Gets the xyz component (output)
  22947. */
  22948. get xyzOut(): NodeMaterialConnectionPoint;
  22949. /**
  22950. * Gets the xy component (output)
  22951. */
  22952. get xyOut(): NodeMaterialConnectionPoint;
  22953. /**
  22954. * Gets the xy component (output)
  22955. * @deprecated Please use xyOut instead.
  22956. */
  22957. get xy(): NodeMaterialConnectionPoint;
  22958. /**
  22959. * Gets the xyz component (output)
  22960. * @deprecated Please use xyzOut instead.
  22961. */
  22962. get xyz(): NodeMaterialConnectionPoint;
  22963. protected _buildBlock(state: NodeMaterialBuildState): this;
  22964. }
  22965. }
  22966. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22967. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22968. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22969. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22970. import { Vector2 } from "babylonjs/Maths/math.vector";
  22971. import { Scene } from "babylonjs/scene";
  22972. /**
  22973. * Block used to remap a float from a range to a new one
  22974. */
  22975. export class RemapBlock extends NodeMaterialBlock {
  22976. /**
  22977. * Gets or sets the source range
  22978. */
  22979. sourceRange: Vector2;
  22980. /**
  22981. * Gets or sets the target range
  22982. */
  22983. targetRange: Vector2;
  22984. /**
  22985. * Creates a new RemapBlock
  22986. * @param name defines the block name
  22987. */
  22988. constructor(name: string);
  22989. /**
  22990. * Gets the current class name
  22991. * @returns the class name
  22992. */
  22993. getClassName(): string;
  22994. /**
  22995. * Gets the input component
  22996. */
  22997. get input(): NodeMaterialConnectionPoint;
  22998. /**
  22999. * Gets the source min input component
  23000. */
  23001. get sourceMin(): NodeMaterialConnectionPoint;
  23002. /**
  23003. * Gets the source max input component
  23004. */
  23005. get sourceMax(): NodeMaterialConnectionPoint;
  23006. /**
  23007. * Gets the target min input component
  23008. */
  23009. get targetMin(): NodeMaterialConnectionPoint;
  23010. /**
  23011. * Gets the target max input component
  23012. */
  23013. get targetMax(): NodeMaterialConnectionPoint;
  23014. /**
  23015. * Gets the output component
  23016. */
  23017. get output(): NodeMaterialConnectionPoint;
  23018. protected _buildBlock(state: NodeMaterialBuildState): this;
  23019. protected _dumpPropertiesCode(): string;
  23020. serialize(): any;
  23021. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23022. }
  23023. }
  23024. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23025. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23026. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23027. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23028. /**
  23029. * Block used to multiply 2 values
  23030. */
  23031. export class MultiplyBlock extends NodeMaterialBlock {
  23032. /**
  23033. * Creates a new MultiplyBlock
  23034. * @param name defines the block name
  23035. */
  23036. constructor(name: string);
  23037. /**
  23038. * Gets the current class name
  23039. * @returns the class name
  23040. */
  23041. getClassName(): string;
  23042. /**
  23043. * Gets the left operand input component
  23044. */
  23045. get left(): NodeMaterialConnectionPoint;
  23046. /**
  23047. * Gets the right operand input component
  23048. */
  23049. get right(): NodeMaterialConnectionPoint;
  23050. /**
  23051. * Gets the output component
  23052. */
  23053. get output(): NodeMaterialConnectionPoint;
  23054. protected _buildBlock(state: NodeMaterialBuildState): this;
  23055. }
  23056. }
  23057. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23058. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23059. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23061. /**
  23062. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23063. */
  23064. export class ColorSplitterBlock extends NodeMaterialBlock {
  23065. /**
  23066. * Create a new ColorSplitterBlock
  23067. * @param name defines the block name
  23068. */
  23069. constructor(name: string);
  23070. /**
  23071. * Gets the current class name
  23072. * @returns the class name
  23073. */
  23074. getClassName(): string;
  23075. /**
  23076. * Gets the rgba component (input)
  23077. */
  23078. get rgba(): NodeMaterialConnectionPoint;
  23079. /**
  23080. * Gets the rgb component (input)
  23081. */
  23082. get rgbIn(): NodeMaterialConnectionPoint;
  23083. /**
  23084. * Gets the rgb component (output)
  23085. */
  23086. get rgbOut(): NodeMaterialConnectionPoint;
  23087. /**
  23088. * Gets the r component (output)
  23089. */
  23090. get r(): NodeMaterialConnectionPoint;
  23091. /**
  23092. * Gets the g component (output)
  23093. */
  23094. get g(): NodeMaterialConnectionPoint;
  23095. /**
  23096. * Gets the b component (output)
  23097. */
  23098. get b(): NodeMaterialConnectionPoint;
  23099. /**
  23100. * Gets the a component (output)
  23101. */
  23102. get a(): NodeMaterialConnectionPoint;
  23103. protected _inputRename(name: string): string;
  23104. protected _outputRename(name: string): string;
  23105. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23106. }
  23107. }
  23108. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23109. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23110. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23111. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23112. import { Scene } from "babylonjs/scene";
  23113. /**
  23114. * Operations supported by the Trigonometry block
  23115. */
  23116. export enum TrigonometryBlockOperations {
  23117. /** Cos */
  23118. Cos = 0,
  23119. /** Sin */
  23120. Sin = 1,
  23121. /** Abs */
  23122. Abs = 2,
  23123. /** Exp */
  23124. Exp = 3,
  23125. /** Exp2 */
  23126. Exp2 = 4,
  23127. /** Round */
  23128. Round = 5,
  23129. /** Floor */
  23130. Floor = 6,
  23131. /** Ceiling */
  23132. Ceiling = 7,
  23133. /** Square root */
  23134. Sqrt = 8,
  23135. /** Log */
  23136. Log = 9,
  23137. /** Tangent */
  23138. Tan = 10,
  23139. /** Arc tangent */
  23140. ArcTan = 11,
  23141. /** Arc cosinus */
  23142. ArcCos = 12,
  23143. /** Arc sinus */
  23144. ArcSin = 13,
  23145. /** Fraction */
  23146. Fract = 14,
  23147. /** Sign */
  23148. Sign = 15,
  23149. /** To radians (from degrees) */
  23150. Radians = 16,
  23151. /** To degrees (from radians) */
  23152. Degrees = 17
  23153. }
  23154. /**
  23155. * Block used to apply trigonometry operation to floats
  23156. */
  23157. export class TrigonometryBlock extends NodeMaterialBlock {
  23158. /**
  23159. * Gets or sets the operation applied by the block
  23160. */
  23161. operation: TrigonometryBlockOperations;
  23162. /**
  23163. * Creates a new TrigonometryBlock
  23164. * @param name defines the block name
  23165. */
  23166. constructor(name: string);
  23167. /**
  23168. * Gets the current class name
  23169. * @returns the class name
  23170. */
  23171. getClassName(): string;
  23172. /**
  23173. * Gets the input component
  23174. */
  23175. get input(): NodeMaterialConnectionPoint;
  23176. /**
  23177. * Gets the output component
  23178. */
  23179. get output(): NodeMaterialConnectionPoint;
  23180. protected _buildBlock(state: NodeMaterialBuildState): this;
  23181. serialize(): any;
  23182. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23183. protected _dumpPropertiesCode(): string;
  23184. }
  23185. }
  23186. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23187. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23188. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23189. import { Scene } from "babylonjs/scene";
  23190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23191. import { Matrix } from "babylonjs/Maths/math.vector";
  23192. import { Mesh } from "babylonjs/Meshes/mesh";
  23193. import { Engine } from "babylonjs/Engines/engine";
  23194. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23195. import { Observable } from "babylonjs/Misc/observable";
  23196. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23197. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23198. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23199. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23200. import { Nullable } from "babylonjs/types";
  23201. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23202. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23203. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23204. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23205. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23206. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23207. import { Effect } from "babylonjs/Materials/effect";
  23208. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23209. import { Camera } from "babylonjs/Cameras/camera";
  23210. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23211. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23212. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23213. /**
  23214. * Interface used to configure the node material editor
  23215. */
  23216. export interface INodeMaterialEditorOptions {
  23217. /** Define the URl to load node editor script */
  23218. editorURL?: string;
  23219. }
  23220. /** @hidden */
  23221. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23222. NORMAL: boolean;
  23223. TANGENT: boolean;
  23224. UV1: boolean;
  23225. /** BONES */
  23226. NUM_BONE_INFLUENCERS: number;
  23227. BonesPerMesh: number;
  23228. BONETEXTURE: boolean;
  23229. /** MORPH TARGETS */
  23230. MORPHTARGETS: boolean;
  23231. MORPHTARGETS_NORMAL: boolean;
  23232. MORPHTARGETS_TANGENT: boolean;
  23233. MORPHTARGETS_UV: boolean;
  23234. NUM_MORPH_INFLUENCERS: number;
  23235. /** IMAGE PROCESSING */
  23236. IMAGEPROCESSING: boolean;
  23237. VIGNETTE: boolean;
  23238. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23239. VIGNETTEBLENDMODEOPAQUE: boolean;
  23240. TONEMAPPING: boolean;
  23241. TONEMAPPING_ACES: boolean;
  23242. CONTRAST: boolean;
  23243. EXPOSURE: boolean;
  23244. COLORCURVES: boolean;
  23245. COLORGRADING: boolean;
  23246. COLORGRADING3D: boolean;
  23247. SAMPLER3DGREENDEPTH: boolean;
  23248. SAMPLER3DBGRMAP: boolean;
  23249. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23250. /** MISC. */
  23251. BUMPDIRECTUV: number;
  23252. constructor();
  23253. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23254. }
  23255. /**
  23256. * Class used to configure NodeMaterial
  23257. */
  23258. export interface INodeMaterialOptions {
  23259. /**
  23260. * Defines if blocks should emit comments
  23261. */
  23262. emitComments: boolean;
  23263. }
  23264. /**
  23265. * Class used to create a node based material built by assembling shader blocks
  23266. */
  23267. export class NodeMaterial extends PushMaterial {
  23268. private static _BuildIdGenerator;
  23269. private _options;
  23270. private _vertexCompilationState;
  23271. private _fragmentCompilationState;
  23272. private _sharedData;
  23273. private _buildId;
  23274. private _buildWasSuccessful;
  23275. private _cachedWorldViewMatrix;
  23276. private _cachedWorldViewProjectionMatrix;
  23277. private _optimizers;
  23278. private _animationFrame;
  23279. /** Define the Url to load node editor script */
  23280. static EditorURL: string;
  23281. /** Define the Url to load snippets */
  23282. static SnippetUrl: string;
  23283. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23284. static IgnoreTexturesAtLoadTime: boolean;
  23285. private BJSNODEMATERIALEDITOR;
  23286. /** Get the inspector from bundle or global */
  23287. private _getGlobalNodeMaterialEditor;
  23288. /**
  23289. * Snippet ID if the material was created from the snippet server
  23290. */
  23291. snippetId: string;
  23292. /**
  23293. * Gets or sets data used by visual editor
  23294. * @see https://nme.babylonjs.com
  23295. */
  23296. editorData: any;
  23297. /**
  23298. * 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)
  23299. */
  23300. ignoreAlpha: boolean;
  23301. /**
  23302. * Defines the maximum number of lights that can be used in the material
  23303. */
  23304. maxSimultaneousLights: number;
  23305. /**
  23306. * Observable raised when the material is built
  23307. */
  23308. onBuildObservable: Observable<NodeMaterial>;
  23309. /**
  23310. * Gets or sets the root nodes of the material vertex shader
  23311. */
  23312. _vertexOutputNodes: NodeMaterialBlock[];
  23313. /**
  23314. * Gets or sets the root nodes of the material fragment (pixel) shader
  23315. */
  23316. _fragmentOutputNodes: NodeMaterialBlock[];
  23317. /** Gets or sets options to control the node material overall behavior */
  23318. get options(): INodeMaterialOptions;
  23319. set options(options: INodeMaterialOptions);
  23320. /**
  23321. * Default configuration related to image processing available in the standard Material.
  23322. */
  23323. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23324. /**
  23325. * Gets the image processing configuration used either in this material.
  23326. */
  23327. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23328. /**
  23329. * Sets the Default image processing configuration used either in the this material.
  23330. *
  23331. * If sets to null, the scene one is in use.
  23332. */
  23333. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23334. /**
  23335. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23336. */
  23337. attachedBlocks: NodeMaterialBlock[];
  23338. /**
  23339. * Specifies the mode of the node material
  23340. * @hidden
  23341. */
  23342. _mode: NodeMaterialModes;
  23343. /**
  23344. * Gets the mode property
  23345. */
  23346. get mode(): NodeMaterialModes;
  23347. /**
  23348. * Create a new node based material
  23349. * @param name defines the material name
  23350. * @param scene defines the hosting scene
  23351. * @param options defines creation option
  23352. */
  23353. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23354. /**
  23355. * Gets the current class name of the material e.g. "NodeMaterial"
  23356. * @returns the class name
  23357. */
  23358. getClassName(): string;
  23359. /**
  23360. * Keep track of the image processing observer to allow dispose and replace.
  23361. */
  23362. private _imageProcessingObserver;
  23363. /**
  23364. * Attaches a new image processing configuration to the Standard Material.
  23365. * @param configuration
  23366. */
  23367. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23368. /**
  23369. * Get a block by its name
  23370. * @param name defines the name of the block to retrieve
  23371. * @returns the required block or null if not found
  23372. */
  23373. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23374. /**
  23375. * Get a block by its name
  23376. * @param predicate defines the predicate used to find the good candidate
  23377. * @returns the required block or null if not found
  23378. */
  23379. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23380. /**
  23381. * Get an input block by its name
  23382. * @param predicate defines the predicate used to find the good candidate
  23383. * @returns the required input block or null if not found
  23384. */
  23385. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23386. /**
  23387. * Gets the list of input blocks attached to this material
  23388. * @returns an array of InputBlocks
  23389. */
  23390. getInputBlocks(): InputBlock[];
  23391. /**
  23392. * Adds a new optimizer to the list of optimizers
  23393. * @param optimizer defines the optimizers to add
  23394. * @returns the current material
  23395. */
  23396. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23397. /**
  23398. * Remove an optimizer from the list of optimizers
  23399. * @param optimizer defines the optimizers to remove
  23400. * @returns the current material
  23401. */
  23402. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23403. /**
  23404. * Add a new block to the list of output nodes
  23405. * @param node defines the node to add
  23406. * @returns the current material
  23407. */
  23408. addOutputNode(node: NodeMaterialBlock): this;
  23409. /**
  23410. * Remove a block from the list of root nodes
  23411. * @param node defines the node to remove
  23412. * @returns the current material
  23413. */
  23414. removeOutputNode(node: NodeMaterialBlock): this;
  23415. private _addVertexOutputNode;
  23416. private _removeVertexOutputNode;
  23417. private _addFragmentOutputNode;
  23418. private _removeFragmentOutputNode;
  23419. /**
  23420. * Specifies if the material will require alpha blending
  23421. * @returns a boolean specifying if alpha blending is needed
  23422. */
  23423. needAlphaBlending(): boolean;
  23424. /**
  23425. * Specifies if this material should be rendered in alpha test mode
  23426. * @returns a boolean specifying if an alpha test is needed.
  23427. */
  23428. needAlphaTesting(): boolean;
  23429. private _initializeBlock;
  23430. private _resetDualBlocks;
  23431. /**
  23432. * Remove a block from the current node material
  23433. * @param block defines the block to remove
  23434. */
  23435. removeBlock(block: NodeMaterialBlock): void;
  23436. /**
  23437. * Build the material and generates the inner effect
  23438. * @param verbose defines if the build should log activity
  23439. */
  23440. build(verbose?: boolean): void;
  23441. /**
  23442. * Runs an otpimization phase to try to improve the shader code
  23443. */
  23444. optimize(): void;
  23445. private _prepareDefinesForAttributes;
  23446. /**
  23447. * Create a post process from the material
  23448. * @param camera The camera to apply the render pass to.
  23449. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23451. * @param engine The engine which the post process will be applied. (default: current engine)
  23452. * @param reusable If the post process can be reused on the same frame. (default: false)
  23453. * @param textureType Type of textures used when performing the post process. (default: 0)
  23454. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23455. * @returns the post process created
  23456. */
  23457. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23458. /**
  23459. * Create the post process effect from the material
  23460. * @param postProcess The post process to create the effect for
  23461. */
  23462. createEffectForPostProcess(postProcess: PostProcess): void;
  23463. private _createEffectForPostProcess;
  23464. /**
  23465. * Create a new procedural texture based on this node material
  23466. * @param size defines the size of the texture
  23467. * @param scene defines the hosting scene
  23468. * @returns the new procedural texture attached to this node material
  23469. */
  23470. createProceduralTexture(size: number | {
  23471. width: number;
  23472. height: number;
  23473. layers?: number;
  23474. }, scene: Scene): Nullable<ProceduralTexture>;
  23475. private _createEffectForParticles;
  23476. private _checkInternals;
  23477. /**
  23478. * Create the effect to be used as the custom effect for a particle system
  23479. * @param particleSystem Particle system to create the effect for
  23480. * @param onCompiled defines a function to call when the effect creation is successful
  23481. * @param onError defines a function to call when the effect creation has failed
  23482. */
  23483. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23484. private _processDefines;
  23485. /**
  23486. * Get if the submesh is ready to be used and all its information available.
  23487. * Child classes can use it to update shaders
  23488. * @param mesh defines the mesh to check
  23489. * @param subMesh defines which submesh to check
  23490. * @param useInstances specifies that instances should be used
  23491. * @returns a boolean indicating that the submesh is ready or not
  23492. */
  23493. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23494. /**
  23495. * Get a string representing the shaders built by the current node graph
  23496. */
  23497. get compiledShaders(): string;
  23498. /**
  23499. * Binds the world matrix to the material
  23500. * @param world defines the world transformation matrix
  23501. */
  23502. bindOnlyWorldMatrix(world: Matrix): void;
  23503. /**
  23504. * Binds the submesh to this material by preparing the effect and shader to draw
  23505. * @param world defines the world transformation matrix
  23506. * @param mesh defines the mesh containing the submesh
  23507. * @param subMesh defines the submesh to bind the material to
  23508. */
  23509. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23510. /**
  23511. * Gets the active textures from the material
  23512. * @returns an array of textures
  23513. */
  23514. getActiveTextures(): BaseTexture[];
  23515. /**
  23516. * Gets the list of texture blocks
  23517. * @returns an array of texture blocks
  23518. */
  23519. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23520. /**
  23521. * Specifies if the material uses a texture
  23522. * @param texture defines the texture to check against the material
  23523. * @returns a boolean specifying if the material uses the texture
  23524. */
  23525. hasTexture(texture: BaseTexture): boolean;
  23526. /**
  23527. * Disposes the material
  23528. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23529. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23530. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23531. */
  23532. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23533. /** Creates the node editor window. */
  23534. private _createNodeEditor;
  23535. /**
  23536. * Launch the node material editor
  23537. * @param config Define the configuration of the editor
  23538. * @return a promise fulfilled when the node editor is visible
  23539. */
  23540. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23541. /**
  23542. * Clear the current material
  23543. */
  23544. clear(): void;
  23545. /**
  23546. * Clear the current material and set it to a default state
  23547. */
  23548. setToDefault(): void;
  23549. /**
  23550. * Clear the current material and set it to a default state for post process
  23551. */
  23552. setToDefaultPostProcess(): void;
  23553. /**
  23554. * Clear the current material and set it to a default state for procedural texture
  23555. */
  23556. setToDefaultProceduralTexture(): void;
  23557. /**
  23558. * Clear the current material and set it to a default state for particle
  23559. */
  23560. setToDefaultParticle(): void;
  23561. /**
  23562. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23563. * @param url defines the url to load from
  23564. * @returns a promise that will fullfil when the material is fully loaded
  23565. */
  23566. loadAsync(url: string): Promise<void>;
  23567. private _gatherBlocks;
  23568. /**
  23569. * Generate a string containing the code declaration required to create an equivalent of this material
  23570. * @returns a string
  23571. */
  23572. generateCode(): string;
  23573. /**
  23574. * Serializes this material in a JSON representation
  23575. * @returns the serialized material object
  23576. */
  23577. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23578. private _restoreConnections;
  23579. /**
  23580. * Clear the current graph and load a new one from a serialization object
  23581. * @param source defines the JSON representation of the material
  23582. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23583. * @param merge defines whether or not the source must be merged or replace the current content
  23584. */
  23585. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23586. /**
  23587. * Makes a duplicate of the current material.
  23588. * @param name - name to use for the new material.
  23589. */
  23590. clone(name: string): NodeMaterial;
  23591. /**
  23592. * Creates a node material from parsed material data
  23593. * @param source defines the JSON representation of the material
  23594. * @param scene defines the hosting scene
  23595. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23596. * @returns a new node material
  23597. */
  23598. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23599. /**
  23600. * Creates a node material from a snippet saved in a remote file
  23601. * @param name defines the name of the material to create
  23602. * @param url defines the url to load from
  23603. * @param scene defines the hosting scene
  23604. * @returns a promise that will resolve to the new node material
  23605. */
  23606. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23607. /**
  23608. * Creates a node material from a snippet saved by the node material editor
  23609. * @param snippetId defines the snippet to load
  23610. * @param scene defines the hosting scene
  23611. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23612. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23613. * @returns a promise that will resolve to the new node material
  23614. */
  23615. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23616. /**
  23617. * Creates a new node material set to default basic configuration
  23618. * @param name defines the name of the material
  23619. * @param scene defines the hosting scene
  23620. * @returns a new NodeMaterial
  23621. */
  23622. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23623. }
  23624. }
  23625. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23626. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23627. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23628. import { Nullable } from "babylonjs/types";
  23629. module "babylonjs/Engines/thinEngine" {
  23630. interface ThinEngine {
  23631. /**
  23632. * Unbind a list of render target textures from the webGL context
  23633. * This is used only when drawBuffer extension or webGL2 are active
  23634. * @param textures defines the render target textures to unbind
  23635. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23636. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23637. */
  23638. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23639. /**
  23640. * Create a multi render target texture
  23641. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23642. * @param size defines the size of the texture
  23643. * @param options defines the creation options
  23644. * @returns the cube texture as an InternalTexture
  23645. */
  23646. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23647. /**
  23648. * Update the sample count for a given multiple render target texture
  23649. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23650. * @param textures defines the textures to update
  23651. * @param samples defines the sample count to set
  23652. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23653. */
  23654. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23655. /**
  23656. * Select a subsets of attachments to draw to.
  23657. * @param attachments gl attachments
  23658. */
  23659. bindAttachments(attachments: number[]): void;
  23660. }
  23661. }
  23662. }
  23663. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23664. import { Scene } from "babylonjs/scene";
  23665. import { Engine } from "babylonjs/Engines/engine";
  23666. import { Texture } from "babylonjs/Materials/Textures/texture";
  23667. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23668. import "babylonjs/Engines/Extensions/engine.multiRender";
  23669. /**
  23670. * Creation options of the multi render target texture.
  23671. */
  23672. export interface IMultiRenderTargetOptions {
  23673. /**
  23674. * Define if the texture needs to create mip maps after render.
  23675. */
  23676. generateMipMaps?: boolean;
  23677. /**
  23678. * Define the types of all the draw buffers we want to create
  23679. */
  23680. types?: number[];
  23681. /**
  23682. * Define the sampling modes of all the draw buffers we want to create
  23683. */
  23684. samplingModes?: number[];
  23685. /**
  23686. * Define if a depth buffer is required
  23687. */
  23688. generateDepthBuffer?: boolean;
  23689. /**
  23690. * Define if a stencil buffer is required
  23691. */
  23692. generateStencilBuffer?: boolean;
  23693. /**
  23694. * Define if a depth texture is required instead of a depth buffer
  23695. */
  23696. generateDepthTexture?: boolean;
  23697. /**
  23698. * Define the number of desired draw buffers
  23699. */
  23700. textureCount?: number;
  23701. /**
  23702. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23703. */
  23704. doNotChangeAspectRatio?: boolean;
  23705. /**
  23706. * Define the default type of the buffers we are creating
  23707. */
  23708. defaultType?: number;
  23709. }
  23710. /**
  23711. * A multi render target, like a render target provides the ability to render to a texture.
  23712. * Unlike the render target, it can render to several draw buffers in one draw.
  23713. * This is specially interesting in deferred rendering or for any effects requiring more than
  23714. * just one color from a single pass.
  23715. */
  23716. export class MultiRenderTarget extends RenderTargetTexture {
  23717. private _internalTextures;
  23718. private _textures;
  23719. private _multiRenderTargetOptions;
  23720. private _count;
  23721. /**
  23722. * Get if draw buffers are currently supported by the used hardware and browser.
  23723. */
  23724. get isSupported(): boolean;
  23725. /**
  23726. * Get the list of textures generated by the multi render target.
  23727. */
  23728. get textures(): Texture[];
  23729. /**
  23730. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23731. */
  23732. get count(): number;
  23733. /**
  23734. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23735. */
  23736. get depthTexture(): Texture;
  23737. /**
  23738. * Set the wrapping mode on U of all the textures we are rendering to.
  23739. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23740. */
  23741. set wrapU(wrap: number);
  23742. /**
  23743. * Set the wrapping mode on V of all the textures we are rendering to.
  23744. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23745. */
  23746. set wrapV(wrap: number);
  23747. /**
  23748. * Instantiate a new multi render target texture.
  23749. * A multi render target, like a render target provides the ability to render to a texture.
  23750. * Unlike the render target, it can render to several draw buffers in one draw.
  23751. * This is specially interesting in deferred rendering or for any effects requiring more than
  23752. * just one color from a single pass.
  23753. * @param name Define the name of the texture
  23754. * @param size Define the size of the buffers to render to
  23755. * @param count Define the number of target we are rendering into
  23756. * @param scene Define the scene the texture belongs to
  23757. * @param options Define the options used to create the multi render target
  23758. */
  23759. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23760. private _initTypes;
  23761. /** @hidden */
  23762. _rebuild(forceFullRebuild?: boolean): void;
  23763. private _createInternalTextures;
  23764. private _createTextures;
  23765. /**
  23766. * Define the number of samples used if MSAA is enabled.
  23767. */
  23768. get samples(): number;
  23769. set samples(value: number);
  23770. /**
  23771. * Resize all the textures in the multi render target.
  23772. * Be careful as it will recreate all the data in the new texture.
  23773. * @param size Define the new size
  23774. */
  23775. resize(size: any): void;
  23776. /**
  23777. * Changes the number of render targets in this MRT
  23778. * Be careful as it will recreate all the data in the new texture.
  23779. * @param count new texture count
  23780. * @param options Specifies texture types and sampling modes for new textures
  23781. */
  23782. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23783. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23784. /**
  23785. * Dispose the render targets and their associated resources
  23786. */
  23787. dispose(): void;
  23788. /**
  23789. * Release all the underlying texture used as draw buffers.
  23790. */
  23791. releaseInternalTextures(): void;
  23792. }
  23793. }
  23794. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  23795. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  23796. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  23797. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  23798. /** @hidden */
  23799. export var imageProcessingPixelShader: {
  23800. name: string;
  23801. shader: string;
  23802. };
  23803. }
  23804. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  23805. import { Nullable } from "babylonjs/types";
  23806. import { Color4 } from "babylonjs/Maths/math.color";
  23807. import { Camera } from "babylonjs/Cameras/camera";
  23808. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23809. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23810. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23811. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23812. import { Engine } from "babylonjs/Engines/engine";
  23813. import "babylonjs/Shaders/imageProcessing.fragment";
  23814. import "babylonjs/Shaders/postprocess.vertex";
  23815. /**
  23816. * ImageProcessingPostProcess
  23817. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23818. */
  23819. export class ImageProcessingPostProcess extends PostProcess {
  23820. /**
  23821. * Default configuration related to image processing available in the PBR Material.
  23822. */
  23823. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23824. /**
  23825. * Gets the image processing configuration used either in this material.
  23826. */
  23827. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23828. /**
  23829. * Sets the Default image processing configuration used either in the this material.
  23830. *
  23831. * If sets to null, the scene one is in use.
  23832. */
  23833. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23834. /**
  23835. * Keep track of the image processing observer to allow dispose and replace.
  23836. */
  23837. private _imageProcessingObserver;
  23838. /**
  23839. * Attaches a new image processing configuration to the PBR Material.
  23840. * @param configuration
  23841. */
  23842. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23843. /**
  23844. * If the post process is supported.
  23845. */
  23846. get isSupported(): boolean;
  23847. /**
  23848. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23849. */
  23850. get colorCurves(): Nullable<ColorCurves>;
  23851. /**
  23852. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23853. */
  23854. set colorCurves(value: Nullable<ColorCurves>);
  23855. /**
  23856. * Gets wether the color curves effect is enabled.
  23857. */
  23858. get colorCurvesEnabled(): boolean;
  23859. /**
  23860. * Sets wether the color curves effect is enabled.
  23861. */
  23862. set colorCurvesEnabled(value: boolean);
  23863. /**
  23864. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23865. */
  23866. get colorGradingTexture(): Nullable<BaseTexture>;
  23867. /**
  23868. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23869. */
  23870. set colorGradingTexture(value: Nullable<BaseTexture>);
  23871. /**
  23872. * Gets wether the color grading effect is enabled.
  23873. */
  23874. get colorGradingEnabled(): boolean;
  23875. /**
  23876. * Gets wether the color grading effect is enabled.
  23877. */
  23878. set colorGradingEnabled(value: boolean);
  23879. /**
  23880. * Gets exposure used in the effect.
  23881. */
  23882. get exposure(): number;
  23883. /**
  23884. * Sets exposure used in the effect.
  23885. */
  23886. set exposure(value: number);
  23887. /**
  23888. * Gets wether tonemapping is enabled or not.
  23889. */
  23890. get toneMappingEnabled(): boolean;
  23891. /**
  23892. * Sets wether tonemapping is enabled or not
  23893. */
  23894. set toneMappingEnabled(value: boolean);
  23895. /**
  23896. * Gets the type of tone mapping effect.
  23897. */
  23898. get toneMappingType(): number;
  23899. /**
  23900. * Sets the type of tone mapping effect.
  23901. */
  23902. set toneMappingType(value: number);
  23903. /**
  23904. * Gets contrast used in the effect.
  23905. */
  23906. get contrast(): number;
  23907. /**
  23908. * Sets contrast used in the effect.
  23909. */
  23910. set contrast(value: number);
  23911. /**
  23912. * Gets Vignette stretch size.
  23913. */
  23914. get vignetteStretch(): number;
  23915. /**
  23916. * Sets Vignette stretch size.
  23917. */
  23918. set vignetteStretch(value: number);
  23919. /**
  23920. * Gets Vignette centre X Offset.
  23921. */
  23922. get vignetteCentreX(): number;
  23923. /**
  23924. * Sets Vignette centre X Offset.
  23925. */
  23926. set vignetteCentreX(value: number);
  23927. /**
  23928. * Gets Vignette centre Y Offset.
  23929. */
  23930. get vignetteCentreY(): number;
  23931. /**
  23932. * Sets Vignette centre Y Offset.
  23933. */
  23934. set vignetteCentreY(value: number);
  23935. /**
  23936. * Gets Vignette weight or intensity of the vignette effect.
  23937. */
  23938. get vignetteWeight(): number;
  23939. /**
  23940. * Sets Vignette weight or intensity of the vignette effect.
  23941. */
  23942. set vignetteWeight(value: number);
  23943. /**
  23944. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23945. * if vignetteEnabled is set to true.
  23946. */
  23947. get vignetteColor(): Color4;
  23948. /**
  23949. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23950. * if vignetteEnabled is set to true.
  23951. */
  23952. set vignetteColor(value: Color4);
  23953. /**
  23954. * Gets Camera field of view used by the Vignette effect.
  23955. */
  23956. get vignetteCameraFov(): number;
  23957. /**
  23958. * Sets Camera field of view used by the Vignette effect.
  23959. */
  23960. set vignetteCameraFov(value: number);
  23961. /**
  23962. * Gets the vignette blend mode allowing different kind of effect.
  23963. */
  23964. get vignetteBlendMode(): number;
  23965. /**
  23966. * Sets the vignette blend mode allowing different kind of effect.
  23967. */
  23968. set vignetteBlendMode(value: number);
  23969. /**
  23970. * Gets wether the vignette effect is enabled.
  23971. */
  23972. get vignetteEnabled(): boolean;
  23973. /**
  23974. * Sets wether the vignette effect is enabled.
  23975. */
  23976. set vignetteEnabled(value: boolean);
  23977. private _fromLinearSpace;
  23978. /**
  23979. * Gets wether the input of the processing is in Gamma or Linear Space.
  23980. */
  23981. get fromLinearSpace(): boolean;
  23982. /**
  23983. * Sets wether the input of the processing is in Gamma or Linear Space.
  23984. */
  23985. set fromLinearSpace(value: boolean);
  23986. /**
  23987. * Defines cache preventing GC.
  23988. */
  23989. private _defines;
  23990. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23991. /**
  23992. * "ImageProcessingPostProcess"
  23993. * @returns "ImageProcessingPostProcess"
  23994. */
  23995. getClassName(): string;
  23996. /**
  23997. * @hidden
  23998. */
  23999. _updateParameters(): void;
  24000. dispose(camera?: Camera): void;
  24001. }
  24002. }
  24003. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24004. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24005. /**
  24006. * Interface for defining prepass effects in the prepass post-process pipeline
  24007. */
  24008. export interface PrePassEffectConfiguration {
  24009. /**
  24010. * Name of the effect
  24011. */
  24012. name: string;
  24013. /**
  24014. * Post process to attach for this effect
  24015. */
  24016. postProcess?: PostProcess;
  24017. /**
  24018. * Textures required in the MRT
  24019. */
  24020. texturesRequired: number[];
  24021. /**
  24022. * Is the effect enabled
  24023. */
  24024. enabled: boolean;
  24025. /**
  24026. * Disposes the effect configuration
  24027. */
  24028. dispose?: () => void;
  24029. /**
  24030. * Creates the associated post process
  24031. */
  24032. createPostProcess?: () => PostProcess;
  24033. }
  24034. }
  24035. declare module "babylonjs/Rendering/prePassRenderer" {
  24036. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  24037. import { Scene } from "babylonjs/scene";
  24038. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  24039. import { Effect } from "babylonjs/Materials/effect";
  24040. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  24041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24042. /**
  24043. * Renders a pre pass of the scene
  24044. * This means every mesh in the scene will be rendered to a render target texture
  24045. * And then this texture will be composited to the rendering canvas with post processes
  24046. * It is necessary for effects like subsurface scattering or deferred shading
  24047. */
  24048. export class PrePassRenderer {
  24049. /** @hidden */
  24050. static _SceneComponentInitialization: (scene: Scene) => void;
  24051. private _textureFormats;
  24052. /**
  24053. * To save performance, we can excluded skinned meshes from the prepass
  24054. */
  24055. excludedSkinnedMesh: AbstractMesh[];
  24056. private _textureIndices;
  24057. private _scene;
  24058. private _engine;
  24059. private _isDirty;
  24060. /**
  24061. * Number of textures in the multi render target texture where the scene is directly rendered
  24062. */
  24063. mrtCount: number;
  24064. /**
  24065. * The render target where the scene is directly rendered
  24066. */
  24067. prePassRT: MultiRenderTarget;
  24068. private _multiRenderAttachments;
  24069. private _defaultAttachments;
  24070. private _clearAttachments;
  24071. private _postProcesses;
  24072. private readonly _clearColor;
  24073. /**
  24074. * Image processing post process for composition
  24075. */
  24076. imageProcessingPostProcess: ImageProcessingPostProcess;
  24077. /**
  24078. * Configuration for prepass effects
  24079. */
  24080. private _effectConfigurations;
  24081. private _mrtFormats;
  24082. private _mrtLayout;
  24083. private _enabled;
  24084. /**
  24085. * Indicates if the prepass is enabled
  24086. */
  24087. get enabled(): boolean;
  24088. /**
  24089. * How many samples are used for MSAA of the scene render target
  24090. */
  24091. get samples(): number;
  24092. set samples(n: number);
  24093. /**
  24094. * Instanciates a prepass renderer
  24095. * @param scene The scene
  24096. */
  24097. constructor(scene: Scene);
  24098. private _initializeAttachments;
  24099. private _createCompositionEffect;
  24100. /**
  24101. * Indicates if rendering a prepass is supported
  24102. */
  24103. get isSupported(): boolean;
  24104. /**
  24105. * Sets the proper output textures to draw in the engine.
  24106. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24107. */
  24108. bindAttachmentsForEffect(effect: Effect): void;
  24109. /**
  24110. * @hidden
  24111. */
  24112. _beforeCameraDraw(): void;
  24113. /**
  24114. * @hidden
  24115. */
  24116. _afterCameraDraw(): void;
  24117. private _checkRTSize;
  24118. private _bindFrameBuffer;
  24119. /**
  24120. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24121. */
  24122. clear(): void;
  24123. private _setState;
  24124. /**
  24125. * Adds an effect configuration to the prepass.
  24126. * If an effect has already been added, it won't add it twice and will return the configuration
  24127. * already present.
  24128. * @param cfg the effect configuration
  24129. * @return the effect configuration now used by the prepass
  24130. */
  24131. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  24132. /**
  24133. * Returns the index of a texture in the multi render target texture array.
  24134. * @param type Texture type
  24135. * @return The index
  24136. */
  24137. getIndex(type: number): number;
  24138. private _enable;
  24139. private _disable;
  24140. private _resetLayout;
  24141. private _resetPostProcessChain;
  24142. private _bindPostProcessChain;
  24143. /**
  24144. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24145. */
  24146. markAsDirty(): void;
  24147. /**
  24148. * Enables a texture on the MultiRenderTarget for prepass
  24149. */
  24150. private _enableTextures;
  24151. private _update;
  24152. private _markAllMaterialsAsPrePassDirty;
  24153. /**
  24154. * Disposes the prepass renderer.
  24155. */
  24156. dispose(): void;
  24157. }
  24158. }
  24159. declare module "babylonjs/PostProcesses/postProcess" {
  24160. import { Nullable } from "babylonjs/types";
  24161. import { SmartArray } from "babylonjs/Misc/smartArray";
  24162. import { Observable } from "babylonjs/Misc/observable";
  24163. import { Vector2 } from "babylonjs/Maths/math.vector";
  24164. import { Camera } from "babylonjs/Cameras/camera";
  24165. import { Effect } from "babylonjs/Materials/effect";
  24166. import "babylonjs/Shaders/postprocess.vertex";
  24167. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24168. import { Engine } from "babylonjs/Engines/engine";
  24169. import { Color4 } from "babylonjs/Maths/math.color";
  24170. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24171. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  24172. import { Scene } from "babylonjs/scene";
  24173. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24174. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  24175. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  24176. /**
  24177. * Size options for a post process
  24178. */
  24179. export type PostProcessOptions = {
  24180. width: number;
  24181. height: number;
  24182. };
  24183. /**
  24184. * PostProcess can be used to apply a shader to a texture after it has been rendered
  24185. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24186. */
  24187. export class PostProcess {
  24188. /**
  24189. * Gets or sets the unique id of the post process
  24190. */
  24191. uniqueId: number;
  24192. /** Name of the PostProcess. */
  24193. name: string;
  24194. /**
  24195. * Width of the texture to apply the post process on
  24196. */
  24197. width: number;
  24198. /**
  24199. * Height of the texture to apply the post process on
  24200. */
  24201. height: number;
  24202. /**
  24203. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  24204. */
  24205. nodeMaterialSource: Nullable<NodeMaterial>;
  24206. /**
  24207. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  24208. * @hidden
  24209. */
  24210. _outputTexture: Nullable<InternalTexture>;
  24211. /**
  24212. * Sampling mode used by the shader
  24213. * See https://doc.babylonjs.com/classes/3.1/texture
  24214. */
  24215. renderTargetSamplingMode: number;
  24216. /**
  24217. * Clear color to use when screen clearing
  24218. */
  24219. clearColor: Color4;
  24220. /**
  24221. * If the buffer needs to be cleared before applying the post process. (default: true)
  24222. * Should be set to false if shader will overwrite all previous pixels.
  24223. */
  24224. autoClear: boolean;
  24225. /**
  24226. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  24227. */
  24228. alphaMode: number;
  24229. /**
  24230. * Sets the setAlphaBlendConstants of the babylon engine
  24231. */
  24232. alphaConstants: Color4;
  24233. /**
  24234. * Animations to be used for the post processing
  24235. */
  24236. animations: import("babylonjs/Animations/animation").Animation[];
  24237. /**
  24238. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  24239. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  24240. */
  24241. enablePixelPerfectMode: boolean;
  24242. /**
  24243. * Force the postprocess to be applied without taking in account viewport
  24244. */
  24245. forceFullscreenViewport: boolean;
  24246. /**
  24247. * List of inspectable custom properties (used by the Inspector)
  24248. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24249. */
  24250. inspectableCustomProperties: IInspectable[];
  24251. /**
  24252. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  24253. *
  24254. * | Value | Type | Description |
  24255. * | ----- | ----------------------------------- | ----------- |
  24256. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  24257. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  24258. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  24259. *
  24260. */
  24261. scaleMode: number;
  24262. /**
  24263. * Force textures to be a power of two (default: false)
  24264. */
  24265. alwaysForcePOT: boolean;
  24266. private _samples;
  24267. /**
  24268. * Number of sample textures (default: 1)
  24269. */
  24270. get samples(): number;
  24271. set samples(n: number);
  24272. /**
  24273. * Modify the scale of the post process to be the same as the viewport (default: false)
  24274. */
  24275. adaptScaleToCurrentViewport: boolean;
  24276. private _camera;
  24277. protected _scene: Scene;
  24278. private _engine;
  24279. private _options;
  24280. private _reusable;
  24281. private _textureType;
  24282. private _textureFormat;
  24283. /**
  24284. * Smart array of input and output textures for the post process.
  24285. * @hidden
  24286. */
  24287. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  24288. /**
  24289. * The index in _textures that corresponds to the output texture.
  24290. * @hidden
  24291. */
  24292. _currentRenderTextureInd: number;
  24293. private _effect;
  24294. private _samplers;
  24295. private _fragmentUrl;
  24296. private _vertexUrl;
  24297. private _parameters;
  24298. private _scaleRatio;
  24299. protected _indexParameters: any;
  24300. private _shareOutputWithPostProcess;
  24301. private _texelSize;
  24302. private _forcedOutputTexture;
  24303. /**
  24304. * Prepass configuration in case this post process needs a texture from prepass
  24305. * @hidden
  24306. */
  24307. _prePassEffectConfiguration: PrePassEffectConfiguration;
  24308. /**
  24309. * Returns the fragment url or shader name used in the post process.
  24310. * @returns the fragment url or name in the shader store.
  24311. */
  24312. getEffectName(): string;
  24313. /**
  24314. * An event triggered when the postprocess is activated.
  24315. */
  24316. onActivateObservable: Observable<Camera>;
  24317. private _onActivateObserver;
  24318. /**
  24319. * A function that is added to the onActivateObservable
  24320. */
  24321. set onActivate(callback: Nullable<(camera: Camera) => void>);
  24322. /**
  24323. * An event triggered when the postprocess changes its size.
  24324. */
  24325. onSizeChangedObservable: Observable<PostProcess>;
  24326. private _onSizeChangedObserver;
  24327. /**
  24328. * A function that is added to the onSizeChangedObservable
  24329. */
  24330. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  24331. /**
  24332. * An event triggered when the postprocess applies its effect.
  24333. */
  24334. onApplyObservable: Observable<Effect>;
  24335. private _onApplyObserver;
  24336. /**
  24337. * A function that is added to the onApplyObservable
  24338. */
  24339. set onApply(callback: (effect: Effect) => void);
  24340. /**
  24341. * An event triggered before rendering the postprocess
  24342. */
  24343. onBeforeRenderObservable: Observable<Effect>;
  24344. private _onBeforeRenderObserver;
  24345. /**
  24346. * A function that is added to the onBeforeRenderObservable
  24347. */
  24348. set onBeforeRender(callback: (effect: Effect) => void);
  24349. /**
  24350. * An event triggered after rendering the postprocess
  24351. */
  24352. onAfterRenderObservable: Observable<Effect>;
  24353. private _onAfterRenderObserver;
  24354. /**
  24355. * A function that is added to the onAfterRenderObservable
  24356. */
  24357. set onAfterRender(callback: (efect: Effect) => void);
  24358. /**
  24359. * 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
  24360. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  24361. */
  24362. get inputTexture(): InternalTexture;
  24363. set inputTexture(value: InternalTexture);
  24364. /**
  24365. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  24366. * the only way to unset it is to use this function to restore its internal state
  24367. */
  24368. restoreDefaultInputTexture(): void;
  24369. /**
  24370. * Gets the camera which post process is applied to.
  24371. * @returns The camera the post process is applied to.
  24372. */
  24373. getCamera(): Camera;
  24374. /**
  24375. * Gets the texel size of the postprocess.
  24376. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  24377. */
  24378. get texelSize(): Vector2;
  24379. /**
  24380. * Creates a new instance PostProcess
  24381. * @param name The name of the PostProcess.
  24382. * @param fragmentUrl The url of the fragment shader to be used.
  24383. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  24384. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  24385. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24386. * @param camera The camera to apply the render pass to.
  24387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24388. * @param engine The engine which the post process will be applied. (default: current engine)
  24389. * @param reusable If the post process can be reused on the same frame. (default: false)
  24390. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  24391. * @param textureType Type of textures used when performing the post process. (default: 0)
  24392. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  24393. * @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
  24394. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  24395. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  24396. */
  24397. 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);
  24398. /**
  24399. * Gets a string identifying the name of the class
  24400. * @returns "PostProcess" string
  24401. */
  24402. getClassName(): string;
  24403. /**
  24404. * Gets the engine which this post process belongs to.
  24405. * @returns The engine the post process was enabled with.
  24406. */
  24407. getEngine(): Engine;
  24408. /**
  24409. * The effect that is created when initializing the post process.
  24410. * @returns The created effect corresponding the the postprocess.
  24411. */
  24412. getEffect(): Effect;
  24413. /**
  24414. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  24415. * @param postProcess The post process to share the output with.
  24416. * @returns This post process.
  24417. */
  24418. shareOutputWith(postProcess: PostProcess): PostProcess;
  24419. /**
  24420. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  24421. * This should be called if the post process that shares output with this post process is disabled/disposed.
  24422. */
  24423. useOwnOutput(): void;
  24424. /**
  24425. * Updates the effect with the current post process compile time values and recompiles the shader.
  24426. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24427. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24428. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24429. * @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
  24430. * @param onCompiled Called when the shader has been compiled.
  24431. * @param onError Called if there is an error when compiling a shader.
  24432. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  24433. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  24434. */
  24435. 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;
  24436. /**
  24437. * The post process is reusable if it can be used multiple times within one frame.
  24438. * @returns If the post process is reusable
  24439. */
  24440. isReusable(): boolean;
  24441. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  24442. markTextureDirty(): void;
  24443. /**
  24444. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  24445. * 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.
  24446. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  24447. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  24448. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  24449. * @returns The target texture that was bound to be written to.
  24450. */
  24451. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  24452. /**
  24453. * If the post process is supported.
  24454. */
  24455. get isSupported(): boolean;
  24456. /**
  24457. * The aspect ratio of the output texture.
  24458. */
  24459. get aspectRatio(): number;
  24460. /**
  24461. * Get a value indicating if the post-process is ready to be used
  24462. * @returns true if the post-process is ready (shader is compiled)
  24463. */
  24464. isReady(): boolean;
  24465. /**
  24466. * Binds all textures and uniforms to the shader, this will be run on every pass.
  24467. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  24468. */
  24469. apply(): Nullable<Effect>;
  24470. private _disposeTextures;
  24471. /**
  24472. * Sets the required values to the prepass renderer.
  24473. * @param prePassRenderer defines the prepass renderer to setup.
  24474. * @returns true if the pre pass is needed.
  24475. */
  24476. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  24477. /**
  24478. * Disposes the post process.
  24479. * @param camera The camera to dispose the post process on.
  24480. */
  24481. dispose(camera?: Camera): void;
  24482. /**
  24483. * Serializes the particle system to a JSON object
  24484. * @returns the JSON object
  24485. */
  24486. serialize(): any;
  24487. /**
  24488. * Creates a material from parsed material data
  24489. * @param parsedPostProcess defines parsed post process data
  24490. * @param scene defines the hosting scene
  24491. * @param rootUrl defines the root URL to use to load textures
  24492. * @returns a new post process
  24493. */
  24494. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  24495. }
  24496. }
  24497. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  24498. /** @hidden */
  24499. export var kernelBlurVaryingDeclaration: {
  24500. name: string;
  24501. shader: string;
  24502. };
  24503. }
  24504. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  24505. /** @hidden */
  24506. export var kernelBlurFragment: {
  24507. name: string;
  24508. shader: string;
  24509. };
  24510. }
  24511. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  24512. /** @hidden */
  24513. export var kernelBlurFragment2: {
  24514. name: string;
  24515. shader: string;
  24516. };
  24517. }
  24518. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  24519. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24520. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  24521. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  24522. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  24523. /** @hidden */
  24524. export var kernelBlurPixelShader: {
  24525. name: string;
  24526. shader: string;
  24527. };
  24528. }
  24529. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  24530. /** @hidden */
  24531. export var kernelBlurVertex: {
  24532. name: string;
  24533. shader: string;
  24534. };
  24535. }
  24536. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  24537. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24538. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  24539. /** @hidden */
  24540. export var kernelBlurVertexShader: {
  24541. name: string;
  24542. shader: string;
  24543. };
  24544. }
  24545. declare module "babylonjs/PostProcesses/blurPostProcess" {
  24546. import { Vector2 } from "babylonjs/Maths/math.vector";
  24547. import { Nullable } from "babylonjs/types";
  24548. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24549. import { Camera } from "babylonjs/Cameras/camera";
  24550. import { Effect } from "babylonjs/Materials/effect";
  24551. import { Engine } from "babylonjs/Engines/engine";
  24552. import "babylonjs/Shaders/kernelBlur.fragment";
  24553. import "babylonjs/Shaders/kernelBlur.vertex";
  24554. import { Scene } from "babylonjs/scene";
  24555. /**
  24556. * The Blur Post Process which blurs an image based on a kernel and direction.
  24557. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  24558. */
  24559. export class BlurPostProcess extends PostProcess {
  24560. private blockCompilation;
  24561. protected _kernel: number;
  24562. protected _idealKernel: number;
  24563. protected _packedFloat: boolean;
  24564. private _staticDefines;
  24565. /** The direction in which to blur the image. */
  24566. direction: Vector2;
  24567. /**
  24568. * Sets the length in pixels of the blur sample region
  24569. */
  24570. set kernel(v: number);
  24571. /**
  24572. * Gets the length in pixels of the blur sample region
  24573. */
  24574. get kernel(): number;
  24575. /**
  24576. * Sets wether or not the blur needs to unpack/repack floats
  24577. */
  24578. set packedFloat(v: boolean);
  24579. /**
  24580. * Gets wether or not the blur is unpacking/repacking floats
  24581. */
  24582. get packedFloat(): boolean;
  24583. /**
  24584. * Gets a string identifying the name of the class
  24585. * @returns "BlurPostProcess" string
  24586. */
  24587. getClassName(): string;
  24588. /**
  24589. * Creates a new instance BlurPostProcess
  24590. * @param name The name of the effect.
  24591. * @param direction The direction in which to blur the image.
  24592. * @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.
  24593. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24594. * @param camera The camera to apply the render pass to.
  24595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24596. * @param engine The engine which the post process will be applied. (default: current engine)
  24597. * @param reusable If the post process can be reused on the same frame. (default: false)
  24598. * @param textureType Type of textures used when performing the post process. (default: 0)
  24599. * @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)
  24600. */
  24601. 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);
  24602. /**
  24603. * Updates the effect with the current post process compile time values and recompiles the shader.
  24604. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24605. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24606. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24607. * @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
  24608. * @param onCompiled Called when the shader has been compiled.
  24609. * @param onError Called if there is an error when compiling a shader.
  24610. */
  24611. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24612. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24613. /**
  24614. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24615. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24616. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24617. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24618. * The gaps between physical kernels are compensated for in the weighting of the samples
  24619. * @param idealKernel Ideal blur kernel.
  24620. * @return Nearest best kernel.
  24621. */
  24622. protected _nearestBestKernel(idealKernel: number): number;
  24623. /**
  24624. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24625. * @param x The point on the Gaussian distribution to sample.
  24626. * @return the value of the Gaussian function at x.
  24627. */
  24628. protected _gaussianWeight(x: number): number;
  24629. /**
  24630. * Generates a string that can be used as a floating point number in GLSL.
  24631. * @param x Value to print.
  24632. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24633. * @return GLSL float string.
  24634. */
  24635. protected _glslFloat(x: number, decimalFigures?: number): string;
  24636. /** @hidden */
  24637. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24638. }
  24639. }
  24640. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24641. import { Scene } from "babylonjs/scene";
  24642. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24643. import { Plane } from "babylonjs/Maths/math.plane";
  24644. /**
  24645. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24646. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24647. * You can then easily use it as a reflectionTexture on a flat surface.
  24648. * In case the surface is not a plane, please consider relying on reflection probes.
  24649. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24650. */
  24651. export class MirrorTexture extends RenderTargetTexture {
  24652. private scene;
  24653. /**
  24654. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24655. * 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.
  24656. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24657. */
  24658. mirrorPlane: Plane;
  24659. /**
  24660. * Define the blur ratio used to blur the reflection if needed.
  24661. */
  24662. set blurRatio(value: number);
  24663. get blurRatio(): number;
  24664. /**
  24665. * Define the adaptive blur kernel used to blur the reflection if needed.
  24666. * This will autocompute the closest best match for the `blurKernel`
  24667. */
  24668. set adaptiveBlurKernel(value: number);
  24669. /**
  24670. * Define the blur kernel used to blur the reflection if needed.
  24671. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24672. */
  24673. set blurKernel(value: number);
  24674. /**
  24675. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24676. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24677. */
  24678. set blurKernelX(value: number);
  24679. get blurKernelX(): number;
  24680. /**
  24681. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24682. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24683. */
  24684. set blurKernelY(value: number);
  24685. get blurKernelY(): number;
  24686. private _autoComputeBlurKernel;
  24687. protected _onRatioRescale(): void;
  24688. private _updateGammaSpace;
  24689. private _imageProcessingConfigChangeObserver;
  24690. private _transformMatrix;
  24691. private _mirrorMatrix;
  24692. private _savedViewMatrix;
  24693. private _blurX;
  24694. private _blurY;
  24695. private _adaptiveBlurKernel;
  24696. private _blurKernelX;
  24697. private _blurKernelY;
  24698. private _blurRatio;
  24699. /**
  24700. * Instantiates a Mirror Texture.
  24701. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24702. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24703. * You can then easily use it as a reflectionTexture on a flat surface.
  24704. * In case the surface is not a plane, please consider relying on reflection probes.
  24705. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24706. * @param name
  24707. * @param size
  24708. * @param scene
  24709. * @param generateMipMaps
  24710. * @param type
  24711. * @param samplingMode
  24712. * @param generateDepthBuffer
  24713. */
  24714. constructor(name: string, size: number | {
  24715. width: number;
  24716. height: number;
  24717. } | {
  24718. ratio: number;
  24719. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24720. private _preparePostProcesses;
  24721. /**
  24722. * Clone the mirror texture.
  24723. * @returns the cloned texture
  24724. */
  24725. clone(): MirrorTexture;
  24726. /**
  24727. * Serialize the texture to a JSON representation you could use in Parse later on
  24728. * @returns the serialized JSON representation
  24729. */
  24730. serialize(): any;
  24731. /**
  24732. * Dispose the texture and release its associated resources.
  24733. */
  24734. dispose(): void;
  24735. }
  24736. }
  24737. declare module "babylonjs/Materials/Textures/texture" {
  24738. import { Observable } from "babylonjs/Misc/observable";
  24739. import { Nullable } from "babylonjs/types";
  24740. import { Matrix } from "babylonjs/Maths/math.vector";
  24741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24742. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24743. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24744. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24745. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24746. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24747. import { Scene } from "babylonjs/scene";
  24748. /**
  24749. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24750. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24751. */
  24752. export class Texture extends BaseTexture {
  24753. /**
  24754. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24755. */
  24756. static SerializeBuffers: boolean;
  24757. /** @hidden */
  24758. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24759. /** @hidden */
  24760. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24761. /** @hidden */
  24762. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24763. /** nearest is mag = nearest and min = nearest and mip = linear */
  24764. static readonly NEAREST_SAMPLINGMODE: number;
  24765. /** nearest is mag = nearest and min = nearest and mip = linear */
  24766. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24767. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24768. static readonly BILINEAR_SAMPLINGMODE: number;
  24769. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24770. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24771. /** Trilinear is mag = linear and min = linear and mip = linear */
  24772. static readonly TRILINEAR_SAMPLINGMODE: number;
  24773. /** Trilinear is mag = linear and min = linear and mip = linear */
  24774. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24775. /** mag = nearest and min = nearest and mip = nearest */
  24776. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24777. /** mag = nearest and min = linear and mip = nearest */
  24778. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24779. /** mag = nearest and min = linear and mip = linear */
  24780. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24781. /** mag = nearest and min = linear and mip = none */
  24782. static readonly NEAREST_LINEAR: number;
  24783. /** mag = nearest and min = nearest and mip = none */
  24784. static readonly NEAREST_NEAREST: number;
  24785. /** mag = linear and min = nearest and mip = nearest */
  24786. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24787. /** mag = linear and min = nearest and mip = linear */
  24788. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24789. /** mag = linear and min = linear and mip = none */
  24790. static readonly LINEAR_LINEAR: number;
  24791. /** mag = linear and min = nearest and mip = none */
  24792. static readonly LINEAR_NEAREST: number;
  24793. /** Explicit coordinates mode */
  24794. static readonly EXPLICIT_MODE: number;
  24795. /** Spherical coordinates mode */
  24796. static readonly SPHERICAL_MODE: number;
  24797. /** Planar coordinates mode */
  24798. static readonly PLANAR_MODE: number;
  24799. /** Cubic coordinates mode */
  24800. static readonly CUBIC_MODE: number;
  24801. /** Projection coordinates mode */
  24802. static readonly PROJECTION_MODE: number;
  24803. /** Inverse Cubic coordinates mode */
  24804. static readonly SKYBOX_MODE: number;
  24805. /** Inverse Cubic coordinates mode */
  24806. static readonly INVCUBIC_MODE: number;
  24807. /** Equirectangular coordinates mode */
  24808. static readonly EQUIRECTANGULAR_MODE: number;
  24809. /** Equirectangular Fixed coordinates mode */
  24810. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24811. /** Equirectangular Fixed Mirrored coordinates mode */
  24812. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24813. /** Texture is not repeating outside of 0..1 UVs */
  24814. static readonly CLAMP_ADDRESSMODE: number;
  24815. /** Texture is repeating outside of 0..1 UVs */
  24816. static readonly WRAP_ADDRESSMODE: number;
  24817. /** Texture is repeating and mirrored */
  24818. static readonly MIRROR_ADDRESSMODE: number;
  24819. /**
  24820. * 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
  24821. */
  24822. static UseSerializedUrlIfAny: boolean;
  24823. /**
  24824. * Define the url of the texture.
  24825. */
  24826. url: Nullable<string>;
  24827. /**
  24828. * Define an offset on the texture to offset the u coordinates of the UVs
  24829. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24830. */
  24831. uOffset: number;
  24832. /**
  24833. * Define an offset on the texture to offset the v coordinates of the UVs
  24834. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24835. */
  24836. vOffset: number;
  24837. /**
  24838. * Define an offset on the texture to scale the u coordinates of the UVs
  24839. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24840. */
  24841. uScale: number;
  24842. /**
  24843. * Define an offset on the texture to scale the v coordinates of the UVs
  24844. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24845. */
  24846. vScale: number;
  24847. /**
  24848. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24849. * @see https://doc.babylonjs.com/how_to/more_materials
  24850. */
  24851. uAng: number;
  24852. /**
  24853. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24854. * @see https://doc.babylonjs.com/how_to/more_materials
  24855. */
  24856. vAng: number;
  24857. /**
  24858. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24859. * @see https://doc.babylonjs.com/how_to/more_materials
  24860. */
  24861. wAng: number;
  24862. /**
  24863. * Defines the center of rotation (U)
  24864. */
  24865. uRotationCenter: number;
  24866. /**
  24867. * Defines the center of rotation (V)
  24868. */
  24869. vRotationCenter: number;
  24870. /**
  24871. * Defines the center of rotation (W)
  24872. */
  24873. wRotationCenter: number;
  24874. /**
  24875. * Are mip maps generated for this texture or not.
  24876. */
  24877. get noMipmap(): boolean;
  24878. /**
  24879. * List of inspectable custom properties (used by the Inspector)
  24880. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24881. */
  24882. inspectableCustomProperties: Nullable<IInspectable[]>;
  24883. private _noMipmap;
  24884. /** @hidden */
  24885. _invertY: boolean;
  24886. private _rowGenerationMatrix;
  24887. private _cachedTextureMatrix;
  24888. private _projectionModeMatrix;
  24889. private _t0;
  24890. private _t1;
  24891. private _t2;
  24892. private _cachedUOffset;
  24893. private _cachedVOffset;
  24894. private _cachedUScale;
  24895. private _cachedVScale;
  24896. private _cachedUAng;
  24897. private _cachedVAng;
  24898. private _cachedWAng;
  24899. private _cachedProjectionMatrixId;
  24900. private _cachedCoordinatesMode;
  24901. /** @hidden */
  24902. protected _initialSamplingMode: number;
  24903. /** @hidden */
  24904. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24905. private _deleteBuffer;
  24906. protected _format: Nullable<number>;
  24907. private _delayedOnLoad;
  24908. private _delayedOnError;
  24909. private _mimeType?;
  24910. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24911. get mimeType(): string | undefined;
  24912. /**
  24913. * Observable triggered once the texture has been loaded.
  24914. */
  24915. onLoadObservable: Observable<Texture>;
  24916. protected _isBlocking: boolean;
  24917. /**
  24918. * Is the texture preventing material to render while loading.
  24919. * If false, a default texture will be used instead of the loading one during the preparation step.
  24920. */
  24921. set isBlocking(value: boolean);
  24922. get isBlocking(): boolean;
  24923. /**
  24924. * Get the current sampling mode associated with the texture.
  24925. */
  24926. get samplingMode(): number;
  24927. /**
  24928. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24929. */
  24930. get invertY(): boolean;
  24931. /**
  24932. * Instantiates a new texture.
  24933. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24934. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24935. * @param url defines the url of the picture to load as a texture
  24936. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24937. * @param noMipmap defines if the texture will require mip maps or not
  24938. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24939. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24940. * @param onLoad defines a callback triggered when the texture has been loaded
  24941. * @param onError defines a callback triggered when an error occurred during the loading session
  24942. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24943. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24944. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24945. * @param mimeType defines an optional mime type information
  24946. */
  24947. 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);
  24948. /**
  24949. * Update the url (and optional buffer) of this texture if url was null during construction.
  24950. * @param url the url of the texture
  24951. * @param buffer the buffer of the texture (defaults to null)
  24952. * @param onLoad callback called when the texture is loaded (defaults to null)
  24953. */
  24954. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24955. /**
  24956. * Finish the loading sequence of a texture flagged as delayed load.
  24957. * @hidden
  24958. */
  24959. delayLoad(): void;
  24960. private _prepareRowForTextureGeneration;
  24961. /**
  24962. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24963. * @returns the transform matrix of the texture.
  24964. */
  24965. getTextureMatrix(uBase?: number): Matrix;
  24966. /**
  24967. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24968. * @returns The reflection texture transform
  24969. */
  24970. getReflectionTextureMatrix(): Matrix;
  24971. /**
  24972. * Clones the texture.
  24973. * @returns the cloned texture
  24974. */
  24975. clone(): Texture;
  24976. /**
  24977. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24978. * @returns The JSON representation of the texture
  24979. */
  24980. serialize(): any;
  24981. /**
  24982. * Get the current class name of the texture useful for serialization or dynamic coding.
  24983. * @returns "Texture"
  24984. */
  24985. getClassName(): string;
  24986. /**
  24987. * Dispose the texture and release its associated resources.
  24988. */
  24989. dispose(): void;
  24990. /**
  24991. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24992. * @param parsedTexture Define the JSON representation of the texture
  24993. * @param scene Define the scene the parsed texture should be instantiated in
  24994. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24995. * @returns The parsed texture if successful
  24996. */
  24997. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24998. /**
  24999. * Creates a texture from its base 64 representation.
  25000. * @param data Define the base64 payload without the data: prefix
  25001. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  25002. * @param scene Define the scene the texture should belong to
  25003. * @param noMipmap Forces the texture to not create mip map information if true
  25004. * @param invertY define if the texture needs to be inverted on the y axis during loading
  25005. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  25006. * @param onLoad define a callback triggered when the texture has been loaded
  25007. * @param onError define a callback triggered when an error occurred during the loading session
  25008. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  25009. * @returns the created texture
  25010. */
  25011. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  25012. /**
  25013. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  25014. * @param data Define the base64 payload without the data: prefix
  25015. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  25016. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  25017. * @param scene Define the scene the texture should belong to
  25018. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  25019. * @param noMipmap Forces the texture to not create mip map information if true
  25020. * @param invertY define if the texture needs to be inverted on the y axis during loading
  25021. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  25022. * @param onLoad define a callback triggered when the texture has been loaded
  25023. * @param onError define a callback triggered when an error occurred during the loading session
  25024. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  25025. * @returns the created texture
  25026. */
  25027. 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;
  25028. }
  25029. }
  25030. declare module "babylonjs/PostProcesses/postProcessManager" {
  25031. import { Nullable } from "babylonjs/types";
  25032. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25033. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25034. import { Scene } from "babylonjs/scene";
  25035. /**
  25036. * PostProcessManager is used to manage one or more post processes or post process pipelines
  25037. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  25038. */
  25039. export class PostProcessManager {
  25040. private _scene;
  25041. private _indexBuffer;
  25042. private _vertexBuffers;
  25043. /**
  25044. * Creates a new instance PostProcess
  25045. * @param scene The scene that the post process is associated with.
  25046. */
  25047. constructor(scene: Scene);
  25048. private _prepareBuffers;
  25049. private _buildIndexBuffer;
  25050. /**
  25051. * Rebuilds the vertex buffers of the manager.
  25052. * @hidden
  25053. */
  25054. _rebuild(): void;
  25055. /**
  25056. * Prepares a frame to be run through a post process.
  25057. * @param sourceTexture The input texture to the post procesess. (default: null)
  25058. * @param postProcesses An array of post processes to be run. (default: null)
  25059. * @returns True if the post processes were able to be run.
  25060. * @hidden
  25061. */
  25062. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  25063. /**
  25064. * Manually render a set of post processes to a texture.
  25065. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  25066. * @param postProcesses An array of post processes to be run.
  25067. * @param targetTexture The target texture to render to.
  25068. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  25069. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  25070. * @param lodLevel defines which lod of the texture to render to
  25071. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  25072. */
  25073. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  25074. /**
  25075. * Finalize the result of the output of the postprocesses.
  25076. * @param doNotPresent If true the result will not be displayed to the screen.
  25077. * @param targetTexture The target texture to render to.
  25078. * @param faceIndex The index of the face to bind the target texture to.
  25079. * @param postProcesses The array of post processes to render.
  25080. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  25081. * @hidden
  25082. */
  25083. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  25084. /**
  25085. * Disposes of the post process manager.
  25086. */
  25087. dispose(): void;
  25088. }
  25089. }
  25090. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  25091. import { Observable } from "babylonjs/Misc/observable";
  25092. import { SmartArray } from "babylonjs/Misc/smartArray";
  25093. import { Nullable, Immutable } from "babylonjs/types";
  25094. import { Camera } from "babylonjs/Cameras/camera";
  25095. import { Scene } from "babylonjs/scene";
  25096. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25097. import { Color4 } from "babylonjs/Maths/math.color";
  25098. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  25099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25100. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25101. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25102. import { Texture } from "babylonjs/Materials/Textures/texture";
  25103. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25104. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  25105. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25106. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  25107. import { Engine } from "babylonjs/Engines/engine";
  25108. /**
  25109. * This Helps creating a texture that will be created from a camera in your scene.
  25110. * It is basically a dynamic texture that could be used to create special effects for instance.
  25111. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  25112. */
  25113. export class RenderTargetTexture extends Texture {
  25114. /**
  25115. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  25116. */
  25117. static readonly REFRESHRATE_RENDER_ONCE: number;
  25118. /**
  25119. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  25120. */
  25121. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  25122. /**
  25123. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  25124. * the central point of your effect and can save a lot of performances.
  25125. */
  25126. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  25127. /**
  25128. * Use this predicate to dynamically define the list of mesh you want to render.
  25129. * If set, the renderList property will be overwritten.
  25130. */
  25131. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  25132. private _renderList;
  25133. /**
  25134. * Use this list to define the list of mesh you want to render.
  25135. */
  25136. get renderList(): Nullable<Array<AbstractMesh>>;
  25137. set renderList(value: Nullable<Array<AbstractMesh>>);
  25138. /**
  25139. * Use this function to overload the renderList array at rendering time.
  25140. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  25141. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  25142. * the cube (if the RTT is a cube, else layerOrFace=0).
  25143. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  25144. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  25145. * hold dummy elements!
  25146. */
  25147. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  25148. private _hookArray;
  25149. /**
  25150. * Define if particles should be rendered in your texture.
  25151. */
  25152. renderParticles: boolean;
  25153. /**
  25154. * Define if sprites should be rendered in your texture.
  25155. */
  25156. renderSprites: boolean;
  25157. /**
  25158. * Define the camera used to render the texture.
  25159. */
  25160. activeCamera: Nullable<Camera>;
  25161. /**
  25162. * Override the mesh isReady function with your own one.
  25163. */
  25164. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  25165. /**
  25166. * Override the render function of the texture with your own one.
  25167. */
  25168. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  25169. /**
  25170. * Define if camera post processes should be use while rendering the texture.
  25171. */
  25172. useCameraPostProcesses: boolean;
  25173. /**
  25174. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  25175. */
  25176. ignoreCameraViewport: boolean;
  25177. private _postProcessManager;
  25178. private _postProcesses;
  25179. private _resizeObserver;
  25180. /**
  25181. * An event triggered when the texture is unbind.
  25182. */
  25183. onBeforeBindObservable: Observable<RenderTargetTexture>;
  25184. /**
  25185. * An event triggered when the texture is unbind.
  25186. */
  25187. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  25188. private _onAfterUnbindObserver;
  25189. /**
  25190. * Set a after unbind callback in the texture.
  25191. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  25192. */
  25193. set onAfterUnbind(callback: () => void);
  25194. /**
  25195. * An event triggered before rendering the texture
  25196. */
  25197. onBeforeRenderObservable: Observable<number>;
  25198. private _onBeforeRenderObserver;
  25199. /**
  25200. * Set a before render callback in the texture.
  25201. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  25202. */
  25203. set onBeforeRender(callback: (faceIndex: number) => void);
  25204. /**
  25205. * An event triggered after rendering the texture
  25206. */
  25207. onAfterRenderObservable: Observable<number>;
  25208. private _onAfterRenderObserver;
  25209. /**
  25210. * Set a after render callback in the texture.
  25211. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  25212. */
  25213. set onAfterRender(callback: (faceIndex: number) => void);
  25214. /**
  25215. * An event triggered after the texture clear
  25216. */
  25217. onClearObservable: Observable<Engine>;
  25218. private _onClearObserver;
  25219. /**
  25220. * Set a clear callback in the texture.
  25221. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  25222. */
  25223. set onClear(callback: (Engine: Engine) => void);
  25224. /**
  25225. * An event triggered when the texture is resized.
  25226. */
  25227. onResizeObservable: Observable<RenderTargetTexture>;
  25228. /**
  25229. * Define the clear color of the Render Target if it should be different from the scene.
  25230. */
  25231. clearColor: Color4;
  25232. protected _size: number | {
  25233. width: number;
  25234. height: number;
  25235. layers?: number;
  25236. };
  25237. protected _initialSizeParameter: number | {
  25238. width: number;
  25239. height: number;
  25240. } | {
  25241. ratio: number;
  25242. };
  25243. protected _sizeRatio: Nullable<number>;
  25244. /** @hidden */
  25245. _generateMipMaps: boolean;
  25246. protected _renderingManager: RenderingManager;
  25247. /** @hidden */
  25248. _waitingRenderList?: string[];
  25249. protected _doNotChangeAspectRatio: boolean;
  25250. protected _currentRefreshId: number;
  25251. protected _refreshRate: number;
  25252. protected _textureMatrix: Matrix;
  25253. protected _samples: number;
  25254. protected _renderTargetOptions: RenderTargetCreationOptions;
  25255. /**
  25256. * Gets render target creation options that were used.
  25257. */
  25258. get renderTargetOptions(): RenderTargetCreationOptions;
  25259. protected _onRatioRescale(): void;
  25260. /**
  25261. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  25262. * It must define where the camera used to render the texture is set
  25263. */
  25264. boundingBoxPosition: Vector3;
  25265. private _boundingBoxSize;
  25266. /**
  25267. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  25268. * When defined, the cubemap will switch to local mode
  25269. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  25270. * @example https://www.babylonjs-playground.com/#RNASML
  25271. */
  25272. set boundingBoxSize(value: Vector3);
  25273. get boundingBoxSize(): Vector3;
  25274. /**
  25275. * In case the RTT has been created with a depth texture, get the associated
  25276. * depth texture.
  25277. * Otherwise, return null.
  25278. */
  25279. get depthStencilTexture(): Nullable<InternalTexture>;
  25280. /**
  25281. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  25282. * or used a shadow, depth texture...
  25283. * @param name The friendly name of the texture
  25284. * @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)
  25285. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  25286. * @param generateMipMaps True if mip maps need to be generated after render.
  25287. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  25288. * @param type The type of the buffer in the RTT (int, half float, float...)
  25289. * @param isCube True if a cube texture needs to be created
  25290. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  25291. * @param generateDepthBuffer True to generate a depth buffer
  25292. * @param generateStencilBuffer True to generate a stencil buffer
  25293. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  25294. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  25295. * @param delayAllocation if the texture allocation should be delayed (default: false)
  25296. */
  25297. constructor(name: string, size: number | {
  25298. width: number;
  25299. height: number;
  25300. layers?: number;
  25301. } | {
  25302. ratio: number;
  25303. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  25304. /**
  25305. * Creates a depth stencil texture.
  25306. * This is only available in WebGL 2 or with the depth texture extension available.
  25307. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  25308. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  25309. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  25310. */
  25311. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  25312. private _processSizeParameter;
  25313. /**
  25314. * Define the number of samples to use in case of MSAA.
  25315. * It defaults to one meaning no MSAA has been enabled.
  25316. */
  25317. get samples(): number;
  25318. set samples(value: number);
  25319. /**
  25320. * Resets the refresh counter of the texture and start bak from scratch.
  25321. * Could be useful to regenerate the texture if it is setup to render only once.
  25322. */
  25323. resetRefreshCounter(): void;
  25324. /**
  25325. * Define the refresh rate of the texture or the rendering frequency.
  25326. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  25327. */
  25328. get refreshRate(): number;
  25329. set refreshRate(value: number);
  25330. /**
  25331. * Adds a post process to the render target rendering passes.
  25332. * @param postProcess define the post process to add
  25333. */
  25334. addPostProcess(postProcess: PostProcess): void;
  25335. /**
  25336. * Clear all the post processes attached to the render target
  25337. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  25338. */
  25339. clearPostProcesses(dispose?: boolean): void;
  25340. /**
  25341. * Remove one of the post process from the list of attached post processes to the texture
  25342. * @param postProcess define the post process to remove from the list
  25343. */
  25344. removePostProcess(postProcess: PostProcess): void;
  25345. /** @hidden */
  25346. _shouldRender(): boolean;
  25347. /**
  25348. * Gets the actual render size of the texture.
  25349. * @returns the width of the render size
  25350. */
  25351. getRenderSize(): number;
  25352. /**
  25353. * Gets the actual render width of the texture.
  25354. * @returns the width of the render size
  25355. */
  25356. getRenderWidth(): number;
  25357. /**
  25358. * Gets the actual render height of the texture.
  25359. * @returns the height of the render size
  25360. */
  25361. getRenderHeight(): number;
  25362. /**
  25363. * Gets the actual number of layers of the texture.
  25364. * @returns the number of layers
  25365. */
  25366. getRenderLayers(): number;
  25367. /**
  25368. * Get if the texture can be rescaled or not.
  25369. */
  25370. get canRescale(): boolean;
  25371. /**
  25372. * Resize the texture using a ratio.
  25373. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  25374. */
  25375. scale(ratio: number): void;
  25376. /**
  25377. * Get the texture reflection matrix used to rotate/transform the reflection.
  25378. * @returns the reflection matrix
  25379. */
  25380. getReflectionTextureMatrix(): Matrix;
  25381. /**
  25382. * Resize the texture to a new desired size.
  25383. * Be carrefull as it will recreate all the data in the new texture.
  25384. * @param size Define the new size. It can be:
  25385. * - a number for squared texture,
  25386. * - an object containing { width: number, height: number }
  25387. * - or an object containing a ratio { ratio: number }
  25388. */
  25389. resize(size: number | {
  25390. width: number;
  25391. height: number;
  25392. } | {
  25393. ratio: number;
  25394. }): void;
  25395. private _defaultRenderListPrepared;
  25396. /**
  25397. * Renders all the objects from the render list into the texture.
  25398. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  25399. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  25400. */
  25401. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  25402. private _bestReflectionRenderTargetDimension;
  25403. private _prepareRenderingManager;
  25404. /**
  25405. * @hidden
  25406. * @param faceIndex face index to bind to if this is a cubetexture
  25407. * @param layer defines the index of the texture to bind in the array
  25408. */
  25409. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  25410. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25411. private renderToTarget;
  25412. /**
  25413. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  25414. * This allowed control for front to back rendering or reversly depending of the special needs.
  25415. *
  25416. * @param renderingGroupId The rendering group id corresponding to its index
  25417. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  25418. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  25419. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  25420. */
  25421. 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;
  25422. /**
  25423. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25424. *
  25425. * @param renderingGroupId The rendering group id corresponding to its index
  25426. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25427. */
  25428. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  25429. /**
  25430. * Clones the texture.
  25431. * @returns the cloned texture
  25432. */
  25433. clone(): RenderTargetTexture;
  25434. /**
  25435. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  25436. * @returns The JSON representation of the texture
  25437. */
  25438. serialize(): any;
  25439. /**
  25440. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  25441. */
  25442. disposeFramebufferObjects(): void;
  25443. /**
  25444. * Dispose the texture and release its associated resources.
  25445. */
  25446. dispose(): void;
  25447. /** @hidden */
  25448. _rebuild(): void;
  25449. /**
  25450. * Clear the info related to rendering groups preventing retention point in material dispose.
  25451. */
  25452. freeRenderingGroups(): void;
  25453. /**
  25454. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  25455. * @returns the view count
  25456. */
  25457. getViewCount(): number;
  25458. }
  25459. }
  25460. declare module "babylonjs/Misc/guid" {
  25461. /**
  25462. * Class used to manipulate GUIDs
  25463. */
  25464. export class GUID {
  25465. /**
  25466. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25467. * Be aware Math.random() could cause collisions, but:
  25468. * "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"
  25469. * @returns a pseudo random id
  25470. */
  25471. static RandomId(): string;
  25472. }
  25473. }
  25474. declare module "babylonjs/Materials/shadowDepthWrapper" {
  25475. import { Nullable } from "babylonjs/types";
  25476. import { Scene } from "babylonjs/scene";
  25477. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25478. import { Material } from "babylonjs/Materials/material";
  25479. import { Effect } from "babylonjs/Materials/effect";
  25480. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  25481. /**
  25482. * Options to be used when creating a shadow depth material
  25483. */
  25484. export interface IIOptionShadowDepthMaterial {
  25485. /** Variables in the vertex shader code that need to have their names remapped.
  25486. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  25487. * "var_name" should be either: worldPos or vNormalW
  25488. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  25489. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  25490. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  25491. */
  25492. remappedVariables?: string[];
  25493. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  25494. standalone?: boolean;
  25495. }
  25496. /**
  25497. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  25498. */
  25499. export class ShadowDepthWrapper {
  25500. private _scene;
  25501. private _options?;
  25502. private _baseMaterial;
  25503. private _onEffectCreatedObserver;
  25504. private _subMeshToEffect;
  25505. private _subMeshToDepthEffect;
  25506. private _meshes;
  25507. /** @hidden */
  25508. _matriceNames: any;
  25509. /** Gets the standalone status of the wrapper */
  25510. get standalone(): boolean;
  25511. /** Gets the base material the wrapper is built upon */
  25512. get baseMaterial(): Material;
  25513. /**
  25514. * Instantiate a new shadow depth wrapper.
  25515. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  25516. * generate the shadow depth map. For more information, please refer to the documentation:
  25517. * https://doc.babylonjs.com/babylon101/shadows
  25518. * @param baseMaterial Material to wrap
  25519. * @param scene Define the scene the material belongs to
  25520. * @param options Options used to create the wrapper
  25521. */
  25522. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  25523. /**
  25524. * Gets the effect to use to generate the depth map
  25525. * @param subMesh subMesh to get the effect for
  25526. * @param shadowGenerator shadow generator to get the effect for
  25527. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  25528. */
  25529. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  25530. /**
  25531. * Specifies that the submesh is ready to be used for depth rendering
  25532. * @param subMesh submesh to check
  25533. * @param defines the list of defines to take into account when checking the effect
  25534. * @param shadowGenerator combined with subMesh, it defines the effect to check
  25535. * @param useInstances specifies that instances should be used
  25536. * @returns a boolean indicating that the submesh is ready or not
  25537. */
  25538. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  25539. /**
  25540. * Disposes the resources
  25541. */
  25542. dispose(): void;
  25543. private _makeEffect;
  25544. }
  25545. }
  25546. declare module "babylonjs/Materials/material" {
  25547. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25548. import { SmartArray } from "babylonjs/Misc/smartArray";
  25549. import { Observable } from "babylonjs/Misc/observable";
  25550. import { Nullable } from "babylonjs/types";
  25551. import { Scene } from "babylonjs/scene";
  25552. import { Matrix } from "babylonjs/Maths/math.vector";
  25553. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25555. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25556. import { Effect } from "babylonjs/Materials/effect";
  25557. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25558. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25559. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25560. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25561. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25562. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25563. import { Mesh } from "babylonjs/Meshes/mesh";
  25564. import { Animation } from "babylonjs/Animations/animation";
  25565. /**
  25566. * Options for compiling materials.
  25567. */
  25568. export interface IMaterialCompilationOptions {
  25569. /**
  25570. * Defines whether clip planes are enabled.
  25571. */
  25572. clipPlane: boolean;
  25573. /**
  25574. * Defines whether instances are enabled.
  25575. */
  25576. useInstances: boolean;
  25577. }
  25578. /**
  25579. * Options passed when calling customShaderNameResolve
  25580. */
  25581. export interface ICustomShaderNameResolveOptions {
  25582. /**
  25583. * 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
  25584. */
  25585. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25586. }
  25587. /**
  25588. * Base class for the main features of a material in Babylon.js
  25589. */
  25590. export class Material implements IAnimatable {
  25591. /**
  25592. * Returns the triangle fill mode
  25593. */
  25594. static readonly TriangleFillMode: number;
  25595. /**
  25596. * Returns the wireframe mode
  25597. */
  25598. static readonly WireFrameFillMode: number;
  25599. /**
  25600. * Returns the point fill mode
  25601. */
  25602. static readonly PointFillMode: number;
  25603. /**
  25604. * Returns the point list draw mode
  25605. */
  25606. static readonly PointListDrawMode: number;
  25607. /**
  25608. * Returns the line list draw mode
  25609. */
  25610. static readonly LineListDrawMode: number;
  25611. /**
  25612. * Returns the line loop draw mode
  25613. */
  25614. static readonly LineLoopDrawMode: number;
  25615. /**
  25616. * Returns the line strip draw mode
  25617. */
  25618. static readonly LineStripDrawMode: number;
  25619. /**
  25620. * Returns the triangle strip draw mode
  25621. */
  25622. static readonly TriangleStripDrawMode: number;
  25623. /**
  25624. * Returns the triangle fan draw mode
  25625. */
  25626. static readonly TriangleFanDrawMode: number;
  25627. /**
  25628. * Stores the clock-wise side orientation
  25629. */
  25630. static readonly ClockWiseSideOrientation: number;
  25631. /**
  25632. * Stores the counter clock-wise side orientation
  25633. */
  25634. static readonly CounterClockWiseSideOrientation: number;
  25635. /**
  25636. * The dirty texture flag value
  25637. */
  25638. static readonly TextureDirtyFlag: number;
  25639. /**
  25640. * The dirty light flag value
  25641. */
  25642. static readonly LightDirtyFlag: number;
  25643. /**
  25644. * The dirty fresnel flag value
  25645. */
  25646. static readonly FresnelDirtyFlag: number;
  25647. /**
  25648. * The dirty attribute flag value
  25649. */
  25650. static readonly AttributesDirtyFlag: number;
  25651. /**
  25652. * The dirty misc flag value
  25653. */
  25654. static readonly MiscDirtyFlag: number;
  25655. /**
  25656. * The dirty prepass flag value
  25657. */
  25658. static readonly PrePassDirtyFlag: number;
  25659. /**
  25660. * The all dirty flag value
  25661. */
  25662. static readonly AllDirtyFlag: number;
  25663. /**
  25664. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25665. */
  25666. static readonly MATERIAL_OPAQUE: number;
  25667. /**
  25668. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25669. */
  25670. static readonly MATERIAL_ALPHATEST: number;
  25671. /**
  25672. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25673. */
  25674. static readonly MATERIAL_ALPHABLEND: number;
  25675. /**
  25676. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25677. * They are also discarded below the alpha cutoff threshold to improve performances.
  25678. */
  25679. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25680. /**
  25681. * The Whiteout method is used to blend normals.
  25682. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25683. */
  25684. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25685. /**
  25686. * The Reoriented Normal Mapping method is used to blend normals.
  25687. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25688. */
  25689. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25690. /**
  25691. * Custom callback helping to override the default shader used in the material.
  25692. */
  25693. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25694. /**
  25695. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25696. */
  25697. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25698. /**
  25699. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25700. * This means that the material can keep using a previous shader while a new one is being compiled.
  25701. * This is mostly used when shader parallel compilation is supported (true by default)
  25702. */
  25703. allowShaderHotSwapping: boolean;
  25704. /**
  25705. * The ID of the material
  25706. */
  25707. id: string;
  25708. /**
  25709. * Gets or sets the unique id of the material
  25710. */
  25711. uniqueId: number;
  25712. /**
  25713. * The name of the material
  25714. */
  25715. name: string;
  25716. /**
  25717. * Gets or sets user defined metadata
  25718. */
  25719. metadata: any;
  25720. /**
  25721. * For internal use only. Please do not use.
  25722. */
  25723. reservedDataStore: any;
  25724. /**
  25725. * Specifies if the ready state should be checked on each call
  25726. */
  25727. checkReadyOnEveryCall: boolean;
  25728. /**
  25729. * Specifies if the ready state should be checked once
  25730. */
  25731. checkReadyOnlyOnce: boolean;
  25732. /**
  25733. * The state of the material
  25734. */
  25735. state: string;
  25736. /**
  25737. * If the material can be rendered to several textures with MRT extension
  25738. */
  25739. get canRenderToMRT(): boolean;
  25740. /**
  25741. * The alpha value of the material
  25742. */
  25743. protected _alpha: number;
  25744. /**
  25745. * List of inspectable custom properties (used by the Inspector)
  25746. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25747. */
  25748. inspectableCustomProperties: IInspectable[];
  25749. /**
  25750. * Sets the alpha value of the material
  25751. */
  25752. set alpha(value: number);
  25753. /**
  25754. * Gets the alpha value of the material
  25755. */
  25756. get alpha(): number;
  25757. /**
  25758. * Specifies if back face culling is enabled
  25759. */
  25760. protected _backFaceCulling: boolean;
  25761. /**
  25762. * Sets the back-face culling state
  25763. */
  25764. set backFaceCulling(value: boolean);
  25765. /**
  25766. * Gets the back-face culling state
  25767. */
  25768. get backFaceCulling(): boolean;
  25769. /**
  25770. * Stores the value for side orientation
  25771. */
  25772. sideOrientation: number;
  25773. /**
  25774. * Callback triggered when the material is compiled
  25775. */
  25776. onCompiled: Nullable<(effect: Effect) => void>;
  25777. /**
  25778. * Callback triggered when an error occurs
  25779. */
  25780. onError: Nullable<(effect: Effect, errors: string) => void>;
  25781. /**
  25782. * Callback triggered to get the render target textures
  25783. */
  25784. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25785. /**
  25786. * Gets a boolean indicating that current material needs to register RTT
  25787. */
  25788. get hasRenderTargetTextures(): boolean;
  25789. /**
  25790. * Specifies if the material should be serialized
  25791. */
  25792. doNotSerialize: boolean;
  25793. /**
  25794. * @hidden
  25795. */
  25796. _storeEffectOnSubMeshes: boolean;
  25797. /**
  25798. * Stores the animations for the material
  25799. */
  25800. animations: Nullable<Array<Animation>>;
  25801. /**
  25802. * An event triggered when the material is disposed
  25803. */
  25804. onDisposeObservable: Observable<Material>;
  25805. /**
  25806. * An observer which watches for dispose events
  25807. */
  25808. private _onDisposeObserver;
  25809. private _onUnBindObservable;
  25810. /**
  25811. * Called during a dispose event
  25812. */
  25813. set onDispose(callback: () => void);
  25814. private _onBindObservable;
  25815. /**
  25816. * An event triggered when the material is bound
  25817. */
  25818. get onBindObservable(): Observable<AbstractMesh>;
  25819. /**
  25820. * An observer which watches for bind events
  25821. */
  25822. private _onBindObserver;
  25823. /**
  25824. * Called during a bind event
  25825. */
  25826. set onBind(callback: (Mesh: AbstractMesh) => void);
  25827. /**
  25828. * An event triggered when the material is unbound
  25829. */
  25830. get onUnBindObservable(): Observable<Material>;
  25831. protected _onEffectCreatedObservable: Nullable<Observable<{
  25832. effect: Effect;
  25833. subMesh: Nullable<SubMesh>;
  25834. }>>;
  25835. /**
  25836. * An event triggered when the effect is (re)created
  25837. */
  25838. get onEffectCreatedObservable(): Observable<{
  25839. effect: Effect;
  25840. subMesh: Nullable<SubMesh>;
  25841. }>;
  25842. /**
  25843. * Stores the value of the alpha mode
  25844. */
  25845. private _alphaMode;
  25846. /**
  25847. * Sets the value of the alpha mode.
  25848. *
  25849. * | Value | Type | Description |
  25850. * | --- | --- | --- |
  25851. * | 0 | ALPHA_DISABLE | |
  25852. * | 1 | ALPHA_ADD | |
  25853. * | 2 | ALPHA_COMBINE | |
  25854. * | 3 | ALPHA_SUBTRACT | |
  25855. * | 4 | ALPHA_MULTIPLY | |
  25856. * | 5 | ALPHA_MAXIMIZED | |
  25857. * | 6 | ALPHA_ONEONE | |
  25858. * | 7 | ALPHA_PREMULTIPLIED | |
  25859. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25860. * | 9 | ALPHA_INTERPOLATE | |
  25861. * | 10 | ALPHA_SCREENMODE | |
  25862. *
  25863. */
  25864. set alphaMode(value: number);
  25865. /**
  25866. * Gets the value of the alpha mode
  25867. */
  25868. get alphaMode(): number;
  25869. /**
  25870. * Stores the state of the need depth pre-pass value
  25871. */
  25872. private _needDepthPrePass;
  25873. /**
  25874. * Sets the need depth pre-pass value
  25875. */
  25876. set needDepthPrePass(value: boolean);
  25877. /**
  25878. * Gets the depth pre-pass value
  25879. */
  25880. get needDepthPrePass(): boolean;
  25881. /**
  25882. * Specifies if depth writing should be disabled
  25883. */
  25884. disableDepthWrite: boolean;
  25885. /**
  25886. * Specifies if color writing should be disabled
  25887. */
  25888. disableColorWrite: boolean;
  25889. /**
  25890. * Specifies if depth writing should be forced
  25891. */
  25892. forceDepthWrite: boolean;
  25893. /**
  25894. * Specifies the depth function that should be used. 0 means the default engine function
  25895. */
  25896. depthFunction: number;
  25897. /**
  25898. * Specifies if there should be a separate pass for culling
  25899. */
  25900. separateCullingPass: boolean;
  25901. /**
  25902. * Stores the state specifing if fog should be enabled
  25903. */
  25904. private _fogEnabled;
  25905. /**
  25906. * Sets the state for enabling fog
  25907. */
  25908. set fogEnabled(value: boolean);
  25909. /**
  25910. * Gets the value of the fog enabled state
  25911. */
  25912. get fogEnabled(): boolean;
  25913. /**
  25914. * Stores the size of points
  25915. */
  25916. pointSize: number;
  25917. /**
  25918. * Stores the z offset value
  25919. */
  25920. zOffset: number;
  25921. get wireframe(): boolean;
  25922. /**
  25923. * Sets the state of wireframe mode
  25924. */
  25925. set wireframe(value: boolean);
  25926. /**
  25927. * Gets the value specifying if point clouds are enabled
  25928. */
  25929. get pointsCloud(): boolean;
  25930. /**
  25931. * Sets the state of point cloud mode
  25932. */
  25933. set pointsCloud(value: boolean);
  25934. /**
  25935. * Gets the material fill mode
  25936. */
  25937. get fillMode(): number;
  25938. /**
  25939. * Sets the material fill mode
  25940. */
  25941. set fillMode(value: number);
  25942. /**
  25943. * @hidden
  25944. * Stores the effects for the material
  25945. */
  25946. _effect: Nullable<Effect>;
  25947. /**
  25948. * Specifies if uniform buffers should be used
  25949. */
  25950. private _useUBO;
  25951. /**
  25952. * Stores a reference to the scene
  25953. */
  25954. private _scene;
  25955. /**
  25956. * Stores the fill mode state
  25957. */
  25958. private _fillMode;
  25959. /**
  25960. * Specifies if the depth write state should be cached
  25961. */
  25962. private _cachedDepthWriteState;
  25963. /**
  25964. * Specifies if the color write state should be cached
  25965. */
  25966. private _cachedColorWriteState;
  25967. /**
  25968. * Specifies if the depth function state should be cached
  25969. */
  25970. private _cachedDepthFunctionState;
  25971. /**
  25972. * Stores the uniform buffer
  25973. */
  25974. protected _uniformBuffer: UniformBuffer;
  25975. /** @hidden */
  25976. _indexInSceneMaterialArray: number;
  25977. /** @hidden */
  25978. meshMap: Nullable<{
  25979. [id: string]: AbstractMesh | undefined;
  25980. }>;
  25981. /**
  25982. * Creates a material instance
  25983. * @param name defines the name of the material
  25984. * @param scene defines the scene to reference
  25985. * @param doNotAdd specifies if the material should be added to the scene
  25986. */
  25987. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25988. /**
  25989. * Returns a string representation of the current material
  25990. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25991. * @returns a string with material information
  25992. */
  25993. toString(fullDetails?: boolean): string;
  25994. /**
  25995. * Gets the class name of the material
  25996. * @returns a string with the class name of the material
  25997. */
  25998. getClassName(): string;
  25999. /**
  26000. * Specifies if updates for the material been locked
  26001. */
  26002. get isFrozen(): boolean;
  26003. /**
  26004. * Locks updates for the material
  26005. */
  26006. freeze(): void;
  26007. /**
  26008. * Unlocks updates for the material
  26009. */
  26010. unfreeze(): void;
  26011. /**
  26012. * Specifies if the material is ready to be used
  26013. * @param mesh defines the mesh to check
  26014. * @param useInstances specifies if instances should be used
  26015. * @returns a boolean indicating if the material is ready to be used
  26016. */
  26017. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26018. /**
  26019. * Specifies that the submesh is ready to be used
  26020. * @param mesh defines the mesh to check
  26021. * @param subMesh defines which submesh to check
  26022. * @param useInstances specifies that instances should be used
  26023. * @returns a boolean indicating that the submesh is ready or not
  26024. */
  26025. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26026. /**
  26027. * Returns the material effect
  26028. * @returns the effect associated with the material
  26029. */
  26030. getEffect(): Nullable<Effect>;
  26031. /**
  26032. * Returns the current scene
  26033. * @returns a Scene
  26034. */
  26035. getScene(): Scene;
  26036. /**
  26037. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26038. */
  26039. protected _forceAlphaTest: boolean;
  26040. /**
  26041. * The transparency mode of the material.
  26042. */
  26043. protected _transparencyMode: Nullable<number>;
  26044. /**
  26045. * Gets the current transparency mode.
  26046. */
  26047. get transparencyMode(): Nullable<number>;
  26048. /**
  26049. * Sets the transparency mode of the material.
  26050. *
  26051. * | Value | Type | Description |
  26052. * | ----- | ----------------------------------- | ----------- |
  26053. * | 0 | OPAQUE | |
  26054. * | 1 | ALPHATEST | |
  26055. * | 2 | ALPHABLEND | |
  26056. * | 3 | ALPHATESTANDBLEND | |
  26057. *
  26058. */
  26059. set transparencyMode(value: Nullable<number>);
  26060. /**
  26061. * Returns true if alpha blending should be disabled.
  26062. */
  26063. protected get _disableAlphaBlending(): boolean;
  26064. /**
  26065. * Specifies whether or not this material should be rendered in alpha blend mode.
  26066. * @returns a boolean specifying if alpha blending is needed
  26067. */
  26068. needAlphaBlending(): boolean;
  26069. /**
  26070. * Specifies if the mesh will require alpha blending
  26071. * @param mesh defines the mesh to check
  26072. * @returns a boolean specifying if alpha blending is needed for the mesh
  26073. */
  26074. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  26075. /**
  26076. * Specifies whether or not this material should be rendered in alpha test mode.
  26077. * @returns a boolean specifying if an alpha test is needed.
  26078. */
  26079. needAlphaTesting(): boolean;
  26080. /**
  26081. * Specifies if material alpha testing should be turned on for the mesh
  26082. * @param mesh defines the mesh to check
  26083. */
  26084. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  26085. /**
  26086. * Gets the texture used for the alpha test
  26087. * @returns the texture to use for alpha testing
  26088. */
  26089. getAlphaTestTexture(): Nullable<BaseTexture>;
  26090. /**
  26091. * Marks the material to indicate that it needs to be re-calculated
  26092. */
  26093. markDirty(): void;
  26094. /** @hidden */
  26095. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  26096. /**
  26097. * Binds the material to the mesh
  26098. * @param world defines the world transformation matrix
  26099. * @param mesh defines the mesh to bind the material to
  26100. */
  26101. bind(world: Matrix, mesh?: Mesh): void;
  26102. /**
  26103. * Binds the submesh to the material
  26104. * @param world defines the world transformation matrix
  26105. * @param mesh defines the mesh containing the submesh
  26106. * @param subMesh defines the submesh to bind the material to
  26107. */
  26108. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26109. /**
  26110. * Binds the world matrix to the material
  26111. * @param world defines the world transformation matrix
  26112. */
  26113. bindOnlyWorldMatrix(world: Matrix): void;
  26114. /**
  26115. * Binds the scene's uniform buffer to the effect.
  26116. * @param effect defines the effect to bind to the scene uniform buffer
  26117. * @param sceneUbo defines the uniform buffer storing scene data
  26118. */
  26119. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  26120. /**
  26121. * Binds the view matrix to the effect
  26122. * @param effect defines the effect to bind the view matrix to
  26123. */
  26124. bindView(effect: Effect): void;
  26125. /**
  26126. * Binds the view projection matrix to the effect
  26127. * @param effect defines the effect to bind the view projection matrix to
  26128. */
  26129. bindViewProjection(effect: Effect): void;
  26130. /**
  26131. * Processes to execute after binding the material to a mesh
  26132. * @param mesh defines the rendered mesh
  26133. */
  26134. protected _afterBind(mesh?: Mesh): void;
  26135. /**
  26136. * Unbinds the material from the mesh
  26137. */
  26138. unbind(): void;
  26139. /**
  26140. * Gets the active textures from the material
  26141. * @returns an array of textures
  26142. */
  26143. getActiveTextures(): BaseTexture[];
  26144. /**
  26145. * Specifies if the material uses a texture
  26146. * @param texture defines the texture to check against the material
  26147. * @returns a boolean specifying if the material uses the texture
  26148. */
  26149. hasTexture(texture: BaseTexture): boolean;
  26150. /**
  26151. * Makes a duplicate of the material, and gives it a new name
  26152. * @param name defines the new name for the duplicated material
  26153. * @returns the cloned material
  26154. */
  26155. clone(name: string): Nullable<Material>;
  26156. /**
  26157. * Gets the meshes bound to the material
  26158. * @returns an array of meshes bound to the material
  26159. */
  26160. getBindedMeshes(): AbstractMesh[];
  26161. /**
  26162. * Force shader compilation
  26163. * @param mesh defines the mesh associated with this material
  26164. * @param onCompiled defines a function to execute once the material is compiled
  26165. * @param options defines the options to configure the compilation
  26166. * @param onError defines a function to execute if the material fails compiling
  26167. */
  26168. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26169. /**
  26170. * Force shader compilation
  26171. * @param mesh defines the mesh that will use this material
  26172. * @param options defines additional options for compiling the shaders
  26173. * @returns a promise that resolves when the compilation completes
  26174. */
  26175. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26176. private static readonly _AllDirtyCallBack;
  26177. private static readonly _ImageProcessingDirtyCallBack;
  26178. private static readonly _TextureDirtyCallBack;
  26179. private static readonly _FresnelDirtyCallBack;
  26180. private static readonly _MiscDirtyCallBack;
  26181. private static readonly _PrePassDirtyCallBack;
  26182. private static readonly _LightsDirtyCallBack;
  26183. private static readonly _AttributeDirtyCallBack;
  26184. private static _FresnelAndMiscDirtyCallBack;
  26185. private static _TextureAndMiscDirtyCallBack;
  26186. private static readonly _DirtyCallbackArray;
  26187. private static readonly _RunDirtyCallBacks;
  26188. /**
  26189. * Marks a define in the material to indicate that it needs to be re-computed
  26190. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26191. */
  26192. markAsDirty(flag: number): void;
  26193. /**
  26194. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26195. * @param func defines a function which checks material defines against the submeshes
  26196. */
  26197. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26198. /**
  26199. * Indicates that the scene should check if the rendering now needs a prepass
  26200. */
  26201. protected _markScenePrePassDirty(): void;
  26202. /**
  26203. * Indicates that we need to re-calculated for all submeshes
  26204. */
  26205. protected _markAllSubMeshesAsAllDirty(): void;
  26206. /**
  26207. * Indicates that image processing needs to be re-calculated for all submeshes
  26208. */
  26209. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26210. /**
  26211. * Indicates that textures need to be re-calculated for all submeshes
  26212. */
  26213. protected _markAllSubMeshesAsTexturesDirty(): void;
  26214. /**
  26215. * Indicates that fresnel needs to be re-calculated for all submeshes
  26216. */
  26217. protected _markAllSubMeshesAsFresnelDirty(): void;
  26218. /**
  26219. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26220. */
  26221. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26222. /**
  26223. * Indicates that lights need to be re-calculated for all submeshes
  26224. */
  26225. protected _markAllSubMeshesAsLightsDirty(): void;
  26226. /**
  26227. * Indicates that attributes need to be re-calculated for all submeshes
  26228. */
  26229. protected _markAllSubMeshesAsAttributesDirty(): void;
  26230. /**
  26231. * Indicates that misc needs to be re-calculated for all submeshes
  26232. */
  26233. protected _markAllSubMeshesAsMiscDirty(): void;
  26234. /**
  26235. * Indicates that prepass needs to be re-calculated for all submeshes
  26236. */
  26237. protected _markAllSubMeshesAsPrePassDirty(): void;
  26238. /**
  26239. * Indicates that textures and misc need to be re-calculated for all submeshes
  26240. */
  26241. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26242. /**
  26243. * Sets the required values to the prepass renderer.
  26244. * @param prePassRenderer defines the prepass renderer to setup.
  26245. * @returns true if the pre pass is needed.
  26246. */
  26247. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26248. /**
  26249. * Disposes the material
  26250. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26251. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26252. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26253. */
  26254. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26255. /** @hidden */
  26256. private releaseVertexArrayObject;
  26257. /**
  26258. * Serializes this material
  26259. * @returns the serialized material object
  26260. */
  26261. serialize(): any;
  26262. /**
  26263. * Creates a material from parsed material data
  26264. * @param parsedMaterial defines parsed material data
  26265. * @param scene defines the hosting scene
  26266. * @param rootUrl defines the root URL to use to load textures
  26267. * @returns a new material
  26268. */
  26269. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26270. }
  26271. }
  26272. declare module "babylonjs/Materials/multiMaterial" {
  26273. import { Nullable } from "babylonjs/types";
  26274. import { Scene } from "babylonjs/scene";
  26275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26276. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26277. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26278. import { Material } from "babylonjs/Materials/material";
  26279. /**
  26280. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26281. * separate meshes. This can be use to improve performances.
  26282. * @see https://doc.babylonjs.com/how_to/multi_materials
  26283. */
  26284. export class MultiMaterial extends Material {
  26285. private _subMaterials;
  26286. /**
  26287. * Gets or Sets the list of Materials used within the multi material.
  26288. * They need to be ordered according to the submeshes order in the associated mesh
  26289. */
  26290. get subMaterials(): Nullable<Material>[];
  26291. set subMaterials(value: Nullable<Material>[]);
  26292. /**
  26293. * Function used to align with Node.getChildren()
  26294. * @returns the list of Materials used within the multi material
  26295. */
  26296. getChildren(): Nullable<Material>[];
  26297. /**
  26298. * Instantiates a new Multi Material
  26299. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26300. * separate meshes. This can be use to improve performances.
  26301. * @see https://doc.babylonjs.com/how_to/multi_materials
  26302. * @param name Define the name in the scene
  26303. * @param scene Define the scene the material belongs to
  26304. */
  26305. constructor(name: string, scene: Scene);
  26306. private _hookArray;
  26307. /**
  26308. * Get one of the submaterial by its index in the submaterials array
  26309. * @param index The index to look the sub material at
  26310. * @returns The Material if the index has been defined
  26311. */
  26312. getSubMaterial(index: number): Nullable<Material>;
  26313. /**
  26314. * Get the list of active textures for the whole sub materials list.
  26315. * @returns All the textures that will be used during the rendering
  26316. */
  26317. getActiveTextures(): BaseTexture[];
  26318. /**
  26319. * Gets the current class name of the material e.g. "MultiMaterial"
  26320. * Mainly use in serialization.
  26321. * @returns the class name
  26322. */
  26323. getClassName(): string;
  26324. /**
  26325. * Checks if the material is ready to render the requested sub mesh
  26326. * @param mesh Define the mesh the submesh belongs to
  26327. * @param subMesh Define the sub mesh to look readyness for
  26328. * @param useInstances Define whether or not the material is used with instances
  26329. * @returns true if ready, otherwise false
  26330. */
  26331. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26332. /**
  26333. * Clones the current material and its related sub materials
  26334. * @param name Define the name of the newly cloned material
  26335. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26336. * @returns the cloned material
  26337. */
  26338. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26339. /**
  26340. * Serializes the materials into a JSON representation.
  26341. * @returns the JSON representation
  26342. */
  26343. serialize(): any;
  26344. /**
  26345. * Dispose the material and release its associated resources
  26346. * @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)
  26347. * @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)
  26348. * @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)
  26349. */
  26350. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26351. /**
  26352. * Creates a MultiMaterial from parsed MultiMaterial data.
  26353. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26354. * @param scene defines the hosting scene
  26355. * @returns a new MultiMaterial
  26356. */
  26357. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26358. }
  26359. }
  26360. declare module "babylonjs/Meshes/subMesh" {
  26361. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26362. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26363. import { Engine } from "babylonjs/Engines/engine";
  26364. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26365. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26366. import { Effect } from "babylonjs/Materials/effect";
  26367. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26368. import { Plane } from "babylonjs/Maths/math.plane";
  26369. import { Collider } from "babylonjs/Collisions/collider";
  26370. import { Material } from "babylonjs/Materials/material";
  26371. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26373. import { Mesh } from "babylonjs/Meshes/mesh";
  26374. import { Ray } from "babylonjs/Culling/ray";
  26375. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26376. /**
  26377. * Defines a subdivision inside a mesh
  26378. */
  26379. export class SubMesh implements ICullable {
  26380. /** the material index to use */
  26381. materialIndex: number;
  26382. /** vertex index start */
  26383. verticesStart: number;
  26384. /** vertices count */
  26385. verticesCount: number;
  26386. /** index start */
  26387. indexStart: number;
  26388. /** indices count */
  26389. indexCount: number;
  26390. /** @hidden */
  26391. _materialDefines: Nullable<MaterialDefines>;
  26392. /** @hidden */
  26393. _materialEffect: Nullable<Effect>;
  26394. /** @hidden */
  26395. _effectOverride: Nullable<Effect>;
  26396. /**
  26397. * Gets material defines used by the effect associated to the sub mesh
  26398. */
  26399. get materialDefines(): Nullable<MaterialDefines>;
  26400. /**
  26401. * Sets material defines used by the effect associated to the sub mesh
  26402. */
  26403. set materialDefines(defines: Nullable<MaterialDefines>);
  26404. /**
  26405. * Gets associated effect
  26406. */
  26407. get effect(): Nullable<Effect>;
  26408. /**
  26409. * Sets associated effect (effect used to render this submesh)
  26410. * @param effect defines the effect to associate with
  26411. * @param defines defines the set of defines used to compile this effect
  26412. */
  26413. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26414. /** @hidden */
  26415. _linesIndexCount: number;
  26416. private _mesh;
  26417. private _renderingMesh;
  26418. private _boundingInfo;
  26419. private _linesIndexBuffer;
  26420. /** @hidden */
  26421. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26422. /** @hidden */
  26423. _trianglePlanes: Plane[];
  26424. /** @hidden */
  26425. _lastColliderTransformMatrix: Nullable<Matrix>;
  26426. /** @hidden */
  26427. _renderId: number;
  26428. /** @hidden */
  26429. _alphaIndex: number;
  26430. /** @hidden */
  26431. _distanceToCamera: number;
  26432. /** @hidden */
  26433. _id: number;
  26434. private _currentMaterial;
  26435. /**
  26436. * Add a new submesh to a mesh
  26437. * @param materialIndex defines the material index to use
  26438. * @param verticesStart defines vertex index start
  26439. * @param verticesCount defines vertices count
  26440. * @param indexStart defines index start
  26441. * @param indexCount defines indices count
  26442. * @param mesh defines the parent mesh
  26443. * @param renderingMesh defines an optional rendering mesh
  26444. * @param createBoundingBox defines if bounding box should be created for this submesh
  26445. * @returns the new submesh
  26446. */
  26447. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26448. /**
  26449. * Creates a new submesh
  26450. * @param materialIndex defines the material index to use
  26451. * @param verticesStart defines vertex index start
  26452. * @param verticesCount defines vertices count
  26453. * @param indexStart defines index start
  26454. * @param indexCount defines indices count
  26455. * @param mesh defines the parent mesh
  26456. * @param renderingMesh defines an optional rendering mesh
  26457. * @param createBoundingBox defines if bounding box should be created for this submesh
  26458. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26459. */
  26460. constructor(
  26461. /** the material index to use */
  26462. materialIndex: number,
  26463. /** vertex index start */
  26464. verticesStart: number,
  26465. /** vertices count */
  26466. verticesCount: number,
  26467. /** index start */
  26468. indexStart: number,
  26469. /** indices count */
  26470. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26471. /**
  26472. * Returns true if this submesh covers the entire parent mesh
  26473. * @ignorenaming
  26474. */
  26475. get IsGlobal(): boolean;
  26476. /**
  26477. * Returns the submesh BoudingInfo object
  26478. * @returns current bounding info (or mesh's one if the submesh is global)
  26479. */
  26480. getBoundingInfo(): BoundingInfo;
  26481. /**
  26482. * Sets the submesh BoundingInfo
  26483. * @param boundingInfo defines the new bounding info to use
  26484. * @returns the SubMesh
  26485. */
  26486. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26487. /**
  26488. * Returns the mesh of the current submesh
  26489. * @return the parent mesh
  26490. */
  26491. getMesh(): AbstractMesh;
  26492. /**
  26493. * Returns the rendering mesh of the submesh
  26494. * @returns the rendering mesh (could be different from parent mesh)
  26495. */
  26496. getRenderingMesh(): Mesh;
  26497. /**
  26498. * Returns the replacement mesh of the submesh
  26499. * @returns the replacement mesh (could be different from parent mesh)
  26500. */
  26501. getReplacementMesh(): Nullable<AbstractMesh>;
  26502. /**
  26503. * Returns the effective mesh of the submesh
  26504. * @returns the effective mesh (could be different from parent mesh)
  26505. */
  26506. getEffectiveMesh(): AbstractMesh;
  26507. /**
  26508. * Returns the submesh material
  26509. * @returns null or the current material
  26510. */
  26511. getMaterial(): Nullable<Material>;
  26512. private _IsMultiMaterial;
  26513. /**
  26514. * Sets a new updated BoundingInfo object to the submesh
  26515. * @param data defines an optional position array to use to determine the bounding info
  26516. * @returns the SubMesh
  26517. */
  26518. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26519. /** @hidden */
  26520. _checkCollision(collider: Collider): boolean;
  26521. /**
  26522. * Updates the submesh BoundingInfo
  26523. * @param world defines the world matrix to use to update the bounding info
  26524. * @returns the submesh
  26525. */
  26526. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26527. /**
  26528. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26529. * @param frustumPlanes defines the frustum planes
  26530. * @returns true if the submesh is intersecting with the frustum
  26531. */
  26532. isInFrustum(frustumPlanes: Plane[]): boolean;
  26533. /**
  26534. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26535. * @param frustumPlanes defines the frustum planes
  26536. * @returns true if the submesh is inside the frustum
  26537. */
  26538. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26539. /**
  26540. * Renders the submesh
  26541. * @param enableAlphaMode defines if alpha needs to be used
  26542. * @returns the submesh
  26543. */
  26544. render(enableAlphaMode: boolean): SubMesh;
  26545. /**
  26546. * @hidden
  26547. */
  26548. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26549. /**
  26550. * Checks if the submesh intersects with a ray
  26551. * @param ray defines the ray to test
  26552. * @returns true is the passed ray intersects the submesh bounding box
  26553. */
  26554. canIntersects(ray: Ray): boolean;
  26555. /**
  26556. * Intersects current submesh with a ray
  26557. * @param ray defines the ray to test
  26558. * @param positions defines mesh's positions array
  26559. * @param indices defines mesh's indices array
  26560. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26561. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26562. * @returns intersection info or null if no intersection
  26563. */
  26564. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26565. /** @hidden */
  26566. private _intersectLines;
  26567. /** @hidden */
  26568. private _intersectUnIndexedLines;
  26569. /** @hidden */
  26570. private _intersectTriangles;
  26571. /** @hidden */
  26572. private _intersectUnIndexedTriangles;
  26573. /** @hidden */
  26574. _rebuild(): void;
  26575. /**
  26576. * Creates a new submesh from the passed mesh
  26577. * @param newMesh defines the new hosting mesh
  26578. * @param newRenderingMesh defines an optional rendering mesh
  26579. * @returns the new submesh
  26580. */
  26581. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26582. /**
  26583. * Release associated resources
  26584. */
  26585. dispose(): void;
  26586. /**
  26587. * Gets the class name
  26588. * @returns the string "SubMesh".
  26589. */
  26590. getClassName(): string;
  26591. /**
  26592. * Creates a new submesh from indices data
  26593. * @param materialIndex the index of the main mesh material
  26594. * @param startIndex the index where to start the copy in the mesh indices array
  26595. * @param indexCount the number of indices to copy then from the startIndex
  26596. * @param mesh the main mesh to create the submesh from
  26597. * @param renderingMesh the optional rendering mesh
  26598. * @returns a new submesh
  26599. */
  26600. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26601. }
  26602. }
  26603. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26604. /**
  26605. * Class used to represent data loading progression
  26606. */
  26607. export class SceneLoaderFlags {
  26608. private static _ForceFullSceneLoadingForIncremental;
  26609. private static _ShowLoadingScreen;
  26610. private static _CleanBoneMatrixWeights;
  26611. private static _loggingLevel;
  26612. /**
  26613. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26614. */
  26615. static get ForceFullSceneLoadingForIncremental(): boolean;
  26616. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26617. /**
  26618. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26619. */
  26620. static get ShowLoadingScreen(): boolean;
  26621. static set ShowLoadingScreen(value: boolean);
  26622. /**
  26623. * Defines the current logging level (while loading the scene)
  26624. * @ignorenaming
  26625. */
  26626. static get loggingLevel(): number;
  26627. static set loggingLevel(value: number);
  26628. /**
  26629. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26630. */
  26631. static get CleanBoneMatrixWeights(): boolean;
  26632. static set CleanBoneMatrixWeights(value: boolean);
  26633. }
  26634. }
  26635. declare module "babylonjs/Meshes/geometry" {
  26636. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26637. import { Scene } from "babylonjs/scene";
  26638. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26639. import { Engine } from "babylonjs/Engines/engine";
  26640. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26641. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26642. import { Effect } from "babylonjs/Materials/effect";
  26643. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26644. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26645. import { Mesh } from "babylonjs/Meshes/mesh";
  26646. /**
  26647. * Class used to store geometry data (vertex buffers + index buffer)
  26648. */
  26649. export class Geometry implements IGetSetVerticesData {
  26650. /**
  26651. * Gets or sets the ID of the geometry
  26652. */
  26653. id: string;
  26654. /**
  26655. * Gets or sets the unique ID of the geometry
  26656. */
  26657. uniqueId: number;
  26658. /**
  26659. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26660. */
  26661. delayLoadState: number;
  26662. /**
  26663. * Gets the file containing the data to load when running in delay load state
  26664. */
  26665. delayLoadingFile: Nullable<string>;
  26666. /**
  26667. * Callback called when the geometry is updated
  26668. */
  26669. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26670. private _scene;
  26671. private _engine;
  26672. private _meshes;
  26673. private _totalVertices;
  26674. /** @hidden */
  26675. _indices: IndicesArray;
  26676. /** @hidden */
  26677. _vertexBuffers: {
  26678. [key: string]: VertexBuffer;
  26679. };
  26680. private _isDisposed;
  26681. private _extend;
  26682. private _boundingBias;
  26683. /** @hidden */
  26684. _delayInfo: Array<string>;
  26685. private _indexBuffer;
  26686. private _indexBufferIsUpdatable;
  26687. /** @hidden */
  26688. _boundingInfo: Nullable<BoundingInfo>;
  26689. /** @hidden */
  26690. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26691. /** @hidden */
  26692. _softwareSkinningFrameId: number;
  26693. private _vertexArrayObjects;
  26694. private _updatable;
  26695. /** @hidden */
  26696. _positions: Nullable<Vector3[]>;
  26697. /**
  26698. * 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
  26699. */
  26700. get boundingBias(): Vector2;
  26701. /**
  26702. * 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
  26703. */
  26704. set boundingBias(value: Vector2);
  26705. /**
  26706. * Static function used to attach a new empty geometry to a mesh
  26707. * @param mesh defines the mesh to attach the geometry to
  26708. * @returns the new Geometry
  26709. */
  26710. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26711. /** Get the list of meshes using this geometry */
  26712. get meshes(): Mesh[];
  26713. /**
  26714. * 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
  26715. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26716. */
  26717. useBoundingInfoFromGeometry: boolean;
  26718. /**
  26719. * Creates a new geometry
  26720. * @param id defines the unique ID
  26721. * @param scene defines the hosting scene
  26722. * @param vertexData defines the VertexData used to get geometry data
  26723. * @param updatable defines if geometry must be updatable (false by default)
  26724. * @param mesh defines the mesh that will be associated with the geometry
  26725. */
  26726. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26727. /**
  26728. * Gets the current extend of the geometry
  26729. */
  26730. get extend(): {
  26731. minimum: Vector3;
  26732. maximum: Vector3;
  26733. };
  26734. /**
  26735. * Gets the hosting scene
  26736. * @returns the hosting Scene
  26737. */
  26738. getScene(): Scene;
  26739. /**
  26740. * Gets the hosting engine
  26741. * @returns the hosting Engine
  26742. */
  26743. getEngine(): Engine;
  26744. /**
  26745. * Defines if the geometry is ready to use
  26746. * @returns true if the geometry is ready to be used
  26747. */
  26748. isReady(): boolean;
  26749. /**
  26750. * Gets a value indicating that the geometry should not be serialized
  26751. */
  26752. get doNotSerialize(): boolean;
  26753. /** @hidden */
  26754. _rebuild(): void;
  26755. /**
  26756. * Affects all geometry data in one call
  26757. * @param vertexData defines the geometry data
  26758. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26759. */
  26760. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26761. /**
  26762. * Set specific vertex data
  26763. * @param kind defines the data kind (Position, normal, etc...)
  26764. * @param data defines the vertex data to use
  26765. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26766. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26767. */
  26768. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26769. /**
  26770. * Removes a specific vertex data
  26771. * @param kind defines the data kind (Position, normal, etc...)
  26772. */
  26773. removeVerticesData(kind: string): void;
  26774. /**
  26775. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26776. * @param buffer defines the vertex buffer to use
  26777. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26778. */
  26779. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26780. /**
  26781. * Update a specific vertex buffer
  26782. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26783. * It will do nothing if the buffer is not updatable
  26784. * @param kind defines the data kind (Position, normal, etc...)
  26785. * @param data defines the data to use
  26786. * @param offset defines the offset in the target buffer where to store the data
  26787. * @param useBytes set to true if the offset is in bytes
  26788. */
  26789. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26790. /**
  26791. * Update a specific vertex buffer
  26792. * This function will create a new buffer if the current one is not updatable
  26793. * @param kind defines the data kind (Position, normal, etc...)
  26794. * @param data defines the data to use
  26795. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26796. */
  26797. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26798. private _updateBoundingInfo;
  26799. /** @hidden */
  26800. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26801. /**
  26802. * Gets total number of vertices
  26803. * @returns the total number of vertices
  26804. */
  26805. getTotalVertices(): number;
  26806. /**
  26807. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26808. * @param kind defines the data kind (Position, normal, etc...)
  26809. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26810. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26811. * @returns a float array containing vertex data
  26812. */
  26813. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26814. /**
  26815. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26816. * @param kind defines the data kind (Position, normal, etc...)
  26817. * @returns true if the vertex buffer with the specified kind is updatable
  26818. */
  26819. isVertexBufferUpdatable(kind: string): boolean;
  26820. /**
  26821. * Gets a specific vertex buffer
  26822. * @param kind defines the data kind (Position, normal, etc...)
  26823. * @returns a VertexBuffer
  26824. */
  26825. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26826. /**
  26827. * Returns all vertex buffers
  26828. * @return an object holding all vertex buffers indexed by kind
  26829. */
  26830. getVertexBuffers(): Nullable<{
  26831. [key: string]: VertexBuffer;
  26832. }>;
  26833. /**
  26834. * Gets a boolean indicating if specific vertex buffer is present
  26835. * @param kind defines the data kind (Position, normal, etc...)
  26836. * @returns true if data is present
  26837. */
  26838. isVerticesDataPresent(kind: string): boolean;
  26839. /**
  26840. * Gets a list of all attached data kinds (Position, normal, etc...)
  26841. * @returns a list of string containing all kinds
  26842. */
  26843. getVerticesDataKinds(): string[];
  26844. /**
  26845. * Update index buffer
  26846. * @param indices defines the indices to store in the index buffer
  26847. * @param offset defines the offset in the target buffer where to store the data
  26848. * @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)
  26849. */
  26850. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26851. /**
  26852. * Creates a new index buffer
  26853. * @param indices defines the indices to store in the index buffer
  26854. * @param totalVertices defines the total number of vertices (could be null)
  26855. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26856. */
  26857. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26858. /**
  26859. * Return the total number of indices
  26860. * @returns the total number of indices
  26861. */
  26862. getTotalIndices(): number;
  26863. /**
  26864. * Gets the index buffer array
  26865. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26866. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26867. * @returns the index buffer array
  26868. */
  26869. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26870. /**
  26871. * Gets the index buffer
  26872. * @return the index buffer
  26873. */
  26874. getIndexBuffer(): Nullable<DataBuffer>;
  26875. /** @hidden */
  26876. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26877. /**
  26878. * Release the associated resources for a specific mesh
  26879. * @param mesh defines the source mesh
  26880. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26881. */
  26882. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26883. /**
  26884. * Apply current geometry to a given mesh
  26885. * @param mesh defines the mesh to apply geometry to
  26886. */
  26887. applyToMesh(mesh: Mesh): void;
  26888. private _updateExtend;
  26889. private _applyToMesh;
  26890. private notifyUpdate;
  26891. /**
  26892. * Load the geometry if it was flagged as delay loaded
  26893. * @param scene defines the hosting scene
  26894. * @param onLoaded defines a callback called when the geometry is loaded
  26895. */
  26896. load(scene: Scene, onLoaded?: () => void): void;
  26897. private _queueLoad;
  26898. /**
  26899. * Invert the geometry to move from a right handed system to a left handed one.
  26900. */
  26901. toLeftHanded(): void;
  26902. /** @hidden */
  26903. _resetPointsArrayCache(): void;
  26904. /** @hidden */
  26905. _generatePointsArray(): boolean;
  26906. /**
  26907. * Gets a value indicating if the geometry is disposed
  26908. * @returns true if the geometry was disposed
  26909. */
  26910. isDisposed(): boolean;
  26911. private _disposeVertexArrayObjects;
  26912. /**
  26913. * Free all associated resources
  26914. */
  26915. dispose(): void;
  26916. /**
  26917. * Clone the current geometry into a new geometry
  26918. * @param id defines the unique ID of the new geometry
  26919. * @returns a new geometry object
  26920. */
  26921. copy(id: string): Geometry;
  26922. /**
  26923. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26924. * @return a JSON representation of the current geometry data (without the vertices data)
  26925. */
  26926. serialize(): any;
  26927. private toNumberArray;
  26928. /**
  26929. * Serialize all vertices data into a JSON oject
  26930. * @returns a JSON representation of the current geometry data
  26931. */
  26932. serializeVerticeData(): any;
  26933. /**
  26934. * Extracts a clone of a mesh geometry
  26935. * @param mesh defines the source mesh
  26936. * @param id defines the unique ID of the new geometry object
  26937. * @returns the new geometry object
  26938. */
  26939. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26940. /**
  26941. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26942. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26943. * Be aware Math.random() could cause collisions, but:
  26944. * "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"
  26945. * @returns a string containing a new GUID
  26946. */
  26947. static RandomId(): string;
  26948. /** @hidden */
  26949. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26950. private static _CleanMatricesWeights;
  26951. /**
  26952. * Create a new geometry from persisted data (Using .babylon file format)
  26953. * @param parsedVertexData defines the persisted data
  26954. * @param scene defines the hosting scene
  26955. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26956. * @returns the new geometry object
  26957. */
  26958. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26959. }
  26960. }
  26961. declare module "babylonjs/Meshes/mesh.vertexData" {
  26962. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26963. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26964. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26965. import { Geometry } from "babylonjs/Meshes/geometry";
  26966. import { Mesh } from "babylonjs/Meshes/mesh";
  26967. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  26968. /**
  26969. * Define an interface for all classes that will get and set the data on vertices
  26970. */
  26971. export interface IGetSetVerticesData {
  26972. /**
  26973. * Gets a boolean indicating if specific vertex data is present
  26974. * @param kind defines the vertex data kind to use
  26975. * @returns true is data kind is present
  26976. */
  26977. isVerticesDataPresent(kind: string): boolean;
  26978. /**
  26979. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26980. * @param kind defines the data kind (Position, normal, etc...)
  26981. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26982. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26983. * @returns a float array containing vertex data
  26984. */
  26985. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26986. /**
  26987. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26988. * @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.
  26989. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26990. * @returns the indices array or an empty array if the mesh has no geometry
  26991. */
  26992. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26993. /**
  26994. * Set specific vertex data
  26995. * @param kind defines the data kind (Position, normal, etc...)
  26996. * @param data defines the vertex data to use
  26997. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26998. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26999. */
  27000. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27001. /**
  27002. * Update a specific associated vertex buffer
  27003. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27004. * - VertexBuffer.PositionKind
  27005. * - VertexBuffer.UVKind
  27006. * - VertexBuffer.UV2Kind
  27007. * - VertexBuffer.UV3Kind
  27008. * - VertexBuffer.UV4Kind
  27009. * - VertexBuffer.UV5Kind
  27010. * - VertexBuffer.UV6Kind
  27011. * - VertexBuffer.ColorKind
  27012. * - VertexBuffer.MatricesIndicesKind
  27013. * - VertexBuffer.MatricesIndicesExtraKind
  27014. * - VertexBuffer.MatricesWeightsKind
  27015. * - VertexBuffer.MatricesWeightsExtraKind
  27016. * @param data defines the data source
  27017. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27018. * @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)
  27019. */
  27020. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27021. /**
  27022. * Creates a new index buffer
  27023. * @param indices defines the indices to store in the index buffer
  27024. * @param totalVertices defines the total number of vertices (could be null)
  27025. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27026. */
  27027. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27028. }
  27029. /**
  27030. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27031. */
  27032. export class VertexData {
  27033. /**
  27034. * Mesh side orientation : usually the external or front surface
  27035. */
  27036. static readonly FRONTSIDE: number;
  27037. /**
  27038. * Mesh side orientation : usually the internal or back surface
  27039. */
  27040. static readonly BACKSIDE: number;
  27041. /**
  27042. * Mesh side orientation : both internal and external or front and back surfaces
  27043. */
  27044. static readonly DOUBLESIDE: number;
  27045. /**
  27046. * Mesh side orientation : by default, `FRONTSIDE`
  27047. */
  27048. static readonly DEFAULTSIDE: number;
  27049. /**
  27050. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27051. */
  27052. positions: Nullable<FloatArray>;
  27053. /**
  27054. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27055. */
  27056. normals: Nullable<FloatArray>;
  27057. /**
  27058. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27059. */
  27060. tangents: Nullable<FloatArray>;
  27061. /**
  27062. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27063. */
  27064. uvs: Nullable<FloatArray>;
  27065. /**
  27066. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27067. */
  27068. uvs2: Nullable<FloatArray>;
  27069. /**
  27070. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27071. */
  27072. uvs3: Nullable<FloatArray>;
  27073. /**
  27074. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27075. */
  27076. uvs4: Nullable<FloatArray>;
  27077. /**
  27078. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27079. */
  27080. uvs5: Nullable<FloatArray>;
  27081. /**
  27082. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27083. */
  27084. uvs6: Nullable<FloatArray>;
  27085. /**
  27086. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27087. */
  27088. colors: Nullable<FloatArray>;
  27089. /**
  27090. * 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).
  27091. */
  27092. matricesIndices: Nullable<FloatArray>;
  27093. /**
  27094. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27095. */
  27096. matricesWeights: Nullable<FloatArray>;
  27097. /**
  27098. * An array extending the number of possible indices
  27099. */
  27100. matricesIndicesExtra: Nullable<FloatArray>;
  27101. /**
  27102. * An array extending the number of possible weights when the number of indices is extended
  27103. */
  27104. matricesWeightsExtra: Nullable<FloatArray>;
  27105. /**
  27106. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27107. */
  27108. indices: Nullable<IndicesArray>;
  27109. /**
  27110. * Uses the passed data array to set the set the values for the specified kind of data
  27111. * @param data a linear array of floating numbers
  27112. * @param kind the type of data that is being set, eg positions, colors etc
  27113. */
  27114. set(data: FloatArray, kind: string): void;
  27115. /**
  27116. * Associates the vertexData to the passed Mesh.
  27117. * Sets it as updatable or not (default `false`)
  27118. * @param mesh the mesh the vertexData is applied to
  27119. * @param updatable when used and having the value true allows new data to update the vertexData
  27120. * @returns the VertexData
  27121. */
  27122. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27123. /**
  27124. * Associates the vertexData to the passed Geometry.
  27125. * Sets it as updatable or not (default `false`)
  27126. * @param geometry the geometry the vertexData is applied to
  27127. * @param updatable when used and having the value true allows new data to update the vertexData
  27128. * @returns VertexData
  27129. */
  27130. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27131. /**
  27132. * Updates the associated mesh
  27133. * @param mesh the mesh to be updated
  27134. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27135. * @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
  27136. * @returns VertexData
  27137. */
  27138. updateMesh(mesh: Mesh): VertexData;
  27139. /**
  27140. * Updates the associated geometry
  27141. * @param geometry the geometry to be updated
  27142. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27143. * @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
  27144. * @returns VertexData.
  27145. */
  27146. updateGeometry(geometry: Geometry): VertexData;
  27147. private _applyTo;
  27148. private _update;
  27149. /**
  27150. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27151. * @param matrix the transforming matrix
  27152. * @returns the VertexData
  27153. */
  27154. transform(matrix: Matrix): VertexData;
  27155. /**
  27156. * Merges the passed VertexData into the current one
  27157. * @param other the VertexData to be merged into the current one
  27158. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27159. * @returns the modified VertexData
  27160. */
  27161. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27162. private _mergeElement;
  27163. private _validate;
  27164. /**
  27165. * Serializes the VertexData
  27166. * @returns a serialized object
  27167. */
  27168. serialize(): any;
  27169. /**
  27170. * Extracts the vertexData from a mesh
  27171. * @param mesh the mesh from which to extract the VertexData
  27172. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27173. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27174. * @returns the object VertexData associated to the passed mesh
  27175. */
  27176. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27177. /**
  27178. * Extracts the vertexData from the geometry
  27179. * @param geometry the geometry from which to extract the VertexData
  27180. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27181. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27182. * @returns the object VertexData associated to the passed mesh
  27183. */
  27184. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27185. private static _ExtractFrom;
  27186. /**
  27187. * Creates the VertexData for a Ribbon
  27188. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27189. * * pathArray array of paths, each of which an array of successive Vector3
  27190. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27191. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27192. * * 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
  27193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27194. * * 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)
  27195. * * 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)
  27196. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27197. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27198. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27199. * @returns the VertexData of the ribbon
  27200. */
  27201. static CreateRibbon(options: {
  27202. pathArray: Vector3[][];
  27203. closeArray?: boolean;
  27204. closePath?: boolean;
  27205. offset?: number;
  27206. sideOrientation?: number;
  27207. frontUVs?: Vector4;
  27208. backUVs?: Vector4;
  27209. invertUV?: boolean;
  27210. uvs?: Vector2[];
  27211. colors?: Color4[];
  27212. }): VertexData;
  27213. /**
  27214. * Creates the VertexData for a box
  27215. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27216. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27217. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27218. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27219. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27220. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27221. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27223. * * 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)
  27224. * * 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)
  27225. * @returns the VertexData of the box
  27226. */
  27227. static CreateBox(options: {
  27228. size?: number;
  27229. width?: number;
  27230. height?: number;
  27231. depth?: number;
  27232. faceUV?: Vector4[];
  27233. faceColors?: Color4[];
  27234. sideOrientation?: number;
  27235. frontUVs?: Vector4;
  27236. backUVs?: Vector4;
  27237. }): VertexData;
  27238. /**
  27239. * Creates the VertexData for a tiled box
  27240. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27241. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27242. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27243. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27245. * @returns the VertexData of the box
  27246. */
  27247. static CreateTiledBox(options: {
  27248. pattern?: number;
  27249. width?: number;
  27250. height?: number;
  27251. depth?: number;
  27252. tileSize?: number;
  27253. tileWidth?: number;
  27254. tileHeight?: number;
  27255. alignHorizontal?: number;
  27256. alignVertical?: number;
  27257. faceUV?: Vector4[];
  27258. faceColors?: Color4[];
  27259. sideOrientation?: number;
  27260. }): VertexData;
  27261. /**
  27262. * Creates the VertexData for a tiled plane
  27263. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27264. * * pattern a limited pattern arrangement depending on the number
  27265. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27266. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27267. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27268. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27269. * * 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)
  27270. * * 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)
  27271. * @returns the VertexData of the tiled plane
  27272. */
  27273. static CreateTiledPlane(options: {
  27274. pattern?: number;
  27275. tileSize?: number;
  27276. tileWidth?: number;
  27277. tileHeight?: number;
  27278. size?: number;
  27279. width?: number;
  27280. height?: number;
  27281. alignHorizontal?: number;
  27282. alignVertical?: number;
  27283. sideOrientation?: number;
  27284. frontUVs?: Vector4;
  27285. backUVs?: Vector4;
  27286. }): VertexData;
  27287. /**
  27288. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27289. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27290. * * segments sets the number of horizontal strips optional, default 32
  27291. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27292. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27293. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27294. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27295. * * 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
  27296. * * 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
  27297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27298. * * 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)
  27299. * * 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)
  27300. * @returns the VertexData of the ellipsoid
  27301. */
  27302. static CreateSphere(options: {
  27303. segments?: number;
  27304. diameter?: number;
  27305. diameterX?: number;
  27306. diameterY?: number;
  27307. diameterZ?: number;
  27308. arc?: number;
  27309. slice?: number;
  27310. sideOrientation?: number;
  27311. frontUVs?: Vector4;
  27312. backUVs?: Vector4;
  27313. }): VertexData;
  27314. /**
  27315. * Creates the VertexData for a cylinder, cone or prism
  27316. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27317. * * height sets the height (y direction) of the cylinder, optional, default 2
  27318. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27319. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27320. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27321. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27322. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27323. * * 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
  27324. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27325. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27326. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27327. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27329. * * 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)
  27330. * * 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)
  27331. * @returns the VertexData of the cylinder, cone or prism
  27332. */
  27333. static CreateCylinder(options: {
  27334. height?: number;
  27335. diameterTop?: number;
  27336. diameterBottom?: number;
  27337. diameter?: number;
  27338. tessellation?: number;
  27339. subdivisions?: number;
  27340. arc?: number;
  27341. faceColors?: Color4[];
  27342. faceUV?: Vector4[];
  27343. hasRings?: boolean;
  27344. enclose?: boolean;
  27345. sideOrientation?: number;
  27346. frontUVs?: Vector4;
  27347. backUVs?: Vector4;
  27348. }): VertexData;
  27349. /**
  27350. * Creates the VertexData for a torus
  27351. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27352. * * diameter the diameter of the torus, optional default 1
  27353. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27354. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27356. * * 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)
  27357. * * 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)
  27358. * @returns the VertexData of the torus
  27359. */
  27360. static CreateTorus(options: {
  27361. diameter?: number;
  27362. thickness?: number;
  27363. tessellation?: number;
  27364. sideOrientation?: number;
  27365. frontUVs?: Vector4;
  27366. backUVs?: Vector4;
  27367. }): VertexData;
  27368. /**
  27369. * Creates the VertexData of the LineSystem
  27370. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27371. * - lines an array of lines, each line being an array of successive Vector3
  27372. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27373. * @returns the VertexData of the LineSystem
  27374. */
  27375. static CreateLineSystem(options: {
  27376. lines: Vector3[][];
  27377. colors?: Nullable<Color4[][]>;
  27378. }): VertexData;
  27379. /**
  27380. * Create the VertexData for a DashedLines
  27381. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27382. * - points an array successive Vector3
  27383. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27384. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27385. * - dashNb the intended total number of dashes, optional, default 200
  27386. * @returns the VertexData for the DashedLines
  27387. */
  27388. static CreateDashedLines(options: {
  27389. points: Vector3[];
  27390. dashSize?: number;
  27391. gapSize?: number;
  27392. dashNb?: number;
  27393. }): VertexData;
  27394. /**
  27395. * Creates the VertexData for a Ground
  27396. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27397. * - width the width (x direction) of the ground, optional, default 1
  27398. * - height the height (z direction) of the ground, optional, default 1
  27399. * - subdivisions the number of subdivisions per side, optional, default 1
  27400. * @returns the VertexData of the Ground
  27401. */
  27402. static CreateGround(options: {
  27403. width?: number;
  27404. height?: number;
  27405. subdivisions?: number;
  27406. subdivisionsX?: number;
  27407. subdivisionsY?: number;
  27408. }): VertexData;
  27409. /**
  27410. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27411. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27412. * * xmin the ground minimum X coordinate, optional, default -1
  27413. * * zmin the ground minimum Z coordinate, optional, default -1
  27414. * * xmax the ground maximum X coordinate, optional, default 1
  27415. * * zmax the ground maximum Z coordinate, optional, default 1
  27416. * * 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}
  27417. * * 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}
  27418. * @returns the VertexData of the TiledGround
  27419. */
  27420. static CreateTiledGround(options: {
  27421. xmin: number;
  27422. zmin: number;
  27423. xmax: number;
  27424. zmax: number;
  27425. subdivisions?: {
  27426. w: number;
  27427. h: number;
  27428. };
  27429. precision?: {
  27430. w: number;
  27431. h: number;
  27432. };
  27433. }): VertexData;
  27434. /**
  27435. * Creates the VertexData of the Ground designed from a heightmap
  27436. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27437. * * width the width (x direction) of the ground
  27438. * * height the height (z direction) of the ground
  27439. * * subdivisions the number of subdivisions per side
  27440. * * minHeight the minimum altitude on the ground, optional, default 0
  27441. * * maxHeight the maximum altitude on the ground, optional default 1
  27442. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27443. * * buffer the array holding the image color data
  27444. * * bufferWidth the width of image
  27445. * * bufferHeight the height of image
  27446. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27447. * @returns the VertexData of the Ground designed from a heightmap
  27448. */
  27449. static CreateGroundFromHeightMap(options: {
  27450. width: number;
  27451. height: number;
  27452. subdivisions: number;
  27453. minHeight: number;
  27454. maxHeight: number;
  27455. colorFilter: Color3;
  27456. buffer: Uint8Array;
  27457. bufferWidth: number;
  27458. bufferHeight: number;
  27459. alphaFilter: number;
  27460. }): VertexData;
  27461. /**
  27462. * Creates the VertexData for a Plane
  27463. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27464. * * size sets the width and height of the plane to the value of size, optional default 1
  27465. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27466. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  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 box
  27471. */
  27472. static CreatePlane(options: {
  27473. size?: number;
  27474. width?: number;
  27475. height?: number;
  27476. sideOrientation?: number;
  27477. frontUVs?: Vector4;
  27478. backUVs?: Vector4;
  27479. }): VertexData;
  27480. /**
  27481. * Creates the VertexData of the Disc or regular Polygon
  27482. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27483. * * radius the radius of the disc, optional default 0.5
  27484. * * tessellation the number of polygon sides, optional, default 64
  27485. * * 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
  27486. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27487. * * 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)
  27488. * * 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)
  27489. * @returns the VertexData of the box
  27490. */
  27491. static CreateDisc(options: {
  27492. radius?: number;
  27493. tessellation?: number;
  27494. arc?: number;
  27495. sideOrientation?: number;
  27496. frontUVs?: Vector4;
  27497. backUVs?: Vector4;
  27498. }): VertexData;
  27499. /**
  27500. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27501. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27502. * @param polygon a mesh built from polygonTriangulation.build()
  27503. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27504. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27505. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27506. * @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)
  27507. * @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)
  27508. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27509. * @returns the VertexData of the Polygon
  27510. */
  27511. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27512. /**
  27513. * Creates the VertexData of the IcoSphere
  27514. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27515. * * radius the radius of the IcoSphere, optional default 1
  27516. * * radiusX allows stretching in the x direction, optional, default radius
  27517. * * radiusY allows stretching in the y direction, optional, default radius
  27518. * * radiusZ allows stretching in the z direction, optional, default radius
  27519. * * flat when true creates a flat shaded mesh, optional, default true
  27520. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27521. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27522. * * 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)
  27523. * * 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)
  27524. * @returns the VertexData of the IcoSphere
  27525. */
  27526. static CreateIcoSphere(options: {
  27527. radius?: number;
  27528. radiusX?: number;
  27529. radiusY?: number;
  27530. radiusZ?: number;
  27531. flat?: boolean;
  27532. subdivisions?: number;
  27533. sideOrientation?: number;
  27534. frontUVs?: Vector4;
  27535. backUVs?: Vector4;
  27536. }): VertexData;
  27537. /**
  27538. * Creates the VertexData for a Polyhedron
  27539. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27540. * * type provided types are:
  27541. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27542. * * 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)
  27543. * * size the size of the IcoSphere, optional default 1
  27544. * * sizeX allows stretching in the x direction, optional, default size
  27545. * * sizeY allows stretching in the y direction, optional, default size
  27546. * * sizeZ allows stretching in the z direction, optional, default size
  27547. * * 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
  27548. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27549. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27550. * * flat when true creates a flat shaded mesh, optional, default true
  27551. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27553. * * 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)
  27554. * * 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)
  27555. * @returns the VertexData of the Polyhedron
  27556. */
  27557. static CreatePolyhedron(options: {
  27558. type?: number;
  27559. size?: number;
  27560. sizeX?: number;
  27561. sizeY?: number;
  27562. sizeZ?: number;
  27563. custom?: any;
  27564. faceUV?: Vector4[];
  27565. faceColors?: Color4[];
  27566. flat?: boolean;
  27567. sideOrientation?: number;
  27568. frontUVs?: Vector4;
  27569. backUVs?: Vector4;
  27570. }): VertexData;
  27571. /**
  27572. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  27573. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  27574. * @returns the VertexData of the Capsule
  27575. */
  27576. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  27577. /**
  27578. * Creates the VertexData for a TorusKnot
  27579. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27580. * * radius the radius of the torus knot, optional, default 2
  27581. * * tube the thickness of the tube, optional, default 0.5
  27582. * * radialSegments the number of sides on each tube segments, optional, default 32
  27583. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27584. * * p the number of windings around the z axis, optional, default 2
  27585. * * q the number of windings around the x axis, optional, default 3
  27586. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27587. * * 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)
  27588. * * 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)
  27589. * @returns the VertexData of the Torus Knot
  27590. */
  27591. static CreateTorusKnot(options: {
  27592. radius?: number;
  27593. tube?: number;
  27594. radialSegments?: number;
  27595. tubularSegments?: number;
  27596. p?: number;
  27597. q?: number;
  27598. sideOrientation?: number;
  27599. frontUVs?: Vector4;
  27600. backUVs?: Vector4;
  27601. }): VertexData;
  27602. /**
  27603. * Compute normals for given positions and indices
  27604. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27605. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27606. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27607. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27608. * * facetNormals : optional array of facet normals (vector3)
  27609. * * facetPositions : optional array of facet positions (vector3)
  27610. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27611. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27612. * * bInfo : optional bounding info, required for facetPartitioning computation
  27613. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27614. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27615. * * useRightHandedSystem: optional boolean to for right handed system computation
  27616. * * depthSort : optional boolean to enable the facet depth sort computation
  27617. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27618. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27619. */
  27620. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27621. facetNormals?: any;
  27622. facetPositions?: any;
  27623. facetPartitioning?: any;
  27624. ratio?: number;
  27625. bInfo?: any;
  27626. bbSize?: Vector3;
  27627. subDiv?: any;
  27628. useRightHandedSystem?: boolean;
  27629. depthSort?: boolean;
  27630. distanceTo?: Vector3;
  27631. depthSortedFacets?: any;
  27632. }): void;
  27633. /** @hidden */
  27634. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27635. /**
  27636. * Applies VertexData created from the imported parameters to the geometry
  27637. * @param parsedVertexData the parsed data from an imported file
  27638. * @param geometry the geometry to apply the VertexData to
  27639. */
  27640. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27641. }
  27642. }
  27643. declare module "babylonjs/Morph/morphTarget" {
  27644. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27645. import { Observable } from "babylonjs/Misc/observable";
  27646. import { Nullable, FloatArray } from "babylonjs/types";
  27647. import { Scene } from "babylonjs/scene";
  27648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27649. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27650. /**
  27651. * Defines a target to use with MorphTargetManager
  27652. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27653. */
  27654. export class MorphTarget implements IAnimatable {
  27655. /** defines the name of the target */
  27656. name: string;
  27657. /**
  27658. * Gets or sets the list of animations
  27659. */
  27660. animations: import("babylonjs/Animations/animation").Animation[];
  27661. private _scene;
  27662. private _positions;
  27663. private _normals;
  27664. private _tangents;
  27665. private _uvs;
  27666. private _influence;
  27667. private _uniqueId;
  27668. /**
  27669. * Observable raised when the influence changes
  27670. */
  27671. onInfluenceChanged: Observable<boolean>;
  27672. /** @hidden */
  27673. _onDataLayoutChanged: Observable<void>;
  27674. /**
  27675. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27676. */
  27677. get influence(): number;
  27678. set influence(influence: number);
  27679. /**
  27680. * Gets or sets the id of the morph Target
  27681. */
  27682. id: string;
  27683. private _animationPropertiesOverride;
  27684. /**
  27685. * Gets or sets the animation properties override
  27686. */
  27687. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27688. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27689. /**
  27690. * Creates a new MorphTarget
  27691. * @param name defines the name of the target
  27692. * @param influence defines the influence to use
  27693. * @param scene defines the scene the morphtarget belongs to
  27694. */
  27695. constructor(
  27696. /** defines the name of the target */
  27697. name: string, influence?: number, scene?: Nullable<Scene>);
  27698. /**
  27699. * Gets the unique ID of this manager
  27700. */
  27701. get uniqueId(): number;
  27702. /**
  27703. * Gets a boolean defining if the target contains position data
  27704. */
  27705. get hasPositions(): boolean;
  27706. /**
  27707. * Gets a boolean defining if the target contains normal data
  27708. */
  27709. get hasNormals(): boolean;
  27710. /**
  27711. * Gets a boolean defining if the target contains tangent data
  27712. */
  27713. get hasTangents(): boolean;
  27714. /**
  27715. * Gets a boolean defining if the target contains texture coordinates data
  27716. */
  27717. get hasUVs(): boolean;
  27718. /**
  27719. * Affects position data to this target
  27720. * @param data defines the position data to use
  27721. */
  27722. setPositions(data: Nullable<FloatArray>): void;
  27723. /**
  27724. * Gets the position data stored in this target
  27725. * @returns a FloatArray containing the position data (or null if not present)
  27726. */
  27727. getPositions(): Nullable<FloatArray>;
  27728. /**
  27729. * Affects normal data to this target
  27730. * @param data defines the normal data to use
  27731. */
  27732. setNormals(data: Nullable<FloatArray>): void;
  27733. /**
  27734. * Gets the normal data stored in this target
  27735. * @returns a FloatArray containing the normal data (or null if not present)
  27736. */
  27737. getNormals(): Nullable<FloatArray>;
  27738. /**
  27739. * Affects tangent data to this target
  27740. * @param data defines the tangent data to use
  27741. */
  27742. setTangents(data: Nullable<FloatArray>): void;
  27743. /**
  27744. * Gets the tangent data stored in this target
  27745. * @returns a FloatArray containing the tangent data (or null if not present)
  27746. */
  27747. getTangents(): Nullable<FloatArray>;
  27748. /**
  27749. * Affects texture coordinates data to this target
  27750. * @param data defines the texture coordinates data to use
  27751. */
  27752. setUVs(data: Nullable<FloatArray>): void;
  27753. /**
  27754. * Gets the texture coordinates data stored in this target
  27755. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27756. */
  27757. getUVs(): Nullable<FloatArray>;
  27758. /**
  27759. * Clone the current target
  27760. * @returns a new MorphTarget
  27761. */
  27762. clone(): MorphTarget;
  27763. /**
  27764. * Serializes the current target into a Serialization object
  27765. * @returns the serialized object
  27766. */
  27767. serialize(): any;
  27768. /**
  27769. * Returns the string "MorphTarget"
  27770. * @returns "MorphTarget"
  27771. */
  27772. getClassName(): string;
  27773. /**
  27774. * Creates a new target from serialized data
  27775. * @param serializationObject defines the serialized data to use
  27776. * @returns a new MorphTarget
  27777. */
  27778. static Parse(serializationObject: any): MorphTarget;
  27779. /**
  27780. * Creates a MorphTarget from mesh data
  27781. * @param mesh defines the source mesh
  27782. * @param name defines the name to use for the new target
  27783. * @param influence defines the influence to attach to the target
  27784. * @returns a new MorphTarget
  27785. */
  27786. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27787. }
  27788. }
  27789. declare module "babylonjs/Morph/morphTargetManager" {
  27790. import { Nullable } from "babylonjs/types";
  27791. import { Scene } from "babylonjs/scene";
  27792. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27793. /**
  27794. * This class is used to deform meshes using morphing between different targets
  27795. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27796. */
  27797. export class MorphTargetManager {
  27798. private _targets;
  27799. private _targetInfluenceChangedObservers;
  27800. private _targetDataLayoutChangedObservers;
  27801. private _activeTargets;
  27802. private _scene;
  27803. private _influences;
  27804. private _supportsNormals;
  27805. private _supportsTangents;
  27806. private _supportsUVs;
  27807. private _vertexCount;
  27808. private _uniqueId;
  27809. private _tempInfluences;
  27810. /**
  27811. * Gets or sets a boolean indicating if normals must be morphed
  27812. */
  27813. enableNormalMorphing: boolean;
  27814. /**
  27815. * Gets or sets a boolean indicating if tangents must be morphed
  27816. */
  27817. enableTangentMorphing: boolean;
  27818. /**
  27819. * Gets or sets a boolean indicating if UV must be morphed
  27820. */
  27821. enableUVMorphing: boolean;
  27822. /**
  27823. * Creates a new MorphTargetManager
  27824. * @param scene defines the current scene
  27825. */
  27826. constructor(scene?: Nullable<Scene>);
  27827. /**
  27828. * Gets the unique ID of this manager
  27829. */
  27830. get uniqueId(): number;
  27831. /**
  27832. * Gets the number of vertices handled by this manager
  27833. */
  27834. get vertexCount(): number;
  27835. /**
  27836. * Gets a boolean indicating if this manager supports morphing of normals
  27837. */
  27838. get supportsNormals(): boolean;
  27839. /**
  27840. * Gets a boolean indicating if this manager supports morphing of tangents
  27841. */
  27842. get supportsTangents(): boolean;
  27843. /**
  27844. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27845. */
  27846. get supportsUVs(): boolean;
  27847. /**
  27848. * Gets the number of targets stored in this manager
  27849. */
  27850. get numTargets(): number;
  27851. /**
  27852. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27853. */
  27854. get numInfluencers(): number;
  27855. /**
  27856. * Gets the list of influences (one per target)
  27857. */
  27858. get influences(): Float32Array;
  27859. /**
  27860. * Gets the active target at specified index. An active target is a target with an influence > 0
  27861. * @param index defines the index to check
  27862. * @returns the requested target
  27863. */
  27864. getActiveTarget(index: number): MorphTarget;
  27865. /**
  27866. * Gets the target at specified index
  27867. * @param index defines the index to check
  27868. * @returns the requested target
  27869. */
  27870. getTarget(index: number): MorphTarget;
  27871. /**
  27872. * Add a new target to this manager
  27873. * @param target defines the target to add
  27874. */
  27875. addTarget(target: MorphTarget): void;
  27876. /**
  27877. * Removes a target from the manager
  27878. * @param target defines the target to remove
  27879. */
  27880. removeTarget(target: MorphTarget): void;
  27881. /**
  27882. * Clone the current manager
  27883. * @returns a new MorphTargetManager
  27884. */
  27885. clone(): MorphTargetManager;
  27886. /**
  27887. * Serializes the current manager into a Serialization object
  27888. * @returns the serialized object
  27889. */
  27890. serialize(): any;
  27891. private _syncActiveTargets;
  27892. /**
  27893. * Syncrhonize the targets with all the meshes using this morph target manager
  27894. */
  27895. synchronize(): void;
  27896. /**
  27897. * Creates a new MorphTargetManager from serialized data
  27898. * @param serializationObject defines the serialized data
  27899. * @param scene defines the hosting scene
  27900. * @returns the new MorphTargetManager
  27901. */
  27902. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27903. }
  27904. }
  27905. declare module "babylonjs/Meshes/meshLODLevel" {
  27906. import { Mesh } from "babylonjs/Meshes/mesh";
  27907. import { Nullable } from "babylonjs/types";
  27908. /**
  27909. * Class used to represent a specific level of detail of a mesh
  27910. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27911. */
  27912. export class MeshLODLevel {
  27913. /** Defines the distance where this level should start being displayed */
  27914. distance: number;
  27915. /** Defines the mesh to use to render this level */
  27916. mesh: Nullable<Mesh>;
  27917. /**
  27918. * Creates a new LOD level
  27919. * @param distance defines the distance where this level should star being displayed
  27920. * @param mesh defines the mesh to use to render this level
  27921. */
  27922. constructor(
  27923. /** Defines the distance where this level should start being displayed */
  27924. distance: number,
  27925. /** Defines the mesh to use to render this level */
  27926. mesh: Nullable<Mesh>);
  27927. }
  27928. }
  27929. declare module "babylonjs/Misc/canvasGenerator" {
  27930. /**
  27931. * Helper class used to generate a canvas to manipulate images
  27932. */
  27933. export class CanvasGenerator {
  27934. /**
  27935. * Create a new canvas (or offscreen canvas depending on the context)
  27936. * @param width defines the expected width
  27937. * @param height defines the expected height
  27938. * @return a new canvas or offscreen canvas
  27939. */
  27940. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27941. }
  27942. }
  27943. declare module "babylonjs/Meshes/groundMesh" {
  27944. import { Scene } from "babylonjs/scene";
  27945. import { Vector3 } from "babylonjs/Maths/math.vector";
  27946. import { Mesh } from "babylonjs/Meshes/mesh";
  27947. /**
  27948. * Mesh representing the gorund
  27949. */
  27950. export class GroundMesh extends Mesh {
  27951. /** If octree should be generated */
  27952. generateOctree: boolean;
  27953. private _heightQuads;
  27954. /** @hidden */
  27955. _subdivisionsX: number;
  27956. /** @hidden */
  27957. _subdivisionsY: number;
  27958. /** @hidden */
  27959. _width: number;
  27960. /** @hidden */
  27961. _height: number;
  27962. /** @hidden */
  27963. _minX: number;
  27964. /** @hidden */
  27965. _maxX: number;
  27966. /** @hidden */
  27967. _minZ: number;
  27968. /** @hidden */
  27969. _maxZ: number;
  27970. constructor(name: string, scene: Scene);
  27971. /**
  27972. * "GroundMesh"
  27973. * @returns "GroundMesh"
  27974. */
  27975. getClassName(): string;
  27976. /**
  27977. * The minimum of x and y subdivisions
  27978. */
  27979. get subdivisions(): number;
  27980. /**
  27981. * X subdivisions
  27982. */
  27983. get subdivisionsX(): number;
  27984. /**
  27985. * Y subdivisions
  27986. */
  27987. get subdivisionsY(): number;
  27988. /**
  27989. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27990. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27991. * @param chunksCount the number of subdivisions for x and y
  27992. * @param octreeBlocksSize (Default: 32)
  27993. */
  27994. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27995. /**
  27996. * Returns a height (y) value in the Worl system :
  27997. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27998. * @param x x coordinate
  27999. * @param z z coordinate
  28000. * @returns the ground y position if (x, z) are outside the ground surface.
  28001. */
  28002. getHeightAtCoordinates(x: number, z: number): number;
  28003. /**
  28004. * Returns a normalized vector (Vector3) orthogonal to the ground
  28005. * at the ground coordinates (x, z) expressed in the World system.
  28006. * @param x x coordinate
  28007. * @param z z coordinate
  28008. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  28009. */
  28010. getNormalAtCoordinates(x: number, z: number): Vector3;
  28011. /**
  28012. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  28013. * at the ground coordinates (x, z) expressed in the World system.
  28014. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  28015. * @param x x coordinate
  28016. * @param z z coordinate
  28017. * @param ref vector to store the result
  28018. * @returns the GroundMesh.
  28019. */
  28020. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  28021. /**
  28022. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  28023. * if the ground has been updated.
  28024. * This can be used in the render loop.
  28025. * @returns the GroundMesh.
  28026. */
  28027. updateCoordinateHeights(): GroundMesh;
  28028. private _getFacetAt;
  28029. private _initHeightQuads;
  28030. private _computeHeightQuads;
  28031. /**
  28032. * Serializes this ground mesh
  28033. * @param serializationObject object to write serialization to
  28034. */
  28035. serialize(serializationObject: any): void;
  28036. /**
  28037. * Parses a serialized ground mesh
  28038. * @param parsedMesh the serialized mesh
  28039. * @param scene the scene to create the ground mesh in
  28040. * @returns the created ground mesh
  28041. */
  28042. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  28043. }
  28044. }
  28045. declare module "babylonjs/Physics/physicsJoint" {
  28046. import { Vector3 } from "babylonjs/Maths/math.vector";
  28047. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  28048. /**
  28049. * Interface for Physics-Joint data
  28050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28051. */
  28052. export interface PhysicsJointData {
  28053. /**
  28054. * The main pivot of the joint
  28055. */
  28056. mainPivot?: Vector3;
  28057. /**
  28058. * The connected pivot of the joint
  28059. */
  28060. connectedPivot?: Vector3;
  28061. /**
  28062. * The main axis of the joint
  28063. */
  28064. mainAxis?: Vector3;
  28065. /**
  28066. * The connected axis of the joint
  28067. */
  28068. connectedAxis?: Vector3;
  28069. /**
  28070. * The collision of the joint
  28071. */
  28072. collision?: boolean;
  28073. /**
  28074. * Native Oimo/Cannon/Energy data
  28075. */
  28076. nativeParams?: any;
  28077. }
  28078. /**
  28079. * This is a holder class for the physics joint created by the physics plugin
  28080. * It holds a set of functions to control the underlying joint
  28081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28082. */
  28083. export class PhysicsJoint {
  28084. /**
  28085. * The type of the physics joint
  28086. */
  28087. type: number;
  28088. /**
  28089. * The data for the physics joint
  28090. */
  28091. jointData: PhysicsJointData;
  28092. private _physicsJoint;
  28093. protected _physicsPlugin: IPhysicsEnginePlugin;
  28094. /**
  28095. * Initializes the physics joint
  28096. * @param type The type of the physics joint
  28097. * @param jointData The data for the physics joint
  28098. */
  28099. constructor(
  28100. /**
  28101. * The type of the physics joint
  28102. */
  28103. type: number,
  28104. /**
  28105. * The data for the physics joint
  28106. */
  28107. jointData: PhysicsJointData);
  28108. /**
  28109. * Gets the physics joint
  28110. */
  28111. get physicsJoint(): any;
  28112. /**
  28113. * Sets the physics joint
  28114. */
  28115. set physicsJoint(newJoint: any);
  28116. /**
  28117. * Sets the physics plugin
  28118. */
  28119. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  28120. /**
  28121. * Execute a function that is physics-plugin specific.
  28122. * @param {Function} func the function that will be executed.
  28123. * It accepts two parameters: the physics world and the physics joint
  28124. */
  28125. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  28126. /**
  28127. * Distance-Joint type
  28128. */
  28129. static DistanceJoint: number;
  28130. /**
  28131. * Hinge-Joint type
  28132. */
  28133. static HingeJoint: number;
  28134. /**
  28135. * Ball-and-Socket joint type
  28136. */
  28137. static BallAndSocketJoint: number;
  28138. /**
  28139. * Wheel-Joint type
  28140. */
  28141. static WheelJoint: number;
  28142. /**
  28143. * Slider-Joint type
  28144. */
  28145. static SliderJoint: number;
  28146. /**
  28147. * Prismatic-Joint type
  28148. */
  28149. static PrismaticJoint: number;
  28150. /**
  28151. * Universal-Joint type
  28152. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  28153. */
  28154. static UniversalJoint: number;
  28155. /**
  28156. * Hinge-Joint 2 type
  28157. */
  28158. static Hinge2Joint: number;
  28159. /**
  28160. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28161. */
  28162. static PointToPointJoint: number;
  28163. /**
  28164. * Spring-Joint type
  28165. */
  28166. static SpringJoint: number;
  28167. /**
  28168. * Lock-Joint type
  28169. */
  28170. static LockJoint: number;
  28171. }
  28172. /**
  28173. * A class representing a physics distance joint
  28174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28175. */
  28176. export class DistanceJoint extends PhysicsJoint {
  28177. /**
  28178. *
  28179. * @param jointData The data for the Distance-Joint
  28180. */
  28181. constructor(jointData: DistanceJointData);
  28182. /**
  28183. * Update the predefined distance.
  28184. * @param maxDistance The maximum preferred distance
  28185. * @param minDistance The minimum preferred distance
  28186. */
  28187. updateDistance(maxDistance: number, minDistance?: number): void;
  28188. }
  28189. /**
  28190. * Represents a Motor-Enabled Joint
  28191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28192. */
  28193. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28194. /**
  28195. * Initializes the Motor-Enabled Joint
  28196. * @param type The type of the joint
  28197. * @param jointData The physica joint data for the joint
  28198. */
  28199. constructor(type: number, jointData: PhysicsJointData);
  28200. /**
  28201. * Set the motor values.
  28202. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28203. * @param force the force to apply
  28204. * @param maxForce max force for this motor.
  28205. */
  28206. setMotor(force?: number, maxForce?: number): void;
  28207. /**
  28208. * Set the motor's limits.
  28209. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28210. * @param upperLimit The upper limit of the motor
  28211. * @param lowerLimit The lower limit of the motor
  28212. */
  28213. setLimit(upperLimit: number, lowerLimit?: number): void;
  28214. }
  28215. /**
  28216. * This class represents a single physics Hinge-Joint
  28217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28218. */
  28219. export class HingeJoint extends MotorEnabledJoint {
  28220. /**
  28221. * Initializes the Hinge-Joint
  28222. * @param jointData The joint data for the Hinge-Joint
  28223. */
  28224. constructor(jointData: PhysicsJointData);
  28225. /**
  28226. * Set the motor values.
  28227. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28228. * @param {number} force the force to apply
  28229. * @param {number} maxForce max force for this motor.
  28230. */
  28231. setMotor(force?: number, maxForce?: number): void;
  28232. /**
  28233. * Set the motor's limits.
  28234. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28235. * @param upperLimit The upper limit of the motor
  28236. * @param lowerLimit The lower limit of the motor
  28237. */
  28238. setLimit(upperLimit: number, lowerLimit?: number): void;
  28239. }
  28240. /**
  28241. * This class represents a dual hinge physics joint (same as wheel joint)
  28242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28243. */
  28244. export class Hinge2Joint extends MotorEnabledJoint {
  28245. /**
  28246. * Initializes the Hinge2-Joint
  28247. * @param jointData The joint data for the Hinge2-Joint
  28248. */
  28249. constructor(jointData: PhysicsJointData);
  28250. /**
  28251. * Set the motor values.
  28252. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28253. * @param {number} targetSpeed the speed the motor is to reach
  28254. * @param {number} maxForce max force for this motor.
  28255. * @param {motorIndex} the motor's index, 0 or 1.
  28256. */
  28257. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28258. /**
  28259. * Set the motor limits.
  28260. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28261. * @param {number} upperLimit the upper limit
  28262. * @param {number} lowerLimit lower limit
  28263. * @param {motorIndex} the motor's index, 0 or 1.
  28264. */
  28265. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28266. }
  28267. /**
  28268. * Interface for a motor enabled joint
  28269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28270. */
  28271. export interface IMotorEnabledJoint {
  28272. /**
  28273. * Physics joint
  28274. */
  28275. physicsJoint: any;
  28276. /**
  28277. * Sets the motor of the motor-enabled joint
  28278. * @param force The force of the motor
  28279. * @param maxForce The maximum force of the motor
  28280. * @param motorIndex The index of the motor
  28281. */
  28282. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28283. /**
  28284. * Sets the limit of the motor
  28285. * @param upperLimit The upper limit of the motor
  28286. * @param lowerLimit The lower limit of the motor
  28287. * @param motorIndex The index of the motor
  28288. */
  28289. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28290. }
  28291. /**
  28292. * Joint data for a Distance-Joint
  28293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28294. */
  28295. export interface DistanceJointData extends PhysicsJointData {
  28296. /**
  28297. * Max distance the 2 joint objects can be apart
  28298. */
  28299. maxDistance: number;
  28300. }
  28301. /**
  28302. * Joint data from a spring joint
  28303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28304. */
  28305. export interface SpringJointData extends PhysicsJointData {
  28306. /**
  28307. * Length of the spring
  28308. */
  28309. length: number;
  28310. /**
  28311. * Stiffness of the spring
  28312. */
  28313. stiffness: number;
  28314. /**
  28315. * Damping of the spring
  28316. */
  28317. damping: number;
  28318. /** this callback will be called when applying the force to the impostors. */
  28319. forceApplicationCallback: () => void;
  28320. }
  28321. }
  28322. declare module "babylonjs/Physics/physicsRaycastResult" {
  28323. import { Vector3 } from "babylonjs/Maths/math.vector";
  28324. /**
  28325. * Holds the data for the raycast result
  28326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28327. */
  28328. export class PhysicsRaycastResult {
  28329. private _hasHit;
  28330. private _hitDistance;
  28331. private _hitNormalWorld;
  28332. private _hitPointWorld;
  28333. private _rayFromWorld;
  28334. private _rayToWorld;
  28335. /**
  28336. * Gets if there was a hit
  28337. */
  28338. get hasHit(): boolean;
  28339. /**
  28340. * Gets the distance from the hit
  28341. */
  28342. get hitDistance(): number;
  28343. /**
  28344. * Gets the hit normal/direction in the world
  28345. */
  28346. get hitNormalWorld(): Vector3;
  28347. /**
  28348. * Gets the hit point in the world
  28349. */
  28350. get hitPointWorld(): Vector3;
  28351. /**
  28352. * Gets the ray "start point" of the ray in the world
  28353. */
  28354. get rayFromWorld(): Vector3;
  28355. /**
  28356. * Gets the ray "end point" of the ray in the world
  28357. */
  28358. get rayToWorld(): Vector3;
  28359. /**
  28360. * Sets the hit data (normal & point in world space)
  28361. * @param hitNormalWorld defines the normal in world space
  28362. * @param hitPointWorld defines the point in world space
  28363. */
  28364. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28365. /**
  28366. * Sets the distance from the start point to the hit point
  28367. * @param distance
  28368. */
  28369. setHitDistance(distance: number): void;
  28370. /**
  28371. * Calculates the distance manually
  28372. */
  28373. calculateHitDistance(): void;
  28374. /**
  28375. * Resets all the values to default
  28376. * @param from The from point on world space
  28377. * @param to The to point on world space
  28378. */
  28379. reset(from?: Vector3, to?: Vector3): void;
  28380. }
  28381. /**
  28382. * Interface for the size containing width and height
  28383. */
  28384. interface IXYZ {
  28385. /**
  28386. * X
  28387. */
  28388. x: number;
  28389. /**
  28390. * Y
  28391. */
  28392. y: number;
  28393. /**
  28394. * Z
  28395. */
  28396. z: number;
  28397. }
  28398. }
  28399. declare module "babylonjs/Physics/IPhysicsEngine" {
  28400. import { Nullable } from "babylonjs/types";
  28401. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28403. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28404. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28405. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28406. /**
  28407. * Interface used to describe a physics joint
  28408. */
  28409. export interface PhysicsImpostorJoint {
  28410. /** Defines the main impostor to which the joint is linked */
  28411. mainImpostor: PhysicsImpostor;
  28412. /** Defines the impostor that is connected to the main impostor using this joint */
  28413. connectedImpostor: PhysicsImpostor;
  28414. /** Defines the joint itself */
  28415. joint: PhysicsJoint;
  28416. }
  28417. /** @hidden */
  28418. export interface IPhysicsEnginePlugin {
  28419. world: any;
  28420. name: string;
  28421. setGravity(gravity: Vector3): void;
  28422. setTimeStep(timeStep: number): void;
  28423. getTimeStep(): number;
  28424. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28425. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28426. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28427. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28428. removePhysicsBody(impostor: PhysicsImpostor): void;
  28429. generateJoint(joint: PhysicsImpostorJoint): void;
  28430. removeJoint(joint: PhysicsImpostorJoint): void;
  28431. isSupported(): boolean;
  28432. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28433. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28434. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28435. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28436. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28437. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28438. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28439. getBodyMass(impostor: PhysicsImpostor): number;
  28440. getBodyFriction(impostor: PhysicsImpostor): number;
  28441. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28442. getBodyRestitution(impostor: PhysicsImpostor): number;
  28443. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28444. getBodyPressure?(impostor: PhysicsImpostor): number;
  28445. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28446. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28447. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28448. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28449. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28450. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28451. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28452. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28453. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28454. sleepBody(impostor: PhysicsImpostor): void;
  28455. wakeUpBody(impostor: PhysicsImpostor): void;
  28456. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28457. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28458. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28459. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28460. getRadius(impostor: PhysicsImpostor): number;
  28461. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28462. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28463. dispose(): void;
  28464. }
  28465. /**
  28466. * Interface used to define a physics engine
  28467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28468. */
  28469. export interface IPhysicsEngine {
  28470. /**
  28471. * Gets the gravity vector used by the simulation
  28472. */
  28473. gravity: Vector3;
  28474. /**
  28475. * Sets the gravity vector used by the simulation
  28476. * @param gravity defines the gravity vector to use
  28477. */
  28478. setGravity(gravity: Vector3): void;
  28479. /**
  28480. * Set the time step of the physics engine.
  28481. * Default is 1/60.
  28482. * To slow it down, enter 1/600 for example.
  28483. * To speed it up, 1/30
  28484. * @param newTimeStep the new timestep to apply to this world.
  28485. */
  28486. setTimeStep(newTimeStep: number): void;
  28487. /**
  28488. * Get the time step of the physics engine.
  28489. * @returns the current time step
  28490. */
  28491. getTimeStep(): number;
  28492. /**
  28493. * Set the sub time step of the physics engine.
  28494. * Default is 0 meaning there is no sub steps
  28495. * To increase physics resolution precision, set a small value (like 1 ms)
  28496. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28497. */
  28498. setSubTimeStep(subTimeStep: number): void;
  28499. /**
  28500. * Get the sub time step of the physics engine.
  28501. * @returns the current sub time step
  28502. */
  28503. getSubTimeStep(): number;
  28504. /**
  28505. * Release all resources
  28506. */
  28507. dispose(): void;
  28508. /**
  28509. * Gets the name of the current physics plugin
  28510. * @returns the name of the plugin
  28511. */
  28512. getPhysicsPluginName(): string;
  28513. /**
  28514. * Adding a new impostor for the impostor tracking.
  28515. * This will be done by the impostor itself.
  28516. * @param impostor the impostor to add
  28517. */
  28518. addImpostor(impostor: PhysicsImpostor): void;
  28519. /**
  28520. * Remove an impostor from the engine.
  28521. * This impostor and its mesh will not longer be updated by the physics engine.
  28522. * @param impostor the impostor to remove
  28523. */
  28524. removeImpostor(impostor: PhysicsImpostor): void;
  28525. /**
  28526. * Add a joint to the physics engine
  28527. * @param mainImpostor defines the main impostor to which the joint is added.
  28528. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28529. * @param joint defines the joint that will connect both impostors.
  28530. */
  28531. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28532. /**
  28533. * Removes a joint from the simulation
  28534. * @param mainImpostor defines the impostor used with the joint
  28535. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28536. * @param joint defines the joint to remove
  28537. */
  28538. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28539. /**
  28540. * Gets the current plugin used to run the simulation
  28541. * @returns current plugin
  28542. */
  28543. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28544. /**
  28545. * Gets the list of physic impostors
  28546. * @returns an array of PhysicsImpostor
  28547. */
  28548. getImpostors(): Array<PhysicsImpostor>;
  28549. /**
  28550. * Gets the impostor for a physics enabled object
  28551. * @param object defines the object impersonated by the impostor
  28552. * @returns the PhysicsImpostor or null if not found
  28553. */
  28554. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28555. /**
  28556. * Gets the impostor for a physics body object
  28557. * @param body defines physics body used by the impostor
  28558. * @returns the PhysicsImpostor or null if not found
  28559. */
  28560. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28561. /**
  28562. * Does a raycast in the physics world
  28563. * @param from when should the ray start?
  28564. * @param to when should the ray end?
  28565. * @returns PhysicsRaycastResult
  28566. */
  28567. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28568. /**
  28569. * Called by the scene. No need to call it.
  28570. * @param delta defines the timespam between frames
  28571. */
  28572. _step(delta: number): void;
  28573. }
  28574. }
  28575. declare module "babylonjs/Physics/physicsImpostor" {
  28576. import { Nullable, IndicesArray } from "babylonjs/types";
  28577. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28578. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28580. import { Scene } from "babylonjs/scene";
  28581. import { Bone } from "babylonjs/Bones/bone";
  28582. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28583. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28584. import { Space } from "babylonjs/Maths/math.axis";
  28585. /**
  28586. * The interface for the physics imposter parameters
  28587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28588. */
  28589. export interface PhysicsImpostorParameters {
  28590. /**
  28591. * The mass of the physics imposter
  28592. */
  28593. mass: number;
  28594. /**
  28595. * The friction of the physics imposter
  28596. */
  28597. friction?: number;
  28598. /**
  28599. * The coefficient of restitution of the physics imposter
  28600. */
  28601. restitution?: number;
  28602. /**
  28603. * The native options of the physics imposter
  28604. */
  28605. nativeOptions?: any;
  28606. /**
  28607. * Specifies if the parent should be ignored
  28608. */
  28609. ignoreParent?: boolean;
  28610. /**
  28611. * Specifies if bi-directional transformations should be disabled
  28612. */
  28613. disableBidirectionalTransformation?: boolean;
  28614. /**
  28615. * The pressure inside the physics imposter, soft object only
  28616. */
  28617. pressure?: number;
  28618. /**
  28619. * The stiffness the physics imposter, soft object only
  28620. */
  28621. stiffness?: number;
  28622. /**
  28623. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28624. */
  28625. velocityIterations?: number;
  28626. /**
  28627. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28628. */
  28629. positionIterations?: number;
  28630. /**
  28631. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28632. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28633. * Add to fix multiple points
  28634. */
  28635. fixedPoints?: number;
  28636. /**
  28637. * The collision margin around a soft object
  28638. */
  28639. margin?: number;
  28640. /**
  28641. * The collision margin around a soft object
  28642. */
  28643. damping?: number;
  28644. /**
  28645. * The path for a rope based on an extrusion
  28646. */
  28647. path?: any;
  28648. /**
  28649. * The shape of an extrusion used for a rope based on an extrusion
  28650. */
  28651. shape?: any;
  28652. }
  28653. /**
  28654. * Interface for a physics-enabled object
  28655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28656. */
  28657. export interface IPhysicsEnabledObject {
  28658. /**
  28659. * The position of the physics-enabled object
  28660. */
  28661. position: Vector3;
  28662. /**
  28663. * The rotation of the physics-enabled object
  28664. */
  28665. rotationQuaternion: Nullable<Quaternion>;
  28666. /**
  28667. * The scale of the physics-enabled object
  28668. */
  28669. scaling: Vector3;
  28670. /**
  28671. * The rotation of the physics-enabled object
  28672. */
  28673. rotation?: Vector3;
  28674. /**
  28675. * The parent of the physics-enabled object
  28676. */
  28677. parent?: any;
  28678. /**
  28679. * The bounding info of the physics-enabled object
  28680. * @returns The bounding info of the physics-enabled object
  28681. */
  28682. getBoundingInfo(): BoundingInfo;
  28683. /**
  28684. * Computes the world matrix
  28685. * @param force Specifies if the world matrix should be computed by force
  28686. * @returns A world matrix
  28687. */
  28688. computeWorldMatrix(force: boolean): Matrix;
  28689. /**
  28690. * Gets the world matrix
  28691. * @returns A world matrix
  28692. */
  28693. getWorldMatrix?(): Matrix;
  28694. /**
  28695. * Gets the child meshes
  28696. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28697. * @returns An array of abstract meshes
  28698. */
  28699. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28700. /**
  28701. * Gets the vertex data
  28702. * @param kind The type of vertex data
  28703. * @returns A nullable array of numbers, or a float32 array
  28704. */
  28705. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28706. /**
  28707. * Gets the indices from the mesh
  28708. * @returns A nullable array of index arrays
  28709. */
  28710. getIndices?(): Nullable<IndicesArray>;
  28711. /**
  28712. * Gets the scene from the mesh
  28713. * @returns the indices array or null
  28714. */
  28715. getScene?(): Scene;
  28716. /**
  28717. * Gets the absolute position from the mesh
  28718. * @returns the absolute position
  28719. */
  28720. getAbsolutePosition(): Vector3;
  28721. /**
  28722. * Gets the absolute pivot point from the mesh
  28723. * @returns the absolute pivot point
  28724. */
  28725. getAbsolutePivotPoint(): Vector3;
  28726. /**
  28727. * Rotates the mesh
  28728. * @param axis The axis of rotation
  28729. * @param amount The amount of rotation
  28730. * @param space The space of the rotation
  28731. * @returns The rotation transform node
  28732. */
  28733. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28734. /**
  28735. * Translates the mesh
  28736. * @param axis The axis of translation
  28737. * @param distance The distance of translation
  28738. * @param space The space of the translation
  28739. * @returns The transform node
  28740. */
  28741. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28742. /**
  28743. * Sets the absolute position of the mesh
  28744. * @param absolutePosition The absolute position of the mesh
  28745. * @returns The transform node
  28746. */
  28747. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28748. /**
  28749. * Gets the class name of the mesh
  28750. * @returns The class name
  28751. */
  28752. getClassName(): string;
  28753. }
  28754. /**
  28755. * Represents a physics imposter
  28756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28757. */
  28758. export class PhysicsImpostor {
  28759. /**
  28760. * The physics-enabled object used as the physics imposter
  28761. */
  28762. object: IPhysicsEnabledObject;
  28763. /**
  28764. * The type of the physics imposter
  28765. */
  28766. type: number;
  28767. private _options;
  28768. private _scene?;
  28769. /**
  28770. * The default object size of the imposter
  28771. */
  28772. static DEFAULT_OBJECT_SIZE: Vector3;
  28773. /**
  28774. * The identity quaternion of the imposter
  28775. */
  28776. static IDENTITY_QUATERNION: Quaternion;
  28777. /** @hidden */
  28778. _pluginData: any;
  28779. private _physicsEngine;
  28780. private _physicsBody;
  28781. private _bodyUpdateRequired;
  28782. private _onBeforePhysicsStepCallbacks;
  28783. private _onAfterPhysicsStepCallbacks;
  28784. /** @hidden */
  28785. _onPhysicsCollideCallbacks: Array<{
  28786. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28787. otherImpostors: Array<PhysicsImpostor>;
  28788. }>;
  28789. private _deltaPosition;
  28790. private _deltaRotation;
  28791. private _deltaRotationConjugated;
  28792. /** @hidden */
  28793. _isFromLine: boolean;
  28794. private _parent;
  28795. private _isDisposed;
  28796. private static _tmpVecs;
  28797. private static _tmpQuat;
  28798. /**
  28799. * Specifies if the physics imposter is disposed
  28800. */
  28801. get isDisposed(): boolean;
  28802. /**
  28803. * Gets the mass of the physics imposter
  28804. */
  28805. get mass(): number;
  28806. set mass(value: number);
  28807. /**
  28808. * Gets the coefficient of friction
  28809. */
  28810. get friction(): number;
  28811. /**
  28812. * Sets the coefficient of friction
  28813. */
  28814. set friction(value: number);
  28815. /**
  28816. * Gets the coefficient of restitution
  28817. */
  28818. get restitution(): number;
  28819. /**
  28820. * Sets the coefficient of restitution
  28821. */
  28822. set restitution(value: number);
  28823. /**
  28824. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28825. */
  28826. get pressure(): number;
  28827. /**
  28828. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28829. */
  28830. set pressure(value: number);
  28831. /**
  28832. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28833. */
  28834. get stiffness(): number;
  28835. /**
  28836. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28837. */
  28838. set stiffness(value: number);
  28839. /**
  28840. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28841. */
  28842. get velocityIterations(): number;
  28843. /**
  28844. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28845. */
  28846. set velocityIterations(value: number);
  28847. /**
  28848. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28849. */
  28850. get positionIterations(): number;
  28851. /**
  28852. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28853. */
  28854. set positionIterations(value: number);
  28855. /**
  28856. * The unique id of the physics imposter
  28857. * set by the physics engine when adding this impostor to the array
  28858. */
  28859. uniqueId: number;
  28860. /**
  28861. * @hidden
  28862. */
  28863. soft: boolean;
  28864. /**
  28865. * @hidden
  28866. */
  28867. segments: number;
  28868. private _joints;
  28869. /**
  28870. * Initializes the physics imposter
  28871. * @param object The physics-enabled object used as the physics imposter
  28872. * @param type The type of the physics imposter
  28873. * @param _options The options for the physics imposter
  28874. * @param _scene The Babylon scene
  28875. */
  28876. constructor(
  28877. /**
  28878. * The physics-enabled object used as the physics imposter
  28879. */
  28880. object: IPhysicsEnabledObject,
  28881. /**
  28882. * The type of the physics imposter
  28883. */
  28884. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28885. /**
  28886. * This function will completly initialize this impostor.
  28887. * It will create a new body - but only if this mesh has no parent.
  28888. * If it has, this impostor will not be used other than to define the impostor
  28889. * of the child mesh.
  28890. * @hidden
  28891. */
  28892. _init(): void;
  28893. private _getPhysicsParent;
  28894. /**
  28895. * Should a new body be generated.
  28896. * @returns boolean specifying if body initialization is required
  28897. */
  28898. isBodyInitRequired(): boolean;
  28899. /**
  28900. * Sets the updated scaling
  28901. * @param updated Specifies if the scaling is updated
  28902. */
  28903. setScalingUpdated(): void;
  28904. /**
  28905. * Force a regeneration of this or the parent's impostor's body.
  28906. * Use under cautious - This will remove all joints already implemented.
  28907. */
  28908. forceUpdate(): void;
  28909. /**
  28910. * Gets the body that holds this impostor. Either its own, or its parent.
  28911. */
  28912. get physicsBody(): any;
  28913. /**
  28914. * Get the parent of the physics imposter
  28915. * @returns Physics imposter or null
  28916. */
  28917. get parent(): Nullable<PhysicsImpostor>;
  28918. /**
  28919. * Sets the parent of the physics imposter
  28920. */
  28921. set parent(value: Nullable<PhysicsImpostor>);
  28922. /**
  28923. * Set the physics body. Used mainly by the physics engine/plugin
  28924. */
  28925. set physicsBody(physicsBody: any);
  28926. /**
  28927. * Resets the update flags
  28928. */
  28929. resetUpdateFlags(): void;
  28930. /**
  28931. * Gets the object extend size
  28932. * @returns the object extend size
  28933. */
  28934. getObjectExtendSize(): Vector3;
  28935. /**
  28936. * Gets the object center
  28937. * @returns The object center
  28938. */
  28939. getObjectCenter(): Vector3;
  28940. /**
  28941. * Get a specific parameter from the options parameters
  28942. * @param paramName The object parameter name
  28943. * @returns The object parameter
  28944. */
  28945. getParam(paramName: string): any;
  28946. /**
  28947. * Sets a specific parameter in the options given to the physics plugin
  28948. * @param paramName The parameter name
  28949. * @param value The value of the parameter
  28950. */
  28951. setParam(paramName: string, value: number): void;
  28952. /**
  28953. * Specifically change the body's mass option. Won't recreate the physics body object
  28954. * @param mass The mass of the physics imposter
  28955. */
  28956. setMass(mass: number): void;
  28957. /**
  28958. * Gets the linear velocity
  28959. * @returns linear velocity or null
  28960. */
  28961. getLinearVelocity(): Nullable<Vector3>;
  28962. /**
  28963. * Sets the linear velocity
  28964. * @param velocity linear velocity or null
  28965. */
  28966. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28967. /**
  28968. * Gets the angular velocity
  28969. * @returns angular velocity or null
  28970. */
  28971. getAngularVelocity(): Nullable<Vector3>;
  28972. /**
  28973. * Sets the angular velocity
  28974. * @param velocity The velocity or null
  28975. */
  28976. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28977. /**
  28978. * Execute a function with the physics plugin native code
  28979. * Provide a function the will have two variables - the world object and the physics body object
  28980. * @param func The function to execute with the physics plugin native code
  28981. */
  28982. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28983. /**
  28984. * Register a function that will be executed before the physics world is stepping forward
  28985. * @param func The function to execute before the physics world is stepped forward
  28986. */
  28987. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28988. /**
  28989. * Unregister a function that will be executed before the physics world is stepping forward
  28990. * @param func The function to execute before the physics world is stepped forward
  28991. */
  28992. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28993. /**
  28994. * Register a function that will be executed after the physics step
  28995. * @param func The function to execute after physics step
  28996. */
  28997. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28998. /**
  28999. * Unregisters a function that will be executed after the physics step
  29000. * @param func The function to execute after physics step
  29001. */
  29002. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  29003. /**
  29004. * register a function that will be executed when this impostor collides against a different body
  29005. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  29006. * @param func Callback that is executed on collision
  29007. */
  29008. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  29009. /**
  29010. * Unregisters the physics imposter on contact
  29011. * @param collideAgainst The physics object to collide against
  29012. * @param func Callback to execute on collision
  29013. */
  29014. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  29015. private _tmpQuat;
  29016. private _tmpQuat2;
  29017. /**
  29018. * Get the parent rotation
  29019. * @returns The parent rotation
  29020. */
  29021. getParentsRotation(): Quaternion;
  29022. /**
  29023. * this function is executed by the physics engine.
  29024. */
  29025. beforeStep: () => void;
  29026. /**
  29027. * this function is executed by the physics engine
  29028. */
  29029. afterStep: () => void;
  29030. /**
  29031. * Legacy collision detection event support
  29032. */
  29033. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  29034. /**
  29035. * event and body object due to cannon's event-based architecture.
  29036. */
  29037. onCollide: (e: {
  29038. body: any;
  29039. }) => void;
  29040. /**
  29041. * Apply a force
  29042. * @param force The force to apply
  29043. * @param contactPoint The contact point for the force
  29044. * @returns The physics imposter
  29045. */
  29046. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  29047. /**
  29048. * Apply an impulse
  29049. * @param force The impulse force
  29050. * @param contactPoint The contact point for the impulse force
  29051. * @returns The physics imposter
  29052. */
  29053. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  29054. /**
  29055. * A help function to create a joint
  29056. * @param otherImpostor A physics imposter used to create a joint
  29057. * @param jointType The type of joint
  29058. * @param jointData The data for the joint
  29059. * @returns The physics imposter
  29060. */
  29061. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  29062. /**
  29063. * Add a joint to this impostor with a different impostor
  29064. * @param otherImpostor A physics imposter used to add a joint
  29065. * @param joint The joint to add
  29066. * @returns The physics imposter
  29067. */
  29068. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  29069. /**
  29070. * Add an anchor to a cloth impostor
  29071. * @param otherImpostor rigid impostor to anchor to
  29072. * @param width ratio across width from 0 to 1
  29073. * @param height ratio up height from 0 to 1
  29074. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  29075. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  29076. * @returns impostor the soft imposter
  29077. */
  29078. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29079. /**
  29080. * Add a hook to a rope impostor
  29081. * @param otherImpostor rigid impostor to anchor to
  29082. * @param length ratio across rope from 0 to 1
  29083. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  29084. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  29085. * @returns impostor the rope imposter
  29086. */
  29087. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29088. /**
  29089. * Will keep this body still, in a sleep mode.
  29090. * @returns the physics imposter
  29091. */
  29092. sleep(): PhysicsImpostor;
  29093. /**
  29094. * Wake the body up.
  29095. * @returns The physics imposter
  29096. */
  29097. wakeUp(): PhysicsImpostor;
  29098. /**
  29099. * Clones the physics imposter
  29100. * @param newObject The physics imposter clones to this physics-enabled object
  29101. * @returns A nullable physics imposter
  29102. */
  29103. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29104. /**
  29105. * Disposes the physics imposter
  29106. */
  29107. dispose(): void;
  29108. /**
  29109. * Sets the delta position
  29110. * @param position The delta position amount
  29111. */
  29112. setDeltaPosition(position: Vector3): void;
  29113. /**
  29114. * Sets the delta rotation
  29115. * @param rotation The delta rotation amount
  29116. */
  29117. setDeltaRotation(rotation: Quaternion): void;
  29118. /**
  29119. * Gets the box size of the physics imposter and stores the result in the input parameter
  29120. * @param result Stores the box size
  29121. * @returns The physics imposter
  29122. */
  29123. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  29124. /**
  29125. * Gets the radius of the physics imposter
  29126. * @returns Radius of the physics imposter
  29127. */
  29128. getRadius(): number;
  29129. /**
  29130. * Sync a bone with this impostor
  29131. * @param bone The bone to sync to the impostor.
  29132. * @param boneMesh The mesh that the bone is influencing.
  29133. * @param jointPivot The pivot of the joint / bone in local space.
  29134. * @param distToJoint Optional distance from the impostor to the joint.
  29135. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29136. */
  29137. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  29138. /**
  29139. * Sync impostor to a bone
  29140. * @param bone The bone that the impostor will be synced to.
  29141. * @param boneMesh The mesh that the bone is influencing.
  29142. * @param jointPivot The pivot of the joint / bone in local space.
  29143. * @param distToJoint Optional distance from the impostor to the joint.
  29144. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29145. * @param boneAxis Optional vector3 axis the bone is aligned with
  29146. */
  29147. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  29148. /**
  29149. * No-Imposter type
  29150. */
  29151. static NoImpostor: number;
  29152. /**
  29153. * Sphere-Imposter type
  29154. */
  29155. static SphereImpostor: number;
  29156. /**
  29157. * Box-Imposter type
  29158. */
  29159. static BoxImpostor: number;
  29160. /**
  29161. * Plane-Imposter type
  29162. */
  29163. static PlaneImpostor: number;
  29164. /**
  29165. * Mesh-imposter type
  29166. */
  29167. static MeshImpostor: number;
  29168. /**
  29169. * Capsule-Impostor type (Ammo.js plugin only)
  29170. */
  29171. static CapsuleImpostor: number;
  29172. /**
  29173. * Cylinder-Imposter type
  29174. */
  29175. static CylinderImpostor: number;
  29176. /**
  29177. * Particle-Imposter type
  29178. */
  29179. static ParticleImpostor: number;
  29180. /**
  29181. * Heightmap-Imposter type
  29182. */
  29183. static HeightmapImpostor: number;
  29184. /**
  29185. * ConvexHull-Impostor type (Ammo.js plugin only)
  29186. */
  29187. static ConvexHullImpostor: number;
  29188. /**
  29189. * Custom-Imposter type (Ammo.js plugin only)
  29190. */
  29191. static CustomImpostor: number;
  29192. /**
  29193. * Rope-Imposter type
  29194. */
  29195. static RopeImpostor: number;
  29196. /**
  29197. * Cloth-Imposter type
  29198. */
  29199. static ClothImpostor: number;
  29200. /**
  29201. * Softbody-Imposter type
  29202. */
  29203. static SoftbodyImpostor: number;
  29204. }
  29205. }
  29206. declare module "babylonjs/Meshes/mesh" {
  29207. import { Observable } from "babylonjs/Misc/observable";
  29208. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29209. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29210. import { Camera } from "babylonjs/Cameras/camera";
  29211. import { Scene } from "babylonjs/scene";
  29212. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29213. import { Color4 } from "babylonjs/Maths/math.color";
  29214. import { Engine } from "babylonjs/Engines/engine";
  29215. import { Node } from "babylonjs/node";
  29216. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29217. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29218. import { Buffer } from "babylonjs/Meshes/buffer";
  29219. import { Geometry } from "babylonjs/Meshes/geometry";
  29220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29221. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29222. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29223. import { Effect } from "babylonjs/Materials/effect";
  29224. import { Material } from "babylonjs/Materials/material";
  29225. import { Skeleton } from "babylonjs/Bones/skeleton";
  29226. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29227. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29228. import { Path3D } from "babylonjs/Maths/math.path";
  29229. import { Plane } from "babylonjs/Maths/math.plane";
  29230. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29231. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  29232. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29233. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29234. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29235. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29236. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29237. /**
  29238. * @hidden
  29239. **/
  29240. export class _CreationDataStorage {
  29241. closePath?: boolean;
  29242. closeArray?: boolean;
  29243. idx: number[];
  29244. dashSize: number;
  29245. gapSize: number;
  29246. path3D: Path3D;
  29247. pathArray: Vector3[][];
  29248. arc: number;
  29249. radius: number;
  29250. cap: number;
  29251. tessellation: number;
  29252. }
  29253. /**
  29254. * @hidden
  29255. **/
  29256. class _InstanceDataStorage {
  29257. visibleInstances: any;
  29258. batchCache: _InstancesBatch;
  29259. instancesBufferSize: number;
  29260. instancesBuffer: Nullable<Buffer>;
  29261. instancesData: Float32Array;
  29262. overridenInstanceCount: number;
  29263. isFrozen: boolean;
  29264. previousBatch: Nullable<_InstancesBatch>;
  29265. hardwareInstancedRendering: boolean;
  29266. sideOrientation: number;
  29267. manualUpdate: boolean;
  29268. previousRenderId: number;
  29269. }
  29270. /**
  29271. * @hidden
  29272. **/
  29273. export class _InstancesBatch {
  29274. mustReturn: boolean;
  29275. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29276. renderSelf: boolean[];
  29277. hardwareInstancedRendering: boolean[];
  29278. }
  29279. /**
  29280. * @hidden
  29281. **/
  29282. class _ThinInstanceDataStorage {
  29283. instancesCount: number;
  29284. matrixBuffer: Nullable<Buffer>;
  29285. matrixBufferSize: number;
  29286. matrixData: Nullable<Float32Array>;
  29287. boundingVectors: Array<Vector3>;
  29288. worldMatrices: Nullable<Matrix[]>;
  29289. }
  29290. /**
  29291. * Class used to represent renderable models
  29292. */
  29293. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29294. /**
  29295. * Mesh side orientation : usually the external or front surface
  29296. */
  29297. static readonly FRONTSIDE: number;
  29298. /**
  29299. * Mesh side orientation : usually the internal or back surface
  29300. */
  29301. static readonly BACKSIDE: number;
  29302. /**
  29303. * Mesh side orientation : both internal and external or front and back surfaces
  29304. */
  29305. static readonly DOUBLESIDE: number;
  29306. /**
  29307. * Mesh side orientation : by default, `FRONTSIDE`
  29308. */
  29309. static readonly DEFAULTSIDE: number;
  29310. /**
  29311. * Mesh cap setting : no cap
  29312. */
  29313. static readonly NO_CAP: number;
  29314. /**
  29315. * Mesh cap setting : one cap at the beginning of the mesh
  29316. */
  29317. static readonly CAP_START: number;
  29318. /**
  29319. * Mesh cap setting : one cap at the end of the mesh
  29320. */
  29321. static readonly CAP_END: number;
  29322. /**
  29323. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29324. */
  29325. static readonly CAP_ALL: number;
  29326. /**
  29327. * Mesh pattern setting : no flip or rotate
  29328. */
  29329. static readonly NO_FLIP: number;
  29330. /**
  29331. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29332. */
  29333. static readonly FLIP_TILE: number;
  29334. /**
  29335. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29336. */
  29337. static readonly ROTATE_TILE: number;
  29338. /**
  29339. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29340. */
  29341. static readonly FLIP_ROW: number;
  29342. /**
  29343. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29344. */
  29345. static readonly ROTATE_ROW: number;
  29346. /**
  29347. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29348. */
  29349. static readonly FLIP_N_ROTATE_TILE: number;
  29350. /**
  29351. * Mesh pattern setting : rotate pattern and rotate
  29352. */
  29353. static readonly FLIP_N_ROTATE_ROW: number;
  29354. /**
  29355. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29356. */
  29357. static readonly CENTER: number;
  29358. /**
  29359. * Mesh tile positioning : part tiles on left
  29360. */
  29361. static readonly LEFT: number;
  29362. /**
  29363. * Mesh tile positioning : part tiles on right
  29364. */
  29365. static readonly RIGHT: number;
  29366. /**
  29367. * Mesh tile positioning : part tiles on top
  29368. */
  29369. static readonly TOP: number;
  29370. /**
  29371. * Mesh tile positioning : part tiles on bottom
  29372. */
  29373. static readonly BOTTOM: number;
  29374. /**
  29375. * Gets the default side orientation.
  29376. * @param orientation the orientation to value to attempt to get
  29377. * @returns the default orientation
  29378. * @hidden
  29379. */
  29380. static _GetDefaultSideOrientation(orientation?: number): number;
  29381. private _internalMeshDataInfo;
  29382. get computeBonesUsingShaders(): boolean;
  29383. set computeBonesUsingShaders(value: boolean);
  29384. /**
  29385. * An event triggered before rendering the mesh
  29386. */
  29387. get onBeforeRenderObservable(): Observable<Mesh>;
  29388. /**
  29389. * An event triggered before binding the mesh
  29390. */
  29391. get onBeforeBindObservable(): Observable<Mesh>;
  29392. /**
  29393. * An event triggered after rendering the mesh
  29394. */
  29395. get onAfterRenderObservable(): Observable<Mesh>;
  29396. /**
  29397. * An event triggered before drawing the mesh
  29398. */
  29399. get onBeforeDrawObservable(): Observable<Mesh>;
  29400. private _onBeforeDrawObserver;
  29401. /**
  29402. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29403. */
  29404. set onBeforeDraw(callback: () => void);
  29405. get hasInstances(): boolean;
  29406. get hasThinInstances(): boolean;
  29407. /**
  29408. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29409. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29410. */
  29411. delayLoadState: number;
  29412. /**
  29413. * Gets the list of instances created from this mesh
  29414. * it is not supposed to be modified manually.
  29415. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29416. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29417. */
  29418. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29419. /**
  29420. * Gets the file containing delay loading data for this mesh
  29421. */
  29422. delayLoadingFile: string;
  29423. /** @hidden */
  29424. _binaryInfo: any;
  29425. /**
  29426. * User defined function used to change how LOD level selection is done
  29427. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29428. */
  29429. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29430. /**
  29431. * Gets or sets the morph target manager
  29432. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29433. */
  29434. get morphTargetManager(): Nullable<MorphTargetManager>;
  29435. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29436. /** @hidden */
  29437. _creationDataStorage: Nullable<_CreationDataStorage>;
  29438. /** @hidden */
  29439. _geometry: Nullable<Geometry>;
  29440. /** @hidden */
  29441. _delayInfo: Array<string>;
  29442. /** @hidden */
  29443. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29444. /** @hidden */
  29445. _instanceDataStorage: _InstanceDataStorage;
  29446. /** @hidden */
  29447. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29448. private _effectiveMaterial;
  29449. /** @hidden */
  29450. _shouldGenerateFlatShading: boolean;
  29451. /** @hidden */
  29452. _originalBuilderSideOrientation: number;
  29453. /**
  29454. * Use this property to change the original side orientation defined at construction time
  29455. */
  29456. overrideMaterialSideOrientation: Nullable<number>;
  29457. /**
  29458. * Gets the source mesh (the one used to clone this one from)
  29459. */
  29460. get source(): Nullable<Mesh>;
  29461. /**
  29462. * Gets the list of clones of this mesh
  29463. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29464. * Note that useClonedMeshMap=true is the default setting
  29465. */
  29466. get cloneMeshMap(): Nullable<{
  29467. [id: string]: Mesh | undefined;
  29468. }>;
  29469. /**
  29470. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29471. */
  29472. get isUnIndexed(): boolean;
  29473. set isUnIndexed(value: boolean);
  29474. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29475. get worldMatrixInstancedBuffer(): Float32Array;
  29476. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29477. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29478. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29479. /**
  29480. * @constructor
  29481. * @param name The value used by scene.getMeshByName() to do a lookup.
  29482. * @param scene The scene to add this mesh to.
  29483. * @param parent The parent of this mesh, if it has one
  29484. * @param source An optional Mesh from which geometry is shared, cloned.
  29485. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29486. * When false, achieved by calling a clone(), also passing False.
  29487. * This will make creation of children, recursive.
  29488. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29489. */
  29490. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29491. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29492. doNotInstantiate: boolean;
  29493. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29494. /**
  29495. * Gets the class name
  29496. * @returns the string "Mesh".
  29497. */
  29498. getClassName(): string;
  29499. /** @hidden */
  29500. get _isMesh(): boolean;
  29501. /**
  29502. * Returns a description of this mesh
  29503. * @param fullDetails define if full details about this mesh must be used
  29504. * @returns a descriptive string representing this mesh
  29505. */
  29506. toString(fullDetails?: boolean): string;
  29507. /** @hidden */
  29508. _unBindEffect(): void;
  29509. /**
  29510. * Gets a boolean indicating if this mesh has LOD
  29511. */
  29512. get hasLODLevels(): boolean;
  29513. /**
  29514. * Gets the list of MeshLODLevel associated with the current mesh
  29515. * @returns an array of MeshLODLevel
  29516. */
  29517. getLODLevels(): MeshLODLevel[];
  29518. private _sortLODLevels;
  29519. /**
  29520. * Add a mesh as LOD level triggered at the given distance.
  29521. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29522. * @param distance The distance from the center of the object to show this level
  29523. * @param mesh The mesh to be added as LOD level (can be null)
  29524. * @return This mesh (for chaining)
  29525. */
  29526. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29527. /**
  29528. * Returns the LOD level mesh at the passed distance or null if not found.
  29529. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29530. * @param distance The distance from the center of the object to show this level
  29531. * @returns a Mesh or `null`
  29532. */
  29533. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29534. /**
  29535. * Remove a mesh from the LOD array
  29536. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29537. * @param mesh defines the mesh to be removed
  29538. * @return This mesh (for chaining)
  29539. */
  29540. removeLODLevel(mesh: Mesh): Mesh;
  29541. /**
  29542. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29543. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29544. * @param camera defines the camera to use to compute distance
  29545. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29546. * @return This mesh (for chaining)
  29547. */
  29548. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29549. /**
  29550. * Gets the mesh internal Geometry object
  29551. */
  29552. get geometry(): Nullable<Geometry>;
  29553. /**
  29554. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29555. * @returns the total number of vertices
  29556. */
  29557. getTotalVertices(): number;
  29558. /**
  29559. * Returns the content of an associated vertex buffer
  29560. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29561. * - VertexBuffer.PositionKind
  29562. * - VertexBuffer.UVKind
  29563. * - VertexBuffer.UV2Kind
  29564. * - VertexBuffer.UV3Kind
  29565. * - VertexBuffer.UV4Kind
  29566. * - VertexBuffer.UV5Kind
  29567. * - VertexBuffer.UV6Kind
  29568. * - VertexBuffer.ColorKind
  29569. * - VertexBuffer.MatricesIndicesKind
  29570. * - VertexBuffer.MatricesIndicesExtraKind
  29571. * - VertexBuffer.MatricesWeightsKind
  29572. * - VertexBuffer.MatricesWeightsExtraKind
  29573. * @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
  29574. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29575. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29576. */
  29577. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29578. /**
  29579. * Returns the mesh VertexBuffer object from the requested `kind`
  29580. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29581. * - VertexBuffer.PositionKind
  29582. * - VertexBuffer.NormalKind
  29583. * - VertexBuffer.UVKind
  29584. * - VertexBuffer.UV2Kind
  29585. * - VertexBuffer.UV3Kind
  29586. * - VertexBuffer.UV4Kind
  29587. * - VertexBuffer.UV5Kind
  29588. * - VertexBuffer.UV6Kind
  29589. * - VertexBuffer.ColorKind
  29590. * - VertexBuffer.MatricesIndicesKind
  29591. * - VertexBuffer.MatricesIndicesExtraKind
  29592. * - VertexBuffer.MatricesWeightsKind
  29593. * - VertexBuffer.MatricesWeightsExtraKind
  29594. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29595. */
  29596. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29597. /**
  29598. * Tests if a specific vertex buffer is associated with this mesh
  29599. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29600. * - VertexBuffer.PositionKind
  29601. * - VertexBuffer.NormalKind
  29602. * - VertexBuffer.UVKind
  29603. * - VertexBuffer.UV2Kind
  29604. * - VertexBuffer.UV3Kind
  29605. * - VertexBuffer.UV4Kind
  29606. * - VertexBuffer.UV5Kind
  29607. * - VertexBuffer.UV6Kind
  29608. * - VertexBuffer.ColorKind
  29609. * - VertexBuffer.MatricesIndicesKind
  29610. * - VertexBuffer.MatricesIndicesExtraKind
  29611. * - VertexBuffer.MatricesWeightsKind
  29612. * - VertexBuffer.MatricesWeightsExtraKind
  29613. * @returns a boolean
  29614. */
  29615. isVerticesDataPresent(kind: string): boolean;
  29616. /**
  29617. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29618. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29619. * - VertexBuffer.PositionKind
  29620. * - VertexBuffer.UVKind
  29621. * - VertexBuffer.UV2Kind
  29622. * - VertexBuffer.UV3Kind
  29623. * - VertexBuffer.UV4Kind
  29624. * - VertexBuffer.UV5Kind
  29625. * - VertexBuffer.UV6Kind
  29626. * - VertexBuffer.ColorKind
  29627. * - VertexBuffer.MatricesIndicesKind
  29628. * - VertexBuffer.MatricesIndicesExtraKind
  29629. * - VertexBuffer.MatricesWeightsKind
  29630. * - VertexBuffer.MatricesWeightsExtraKind
  29631. * @returns a boolean
  29632. */
  29633. isVertexBufferUpdatable(kind: string): boolean;
  29634. /**
  29635. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29636. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29637. * - VertexBuffer.PositionKind
  29638. * - VertexBuffer.NormalKind
  29639. * - VertexBuffer.UVKind
  29640. * - VertexBuffer.UV2Kind
  29641. * - VertexBuffer.UV3Kind
  29642. * - VertexBuffer.UV4Kind
  29643. * - VertexBuffer.UV5Kind
  29644. * - VertexBuffer.UV6Kind
  29645. * - VertexBuffer.ColorKind
  29646. * - VertexBuffer.MatricesIndicesKind
  29647. * - VertexBuffer.MatricesIndicesExtraKind
  29648. * - VertexBuffer.MatricesWeightsKind
  29649. * - VertexBuffer.MatricesWeightsExtraKind
  29650. * @returns an array of strings
  29651. */
  29652. getVerticesDataKinds(): string[];
  29653. /**
  29654. * Returns a positive integer : the total number of indices in this mesh geometry.
  29655. * @returns the numner of indices or zero if the mesh has no geometry.
  29656. */
  29657. getTotalIndices(): number;
  29658. /**
  29659. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29660. * @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.
  29661. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29662. * @returns the indices array or an empty array if the mesh has no geometry
  29663. */
  29664. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29665. get isBlocked(): boolean;
  29666. /**
  29667. * Determine if the current mesh is ready to be rendered
  29668. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29669. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29670. * @returns true if all associated assets are ready (material, textures, shaders)
  29671. */
  29672. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29673. /**
  29674. * 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.
  29675. */
  29676. get areNormalsFrozen(): boolean;
  29677. /**
  29678. * 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.
  29679. * @returns the current mesh
  29680. */
  29681. freezeNormals(): Mesh;
  29682. /**
  29683. * 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
  29684. * @returns the current mesh
  29685. */
  29686. unfreezeNormals(): Mesh;
  29687. /**
  29688. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29689. */
  29690. set overridenInstanceCount(count: number);
  29691. /** @hidden */
  29692. _preActivate(): Mesh;
  29693. /** @hidden */
  29694. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29695. /** @hidden */
  29696. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29697. protected _afterComputeWorldMatrix(): void;
  29698. /** @hidden */
  29699. _postActivate(): void;
  29700. /**
  29701. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29702. * This means the mesh underlying bounding box and sphere are recomputed.
  29703. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29704. * @returns the current mesh
  29705. */
  29706. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29707. /** @hidden */
  29708. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29709. /**
  29710. * This function will subdivide the mesh into multiple submeshes
  29711. * @param count defines the expected number of submeshes
  29712. */
  29713. subdivide(count: number): void;
  29714. /**
  29715. * Copy a FloatArray into a specific associated vertex buffer
  29716. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29717. * - VertexBuffer.PositionKind
  29718. * - VertexBuffer.UVKind
  29719. * - VertexBuffer.UV2Kind
  29720. * - VertexBuffer.UV3Kind
  29721. * - VertexBuffer.UV4Kind
  29722. * - VertexBuffer.UV5Kind
  29723. * - VertexBuffer.UV6Kind
  29724. * - VertexBuffer.ColorKind
  29725. * - VertexBuffer.MatricesIndicesKind
  29726. * - VertexBuffer.MatricesIndicesExtraKind
  29727. * - VertexBuffer.MatricesWeightsKind
  29728. * - VertexBuffer.MatricesWeightsExtraKind
  29729. * @param data defines the data source
  29730. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29731. * @param stride defines the data stride size (can be null)
  29732. * @returns the current mesh
  29733. */
  29734. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29735. /**
  29736. * Delete a vertex buffer associated with this mesh
  29737. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29738. * - VertexBuffer.PositionKind
  29739. * - VertexBuffer.UVKind
  29740. * - VertexBuffer.UV2Kind
  29741. * - VertexBuffer.UV3Kind
  29742. * - VertexBuffer.UV4Kind
  29743. * - VertexBuffer.UV5Kind
  29744. * - VertexBuffer.UV6Kind
  29745. * - VertexBuffer.ColorKind
  29746. * - VertexBuffer.MatricesIndicesKind
  29747. * - VertexBuffer.MatricesIndicesExtraKind
  29748. * - VertexBuffer.MatricesWeightsKind
  29749. * - VertexBuffer.MatricesWeightsExtraKind
  29750. */
  29751. removeVerticesData(kind: string): void;
  29752. /**
  29753. * Flags an associated vertex buffer as updatable
  29754. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29755. * - VertexBuffer.PositionKind
  29756. * - VertexBuffer.UVKind
  29757. * - VertexBuffer.UV2Kind
  29758. * - VertexBuffer.UV3Kind
  29759. * - VertexBuffer.UV4Kind
  29760. * - VertexBuffer.UV5Kind
  29761. * - VertexBuffer.UV6Kind
  29762. * - VertexBuffer.ColorKind
  29763. * - VertexBuffer.MatricesIndicesKind
  29764. * - VertexBuffer.MatricesIndicesExtraKind
  29765. * - VertexBuffer.MatricesWeightsKind
  29766. * - VertexBuffer.MatricesWeightsExtraKind
  29767. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29768. */
  29769. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29770. /**
  29771. * Sets the mesh global Vertex Buffer
  29772. * @param buffer defines the buffer to use
  29773. * @returns the current mesh
  29774. */
  29775. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29776. /**
  29777. * Update a specific associated vertex buffer
  29778. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29779. * - VertexBuffer.PositionKind
  29780. * - VertexBuffer.UVKind
  29781. * - VertexBuffer.UV2Kind
  29782. * - VertexBuffer.UV3Kind
  29783. * - VertexBuffer.UV4Kind
  29784. * - VertexBuffer.UV5Kind
  29785. * - VertexBuffer.UV6Kind
  29786. * - VertexBuffer.ColorKind
  29787. * - VertexBuffer.MatricesIndicesKind
  29788. * - VertexBuffer.MatricesIndicesExtraKind
  29789. * - VertexBuffer.MatricesWeightsKind
  29790. * - VertexBuffer.MatricesWeightsExtraKind
  29791. * @param data defines the data source
  29792. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29793. * @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)
  29794. * @returns the current mesh
  29795. */
  29796. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29797. /**
  29798. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29799. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29800. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29801. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29802. * @returns the current mesh
  29803. */
  29804. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29805. /**
  29806. * Creates a un-shared specific occurence of the geometry for the mesh.
  29807. * @returns the current mesh
  29808. */
  29809. makeGeometryUnique(): Mesh;
  29810. /**
  29811. * Set the index buffer of this mesh
  29812. * @param indices defines the source data
  29813. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29814. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29815. * @returns the current mesh
  29816. */
  29817. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29818. /**
  29819. * Update the current index buffer
  29820. * @param indices defines the source data
  29821. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29822. * @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)
  29823. * @returns the current mesh
  29824. */
  29825. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29826. /**
  29827. * Invert the geometry to move from a right handed system to a left handed one.
  29828. * @returns the current mesh
  29829. */
  29830. toLeftHanded(): Mesh;
  29831. /** @hidden */
  29832. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29833. /** @hidden */
  29834. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29835. /**
  29836. * Registers for this mesh a javascript function called just before the rendering process
  29837. * @param func defines the function to call before rendering this mesh
  29838. * @returns the current mesh
  29839. */
  29840. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29841. /**
  29842. * Disposes a previously registered javascript function called before the rendering
  29843. * @param func defines the function to remove
  29844. * @returns the current mesh
  29845. */
  29846. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29847. /**
  29848. * Registers for this mesh a javascript function called just after the rendering is complete
  29849. * @param func defines the function to call after rendering this mesh
  29850. * @returns the current mesh
  29851. */
  29852. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29853. /**
  29854. * Disposes a previously registered javascript function called after the rendering.
  29855. * @param func defines the function to remove
  29856. * @returns the current mesh
  29857. */
  29858. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29859. /** @hidden */
  29860. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29861. /** @hidden */
  29862. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29863. /** @hidden */
  29864. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29865. /** @hidden */
  29866. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29867. /** @hidden */
  29868. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29869. /** @hidden */
  29870. _rebuild(): void;
  29871. /** @hidden */
  29872. _freeze(): void;
  29873. /** @hidden */
  29874. _unFreeze(): void;
  29875. /**
  29876. * 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
  29877. * @param subMesh defines the subMesh to render
  29878. * @param enableAlphaMode defines if alpha mode can be changed
  29879. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29880. * @returns the current mesh
  29881. */
  29882. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29883. private _onBeforeDraw;
  29884. /**
  29885. * Renormalize the mesh and patch it up if there are no weights
  29886. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29887. * However in the case of zero weights then we set just a single influence to 1.
  29888. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29889. */
  29890. cleanMatrixWeights(): void;
  29891. private normalizeSkinFourWeights;
  29892. private normalizeSkinWeightsAndExtra;
  29893. /**
  29894. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29895. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29896. * the user know there was an issue with importing the mesh
  29897. * @returns a validation object with skinned, valid and report string
  29898. */
  29899. validateSkinning(): {
  29900. skinned: boolean;
  29901. valid: boolean;
  29902. report: string;
  29903. };
  29904. /** @hidden */
  29905. _checkDelayState(): Mesh;
  29906. private _queueLoad;
  29907. /**
  29908. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29909. * A mesh is in the frustum if its bounding box intersects the frustum
  29910. * @param frustumPlanes defines the frustum to test
  29911. * @returns true if the mesh is in the frustum planes
  29912. */
  29913. isInFrustum(frustumPlanes: Plane[]): boolean;
  29914. /**
  29915. * Sets the mesh material by the material or multiMaterial `id` property
  29916. * @param id is a string identifying the material or the multiMaterial
  29917. * @returns the current mesh
  29918. */
  29919. setMaterialByID(id: string): Mesh;
  29920. /**
  29921. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29922. * @returns an array of IAnimatable
  29923. */
  29924. getAnimatables(): IAnimatable[];
  29925. /**
  29926. * Modifies the mesh geometry according to the passed transformation matrix.
  29927. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29928. * The mesh normals are modified using the same transformation.
  29929. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29930. * @param transform defines the transform matrix to use
  29931. * @see https://doc.babylonjs.com/resources/baking_transformations
  29932. * @returns the current mesh
  29933. */
  29934. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29935. /**
  29936. * Modifies the mesh geometry according to its own current World Matrix.
  29937. * The mesh World Matrix is then reset.
  29938. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29939. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29940. * @see https://doc.babylonjs.com/resources/baking_transformations
  29941. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29942. * @returns the current mesh
  29943. */
  29944. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29945. /** @hidden */
  29946. get _positions(): Nullable<Vector3[]>;
  29947. /** @hidden */
  29948. _resetPointsArrayCache(): Mesh;
  29949. /** @hidden */
  29950. _generatePointsArray(): boolean;
  29951. /**
  29952. * Returns a new Mesh object generated from the current mesh properties.
  29953. * This method must not get confused with createInstance()
  29954. * @param name is a string, the name given to the new mesh
  29955. * @param newParent can be any Node object (default `null`)
  29956. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29957. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29958. * @returns a new mesh
  29959. */
  29960. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29961. /**
  29962. * Releases resources associated with this mesh.
  29963. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29964. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29965. */
  29966. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29967. /** @hidden */
  29968. _disposeInstanceSpecificData(): void;
  29969. /** @hidden */
  29970. _disposeThinInstanceSpecificData(): void;
  29971. /**
  29972. * Modifies the mesh geometry according to a displacement map.
  29973. * 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.
  29974. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29975. * @param url is a string, the URL from the image file is to be downloaded.
  29976. * @param minHeight is the lower limit of the displacement.
  29977. * @param maxHeight is the upper limit of the displacement.
  29978. * @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.
  29979. * @param uvOffset is an optional vector2 used to offset UV.
  29980. * @param uvScale is an optional vector2 used to scale UV.
  29981. * @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.
  29982. * @returns the Mesh.
  29983. */
  29984. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29985. /**
  29986. * Modifies the mesh geometry according to a displacementMap buffer.
  29987. * 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.
  29988. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29989. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29990. * @param heightMapWidth is the width of the buffer image.
  29991. * @param heightMapHeight is the height of the buffer image.
  29992. * @param minHeight is the lower limit of the displacement.
  29993. * @param maxHeight is the upper limit of the displacement.
  29994. * @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.
  29995. * @param uvOffset is an optional vector2 used to offset UV.
  29996. * @param uvScale is an optional vector2 used to scale UV.
  29997. * @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.
  29998. * @returns the Mesh.
  29999. */
  30000. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  30001. /**
  30002. * Modify the mesh to get a flat shading rendering.
  30003. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  30004. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  30005. * @returns current mesh
  30006. */
  30007. convertToFlatShadedMesh(): Mesh;
  30008. /**
  30009. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  30010. * In other words, more vertices, no more indices and a single bigger VBO.
  30011. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  30012. * @returns current mesh
  30013. */
  30014. convertToUnIndexedMesh(): Mesh;
  30015. /**
  30016. * Inverses facet orientations.
  30017. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30018. * @param flipNormals will also inverts the normals
  30019. * @returns current mesh
  30020. */
  30021. flipFaces(flipNormals?: boolean): Mesh;
  30022. /**
  30023. * Increase the number of facets and hence vertices in a mesh
  30024. * Vertex normals are interpolated from existing vertex normals
  30025. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30026. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  30027. */
  30028. increaseVertices(numberPerEdge: number): void;
  30029. /**
  30030. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  30031. * This will undo any application of covertToFlatShadedMesh
  30032. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30033. */
  30034. forceSharedVertices(): void;
  30035. /** @hidden */
  30036. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  30037. /** @hidden */
  30038. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  30039. /**
  30040. * Creates a new InstancedMesh object from the mesh model.
  30041. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  30042. * @param name defines the name of the new instance
  30043. * @returns a new InstancedMesh
  30044. */
  30045. createInstance(name: string): InstancedMesh;
  30046. /**
  30047. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  30048. * After this call, all the mesh instances have the same submeshes than the current mesh.
  30049. * @returns the current mesh
  30050. */
  30051. synchronizeInstances(): Mesh;
  30052. /**
  30053. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  30054. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  30055. * This should be used together with the simplification to avoid disappearing triangles.
  30056. * @param successCallback an optional success callback to be called after the optimization finished.
  30057. * @returns the current mesh
  30058. */
  30059. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  30060. /**
  30061. * Serialize current mesh
  30062. * @param serializationObject defines the object which will receive the serialization data
  30063. */
  30064. serialize(serializationObject: any): void;
  30065. /** @hidden */
  30066. _syncGeometryWithMorphTargetManager(): void;
  30067. /** @hidden */
  30068. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  30069. /**
  30070. * Returns a new Mesh object parsed from the source provided.
  30071. * @param parsedMesh is the source
  30072. * @param scene defines the hosting scene
  30073. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  30074. * @returns a new Mesh
  30075. */
  30076. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  30077. /**
  30078. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  30079. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30080. * @param name defines the name of the mesh to create
  30081. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  30082. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  30083. * @param closePath creates a seam between the first and the last points of each path of the path array
  30084. * @param offset is taken in account only if the `pathArray` is containing a single path
  30085. * @param scene defines the hosting scene
  30086. * @param updatable defines if the mesh must be flagged as updatable
  30087. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30088. * @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)
  30089. * @returns a new Mesh
  30090. */
  30091. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30092. /**
  30093. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  30094. * @param name defines the name of the mesh to create
  30095. * @param radius sets the radius size (float) of the polygon (default 0.5)
  30096. * @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
  30097. * @param scene defines the hosting scene
  30098. * @param updatable defines if the mesh must be flagged as updatable
  30099. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30100. * @returns a new Mesh
  30101. */
  30102. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30103. /**
  30104. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  30105. * @param name defines the name of the mesh to create
  30106. * @param size sets the size (float) of each box side (default 1)
  30107. * @param scene defines the hosting scene
  30108. * @param updatable defines if the mesh must be flagged as updatable
  30109. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30110. * @returns a new Mesh
  30111. */
  30112. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30113. /**
  30114. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  30115. * @param name defines the name of the mesh to create
  30116. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30117. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30118. * @param scene defines the hosting scene
  30119. * @param updatable defines if the mesh must be flagged as updatable
  30120. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30121. * @returns a new Mesh
  30122. */
  30123. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30124. /**
  30125. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  30126. * @param name defines the name of the mesh to create
  30127. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30128. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30129. * @param scene defines the hosting scene
  30130. * @returns a new Mesh
  30131. */
  30132. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  30133. /**
  30134. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  30135. * @param name defines the name of the mesh to create
  30136. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  30137. * @param diameterTop set the top cap diameter (floats, default 1)
  30138. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  30139. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  30140. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  30141. * @param scene defines the hosting scene
  30142. * @param updatable defines if the mesh must be flagged as updatable
  30143. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30144. * @returns a new Mesh
  30145. */
  30146. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  30147. /**
  30148. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  30149. * @param name defines the name of the mesh to create
  30150. * @param diameter sets the diameter size (float) of the torus (default 1)
  30151. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  30152. * @param tessellation sets the number of torus sides (postive integer, default 16)
  30153. * @param scene defines the hosting scene
  30154. * @param updatable defines if the mesh must be flagged as updatable
  30155. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30156. * @returns a new Mesh
  30157. */
  30158. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30159. /**
  30160. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30161. * @param name defines the name of the mesh to create
  30162. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30163. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30164. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30165. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30166. * @param p the number of windings on X axis (positive integers, default 2)
  30167. * @param q the number of windings on Y axis (positive integers, default 3)
  30168. * @param scene defines the hosting scene
  30169. * @param updatable defines if the mesh must be flagged as updatable
  30170. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30171. * @returns a new Mesh
  30172. */
  30173. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30174. /**
  30175. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30176. * @param name defines the name of the mesh to create
  30177. * @param points is an array successive Vector3
  30178. * @param scene defines the hosting scene
  30179. * @param updatable defines if the mesh must be flagged as updatable
  30180. * @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).
  30181. * @returns a new Mesh
  30182. */
  30183. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30184. /**
  30185. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30186. * @param name defines the name of the mesh to create
  30187. * @param points is an array successive Vector3
  30188. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30189. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30190. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30191. * @param scene defines the hosting scene
  30192. * @param updatable defines if the mesh must be flagged as updatable
  30193. * @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)
  30194. * @returns a new Mesh
  30195. */
  30196. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30197. /**
  30198. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30199. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30200. * 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.
  30201. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30202. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30203. * Remember you can only change the shape positions, not their number when updating a polygon.
  30204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30205. * @param name defines the name of the mesh to create
  30206. * @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
  30207. * @param scene defines the hosting scene
  30208. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30209. * @param updatable defines if the mesh must be flagged as updatable
  30210. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30211. * @param earcutInjection can be used to inject your own earcut reference
  30212. * @returns a new Mesh
  30213. */
  30214. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30215. /**
  30216. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30218. * @param name defines the name of the mesh to create
  30219. * @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
  30220. * @param depth defines the height of extrusion
  30221. * @param scene defines the hosting scene
  30222. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30223. * @param updatable defines if the mesh must be flagged as updatable
  30224. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30225. * @param earcutInjection can be used to inject your own earcut reference
  30226. * @returns a new Mesh
  30227. */
  30228. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30229. /**
  30230. * Creates an extruded shape mesh.
  30231. * 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
  30232. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30233. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30234. * @param name defines the name of the mesh to create
  30235. * @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
  30236. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30237. * @param scale is the value to scale the shape
  30238. * @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
  30239. * @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
  30240. * @param scene defines the hosting scene
  30241. * @param updatable defines if the mesh must be flagged as updatable
  30242. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30243. * @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)
  30244. * @returns a new Mesh
  30245. */
  30246. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30247. /**
  30248. * Creates an custom extruded shape mesh.
  30249. * The custom extrusion is a parametric shape.
  30250. * It has no predefined shape. Its final shape will depend on the input parameters.
  30251. * Please consider using the same method from the MeshBuilder class instead
  30252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30253. * @param name defines the name of the mesh to create
  30254. * @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
  30255. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30256. * @param scaleFunction is a custom Javascript function called on each path point
  30257. * @param rotationFunction is a custom Javascript function called on each path point
  30258. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30259. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30260. * @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
  30261. * @param scene defines the hosting scene
  30262. * @param updatable defines if the mesh must be flagged as updatable
  30263. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30264. * @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)
  30265. * @returns a new Mesh
  30266. */
  30267. 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;
  30268. /**
  30269. * Creates lathe mesh.
  30270. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30271. * Please consider using the same method from the MeshBuilder class instead
  30272. * @param name defines the name of the mesh to create
  30273. * @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
  30274. * @param radius is the radius value of the lathe
  30275. * @param tessellation is the side number of the lathe.
  30276. * @param scene defines the hosting scene
  30277. * @param updatable defines if the mesh must be flagged as updatable
  30278. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30279. * @returns a new Mesh
  30280. */
  30281. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30282. /**
  30283. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30284. * @param name defines the name of the mesh to create
  30285. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30286. * @param scene defines the hosting scene
  30287. * @param updatable defines if the mesh must be flagged as updatable
  30288. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30289. * @returns a new Mesh
  30290. */
  30291. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30292. /**
  30293. * Creates a ground mesh.
  30294. * Please consider using the same method from the MeshBuilder class instead
  30295. * @param name defines the name of the mesh to create
  30296. * @param width set the width of the ground
  30297. * @param height set the height of the ground
  30298. * @param subdivisions sets the number of subdivisions per side
  30299. * @param scene defines the hosting scene
  30300. * @param updatable defines if the mesh must be flagged as updatable
  30301. * @returns a new Mesh
  30302. */
  30303. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30304. /**
  30305. * Creates a tiled ground mesh.
  30306. * Please consider using the same method from the MeshBuilder class instead
  30307. * @param name defines the name of the mesh to create
  30308. * @param xmin set the ground minimum X coordinate
  30309. * @param zmin set the ground minimum Y coordinate
  30310. * @param xmax set the ground maximum X coordinate
  30311. * @param zmax set the ground maximum Z coordinate
  30312. * @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
  30313. * @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
  30314. * @param scene defines the hosting scene
  30315. * @param updatable defines if the mesh must be flagged as updatable
  30316. * @returns a new Mesh
  30317. */
  30318. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30319. w: number;
  30320. h: number;
  30321. }, precision: {
  30322. w: number;
  30323. h: number;
  30324. }, scene: Scene, updatable?: boolean): Mesh;
  30325. /**
  30326. * Creates a ground mesh from a height map.
  30327. * Please consider using the same method from the MeshBuilder class instead
  30328. * @see https://doc.babylonjs.com/babylon101/height_map
  30329. * @param name defines the name of the mesh to create
  30330. * @param url sets the URL of the height map image resource
  30331. * @param width set the ground width size
  30332. * @param height set the ground height size
  30333. * @param subdivisions sets the number of subdivision per side
  30334. * @param minHeight is the minimum altitude on the ground
  30335. * @param maxHeight is the maximum altitude on the ground
  30336. * @param scene defines the hosting scene
  30337. * @param updatable defines if the mesh must be flagged as updatable
  30338. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30339. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30340. * @returns a new Mesh
  30341. */
  30342. 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;
  30343. /**
  30344. * Creates a tube mesh.
  30345. * The tube is a parametric shape.
  30346. * It has no predefined shape. Its final shape will depend on the input parameters.
  30347. * Please consider using the same method from the MeshBuilder class instead
  30348. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30349. * @param name defines the name of the mesh to create
  30350. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30351. * @param radius sets the tube radius size
  30352. * @param tessellation is the number of sides on the tubular surface
  30353. * @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
  30354. * @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
  30355. * @param scene defines the hosting scene
  30356. * @param updatable defines if the mesh must be flagged as updatable
  30357. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30358. * @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)
  30359. * @returns a new Mesh
  30360. */
  30361. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30362. (i: number, distance: number): number;
  30363. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30364. /**
  30365. * Creates a polyhedron mesh.
  30366. * Please consider using the same method from the MeshBuilder class instead.
  30367. * * 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
  30368. * * The parameter `size` (positive float, default 1) sets the polygon size
  30369. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30370. * * 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`
  30371. * * 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
  30372. * * 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)`)
  30373. * * 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
  30374. * * 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
  30375. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30376. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30378. * @param name defines the name of the mesh to create
  30379. * @param options defines the options used to create the mesh
  30380. * @param scene defines the hosting scene
  30381. * @returns a new Mesh
  30382. */
  30383. static CreatePolyhedron(name: string, options: {
  30384. type?: number;
  30385. size?: number;
  30386. sizeX?: number;
  30387. sizeY?: number;
  30388. sizeZ?: number;
  30389. custom?: any;
  30390. faceUV?: Vector4[];
  30391. faceColors?: Color4[];
  30392. updatable?: boolean;
  30393. sideOrientation?: number;
  30394. }, scene: Scene): Mesh;
  30395. /**
  30396. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30397. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30398. * * 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`)
  30399. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30400. * * 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
  30401. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30404. * @param name defines the name of the mesh
  30405. * @param options defines the options used to create the mesh
  30406. * @param scene defines the hosting scene
  30407. * @returns a new Mesh
  30408. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30409. */
  30410. static CreateIcoSphere(name: string, options: {
  30411. radius?: number;
  30412. flat?: boolean;
  30413. subdivisions?: number;
  30414. sideOrientation?: number;
  30415. updatable?: boolean;
  30416. }, scene: Scene): Mesh;
  30417. /**
  30418. * Creates a decal mesh.
  30419. * Please consider using the same method from the MeshBuilder class instead.
  30420. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30421. * @param name defines the name of the mesh
  30422. * @param sourceMesh defines the mesh receiving the decal
  30423. * @param position sets the position of the decal in world coordinates
  30424. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30425. * @param size sets the decal scaling
  30426. * @param angle sets the angle to rotate the decal
  30427. * @returns a new Mesh
  30428. */
  30429. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30430. /** Creates a Capsule Mesh
  30431. * @param name defines the name of the mesh.
  30432. * @param options the constructors options used to shape the mesh.
  30433. * @param scene defines the scene the mesh is scoped to.
  30434. * @returns the capsule mesh
  30435. * @see https://doc.babylonjs.com/how_to/capsule_shape
  30436. */
  30437. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  30438. /**
  30439. * Prepare internal position array for software CPU skinning
  30440. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30441. */
  30442. setPositionsForCPUSkinning(): Float32Array;
  30443. /**
  30444. * Prepare internal normal array for software CPU skinning
  30445. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30446. */
  30447. setNormalsForCPUSkinning(): Float32Array;
  30448. /**
  30449. * Updates the vertex buffer by applying transformation from the bones
  30450. * @param skeleton defines the skeleton to apply to current mesh
  30451. * @returns the current mesh
  30452. */
  30453. applySkeleton(skeleton: Skeleton): Mesh;
  30454. /**
  30455. * 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
  30456. * @param meshes defines the list of meshes to scan
  30457. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30458. */
  30459. static MinMax(meshes: AbstractMesh[]): {
  30460. min: Vector3;
  30461. max: Vector3;
  30462. };
  30463. /**
  30464. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30465. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30466. * @returns a vector3
  30467. */
  30468. static Center(meshesOrMinMaxVector: {
  30469. min: Vector3;
  30470. max: Vector3;
  30471. } | AbstractMesh[]): Vector3;
  30472. /**
  30473. * Merge the array of meshes into a single mesh for performance reasons.
  30474. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30475. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30476. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30477. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30478. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30479. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30480. * @returns a new mesh
  30481. */
  30482. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30483. /** @hidden */
  30484. addInstance(instance: InstancedMesh): void;
  30485. /** @hidden */
  30486. removeInstance(instance: InstancedMesh): void;
  30487. }
  30488. }
  30489. declare module "babylonjs/Cameras/camera" {
  30490. import { SmartArray } from "babylonjs/Misc/smartArray";
  30491. import { Observable } from "babylonjs/Misc/observable";
  30492. import { Nullable } from "babylonjs/types";
  30493. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30494. import { Scene } from "babylonjs/scene";
  30495. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30496. import { Node } from "babylonjs/node";
  30497. import { Mesh } from "babylonjs/Meshes/mesh";
  30498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30499. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30500. import { Viewport } from "babylonjs/Maths/math.viewport";
  30501. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30502. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30503. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30504. import { Ray } from "babylonjs/Culling/ray";
  30505. /**
  30506. * This is the base class of all the camera used in the application.
  30507. * @see https://doc.babylonjs.com/features/cameras
  30508. */
  30509. export class Camera extends Node {
  30510. /** @hidden */
  30511. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30512. /**
  30513. * This is the default projection mode used by the cameras.
  30514. * It helps recreating a feeling of perspective and better appreciate depth.
  30515. * This is the best way to simulate real life cameras.
  30516. */
  30517. static readonly PERSPECTIVE_CAMERA: number;
  30518. /**
  30519. * This helps creating camera with an orthographic mode.
  30520. * 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.
  30521. */
  30522. static readonly ORTHOGRAPHIC_CAMERA: number;
  30523. /**
  30524. * This is the default FOV mode for perspective cameras.
  30525. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30526. */
  30527. static readonly FOVMODE_VERTICAL_FIXED: number;
  30528. /**
  30529. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30530. */
  30531. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30532. /**
  30533. * This specifies ther is no need for a camera rig.
  30534. * Basically only one eye is rendered corresponding to the camera.
  30535. */
  30536. static readonly RIG_MODE_NONE: number;
  30537. /**
  30538. * Simulates a camera Rig with one blue eye and one red eye.
  30539. * This can be use with 3d blue and red glasses.
  30540. */
  30541. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30542. /**
  30543. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30544. */
  30545. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30546. /**
  30547. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30548. */
  30549. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30550. /**
  30551. * Defines that both eyes of the camera will be rendered over under each other.
  30552. */
  30553. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30554. /**
  30555. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30556. */
  30557. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30558. /**
  30559. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30560. */
  30561. static readonly RIG_MODE_VR: number;
  30562. /**
  30563. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30564. */
  30565. static readonly RIG_MODE_WEBVR: number;
  30566. /**
  30567. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30568. */
  30569. static readonly RIG_MODE_CUSTOM: number;
  30570. /**
  30571. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30572. */
  30573. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30574. /**
  30575. * Define the input manager associated with the camera.
  30576. */
  30577. inputs: CameraInputsManager<Camera>;
  30578. /** @hidden */
  30579. _position: Vector3;
  30580. /**
  30581. * Define the current local position of the camera in the scene
  30582. */
  30583. get position(): Vector3;
  30584. set position(newPosition: Vector3);
  30585. protected _upVector: Vector3;
  30586. /**
  30587. * The vector the camera should consider as up.
  30588. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30589. */
  30590. set upVector(vec: Vector3);
  30591. get upVector(): Vector3;
  30592. /**
  30593. * Define the current limit on the left side for an orthographic camera
  30594. * In scene unit
  30595. */
  30596. orthoLeft: Nullable<number>;
  30597. /**
  30598. * Define the current limit on the right side for an orthographic camera
  30599. * In scene unit
  30600. */
  30601. orthoRight: Nullable<number>;
  30602. /**
  30603. * Define the current limit on the bottom side for an orthographic camera
  30604. * In scene unit
  30605. */
  30606. orthoBottom: Nullable<number>;
  30607. /**
  30608. * Define the current limit on the top side for an orthographic camera
  30609. * In scene unit
  30610. */
  30611. orthoTop: Nullable<number>;
  30612. /**
  30613. * Field Of View is set in Radians. (default is 0.8)
  30614. */
  30615. fov: number;
  30616. /**
  30617. * Define the minimum distance the camera can see from.
  30618. * This is important to note that the depth buffer are not infinite and the closer it starts
  30619. * the more your scene might encounter depth fighting issue.
  30620. */
  30621. minZ: number;
  30622. /**
  30623. * Define the maximum distance the camera can see to.
  30624. * This is important to note that the depth buffer are not infinite and the further it end
  30625. * the more your scene might encounter depth fighting issue.
  30626. */
  30627. maxZ: number;
  30628. /**
  30629. * Define the default inertia of the camera.
  30630. * This helps giving a smooth feeling to the camera movement.
  30631. */
  30632. inertia: number;
  30633. /**
  30634. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30635. */
  30636. mode: number;
  30637. /**
  30638. * Define whether the camera is intermediate.
  30639. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30640. */
  30641. isIntermediate: boolean;
  30642. /**
  30643. * Define the viewport of the camera.
  30644. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30645. */
  30646. viewport: Viewport;
  30647. /**
  30648. * Restricts the camera to viewing objects with the same layerMask.
  30649. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30650. */
  30651. layerMask: number;
  30652. /**
  30653. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30654. */
  30655. fovMode: number;
  30656. /**
  30657. * Rig mode of the camera.
  30658. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30659. * This is normally controlled byt the camera themselves as internal use.
  30660. */
  30661. cameraRigMode: number;
  30662. /**
  30663. * Defines the distance between both "eyes" in case of a RIG
  30664. */
  30665. interaxialDistance: number;
  30666. /**
  30667. * Defines if stereoscopic rendering is done side by side or over under.
  30668. */
  30669. isStereoscopicSideBySide: boolean;
  30670. /**
  30671. * 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
  30672. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30673. * else in the scene. (Eg. security camera)
  30674. *
  30675. * 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)
  30676. */
  30677. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30678. /**
  30679. * When set, the camera will render to this render target instead of the default canvas
  30680. *
  30681. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30682. */
  30683. outputRenderTarget: Nullable<RenderTargetTexture>;
  30684. /**
  30685. * Observable triggered when the camera view matrix has changed.
  30686. */
  30687. onViewMatrixChangedObservable: Observable<Camera>;
  30688. /**
  30689. * Observable triggered when the camera Projection matrix has changed.
  30690. */
  30691. onProjectionMatrixChangedObservable: Observable<Camera>;
  30692. /**
  30693. * Observable triggered when the inputs have been processed.
  30694. */
  30695. onAfterCheckInputsObservable: Observable<Camera>;
  30696. /**
  30697. * Observable triggered when reset has been called and applied to the camera.
  30698. */
  30699. onRestoreStateObservable: Observable<Camera>;
  30700. /**
  30701. * Is this camera a part of a rig system?
  30702. */
  30703. isRigCamera: boolean;
  30704. /**
  30705. * If isRigCamera set to true this will be set with the parent camera.
  30706. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30707. */
  30708. rigParent?: Camera;
  30709. /** @hidden */
  30710. _cameraRigParams: any;
  30711. /** @hidden */
  30712. _rigCameras: Camera[];
  30713. /** @hidden */
  30714. _rigPostProcess: Nullable<PostProcess>;
  30715. protected _webvrViewMatrix: Matrix;
  30716. /** @hidden */
  30717. _skipRendering: boolean;
  30718. /** @hidden */
  30719. _projectionMatrix: Matrix;
  30720. /** @hidden */
  30721. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30722. /** @hidden */
  30723. _activeMeshes: SmartArray<AbstractMesh>;
  30724. protected _globalPosition: Vector3;
  30725. /** @hidden */
  30726. _computedViewMatrix: Matrix;
  30727. private _doNotComputeProjectionMatrix;
  30728. private _transformMatrix;
  30729. private _frustumPlanes;
  30730. private _refreshFrustumPlanes;
  30731. private _storedFov;
  30732. private _stateStored;
  30733. /**
  30734. * Instantiates a new camera object.
  30735. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30736. * @see https://doc.babylonjs.com/features/cameras
  30737. * @param name Defines the name of the camera in the scene
  30738. * @param position Defines the position of the camera
  30739. * @param scene Defines the scene the camera belongs too
  30740. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30741. */
  30742. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30743. /**
  30744. * Store current camera state (fov, position, etc..)
  30745. * @returns the camera
  30746. */
  30747. storeState(): Camera;
  30748. /**
  30749. * Restores the camera state values if it has been stored. You must call storeState() first
  30750. */
  30751. protected _restoreStateValues(): boolean;
  30752. /**
  30753. * Restored camera state. You must call storeState() first.
  30754. * @returns true if restored and false otherwise
  30755. */
  30756. restoreState(): boolean;
  30757. /**
  30758. * Gets the class name of the camera.
  30759. * @returns the class name
  30760. */
  30761. getClassName(): string;
  30762. /** @hidden */
  30763. readonly _isCamera: boolean;
  30764. /**
  30765. * Gets a string representation of the camera useful for debug purpose.
  30766. * @param fullDetails Defines that a more verboe level of logging is required
  30767. * @returns the string representation
  30768. */
  30769. toString(fullDetails?: boolean): string;
  30770. /**
  30771. * Gets the current world space position of the camera.
  30772. */
  30773. get globalPosition(): Vector3;
  30774. /**
  30775. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30776. * @returns the active meshe list
  30777. */
  30778. getActiveMeshes(): SmartArray<AbstractMesh>;
  30779. /**
  30780. * Check whether a mesh is part of the current active mesh list of the camera
  30781. * @param mesh Defines the mesh to check
  30782. * @returns true if active, false otherwise
  30783. */
  30784. isActiveMesh(mesh: Mesh): boolean;
  30785. /**
  30786. * Is this camera ready to be used/rendered
  30787. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30788. * @return true if the camera is ready
  30789. */
  30790. isReady(completeCheck?: boolean): boolean;
  30791. /** @hidden */
  30792. _initCache(): void;
  30793. /** @hidden */
  30794. _updateCache(ignoreParentClass?: boolean): void;
  30795. /** @hidden */
  30796. _isSynchronized(): boolean;
  30797. /** @hidden */
  30798. _isSynchronizedViewMatrix(): boolean;
  30799. /** @hidden */
  30800. _isSynchronizedProjectionMatrix(): boolean;
  30801. /**
  30802. * Attach the input controls to a specific dom element to get the input from.
  30803. * @param element Defines the element the controls should be listened from
  30804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30805. */
  30806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30807. /**
  30808. * Detach the current controls from the specified dom element.
  30809. * @param element Defines the element to stop listening the inputs from
  30810. */
  30811. detachControl(element: HTMLElement): void;
  30812. /**
  30813. * Update the camera state according to the different inputs gathered during the frame.
  30814. */
  30815. update(): void;
  30816. /** @hidden */
  30817. _checkInputs(): void;
  30818. /** @hidden */
  30819. get rigCameras(): Camera[];
  30820. /**
  30821. * Gets the post process used by the rig cameras
  30822. */
  30823. get rigPostProcess(): Nullable<PostProcess>;
  30824. /**
  30825. * Internal, gets the first post proces.
  30826. * @returns the first post process to be run on this camera.
  30827. */
  30828. _getFirstPostProcess(): Nullable<PostProcess>;
  30829. private _cascadePostProcessesToRigCams;
  30830. /**
  30831. * Attach a post process to the camera.
  30832. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30833. * @param postProcess The post process to attach to the camera
  30834. * @param insertAt The position of the post process in case several of them are in use in the scene
  30835. * @returns the position the post process has been inserted at
  30836. */
  30837. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30838. /**
  30839. * Detach a post process to the camera.
  30840. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30841. * @param postProcess The post process to detach from the camera
  30842. */
  30843. detachPostProcess(postProcess: PostProcess): void;
  30844. /**
  30845. * Gets the current world matrix of the camera
  30846. */
  30847. getWorldMatrix(): Matrix;
  30848. /** @hidden */
  30849. _getViewMatrix(): Matrix;
  30850. /**
  30851. * Gets the current view matrix of the camera.
  30852. * @param force forces the camera to recompute the matrix without looking at the cached state
  30853. * @returns the view matrix
  30854. */
  30855. getViewMatrix(force?: boolean): Matrix;
  30856. /**
  30857. * Freeze the projection matrix.
  30858. * It will prevent the cache check of the camera projection compute and can speed up perf
  30859. * if no parameter of the camera are meant to change
  30860. * @param projection Defines manually a projection if necessary
  30861. */
  30862. freezeProjectionMatrix(projection?: Matrix): void;
  30863. /**
  30864. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30865. */
  30866. unfreezeProjectionMatrix(): void;
  30867. /**
  30868. * Gets the current projection matrix of the camera.
  30869. * @param force forces the camera to recompute the matrix without looking at the cached state
  30870. * @returns the projection matrix
  30871. */
  30872. getProjectionMatrix(force?: boolean): Matrix;
  30873. /**
  30874. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30875. * @returns a Matrix
  30876. */
  30877. getTransformationMatrix(): Matrix;
  30878. private _updateFrustumPlanes;
  30879. /**
  30880. * Checks if a cullable object (mesh...) is in the camera frustum
  30881. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30882. * @param target The object to check
  30883. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30884. * @returns true if the object is in frustum otherwise false
  30885. */
  30886. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30887. /**
  30888. * Checks if a cullable object (mesh...) is in the camera frustum
  30889. * Unlike isInFrustum this cheks the full bounding box
  30890. * @param target The object to check
  30891. * @returns true if the object is in frustum otherwise false
  30892. */
  30893. isCompletelyInFrustum(target: ICullable): boolean;
  30894. /**
  30895. * Gets a ray in the forward direction from the camera.
  30896. * @param length Defines the length of the ray to create
  30897. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30898. * @param origin Defines the start point of the ray which defaults to the camera position
  30899. * @returns the forward ray
  30900. */
  30901. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30902. /**
  30903. * Gets a ray in the forward direction from the camera.
  30904. * @param refRay the ray to (re)use when setting the values
  30905. * @param length Defines the length of the ray to create
  30906. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30907. * @param origin Defines the start point of the ray which defaults to the camera position
  30908. * @returns the forward ray
  30909. */
  30910. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30911. /**
  30912. * Releases resources associated with this node.
  30913. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30914. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30915. */
  30916. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30917. /** @hidden */
  30918. _isLeftCamera: boolean;
  30919. /**
  30920. * Gets the left camera of a rig setup in case of Rigged Camera
  30921. */
  30922. get isLeftCamera(): boolean;
  30923. /** @hidden */
  30924. _isRightCamera: boolean;
  30925. /**
  30926. * Gets the right camera of a rig setup in case of Rigged Camera
  30927. */
  30928. get isRightCamera(): boolean;
  30929. /**
  30930. * Gets the left camera of a rig setup in case of Rigged Camera
  30931. */
  30932. get leftCamera(): Nullable<FreeCamera>;
  30933. /**
  30934. * Gets the right camera of a rig setup in case of Rigged Camera
  30935. */
  30936. get rightCamera(): Nullable<FreeCamera>;
  30937. /**
  30938. * Gets the left camera target of a rig setup in case of Rigged Camera
  30939. * @returns the target position
  30940. */
  30941. getLeftTarget(): Nullable<Vector3>;
  30942. /**
  30943. * Gets the right camera target of a rig setup in case of Rigged Camera
  30944. * @returns the target position
  30945. */
  30946. getRightTarget(): Nullable<Vector3>;
  30947. /**
  30948. * @hidden
  30949. */
  30950. setCameraRigMode(mode: number, rigParams: any): void;
  30951. /** @hidden */
  30952. static _setStereoscopicRigMode(camera: Camera): void;
  30953. /** @hidden */
  30954. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30955. /** @hidden */
  30956. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30957. /** @hidden */
  30958. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30959. /** @hidden */
  30960. _getVRProjectionMatrix(): Matrix;
  30961. protected _updateCameraRotationMatrix(): void;
  30962. protected _updateWebVRCameraRotationMatrix(): void;
  30963. /**
  30964. * This function MUST be overwritten by the different WebVR cameras available.
  30965. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30966. * @hidden
  30967. */
  30968. _getWebVRProjectionMatrix(): Matrix;
  30969. /**
  30970. * This function MUST be overwritten by the different WebVR cameras available.
  30971. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30972. * @hidden
  30973. */
  30974. _getWebVRViewMatrix(): Matrix;
  30975. /** @hidden */
  30976. setCameraRigParameter(name: string, value: any): void;
  30977. /**
  30978. * needs to be overridden by children so sub has required properties to be copied
  30979. * @hidden
  30980. */
  30981. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30982. /**
  30983. * May need to be overridden by children
  30984. * @hidden
  30985. */
  30986. _updateRigCameras(): void;
  30987. /** @hidden */
  30988. _setupInputs(): void;
  30989. /**
  30990. * Serialiaze the camera setup to a json represention
  30991. * @returns the JSON representation
  30992. */
  30993. serialize(): any;
  30994. /**
  30995. * Clones the current camera.
  30996. * @param name The cloned camera name
  30997. * @returns the cloned camera
  30998. */
  30999. clone(name: string): Camera;
  31000. /**
  31001. * Gets the direction of the camera relative to a given local axis.
  31002. * @param localAxis Defines the reference axis to provide a relative direction.
  31003. * @return the direction
  31004. */
  31005. getDirection(localAxis: Vector3): Vector3;
  31006. /**
  31007. * Returns the current camera absolute rotation
  31008. */
  31009. get absoluteRotation(): Quaternion;
  31010. /**
  31011. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31012. * @param localAxis Defines the reference axis to provide a relative direction.
  31013. * @param result Defines the vector to store the result in
  31014. */
  31015. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31016. /**
  31017. * Gets a camera constructor for a given camera type
  31018. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31019. * @param name The name of the camera the result will be able to instantiate
  31020. * @param scene The scene the result will construct the camera in
  31021. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31022. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31023. * @returns a factory method to construc the camera
  31024. */
  31025. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31026. /**
  31027. * Compute the world matrix of the camera.
  31028. * @returns the camera world matrix
  31029. */
  31030. computeWorldMatrix(): Matrix;
  31031. /**
  31032. * Parse a JSON and creates the camera from the parsed information
  31033. * @param parsedCamera The JSON to parse
  31034. * @param scene The scene to instantiate the camera in
  31035. * @returns the newly constructed camera
  31036. */
  31037. static Parse(parsedCamera: any, scene: Scene): Camera;
  31038. }
  31039. }
  31040. declare module "babylonjs/Meshes/Builders/discBuilder" {
  31041. import { Nullable } from "babylonjs/types";
  31042. import { Scene } from "babylonjs/scene";
  31043. import { Vector4 } from "babylonjs/Maths/math.vector";
  31044. import { Mesh } from "babylonjs/Meshes/mesh";
  31045. /**
  31046. * Class containing static functions to help procedurally build meshes
  31047. */
  31048. export class DiscBuilder {
  31049. /**
  31050. * Creates a plane polygonal mesh. By default, this is a disc
  31051. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  31052. * * 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
  31053. * * 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
  31054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  31055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  31056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  31057. * @param name defines the name of the mesh
  31058. * @param options defines the options used to create the mesh
  31059. * @param scene defines the hosting scene
  31060. * @returns the plane polygonal mesh
  31061. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  31062. */
  31063. static CreateDisc(name: string, options: {
  31064. radius?: number;
  31065. tessellation?: number;
  31066. arc?: number;
  31067. updatable?: boolean;
  31068. sideOrientation?: number;
  31069. frontUVs?: Vector4;
  31070. backUVs?: Vector4;
  31071. }, scene?: Nullable<Scene>): Mesh;
  31072. }
  31073. }
  31074. declare module "babylonjs/Materials/fresnelParameters" {
  31075. import { DeepImmutable } from "babylonjs/types";
  31076. import { Color3 } from "babylonjs/Maths/math.color";
  31077. /**
  31078. * Options to be used when creating a FresnelParameters.
  31079. */
  31080. export type IFresnelParametersCreationOptions = {
  31081. /**
  31082. * Define the color used on edges (grazing angle)
  31083. */
  31084. leftColor?: Color3;
  31085. /**
  31086. * Define the color used on center
  31087. */
  31088. rightColor?: Color3;
  31089. /**
  31090. * Define bias applied to computed fresnel term
  31091. */
  31092. bias?: number;
  31093. /**
  31094. * Defined the power exponent applied to fresnel term
  31095. */
  31096. power?: number;
  31097. /**
  31098. * Define if the fresnel effect is enable or not.
  31099. */
  31100. isEnabled?: boolean;
  31101. };
  31102. /**
  31103. * Serialized format for FresnelParameters.
  31104. */
  31105. export type IFresnelParametersSerialized = {
  31106. /**
  31107. * Define the color used on edges (grazing angle) [as an array]
  31108. */
  31109. leftColor: number[];
  31110. /**
  31111. * Define the color used on center [as an array]
  31112. */
  31113. rightColor: number[];
  31114. /**
  31115. * Define bias applied to computed fresnel term
  31116. */
  31117. bias: number;
  31118. /**
  31119. * Defined the power exponent applied to fresnel term
  31120. */
  31121. power?: number;
  31122. /**
  31123. * Define if the fresnel effect is enable or not.
  31124. */
  31125. isEnabled: boolean;
  31126. };
  31127. /**
  31128. * This represents all the required information to add a fresnel effect on a material:
  31129. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31130. */
  31131. export class FresnelParameters {
  31132. private _isEnabled;
  31133. /**
  31134. * Define if the fresnel effect is enable or not.
  31135. */
  31136. get isEnabled(): boolean;
  31137. set isEnabled(value: boolean);
  31138. /**
  31139. * Define the color used on edges (grazing angle)
  31140. */
  31141. leftColor: Color3;
  31142. /**
  31143. * Define the color used on center
  31144. */
  31145. rightColor: Color3;
  31146. /**
  31147. * Define bias applied to computed fresnel term
  31148. */
  31149. bias: number;
  31150. /**
  31151. * Defined the power exponent applied to fresnel term
  31152. */
  31153. power: number;
  31154. /**
  31155. * Creates a new FresnelParameters object.
  31156. *
  31157. * @param options provide your own settings to optionally to override defaults
  31158. */
  31159. constructor(options?: IFresnelParametersCreationOptions);
  31160. /**
  31161. * Clones the current fresnel and its valuues
  31162. * @returns a clone fresnel configuration
  31163. */
  31164. clone(): FresnelParameters;
  31165. /**
  31166. * Determines equality between FresnelParameters objects
  31167. * @param otherFresnelParameters defines the second operand
  31168. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31169. */
  31170. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31171. /**
  31172. * Serializes the current fresnel parameters to a JSON representation.
  31173. * @return the JSON serialization
  31174. */
  31175. serialize(): IFresnelParametersSerialized;
  31176. /**
  31177. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31178. * @param parsedFresnelParameters Define the JSON representation
  31179. * @returns the parsed parameters
  31180. */
  31181. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31182. }
  31183. }
  31184. declare module "babylonjs/Materials/materialFlags" {
  31185. /**
  31186. * This groups all the flags used to control the materials channel.
  31187. */
  31188. export class MaterialFlags {
  31189. private static _DiffuseTextureEnabled;
  31190. /**
  31191. * Are diffuse textures enabled in the application.
  31192. */
  31193. static get DiffuseTextureEnabled(): boolean;
  31194. static set DiffuseTextureEnabled(value: boolean);
  31195. private static _DetailTextureEnabled;
  31196. /**
  31197. * Are detail textures enabled in the application.
  31198. */
  31199. static get DetailTextureEnabled(): boolean;
  31200. static set DetailTextureEnabled(value: boolean);
  31201. private static _AmbientTextureEnabled;
  31202. /**
  31203. * Are ambient textures enabled in the application.
  31204. */
  31205. static get AmbientTextureEnabled(): boolean;
  31206. static set AmbientTextureEnabled(value: boolean);
  31207. private static _OpacityTextureEnabled;
  31208. /**
  31209. * Are opacity textures enabled in the application.
  31210. */
  31211. static get OpacityTextureEnabled(): boolean;
  31212. static set OpacityTextureEnabled(value: boolean);
  31213. private static _ReflectionTextureEnabled;
  31214. /**
  31215. * Are reflection textures enabled in the application.
  31216. */
  31217. static get ReflectionTextureEnabled(): boolean;
  31218. static set ReflectionTextureEnabled(value: boolean);
  31219. private static _EmissiveTextureEnabled;
  31220. /**
  31221. * Are emissive textures enabled in the application.
  31222. */
  31223. static get EmissiveTextureEnabled(): boolean;
  31224. static set EmissiveTextureEnabled(value: boolean);
  31225. private static _SpecularTextureEnabled;
  31226. /**
  31227. * Are specular textures enabled in the application.
  31228. */
  31229. static get SpecularTextureEnabled(): boolean;
  31230. static set SpecularTextureEnabled(value: boolean);
  31231. private static _BumpTextureEnabled;
  31232. /**
  31233. * Are bump textures enabled in the application.
  31234. */
  31235. static get BumpTextureEnabled(): boolean;
  31236. static set BumpTextureEnabled(value: boolean);
  31237. private static _LightmapTextureEnabled;
  31238. /**
  31239. * Are lightmap textures enabled in the application.
  31240. */
  31241. static get LightmapTextureEnabled(): boolean;
  31242. static set LightmapTextureEnabled(value: boolean);
  31243. private static _RefractionTextureEnabled;
  31244. /**
  31245. * Are refraction textures enabled in the application.
  31246. */
  31247. static get RefractionTextureEnabled(): boolean;
  31248. static set RefractionTextureEnabled(value: boolean);
  31249. private static _ColorGradingTextureEnabled;
  31250. /**
  31251. * Are color grading textures enabled in the application.
  31252. */
  31253. static get ColorGradingTextureEnabled(): boolean;
  31254. static set ColorGradingTextureEnabled(value: boolean);
  31255. private static _FresnelEnabled;
  31256. /**
  31257. * Are fresnels enabled in the application.
  31258. */
  31259. static get FresnelEnabled(): boolean;
  31260. static set FresnelEnabled(value: boolean);
  31261. private static _ClearCoatTextureEnabled;
  31262. /**
  31263. * Are clear coat textures enabled in the application.
  31264. */
  31265. static get ClearCoatTextureEnabled(): boolean;
  31266. static set ClearCoatTextureEnabled(value: boolean);
  31267. private static _ClearCoatBumpTextureEnabled;
  31268. /**
  31269. * Are clear coat bump textures enabled in the application.
  31270. */
  31271. static get ClearCoatBumpTextureEnabled(): boolean;
  31272. static set ClearCoatBumpTextureEnabled(value: boolean);
  31273. private static _ClearCoatTintTextureEnabled;
  31274. /**
  31275. * Are clear coat tint textures enabled in the application.
  31276. */
  31277. static get ClearCoatTintTextureEnabled(): boolean;
  31278. static set ClearCoatTintTextureEnabled(value: boolean);
  31279. private static _SheenTextureEnabled;
  31280. /**
  31281. * Are sheen textures enabled in the application.
  31282. */
  31283. static get SheenTextureEnabled(): boolean;
  31284. static set SheenTextureEnabled(value: boolean);
  31285. private static _AnisotropicTextureEnabled;
  31286. /**
  31287. * Are anisotropic textures enabled in the application.
  31288. */
  31289. static get AnisotropicTextureEnabled(): boolean;
  31290. static set AnisotropicTextureEnabled(value: boolean);
  31291. private static _ThicknessTextureEnabled;
  31292. /**
  31293. * Are thickness textures enabled in the application.
  31294. */
  31295. static get ThicknessTextureEnabled(): boolean;
  31296. static set ThicknessTextureEnabled(value: boolean);
  31297. }
  31298. }
  31299. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31300. /** @hidden */
  31301. export var defaultFragmentDeclaration: {
  31302. name: string;
  31303. shader: string;
  31304. };
  31305. }
  31306. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31307. /** @hidden */
  31308. export var defaultUboDeclaration: {
  31309. name: string;
  31310. shader: string;
  31311. };
  31312. }
  31313. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31314. /** @hidden */
  31315. export var prePassDeclaration: {
  31316. name: string;
  31317. shader: string;
  31318. };
  31319. }
  31320. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31321. /** @hidden */
  31322. export var lightFragmentDeclaration: {
  31323. name: string;
  31324. shader: string;
  31325. };
  31326. }
  31327. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31328. /** @hidden */
  31329. export var lightUboDeclaration: {
  31330. name: string;
  31331. shader: string;
  31332. };
  31333. }
  31334. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31335. /** @hidden */
  31336. export var lightsFragmentFunctions: {
  31337. name: string;
  31338. shader: string;
  31339. };
  31340. }
  31341. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31342. /** @hidden */
  31343. export var shadowsFragmentFunctions: {
  31344. name: string;
  31345. shader: string;
  31346. };
  31347. }
  31348. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31349. /** @hidden */
  31350. export var fresnelFunction: {
  31351. name: string;
  31352. shader: string;
  31353. };
  31354. }
  31355. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31356. /** @hidden */
  31357. export var bumpFragmentMainFunctions: {
  31358. name: string;
  31359. shader: string;
  31360. };
  31361. }
  31362. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31363. /** @hidden */
  31364. export var bumpFragmentFunctions: {
  31365. name: string;
  31366. shader: string;
  31367. };
  31368. }
  31369. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31370. /** @hidden */
  31371. export var logDepthDeclaration: {
  31372. name: string;
  31373. shader: string;
  31374. };
  31375. }
  31376. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31377. /** @hidden */
  31378. export var bumpFragment: {
  31379. name: string;
  31380. shader: string;
  31381. };
  31382. }
  31383. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31384. /** @hidden */
  31385. export var depthPrePass: {
  31386. name: string;
  31387. shader: string;
  31388. };
  31389. }
  31390. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31391. /** @hidden */
  31392. export var lightFragment: {
  31393. name: string;
  31394. shader: string;
  31395. };
  31396. }
  31397. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31398. /** @hidden */
  31399. export var logDepthFragment: {
  31400. name: string;
  31401. shader: string;
  31402. };
  31403. }
  31404. declare module "babylonjs/Shaders/default.fragment" {
  31405. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31406. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31407. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31408. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31409. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31410. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31411. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31412. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31413. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31414. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31415. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31416. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31417. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31418. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31419. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31420. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31421. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31422. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31423. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31424. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31425. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31426. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31427. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31428. /** @hidden */
  31429. export var defaultPixelShader: {
  31430. name: string;
  31431. shader: string;
  31432. };
  31433. }
  31434. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31435. /** @hidden */
  31436. export var defaultVertexDeclaration: {
  31437. name: string;
  31438. shader: string;
  31439. };
  31440. }
  31441. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  31442. /** @hidden */
  31443. export var prePassVertexDeclaration: {
  31444. name: string;
  31445. shader: string;
  31446. };
  31447. }
  31448. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31449. /** @hidden */
  31450. export var bumpVertexDeclaration: {
  31451. name: string;
  31452. shader: string;
  31453. };
  31454. }
  31455. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  31456. /** @hidden */
  31457. export var prePassVertex: {
  31458. name: string;
  31459. shader: string;
  31460. };
  31461. }
  31462. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31463. /** @hidden */
  31464. export var bumpVertex: {
  31465. name: string;
  31466. shader: string;
  31467. };
  31468. }
  31469. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31470. /** @hidden */
  31471. export var fogVertex: {
  31472. name: string;
  31473. shader: string;
  31474. };
  31475. }
  31476. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31477. /** @hidden */
  31478. export var shadowsVertex: {
  31479. name: string;
  31480. shader: string;
  31481. };
  31482. }
  31483. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31484. /** @hidden */
  31485. export var pointCloudVertex: {
  31486. name: string;
  31487. shader: string;
  31488. };
  31489. }
  31490. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31491. /** @hidden */
  31492. export var logDepthVertex: {
  31493. name: string;
  31494. shader: string;
  31495. };
  31496. }
  31497. declare module "babylonjs/Shaders/default.vertex" {
  31498. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31499. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31500. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31501. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31502. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31503. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  31504. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31505. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31506. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31507. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31508. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31509. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31510. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31511. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31512. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31513. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31514. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31515. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  31516. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31517. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31518. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31519. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31520. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31521. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31522. /** @hidden */
  31523. export var defaultVertexShader: {
  31524. name: string;
  31525. shader: string;
  31526. };
  31527. }
  31528. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31529. import { Nullable } from "babylonjs/types";
  31530. import { Scene } from "babylonjs/scene";
  31531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31532. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31533. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31534. /**
  31535. * @hidden
  31536. */
  31537. export interface IMaterialDetailMapDefines {
  31538. DETAIL: boolean;
  31539. DETAILDIRECTUV: number;
  31540. DETAIL_NORMALBLENDMETHOD: number;
  31541. /** @hidden */
  31542. _areTexturesDirty: boolean;
  31543. }
  31544. /**
  31545. * Define the code related to the detail map parameters of a material
  31546. *
  31547. * Inspired from:
  31548. * 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
  31549. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31550. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31551. */
  31552. export class DetailMapConfiguration {
  31553. private _texture;
  31554. /**
  31555. * The detail texture of the material.
  31556. */
  31557. texture: Nullable<BaseTexture>;
  31558. /**
  31559. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31560. * Bigger values mean stronger blending
  31561. */
  31562. diffuseBlendLevel: number;
  31563. /**
  31564. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31565. * Bigger values mean stronger blending. Only used with PBR materials
  31566. */
  31567. roughnessBlendLevel: number;
  31568. /**
  31569. * Defines how strong the bump effect from the detail map is
  31570. * Bigger values mean stronger effect
  31571. */
  31572. bumpLevel: number;
  31573. private _normalBlendMethod;
  31574. /**
  31575. * The method used to blend the bump and detail normals together
  31576. */
  31577. normalBlendMethod: number;
  31578. private _isEnabled;
  31579. /**
  31580. * Enable or disable the detail map on this material
  31581. */
  31582. isEnabled: boolean;
  31583. /** @hidden */
  31584. private _internalMarkAllSubMeshesAsTexturesDirty;
  31585. /** @hidden */
  31586. _markAllSubMeshesAsTexturesDirty(): void;
  31587. /**
  31588. * Instantiate a new detail map
  31589. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31590. */
  31591. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31592. /**
  31593. * Gets whether the submesh is ready to be used or not.
  31594. * @param defines the list of "defines" to update.
  31595. * @param scene defines the scene the material belongs to.
  31596. * @returns - boolean indicating that the submesh is ready or not.
  31597. */
  31598. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31599. /**
  31600. * Update the defines for detail map usage
  31601. * @param defines the list of "defines" to update.
  31602. * @param scene defines the scene the material belongs to.
  31603. */
  31604. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31605. /**
  31606. * Binds the material data.
  31607. * @param uniformBuffer defines the Uniform buffer to fill in.
  31608. * @param scene defines the scene the material belongs to.
  31609. * @param isFrozen defines whether the material is frozen or not.
  31610. */
  31611. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31612. /**
  31613. * Checks to see if a texture is used in the material.
  31614. * @param texture - Base texture to use.
  31615. * @returns - Boolean specifying if a texture is used in the material.
  31616. */
  31617. hasTexture(texture: BaseTexture): boolean;
  31618. /**
  31619. * Returns an array of the actively used textures.
  31620. * @param activeTextures Array of BaseTextures
  31621. */
  31622. getActiveTextures(activeTextures: BaseTexture[]): void;
  31623. /**
  31624. * Returns the animatable textures.
  31625. * @param animatables Array of animatable textures.
  31626. */
  31627. getAnimatables(animatables: IAnimatable[]): void;
  31628. /**
  31629. * Disposes the resources of the material.
  31630. * @param forceDisposeTextures - Forces the disposal of all textures.
  31631. */
  31632. dispose(forceDisposeTextures?: boolean): void;
  31633. /**
  31634. * Get the current class name useful for serialization or dynamic coding.
  31635. * @returns "DetailMap"
  31636. */
  31637. getClassName(): string;
  31638. /**
  31639. * Add the required uniforms to the current list.
  31640. * @param uniforms defines the current uniform list.
  31641. */
  31642. static AddUniforms(uniforms: string[]): void;
  31643. /**
  31644. * Add the required samplers to the current list.
  31645. * @param samplers defines the current sampler list.
  31646. */
  31647. static AddSamplers(samplers: string[]): void;
  31648. /**
  31649. * Add the required uniforms to the current buffer.
  31650. * @param uniformBuffer defines the current uniform buffer.
  31651. */
  31652. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31653. /**
  31654. * Makes a duplicate of the current instance into another one.
  31655. * @param detailMap define the instance where to copy the info
  31656. */
  31657. copyTo(detailMap: DetailMapConfiguration): void;
  31658. /**
  31659. * Serializes this detail map instance
  31660. * @returns - An object with the serialized instance.
  31661. */
  31662. serialize(): any;
  31663. /**
  31664. * Parses a detail map setting from a serialized object.
  31665. * @param source - Serialized object.
  31666. * @param scene Defines the scene we are parsing for
  31667. * @param rootUrl Defines the rootUrl to load from
  31668. */
  31669. parse(source: any, scene: Scene, rootUrl: string): void;
  31670. }
  31671. }
  31672. declare module "babylonjs/Materials/standardMaterial" {
  31673. import { SmartArray } from "babylonjs/Misc/smartArray";
  31674. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31675. import { Nullable } from "babylonjs/types";
  31676. import { Scene } from "babylonjs/scene";
  31677. import { Matrix } from "babylonjs/Maths/math.vector";
  31678. import { Color3 } from "babylonjs/Maths/math.color";
  31679. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31681. import { Mesh } from "babylonjs/Meshes/mesh";
  31682. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  31683. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31684. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31685. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31686. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31687. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31688. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31689. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31690. import "babylonjs/Shaders/default.fragment";
  31691. import "babylonjs/Shaders/default.vertex";
  31692. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31693. /** @hidden */
  31694. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31695. MAINUV1: boolean;
  31696. MAINUV2: boolean;
  31697. DIFFUSE: boolean;
  31698. DIFFUSEDIRECTUV: number;
  31699. DETAIL: boolean;
  31700. DETAILDIRECTUV: number;
  31701. DETAIL_NORMALBLENDMETHOD: number;
  31702. AMBIENT: boolean;
  31703. AMBIENTDIRECTUV: number;
  31704. OPACITY: boolean;
  31705. OPACITYDIRECTUV: number;
  31706. OPACITYRGB: boolean;
  31707. REFLECTION: boolean;
  31708. EMISSIVE: boolean;
  31709. EMISSIVEDIRECTUV: number;
  31710. SPECULAR: boolean;
  31711. SPECULARDIRECTUV: number;
  31712. BUMP: boolean;
  31713. BUMPDIRECTUV: number;
  31714. PARALLAX: boolean;
  31715. PARALLAXOCCLUSION: boolean;
  31716. SPECULAROVERALPHA: boolean;
  31717. CLIPPLANE: boolean;
  31718. CLIPPLANE2: boolean;
  31719. CLIPPLANE3: boolean;
  31720. CLIPPLANE4: boolean;
  31721. CLIPPLANE5: boolean;
  31722. CLIPPLANE6: boolean;
  31723. ALPHATEST: boolean;
  31724. DEPTHPREPASS: boolean;
  31725. ALPHAFROMDIFFUSE: boolean;
  31726. POINTSIZE: boolean;
  31727. FOG: boolean;
  31728. SPECULARTERM: boolean;
  31729. DIFFUSEFRESNEL: boolean;
  31730. OPACITYFRESNEL: boolean;
  31731. REFLECTIONFRESNEL: boolean;
  31732. REFRACTIONFRESNEL: boolean;
  31733. EMISSIVEFRESNEL: boolean;
  31734. FRESNEL: boolean;
  31735. NORMAL: boolean;
  31736. UV1: boolean;
  31737. UV2: boolean;
  31738. VERTEXCOLOR: boolean;
  31739. VERTEXALPHA: boolean;
  31740. NUM_BONE_INFLUENCERS: number;
  31741. BonesPerMesh: number;
  31742. BONETEXTURE: boolean;
  31743. BONES_VELOCITY_ENABLED: boolean;
  31744. INSTANCES: boolean;
  31745. THIN_INSTANCES: boolean;
  31746. GLOSSINESS: boolean;
  31747. ROUGHNESS: boolean;
  31748. EMISSIVEASILLUMINATION: boolean;
  31749. LINKEMISSIVEWITHDIFFUSE: boolean;
  31750. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31751. LIGHTMAP: boolean;
  31752. LIGHTMAPDIRECTUV: number;
  31753. OBJECTSPACE_NORMALMAP: boolean;
  31754. USELIGHTMAPASSHADOWMAP: boolean;
  31755. REFLECTIONMAP_3D: boolean;
  31756. REFLECTIONMAP_SPHERICAL: boolean;
  31757. REFLECTIONMAP_PLANAR: boolean;
  31758. REFLECTIONMAP_CUBIC: boolean;
  31759. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31760. REFLECTIONMAP_PROJECTION: boolean;
  31761. REFLECTIONMAP_SKYBOX: boolean;
  31762. REFLECTIONMAP_EXPLICIT: boolean;
  31763. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31764. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31765. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31766. INVERTCUBICMAP: boolean;
  31767. LOGARITHMICDEPTH: boolean;
  31768. REFRACTION: boolean;
  31769. REFRACTIONMAP_3D: boolean;
  31770. REFLECTIONOVERALPHA: boolean;
  31771. TWOSIDEDLIGHTING: boolean;
  31772. SHADOWFLOAT: boolean;
  31773. MORPHTARGETS: boolean;
  31774. MORPHTARGETS_NORMAL: boolean;
  31775. MORPHTARGETS_TANGENT: boolean;
  31776. MORPHTARGETS_UV: boolean;
  31777. NUM_MORPH_INFLUENCERS: number;
  31778. NONUNIFORMSCALING: boolean;
  31779. PREMULTIPLYALPHA: boolean;
  31780. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31781. ALPHABLEND: boolean;
  31782. PREPASS: boolean;
  31783. PREPASS_IRRADIANCE: boolean;
  31784. PREPASS_IRRADIANCE_INDEX: number;
  31785. PREPASS_ALBEDO: boolean;
  31786. PREPASS_ALBEDO_INDEX: number;
  31787. PREPASS_DEPTHNORMAL: boolean;
  31788. PREPASS_DEPTHNORMAL_INDEX: number;
  31789. PREPASS_POSITION: boolean;
  31790. PREPASS_POSITION_INDEX: number;
  31791. PREPASS_VELOCITY: boolean;
  31792. PREPASS_VELOCITY_INDEX: number;
  31793. PREPASS_REFLECTIVITY: boolean;
  31794. PREPASS_REFLECTIVITY_INDEX: number;
  31795. SCENE_MRT_COUNT: number;
  31796. RGBDLIGHTMAP: boolean;
  31797. RGBDREFLECTION: boolean;
  31798. RGBDREFRACTION: boolean;
  31799. IMAGEPROCESSING: boolean;
  31800. VIGNETTE: boolean;
  31801. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31802. VIGNETTEBLENDMODEOPAQUE: boolean;
  31803. TONEMAPPING: boolean;
  31804. TONEMAPPING_ACES: boolean;
  31805. CONTRAST: boolean;
  31806. COLORCURVES: boolean;
  31807. COLORGRADING: boolean;
  31808. COLORGRADING3D: boolean;
  31809. SAMPLER3DGREENDEPTH: boolean;
  31810. SAMPLER3DBGRMAP: boolean;
  31811. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31812. MULTIVIEW: boolean;
  31813. /**
  31814. * If the reflection texture on this material is in linear color space
  31815. * @hidden
  31816. */
  31817. IS_REFLECTION_LINEAR: boolean;
  31818. /**
  31819. * If the refraction texture on this material is in linear color space
  31820. * @hidden
  31821. */
  31822. IS_REFRACTION_LINEAR: boolean;
  31823. EXPOSURE: boolean;
  31824. constructor();
  31825. setReflectionMode(modeToEnable: string): void;
  31826. }
  31827. /**
  31828. * This is the default material used in Babylon. It is the best trade off between quality
  31829. * and performances.
  31830. * @see https://doc.babylonjs.com/babylon101/materials
  31831. */
  31832. export class StandardMaterial extends PushMaterial {
  31833. private _diffuseTexture;
  31834. /**
  31835. * The basic texture of the material as viewed under a light.
  31836. */
  31837. diffuseTexture: Nullable<BaseTexture>;
  31838. private _ambientTexture;
  31839. /**
  31840. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31841. */
  31842. ambientTexture: Nullable<BaseTexture>;
  31843. private _opacityTexture;
  31844. /**
  31845. * Define the transparency of the material from a texture.
  31846. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31847. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31848. */
  31849. opacityTexture: Nullable<BaseTexture>;
  31850. private _reflectionTexture;
  31851. /**
  31852. * Define the texture used to display the reflection.
  31853. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31854. */
  31855. reflectionTexture: Nullable<BaseTexture>;
  31856. private _emissiveTexture;
  31857. /**
  31858. * Define texture of the material as if self lit.
  31859. * This will be mixed in the final result even in the absence of light.
  31860. */
  31861. emissiveTexture: Nullable<BaseTexture>;
  31862. private _specularTexture;
  31863. /**
  31864. * Define how the color and intensity of the highlight given by the light in the material.
  31865. */
  31866. specularTexture: Nullable<BaseTexture>;
  31867. private _bumpTexture;
  31868. /**
  31869. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31870. * 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.
  31871. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31872. */
  31873. bumpTexture: Nullable<BaseTexture>;
  31874. private _lightmapTexture;
  31875. /**
  31876. * Complex lighting can be computationally expensive to compute at runtime.
  31877. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31878. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31879. */
  31880. lightmapTexture: Nullable<BaseTexture>;
  31881. private _refractionTexture;
  31882. /**
  31883. * Define the texture used to display the refraction.
  31884. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31885. */
  31886. refractionTexture: Nullable<BaseTexture>;
  31887. /**
  31888. * The color of the material lit by the environmental background lighting.
  31889. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31890. */
  31891. ambientColor: Color3;
  31892. /**
  31893. * The basic color of the material as viewed under a light.
  31894. */
  31895. diffuseColor: Color3;
  31896. /**
  31897. * Define how the color and intensity of the highlight given by the light in the material.
  31898. */
  31899. specularColor: Color3;
  31900. /**
  31901. * Define the color of the material as if self lit.
  31902. * This will be mixed in the final result even in the absence of light.
  31903. */
  31904. emissiveColor: Color3;
  31905. /**
  31906. * Defines how sharp are the highlights in the material.
  31907. * The bigger the value the sharper giving a more glossy feeling to the result.
  31908. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31909. */
  31910. specularPower: number;
  31911. private _useAlphaFromDiffuseTexture;
  31912. /**
  31913. * Does the transparency come from the diffuse texture alpha channel.
  31914. */
  31915. useAlphaFromDiffuseTexture: boolean;
  31916. private _useEmissiveAsIllumination;
  31917. /**
  31918. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31919. */
  31920. useEmissiveAsIllumination: boolean;
  31921. private _linkEmissiveWithDiffuse;
  31922. /**
  31923. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31924. * the emissive level when the final color is close to one.
  31925. */
  31926. linkEmissiveWithDiffuse: boolean;
  31927. private _useSpecularOverAlpha;
  31928. /**
  31929. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31930. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31931. */
  31932. useSpecularOverAlpha: boolean;
  31933. private _useReflectionOverAlpha;
  31934. /**
  31935. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31936. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31937. */
  31938. useReflectionOverAlpha: boolean;
  31939. private _disableLighting;
  31940. /**
  31941. * Does lights from the scene impacts this material.
  31942. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31943. */
  31944. disableLighting: boolean;
  31945. private _useObjectSpaceNormalMap;
  31946. /**
  31947. * Allows using an object space normal map (instead of tangent space).
  31948. */
  31949. useObjectSpaceNormalMap: boolean;
  31950. private _useParallax;
  31951. /**
  31952. * Is parallax enabled or not.
  31953. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31954. */
  31955. useParallax: boolean;
  31956. private _useParallaxOcclusion;
  31957. /**
  31958. * Is parallax occlusion enabled or not.
  31959. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31960. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31961. */
  31962. useParallaxOcclusion: boolean;
  31963. /**
  31964. * 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.
  31965. */
  31966. parallaxScaleBias: number;
  31967. private _roughness;
  31968. /**
  31969. * Helps to define how blurry the reflections should appears in the material.
  31970. */
  31971. roughness: number;
  31972. /**
  31973. * In case of refraction, define the value of the index of refraction.
  31974. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31975. */
  31976. indexOfRefraction: number;
  31977. /**
  31978. * Invert the refraction texture alongside the y axis.
  31979. * It can be useful with procedural textures or probe for instance.
  31980. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31981. */
  31982. invertRefractionY: boolean;
  31983. /**
  31984. * Defines the alpha limits in alpha test mode.
  31985. */
  31986. alphaCutOff: number;
  31987. private _useLightmapAsShadowmap;
  31988. /**
  31989. * In case of light mapping, define whether the map contains light or shadow informations.
  31990. */
  31991. useLightmapAsShadowmap: boolean;
  31992. private _diffuseFresnelParameters;
  31993. /**
  31994. * Define the diffuse fresnel parameters of the material.
  31995. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31996. */
  31997. diffuseFresnelParameters: FresnelParameters;
  31998. private _opacityFresnelParameters;
  31999. /**
  32000. * Define the opacity fresnel parameters of the material.
  32001. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32002. */
  32003. opacityFresnelParameters: FresnelParameters;
  32004. private _reflectionFresnelParameters;
  32005. /**
  32006. * Define the reflection fresnel parameters of the material.
  32007. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32008. */
  32009. reflectionFresnelParameters: FresnelParameters;
  32010. private _refractionFresnelParameters;
  32011. /**
  32012. * Define the refraction fresnel parameters of the material.
  32013. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32014. */
  32015. refractionFresnelParameters: FresnelParameters;
  32016. private _emissiveFresnelParameters;
  32017. /**
  32018. * Define the emissive fresnel parameters of the material.
  32019. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32020. */
  32021. emissiveFresnelParameters: FresnelParameters;
  32022. private _useReflectionFresnelFromSpecular;
  32023. /**
  32024. * If true automatically deducts the fresnels values from the material specularity.
  32025. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32026. */
  32027. useReflectionFresnelFromSpecular: boolean;
  32028. private _useGlossinessFromSpecularMapAlpha;
  32029. /**
  32030. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  32031. */
  32032. useGlossinessFromSpecularMapAlpha: boolean;
  32033. private _maxSimultaneousLights;
  32034. /**
  32035. * Defines the maximum number of lights that can be used in the material
  32036. */
  32037. maxSimultaneousLights: number;
  32038. private _invertNormalMapX;
  32039. /**
  32040. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32041. */
  32042. invertNormalMapX: boolean;
  32043. private _invertNormalMapY;
  32044. /**
  32045. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32046. */
  32047. invertNormalMapY: boolean;
  32048. private _twoSidedLighting;
  32049. /**
  32050. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32051. */
  32052. twoSidedLighting: boolean;
  32053. /**
  32054. * Default configuration related to image processing available in the standard Material.
  32055. */
  32056. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32057. /**
  32058. * Gets the image processing configuration used either in this material.
  32059. */
  32060. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  32061. /**
  32062. * Sets the Default image processing configuration used either in the this material.
  32063. *
  32064. * If sets to null, the scene one is in use.
  32065. */
  32066. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  32067. /**
  32068. * Keep track of the image processing observer to allow dispose and replace.
  32069. */
  32070. private _imageProcessingObserver;
  32071. /**
  32072. * Attaches a new image processing configuration to the Standard Material.
  32073. * @param configuration
  32074. */
  32075. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32076. /**
  32077. * Defines additionnal PrePass parameters for the material.
  32078. */
  32079. readonly prePassConfiguration: PrePassConfiguration;
  32080. /**
  32081. * Gets wether the color curves effect is enabled.
  32082. */
  32083. get cameraColorCurvesEnabled(): boolean;
  32084. /**
  32085. * Sets wether the color curves effect is enabled.
  32086. */
  32087. set cameraColorCurvesEnabled(value: boolean);
  32088. /**
  32089. * Gets wether the color grading effect is enabled.
  32090. */
  32091. get cameraColorGradingEnabled(): boolean;
  32092. /**
  32093. * Gets wether the color grading effect is enabled.
  32094. */
  32095. set cameraColorGradingEnabled(value: boolean);
  32096. /**
  32097. * Gets wether tonemapping is enabled or not.
  32098. */
  32099. get cameraToneMappingEnabled(): boolean;
  32100. /**
  32101. * Sets wether tonemapping is enabled or not
  32102. */
  32103. set cameraToneMappingEnabled(value: boolean);
  32104. /**
  32105. * The camera exposure used on this material.
  32106. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32107. * This corresponds to a photographic exposure.
  32108. */
  32109. get cameraExposure(): number;
  32110. /**
  32111. * The camera exposure used on this material.
  32112. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32113. * This corresponds to a photographic exposure.
  32114. */
  32115. set cameraExposure(value: number);
  32116. /**
  32117. * Gets The camera contrast used on this material.
  32118. */
  32119. get cameraContrast(): number;
  32120. /**
  32121. * Sets The camera contrast used on this material.
  32122. */
  32123. set cameraContrast(value: number);
  32124. /**
  32125. * Gets the Color Grading 2D Lookup Texture.
  32126. */
  32127. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  32128. /**
  32129. * Sets the Color Grading 2D Lookup Texture.
  32130. */
  32131. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  32132. /**
  32133. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32134. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32135. * 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;
  32136. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32137. */
  32138. get cameraColorCurves(): Nullable<ColorCurves>;
  32139. /**
  32140. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32141. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32142. * 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;
  32143. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32144. */
  32145. set cameraColorCurves(value: Nullable<ColorCurves>);
  32146. /**
  32147. * Can this material render to several textures at once
  32148. */
  32149. get canRenderToMRT(): boolean;
  32150. /**
  32151. * Defines the detail map parameters for the material.
  32152. */
  32153. readonly detailMap: DetailMapConfiguration;
  32154. protected _renderTargets: SmartArray<RenderTargetTexture>;
  32155. protected _worldViewProjectionMatrix: Matrix;
  32156. protected _globalAmbientColor: Color3;
  32157. protected _useLogarithmicDepth: boolean;
  32158. protected _rebuildInParallel: boolean;
  32159. /**
  32160. * Instantiates a new standard material.
  32161. * This is the default material used in Babylon. It is the best trade off between quality
  32162. * and performances.
  32163. * @see https://doc.babylonjs.com/babylon101/materials
  32164. * @param name Define the name of the material in the scene
  32165. * @param scene Define the scene the material belong to
  32166. */
  32167. constructor(name: string, scene: Scene);
  32168. /**
  32169. * Gets a boolean indicating that current material needs to register RTT
  32170. */
  32171. get hasRenderTargetTextures(): boolean;
  32172. /**
  32173. * Gets the current class name of the material e.g. "StandardMaterial"
  32174. * Mainly use in serialization.
  32175. * @returns the class name
  32176. */
  32177. getClassName(): string;
  32178. /**
  32179. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  32180. * You can try switching to logarithmic depth.
  32181. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  32182. */
  32183. get useLogarithmicDepth(): boolean;
  32184. set useLogarithmicDepth(value: boolean);
  32185. /**
  32186. * Specifies if the material will require alpha blending
  32187. * @returns a boolean specifying if alpha blending is needed
  32188. */
  32189. needAlphaBlending(): boolean;
  32190. /**
  32191. * Specifies if this material should be rendered in alpha test mode
  32192. * @returns a boolean specifying if an alpha test is needed.
  32193. */
  32194. needAlphaTesting(): boolean;
  32195. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  32196. /**
  32197. * Get the texture used for alpha test purpose.
  32198. * @returns the diffuse texture in case of the standard material.
  32199. */
  32200. getAlphaTestTexture(): Nullable<BaseTexture>;
  32201. /**
  32202. * Get if the submesh is ready to be used and all its information available.
  32203. * Child classes can use it to update shaders
  32204. * @param mesh defines the mesh to check
  32205. * @param subMesh defines which submesh to check
  32206. * @param useInstances specifies that instances should be used
  32207. * @returns a boolean indicating that the submesh is ready or not
  32208. */
  32209. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32210. /**
  32211. * Builds the material UBO layouts.
  32212. * Used internally during the effect preparation.
  32213. */
  32214. buildUniformLayout(): void;
  32215. /**
  32216. * Unbinds the material from the mesh
  32217. */
  32218. unbind(): void;
  32219. /**
  32220. * Binds the submesh to this material by preparing the effect and shader to draw
  32221. * @param world defines the world transformation matrix
  32222. * @param mesh defines the mesh containing the submesh
  32223. * @param subMesh defines the submesh to bind the material to
  32224. */
  32225. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32226. /**
  32227. * Get the list of animatables in the material.
  32228. * @returns the list of animatables object used in the material
  32229. */
  32230. getAnimatables(): IAnimatable[];
  32231. /**
  32232. * Gets the active textures from the material
  32233. * @returns an array of textures
  32234. */
  32235. getActiveTextures(): BaseTexture[];
  32236. /**
  32237. * Specifies if the material uses a texture
  32238. * @param texture defines the texture to check against the material
  32239. * @returns a boolean specifying if the material uses the texture
  32240. */
  32241. hasTexture(texture: BaseTexture): boolean;
  32242. /**
  32243. * Disposes the material
  32244. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32245. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32246. */
  32247. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32248. /**
  32249. * Makes a duplicate of the material, and gives it a new name
  32250. * @param name defines the new name for the duplicated material
  32251. * @returns the cloned material
  32252. */
  32253. clone(name: string): StandardMaterial;
  32254. /**
  32255. * Serializes this material in a JSON representation
  32256. * @returns the serialized material object
  32257. */
  32258. serialize(): any;
  32259. /**
  32260. * Creates a standard material from parsed material data
  32261. * @param source defines the JSON representation of the material
  32262. * @param scene defines the hosting scene
  32263. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32264. * @returns a new standard material
  32265. */
  32266. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32267. /**
  32268. * Are diffuse textures enabled in the application.
  32269. */
  32270. static get DiffuseTextureEnabled(): boolean;
  32271. static set DiffuseTextureEnabled(value: boolean);
  32272. /**
  32273. * Are detail textures enabled in the application.
  32274. */
  32275. static get DetailTextureEnabled(): boolean;
  32276. static set DetailTextureEnabled(value: boolean);
  32277. /**
  32278. * Are ambient textures enabled in the application.
  32279. */
  32280. static get AmbientTextureEnabled(): boolean;
  32281. static set AmbientTextureEnabled(value: boolean);
  32282. /**
  32283. * Are opacity textures enabled in the application.
  32284. */
  32285. static get OpacityTextureEnabled(): boolean;
  32286. static set OpacityTextureEnabled(value: boolean);
  32287. /**
  32288. * Are reflection textures enabled in the application.
  32289. */
  32290. static get ReflectionTextureEnabled(): boolean;
  32291. static set ReflectionTextureEnabled(value: boolean);
  32292. /**
  32293. * Are emissive textures enabled in the application.
  32294. */
  32295. static get EmissiveTextureEnabled(): boolean;
  32296. static set EmissiveTextureEnabled(value: boolean);
  32297. /**
  32298. * Are specular textures enabled in the application.
  32299. */
  32300. static get SpecularTextureEnabled(): boolean;
  32301. static set SpecularTextureEnabled(value: boolean);
  32302. /**
  32303. * Are bump textures enabled in the application.
  32304. */
  32305. static get BumpTextureEnabled(): boolean;
  32306. static set BumpTextureEnabled(value: boolean);
  32307. /**
  32308. * Are lightmap textures enabled in the application.
  32309. */
  32310. static get LightmapTextureEnabled(): boolean;
  32311. static set LightmapTextureEnabled(value: boolean);
  32312. /**
  32313. * Are refraction textures enabled in the application.
  32314. */
  32315. static get RefractionTextureEnabled(): boolean;
  32316. static set RefractionTextureEnabled(value: boolean);
  32317. /**
  32318. * Are color grading textures enabled in the application.
  32319. */
  32320. static get ColorGradingTextureEnabled(): boolean;
  32321. static set ColorGradingTextureEnabled(value: boolean);
  32322. /**
  32323. * Are fresnels enabled in the application.
  32324. */
  32325. static get FresnelEnabled(): boolean;
  32326. static set FresnelEnabled(value: boolean);
  32327. }
  32328. }
  32329. declare module "babylonjs/Particles/solidParticleSystem" {
  32330. import { Nullable } from "babylonjs/types";
  32331. import { Mesh } from "babylonjs/Meshes/mesh";
  32332. import { Scene, IDisposable } from "babylonjs/scene";
  32333. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32334. import { Material } from "babylonjs/Materials/material";
  32335. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32336. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32337. /**
  32338. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32339. *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.
  32340. * The SPS is also a particle system. It provides some methods to manage the particles.
  32341. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32342. *
  32343. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32344. */
  32345. export class SolidParticleSystem implements IDisposable {
  32346. /**
  32347. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32348. * Example : var p = SPS.particles[i];
  32349. */
  32350. particles: SolidParticle[];
  32351. /**
  32352. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32353. */
  32354. nbParticles: number;
  32355. /**
  32356. * If the particles must ever face the camera (default false). Useful for planar particles.
  32357. */
  32358. billboard: boolean;
  32359. /**
  32360. * Recompute normals when adding a shape
  32361. */
  32362. recomputeNormals: boolean;
  32363. /**
  32364. * This a counter ofr your own usage. It's not set by any SPS functions.
  32365. */
  32366. counter: number;
  32367. /**
  32368. * The SPS name. This name is also given to the underlying mesh.
  32369. */
  32370. name: string;
  32371. /**
  32372. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32373. */
  32374. mesh: Mesh;
  32375. /**
  32376. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32377. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32378. */
  32379. vars: any;
  32380. /**
  32381. * This array is populated when the SPS is set as 'pickable'.
  32382. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32383. * Each element of this array is an object `{idx: int, faceId: int}`.
  32384. * `idx` is the picked particle index in the `SPS.particles` array
  32385. * `faceId` is the picked face index counted within this particle.
  32386. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32387. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32388. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32389. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32390. */
  32391. pickedParticles: {
  32392. idx: number;
  32393. faceId: number;
  32394. }[];
  32395. /**
  32396. * This array is populated when the SPS is set as 'pickable'
  32397. * Each key of this array is a submesh index.
  32398. * Each element of this array is a second array defined like this :
  32399. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32400. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32401. * `idx` is the picked particle index in the `SPS.particles` array
  32402. * `faceId` is the picked face index counted within this particle.
  32403. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32404. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32405. */
  32406. pickedBySubMesh: {
  32407. idx: number;
  32408. faceId: number;
  32409. }[][];
  32410. /**
  32411. * This array is populated when `enableDepthSort` is set to true.
  32412. * Each element of this array is an instance of the class DepthSortedParticle.
  32413. */
  32414. depthSortedParticles: DepthSortedParticle[];
  32415. /**
  32416. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32417. * @hidden
  32418. */
  32419. _bSphereOnly: boolean;
  32420. /**
  32421. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32422. * @hidden
  32423. */
  32424. _bSphereRadiusFactor: number;
  32425. private _scene;
  32426. private _positions;
  32427. private _indices;
  32428. private _normals;
  32429. private _colors;
  32430. private _uvs;
  32431. private _indices32;
  32432. private _positions32;
  32433. private _normals32;
  32434. private _fixedNormal32;
  32435. private _colors32;
  32436. private _uvs32;
  32437. private _index;
  32438. private _updatable;
  32439. private _pickable;
  32440. private _isVisibilityBoxLocked;
  32441. private _alwaysVisible;
  32442. private _depthSort;
  32443. private _expandable;
  32444. private _shapeCounter;
  32445. private _copy;
  32446. private _color;
  32447. private _computeParticleColor;
  32448. private _computeParticleTexture;
  32449. private _computeParticleRotation;
  32450. private _computeParticleVertex;
  32451. private _computeBoundingBox;
  32452. private _depthSortParticles;
  32453. private _camera;
  32454. private _mustUnrotateFixedNormals;
  32455. private _particlesIntersect;
  32456. private _needs32Bits;
  32457. private _isNotBuilt;
  32458. private _lastParticleId;
  32459. private _idxOfId;
  32460. private _multimaterialEnabled;
  32461. private _useModelMaterial;
  32462. private _indicesByMaterial;
  32463. private _materialIndexes;
  32464. private _depthSortFunction;
  32465. private _materialSortFunction;
  32466. private _materials;
  32467. private _multimaterial;
  32468. private _materialIndexesById;
  32469. private _defaultMaterial;
  32470. private _autoUpdateSubMeshes;
  32471. private _tmpVertex;
  32472. /**
  32473. * Creates a SPS (Solid Particle System) object.
  32474. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32475. * @param scene (Scene) is the scene in which the SPS is added.
  32476. * @param options defines the options of the sps e.g.
  32477. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32478. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32479. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32480. * * 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.
  32481. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32482. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32483. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32484. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32485. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32486. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32487. */
  32488. constructor(name: string, scene: Scene, options?: {
  32489. updatable?: boolean;
  32490. isPickable?: boolean;
  32491. enableDepthSort?: boolean;
  32492. particleIntersection?: boolean;
  32493. boundingSphereOnly?: boolean;
  32494. bSphereRadiusFactor?: number;
  32495. expandable?: boolean;
  32496. useModelMaterial?: boolean;
  32497. enableMultiMaterial?: boolean;
  32498. });
  32499. /**
  32500. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32501. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32502. * @returns the created mesh
  32503. */
  32504. buildMesh(): Mesh;
  32505. /**
  32506. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32507. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32508. * Thus the particles generated from `digest()` have their property `position` set yet.
  32509. * @param mesh ( Mesh ) is the mesh to be digested
  32510. * @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
  32511. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32512. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32513. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32514. * @returns the current SPS
  32515. */
  32516. digest(mesh: Mesh, options?: {
  32517. facetNb?: number;
  32518. number?: number;
  32519. delta?: number;
  32520. storage?: [];
  32521. }): SolidParticleSystem;
  32522. /**
  32523. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32524. * @hidden
  32525. */
  32526. private _unrotateFixedNormals;
  32527. /**
  32528. * Resets the temporary working copy particle
  32529. * @hidden
  32530. */
  32531. private _resetCopy;
  32532. /**
  32533. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32534. * @param p the current index in the positions array to be updated
  32535. * @param ind the current index in the indices array
  32536. * @param shape a Vector3 array, the shape geometry
  32537. * @param positions the positions array to be updated
  32538. * @param meshInd the shape indices array
  32539. * @param indices the indices array to be updated
  32540. * @param meshUV the shape uv array
  32541. * @param uvs the uv array to be updated
  32542. * @param meshCol the shape color array
  32543. * @param colors the color array to be updated
  32544. * @param meshNor the shape normals array
  32545. * @param normals the normals array to be updated
  32546. * @param idx the particle index
  32547. * @param idxInShape the particle index in its shape
  32548. * @param options the addShape() method passed options
  32549. * @model the particle model
  32550. * @hidden
  32551. */
  32552. private _meshBuilder;
  32553. /**
  32554. * Returns a shape Vector3 array from positions float array
  32555. * @param positions float array
  32556. * @returns a vector3 array
  32557. * @hidden
  32558. */
  32559. private _posToShape;
  32560. /**
  32561. * Returns a shapeUV array from a float uvs (array deep copy)
  32562. * @param uvs as a float array
  32563. * @returns a shapeUV array
  32564. * @hidden
  32565. */
  32566. private _uvsToShapeUV;
  32567. /**
  32568. * Adds a new particle object in the particles array
  32569. * @param idx particle index in particles array
  32570. * @param id particle id
  32571. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32572. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32573. * @param model particle ModelShape object
  32574. * @param shapeId model shape identifier
  32575. * @param idxInShape index of the particle in the current model
  32576. * @param bInfo model bounding info object
  32577. * @param storage target storage array, if any
  32578. * @hidden
  32579. */
  32580. private _addParticle;
  32581. /**
  32582. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32583. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32584. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32585. * @param nb (positive integer) the number of particles to be created from this model
  32586. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32587. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32588. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32589. * @returns the number of shapes in the system
  32590. */
  32591. addShape(mesh: Mesh, nb: number, options?: {
  32592. positionFunction?: any;
  32593. vertexFunction?: any;
  32594. storage?: [];
  32595. }): number;
  32596. /**
  32597. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32598. * @hidden
  32599. */
  32600. private _rebuildParticle;
  32601. /**
  32602. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32603. * @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.
  32604. * @returns the SPS.
  32605. */
  32606. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32607. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32608. * Returns an array with the removed particles.
  32609. * 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.
  32610. * The SPS can't be empty so at least one particle needs to remain in place.
  32611. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32612. * @param start index of the first particle to remove
  32613. * @param end index of the last particle to remove (included)
  32614. * @returns an array populated with the removed particles
  32615. */
  32616. removeParticles(start: number, end: number): SolidParticle[];
  32617. /**
  32618. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32619. * @param solidParticleArray an array populated with Solid Particles objects
  32620. * @returns the SPS
  32621. */
  32622. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32623. /**
  32624. * Creates a new particle and modifies the SPS mesh geometry :
  32625. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32626. * - calls _addParticle() to populate the particle array
  32627. * factorized code from addShape() and insertParticlesFromArray()
  32628. * @param idx particle index in the particles array
  32629. * @param i particle index in its shape
  32630. * @param modelShape particle ModelShape object
  32631. * @param shape shape vertex array
  32632. * @param meshInd shape indices array
  32633. * @param meshUV shape uv array
  32634. * @param meshCol shape color array
  32635. * @param meshNor shape normals array
  32636. * @param bbInfo shape bounding info
  32637. * @param storage target particle storage
  32638. * @options addShape() passed options
  32639. * @hidden
  32640. */
  32641. private _insertNewParticle;
  32642. /**
  32643. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32644. * This method calls `updateParticle()` for each particle of the SPS.
  32645. * For an animated SPS, it is usually called within the render loop.
  32646. * 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.
  32647. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32648. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32649. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32650. * @returns the SPS.
  32651. */
  32652. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32653. /**
  32654. * Disposes the SPS.
  32655. */
  32656. dispose(): void;
  32657. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32658. * idx is the particle index in the SPS
  32659. * faceId is the picked face index counted within this particle.
  32660. * Returns null if the pickInfo can't identify a picked particle.
  32661. * @param pickingInfo (PickingInfo object)
  32662. * @returns {idx: number, faceId: number} or null
  32663. */
  32664. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32665. idx: number;
  32666. faceId: number;
  32667. }>;
  32668. /**
  32669. * Returns a SolidParticle object from its identifier : particle.id
  32670. * @param id (integer) the particle Id
  32671. * @returns the searched particle or null if not found in the SPS.
  32672. */
  32673. getParticleById(id: number): Nullable<SolidParticle>;
  32674. /**
  32675. * Returns a new array populated with the particles having the passed shapeId.
  32676. * @param shapeId (integer) the shape identifier
  32677. * @returns a new solid particle array
  32678. */
  32679. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32680. /**
  32681. * Populates the passed array "ref" with the particles having the passed shapeId.
  32682. * @param shapeId the shape identifier
  32683. * @returns the SPS
  32684. * @param ref
  32685. */
  32686. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32687. /**
  32688. * Computes the required SubMeshes according the materials assigned to the particles.
  32689. * @returns the solid particle system.
  32690. * Does nothing if called before the SPS mesh is built.
  32691. */
  32692. computeSubMeshes(): SolidParticleSystem;
  32693. /**
  32694. * Sorts the solid particles by material when MultiMaterial is enabled.
  32695. * Updates the indices32 array.
  32696. * Updates the indicesByMaterial array.
  32697. * Updates the mesh indices array.
  32698. * @returns the SPS
  32699. * @hidden
  32700. */
  32701. private _sortParticlesByMaterial;
  32702. /**
  32703. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32704. * @hidden
  32705. */
  32706. private _setMaterialIndexesById;
  32707. /**
  32708. * Returns an array with unique values of Materials from the passed array
  32709. * @param array the material array to be checked and filtered
  32710. * @hidden
  32711. */
  32712. private _filterUniqueMaterialId;
  32713. /**
  32714. * Sets a new Standard Material as _defaultMaterial if not already set.
  32715. * @hidden
  32716. */
  32717. private _setDefaultMaterial;
  32718. /**
  32719. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32720. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32721. * @returns the SPS.
  32722. */
  32723. refreshVisibleSize(): SolidParticleSystem;
  32724. /**
  32725. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32726. * @param size the size (float) of the visibility box
  32727. * note : this doesn't lock the SPS mesh bounding box.
  32728. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32729. */
  32730. setVisibilityBox(size: number): void;
  32731. /**
  32732. * Gets whether the SPS as always visible or not
  32733. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32734. */
  32735. get isAlwaysVisible(): boolean;
  32736. /**
  32737. * Sets the SPS as always visible or not
  32738. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32739. */
  32740. set isAlwaysVisible(val: boolean);
  32741. /**
  32742. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32743. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32744. */
  32745. set isVisibilityBoxLocked(val: boolean);
  32746. /**
  32747. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32748. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32749. */
  32750. get isVisibilityBoxLocked(): boolean;
  32751. /**
  32752. * Tells to `setParticles()` to compute the particle rotations or not.
  32753. * Default value : true. The SPS is faster when it's set to false.
  32754. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32755. */
  32756. set computeParticleRotation(val: boolean);
  32757. /**
  32758. * Tells to `setParticles()` to compute the particle colors or not.
  32759. * Default value : true. The SPS is faster when it's set to false.
  32760. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32761. */
  32762. set computeParticleColor(val: boolean);
  32763. set computeParticleTexture(val: boolean);
  32764. /**
  32765. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32766. * Default value : false. The SPS is faster when it's set to false.
  32767. * Note : the particle custom vertex positions aren't stored values.
  32768. */
  32769. set computeParticleVertex(val: boolean);
  32770. /**
  32771. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32772. */
  32773. set computeBoundingBox(val: boolean);
  32774. /**
  32775. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32776. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32777. * Default : `true`
  32778. */
  32779. set depthSortParticles(val: boolean);
  32780. /**
  32781. * Gets if `setParticles()` computes the particle rotations or not.
  32782. * Default value : true. The SPS is faster when it's set to false.
  32783. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32784. */
  32785. get computeParticleRotation(): boolean;
  32786. /**
  32787. * Gets if `setParticles()` computes the particle colors or not.
  32788. * Default value : true. The SPS is faster when it's set to false.
  32789. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32790. */
  32791. get computeParticleColor(): boolean;
  32792. /**
  32793. * Gets if `setParticles()` computes the particle textures or not.
  32794. * Default value : true. The SPS is faster when it's set to false.
  32795. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32796. */
  32797. get computeParticleTexture(): boolean;
  32798. /**
  32799. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32800. * Default value : false. The SPS is faster when it's set to false.
  32801. * Note : the particle custom vertex positions aren't stored values.
  32802. */
  32803. get computeParticleVertex(): boolean;
  32804. /**
  32805. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32806. */
  32807. get computeBoundingBox(): boolean;
  32808. /**
  32809. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32810. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32811. * Default : `true`
  32812. */
  32813. get depthSortParticles(): boolean;
  32814. /**
  32815. * Gets if the SPS is created as expandable at construction time.
  32816. * Default : `false`
  32817. */
  32818. get expandable(): boolean;
  32819. /**
  32820. * Gets if the SPS supports the Multi Materials
  32821. */
  32822. get multimaterialEnabled(): boolean;
  32823. /**
  32824. * Gets if the SPS uses the model materials for its own multimaterial.
  32825. */
  32826. get useModelMaterial(): boolean;
  32827. /**
  32828. * The SPS used material array.
  32829. */
  32830. get materials(): Material[];
  32831. /**
  32832. * Sets the SPS MultiMaterial from the passed materials.
  32833. * Note : the passed array is internally copied and not used then by reference.
  32834. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32835. */
  32836. setMultiMaterial(materials: Material[]): void;
  32837. /**
  32838. * The SPS computed multimaterial object
  32839. */
  32840. get multimaterial(): MultiMaterial;
  32841. set multimaterial(mm: MultiMaterial);
  32842. /**
  32843. * If the subMeshes must be updated on the next call to setParticles()
  32844. */
  32845. get autoUpdateSubMeshes(): boolean;
  32846. set autoUpdateSubMeshes(val: boolean);
  32847. /**
  32848. * This function does nothing. It may be overwritten to set all the particle first values.
  32849. * The SPS doesn't call this function, you may have to call it by your own.
  32850. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32851. */
  32852. initParticles(): void;
  32853. /**
  32854. * This function does nothing. It may be overwritten to recycle a particle.
  32855. * The SPS doesn't call this function, you may have to call it by your own.
  32856. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32857. * @param particle The particle to recycle
  32858. * @returns the recycled particle
  32859. */
  32860. recycleParticle(particle: SolidParticle): SolidParticle;
  32861. /**
  32862. * Updates a particle : this function should be overwritten by the user.
  32863. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32864. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32865. * @example : just set a particle position or velocity and recycle conditions
  32866. * @param particle The particle to update
  32867. * @returns the updated particle
  32868. */
  32869. updateParticle(particle: SolidParticle): SolidParticle;
  32870. /**
  32871. * Updates a vertex of a particle : it can be overwritten by the user.
  32872. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32873. * @param particle the current particle
  32874. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32875. * @param pt the index of the current vertex in the particle shape
  32876. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32877. * @example : just set a vertex particle position or color
  32878. * @returns the sps
  32879. */
  32880. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32881. /**
  32882. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32883. * This does nothing and may be overwritten by the user.
  32884. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32885. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32886. * @param update the boolean update value actually passed to setParticles()
  32887. */
  32888. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32889. /**
  32890. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32891. * This will be passed three parameters.
  32892. * This does nothing and may be overwritten by the user.
  32893. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32894. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32895. * @param update the boolean update value actually passed to setParticles()
  32896. */
  32897. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32898. }
  32899. }
  32900. declare module "babylonjs/Particles/solidParticle" {
  32901. import { Nullable } from "babylonjs/types";
  32902. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32903. import { Color4 } from "babylonjs/Maths/math.color";
  32904. import { Mesh } from "babylonjs/Meshes/mesh";
  32905. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32906. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32907. import { Plane } from "babylonjs/Maths/math.plane";
  32908. import { Material } from "babylonjs/Materials/material";
  32909. /**
  32910. * Represents one particle of a solid particle system.
  32911. */
  32912. export class SolidParticle {
  32913. /**
  32914. * particle global index
  32915. */
  32916. idx: number;
  32917. /**
  32918. * particle identifier
  32919. */
  32920. id: number;
  32921. /**
  32922. * The color of the particle
  32923. */
  32924. color: Nullable<Color4>;
  32925. /**
  32926. * The world space position of the particle.
  32927. */
  32928. position: Vector3;
  32929. /**
  32930. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32931. */
  32932. rotation: Vector3;
  32933. /**
  32934. * The world space rotation quaternion of the particle.
  32935. */
  32936. rotationQuaternion: Nullable<Quaternion>;
  32937. /**
  32938. * The scaling of the particle.
  32939. */
  32940. scaling: Vector3;
  32941. /**
  32942. * The uvs of the particle.
  32943. */
  32944. uvs: Vector4;
  32945. /**
  32946. * The current speed of the particle.
  32947. */
  32948. velocity: Vector3;
  32949. /**
  32950. * The pivot point in the particle local space.
  32951. */
  32952. pivot: Vector3;
  32953. /**
  32954. * Must the particle be translated from its pivot point in its local space ?
  32955. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32956. * Default : false
  32957. */
  32958. translateFromPivot: boolean;
  32959. /**
  32960. * Is the particle active or not ?
  32961. */
  32962. alive: boolean;
  32963. /**
  32964. * Is the particle visible or not ?
  32965. */
  32966. isVisible: boolean;
  32967. /**
  32968. * Index of this particle in the global "positions" array (Internal use)
  32969. * @hidden
  32970. */
  32971. _pos: number;
  32972. /**
  32973. * @hidden Index of this particle in the global "indices" array (Internal use)
  32974. */
  32975. _ind: number;
  32976. /**
  32977. * @hidden ModelShape of this particle (Internal use)
  32978. */
  32979. _model: ModelShape;
  32980. /**
  32981. * ModelShape id of this particle
  32982. */
  32983. shapeId: number;
  32984. /**
  32985. * Index of the particle in its shape id
  32986. */
  32987. idxInShape: number;
  32988. /**
  32989. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32990. */
  32991. _modelBoundingInfo: BoundingInfo;
  32992. /**
  32993. * @hidden Particle BoundingInfo object (Internal use)
  32994. */
  32995. _boundingInfo: BoundingInfo;
  32996. /**
  32997. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32998. */
  32999. _sps: SolidParticleSystem;
  33000. /**
  33001. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  33002. */
  33003. _stillInvisible: boolean;
  33004. /**
  33005. * @hidden Last computed particle rotation matrix
  33006. */
  33007. _rotationMatrix: number[];
  33008. /**
  33009. * Parent particle Id, if any.
  33010. * Default null.
  33011. */
  33012. parentId: Nullable<number>;
  33013. /**
  33014. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  33015. */
  33016. materialIndex: Nullable<number>;
  33017. /**
  33018. * Custom object or properties.
  33019. */
  33020. props: Nullable<any>;
  33021. /**
  33022. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  33023. * The possible values are :
  33024. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33025. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33026. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33027. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33028. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33029. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  33030. * */
  33031. cullingStrategy: number;
  33032. /**
  33033. * @hidden Internal global position in the SPS.
  33034. */
  33035. _globalPosition: Vector3;
  33036. /**
  33037. * Creates a Solid Particle object.
  33038. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  33039. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  33040. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  33041. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  33042. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  33043. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  33044. * @param shapeId (integer) is the model shape identifier in the SPS.
  33045. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  33046. * @param sps defines the sps it is associated to
  33047. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  33048. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  33049. */
  33050. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  33051. /**
  33052. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  33053. * @param target the particle target
  33054. * @returns the current particle
  33055. */
  33056. copyToRef(target: SolidParticle): SolidParticle;
  33057. /**
  33058. * Legacy support, changed scale to scaling
  33059. */
  33060. get scale(): Vector3;
  33061. /**
  33062. * Legacy support, changed scale to scaling
  33063. */
  33064. set scale(scale: Vector3);
  33065. /**
  33066. * Legacy support, changed quaternion to rotationQuaternion
  33067. */
  33068. get quaternion(): Nullable<Quaternion>;
  33069. /**
  33070. * Legacy support, changed quaternion to rotationQuaternion
  33071. */
  33072. set quaternion(q: Nullable<Quaternion>);
  33073. /**
  33074. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  33075. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  33076. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  33077. * @returns true if it intersects
  33078. */
  33079. intersectsMesh(target: Mesh | SolidParticle): boolean;
  33080. /**
  33081. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  33082. * A particle is in the frustum if its bounding box intersects the frustum
  33083. * @param frustumPlanes defines the frustum to test
  33084. * @returns true if the particle is in the frustum planes
  33085. */
  33086. isInFrustum(frustumPlanes: Plane[]): boolean;
  33087. /**
  33088. * get the rotation matrix of the particle
  33089. * @hidden
  33090. */
  33091. getRotationMatrix(m: Matrix): void;
  33092. }
  33093. /**
  33094. * Represents the shape of the model used by one particle of a solid particle system.
  33095. * SPS internal tool, don't use it manually.
  33096. */
  33097. export class ModelShape {
  33098. /**
  33099. * The shape id
  33100. * @hidden
  33101. */
  33102. shapeID: number;
  33103. /**
  33104. * flat array of model positions (internal use)
  33105. * @hidden
  33106. */
  33107. _shape: Vector3[];
  33108. /**
  33109. * flat array of model UVs (internal use)
  33110. * @hidden
  33111. */
  33112. _shapeUV: number[];
  33113. /**
  33114. * color array of the model
  33115. * @hidden
  33116. */
  33117. _shapeColors: number[];
  33118. /**
  33119. * indices array of the model
  33120. * @hidden
  33121. */
  33122. _indices: number[];
  33123. /**
  33124. * normals array of the model
  33125. * @hidden
  33126. */
  33127. _normals: number[];
  33128. /**
  33129. * length of the shape in the model indices array (internal use)
  33130. * @hidden
  33131. */
  33132. _indicesLength: number;
  33133. /**
  33134. * Custom position function (internal use)
  33135. * @hidden
  33136. */
  33137. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33138. /**
  33139. * Custom vertex function (internal use)
  33140. * @hidden
  33141. */
  33142. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33143. /**
  33144. * Model material (internal use)
  33145. * @hidden
  33146. */
  33147. _material: Nullable<Material>;
  33148. /**
  33149. * 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.
  33150. * SPS internal tool, don't use it manually.
  33151. * @hidden
  33152. */
  33153. 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>);
  33154. }
  33155. /**
  33156. * Represents a Depth Sorted Particle in the solid particle system.
  33157. * @hidden
  33158. */
  33159. export class DepthSortedParticle {
  33160. /**
  33161. * Particle index
  33162. */
  33163. idx: number;
  33164. /**
  33165. * Index of the particle in the "indices" array
  33166. */
  33167. ind: number;
  33168. /**
  33169. * Length of the particle shape in the "indices" array
  33170. */
  33171. indicesLength: number;
  33172. /**
  33173. * Squared distance from the particle to the camera
  33174. */
  33175. sqDistance: number;
  33176. /**
  33177. * Material index when used with MultiMaterials
  33178. */
  33179. materialIndex: number;
  33180. /**
  33181. * Creates a new sorted particle
  33182. * @param materialIndex
  33183. */
  33184. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  33185. }
  33186. /**
  33187. * Represents a solid particle vertex
  33188. */
  33189. export class SolidParticleVertex {
  33190. /**
  33191. * Vertex position
  33192. */
  33193. position: Vector3;
  33194. /**
  33195. * Vertex color
  33196. */
  33197. color: Color4;
  33198. /**
  33199. * Vertex UV
  33200. */
  33201. uv: Vector2;
  33202. /**
  33203. * Creates a new solid particle vertex
  33204. */
  33205. constructor();
  33206. /** Vertex x coordinate */
  33207. get x(): number;
  33208. set x(val: number);
  33209. /** Vertex y coordinate */
  33210. get y(): number;
  33211. set y(val: number);
  33212. /** Vertex z coordinate */
  33213. get z(): number;
  33214. set z(val: number);
  33215. }
  33216. }
  33217. declare module "babylonjs/Collisions/meshCollisionData" {
  33218. import { Collider } from "babylonjs/Collisions/collider";
  33219. import { Vector3 } from "babylonjs/Maths/math.vector";
  33220. import { Nullable } from "babylonjs/types";
  33221. import { Observer } from "babylonjs/Misc/observable";
  33222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33223. /**
  33224. * @hidden
  33225. */
  33226. export class _MeshCollisionData {
  33227. _checkCollisions: boolean;
  33228. _collisionMask: number;
  33229. _collisionGroup: number;
  33230. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33231. _collider: Nullable<Collider>;
  33232. _oldPositionForCollisions: Vector3;
  33233. _diffPositionForCollisions: Vector3;
  33234. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33235. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33236. _collisionResponse: boolean;
  33237. }
  33238. }
  33239. declare module "babylonjs/Meshes/abstractMesh" {
  33240. import { Observable } from "babylonjs/Misc/observable";
  33241. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33242. import { Camera } from "babylonjs/Cameras/camera";
  33243. import { Scene, IDisposable } from "babylonjs/scene";
  33244. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33245. import { Node } from "babylonjs/node";
  33246. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33247. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33248. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33249. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33250. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33251. import { Material } from "babylonjs/Materials/material";
  33252. import { Light } from "babylonjs/Lights/light";
  33253. import { Skeleton } from "babylonjs/Bones/skeleton";
  33254. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33255. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33256. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33257. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33258. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33259. import { Plane } from "babylonjs/Maths/math.plane";
  33260. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33261. import { Ray } from "babylonjs/Culling/ray";
  33262. import { Collider } from "babylonjs/Collisions/collider";
  33263. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33264. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33265. /** @hidden */
  33266. class _FacetDataStorage {
  33267. facetPositions: Vector3[];
  33268. facetNormals: Vector3[];
  33269. facetPartitioning: number[][];
  33270. facetNb: number;
  33271. partitioningSubdivisions: number;
  33272. partitioningBBoxRatio: number;
  33273. facetDataEnabled: boolean;
  33274. facetParameters: any;
  33275. bbSize: Vector3;
  33276. subDiv: {
  33277. max: number;
  33278. X: number;
  33279. Y: number;
  33280. Z: number;
  33281. };
  33282. facetDepthSort: boolean;
  33283. facetDepthSortEnabled: boolean;
  33284. depthSortedIndices: IndicesArray;
  33285. depthSortedFacets: {
  33286. ind: number;
  33287. sqDistance: number;
  33288. }[];
  33289. facetDepthSortFunction: (f1: {
  33290. ind: number;
  33291. sqDistance: number;
  33292. }, f2: {
  33293. ind: number;
  33294. sqDistance: number;
  33295. }) => number;
  33296. facetDepthSortFrom: Vector3;
  33297. facetDepthSortOrigin: Vector3;
  33298. invertedMatrix: Matrix;
  33299. }
  33300. /**
  33301. * @hidden
  33302. **/
  33303. class _InternalAbstractMeshDataInfo {
  33304. _hasVertexAlpha: boolean;
  33305. _useVertexColors: boolean;
  33306. _numBoneInfluencers: number;
  33307. _applyFog: boolean;
  33308. _receiveShadows: boolean;
  33309. _facetData: _FacetDataStorage;
  33310. _visibility: number;
  33311. _skeleton: Nullable<Skeleton>;
  33312. _layerMask: number;
  33313. _computeBonesUsingShaders: boolean;
  33314. _isActive: boolean;
  33315. _onlyForInstances: boolean;
  33316. _isActiveIntermediate: boolean;
  33317. _onlyForInstancesIntermediate: boolean;
  33318. _actAsRegularMesh: boolean;
  33319. }
  33320. /**
  33321. * Class used to store all common mesh properties
  33322. */
  33323. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33324. /** No occlusion */
  33325. static OCCLUSION_TYPE_NONE: number;
  33326. /** Occlusion set to optimisitic */
  33327. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33328. /** Occlusion set to strict */
  33329. static OCCLUSION_TYPE_STRICT: number;
  33330. /** Use an accurante occlusion algorithm */
  33331. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33332. /** Use a conservative occlusion algorithm */
  33333. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33334. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33335. * Test order :
  33336. * Is the bounding sphere outside the frustum ?
  33337. * If not, are the bounding box vertices outside the frustum ?
  33338. * It not, then the cullable object is in the frustum.
  33339. */
  33340. static readonly CULLINGSTRATEGY_STANDARD: number;
  33341. /** Culling strategy : Bounding Sphere Only.
  33342. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33343. * It's also less accurate than the standard because some not visible objects can still be selected.
  33344. * Test : is the bounding sphere outside the frustum ?
  33345. * If not, then the cullable object is in the frustum.
  33346. */
  33347. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33348. /** Culling strategy : Optimistic Inclusion.
  33349. * This in an inclusion test first, then the standard exclusion test.
  33350. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33351. * 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.
  33352. * Anyway, it's as accurate as the standard strategy.
  33353. * Test :
  33354. * Is the cullable object bounding sphere center in the frustum ?
  33355. * If not, apply the default culling strategy.
  33356. */
  33357. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33358. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33359. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33360. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33361. * 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.
  33362. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33363. * Test :
  33364. * Is the cullable object bounding sphere center in the frustum ?
  33365. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33366. */
  33367. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33368. /**
  33369. * No billboard
  33370. */
  33371. static get BILLBOARDMODE_NONE(): number;
  33372. /** Billboard on X axis */
  33373. static get BILLBOARDMODE_X(): number;
  33374. /** Billboard on Y axis */
  33375. static get BILLBOARDMODE_Y(): number;
  33376. /** Billboard on Z axis */
  33377. static get BILLBOARDMODE_Z(): number;
  33378. /** Billboard on all axes */
  33379. static get BILLBOARDMODE_ALL(): number;
  33380. /** Billboard on using position instead of orientation */
  33381. static get BILLBOARDMODE_USE_POSITION(): number;
  33382. /** @hidden */
  33383. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33384. /**
  33385. * The culling strategy to use to check whether the mesh must be rendered or not.
  33386. * This value can be changed at any time and will be used on the next render mesh selection.
  33387. * The possible values are :
  33388. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33389. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33390. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33391. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33392. * Please read each static variable documentation to get details about the culling process.
  33393. * */
  33394. cullingStrategy: number;
  33395. /**
  33396. * Gets the number of facets in the mesh
  33397. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33398. */
  33399. get facetNb(): number;
  33400. /**
  33401. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33402. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33403. */
  33404. get partitioningSubdivisions(): number;
  33405. set partitioningSubdivisions(nb: number);
  33406. /**
  33407. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33408. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33409. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33410. */
  33411. get partitioningBBoxRatio(): number;
  33412. set partitioningBBoxRatio(ratio: number);
  33413. /**
  33414. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33415. * Works only for updatable meshes.
  33416. * Doesn't work with multi-materials
  33417. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33418. */
  33419. get mustDepthSortFacets(): boolean;
  33420. set mustDepthSortFacets(sort: boolean);
  33421. /**
  33422. * The location (Vector3) where the facet depth sort must be computed from.
  33423. * By default, the active camera position.
  33424. * Used only when facet depth sort is enabled
  33425. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33426. */
  33427. get facetDepthSortFrom(): Vector3;
  33428. set facetDepthSortFrom(location: Vector3);
  33429. /**
  33430. * gets a boolean indicating if facetData is enabled
  33431. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33432. */
  33433. get isFacetDataEnabled(): boolean;
  33434. /** @hidden */
  33435. _updateNonUniformScalingState(value: boolean): boolean;
  33436. /**
  33437. * An event triggered when this mesh collides with another one
  33438. */
  33439. onCollideObservable: Observable<AbstractMesh>;
  33440. /** Set a function to call when this mesh collides with another one */
  33441. set onCollide(callback: () => void);
  33442. /**
  33443. * An event triggered when the collision's position changes
  33444. */
  33445. onCollisionPositionChangeObservable: Observable<Vector3>;
  33446. /** Set a function to call when the collision's position changes */
  33447. set onCollisionPositionChange(callback: () => void);
  33448. /**
  33449. * An event triggered when material is changed
  33450. */
  33451. onMaterialChangedObservable: Observable<AbstractMesh>;
  33452. /**
  33453. * Gets or sets the orientation for POV movement & rotation
  33454. */
  33455. definedFacingForward: boolean;
  33456. /** @hidden */
  33457. _occlusionQuery: Nullable<WebGLQuery>;
  33458. /** @hidden */
  33459. _renderingGroup: Nullable<RenderingGroup>;
  33460. /**
  33461. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33462. */
  33463. get visibility(): number;
  33464. /**
  33465. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33466. */
  33467. set visibility(value: number);
  33468. /** Gets or sets the alpha index used to sort transparent meshes
  33469. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33470. */
  33471. alphaIndex: number;
  33472. /**
  33473. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33474. */
  33475. isVisible: boolean;
  33476. /**
  33477. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33478. */
  33479. isPickable: boolean;
  33480. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33481. showSubMeshesBoundingBox: boolean;
  33482. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33483. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33484. */
  33485. isBlocker: boolean;
  33486. /**
  33487. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33488. */
  33489. enablePointerMoveEvents: boolean;
  33490. private _renderingGroupId;
  33491. /**
  33492. * Specifies the rendering group id for this mesh (0 by default)
  33493. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33494. */
  33495. get renderingGroupId(): number;
  33496. set renderingGroupId(value: number);
  33497. private _material;
  33498. /** Gets or sets current material */
  33499. get material(): Nullable<Material>;
  33500. set material(value: Nullable<Material>);
  33501. /**
  33502. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33503. * @see https://doc.babylonjs.com/babylon101/shadows
  33504. */
  33505. get receiveShadows(): boolean;
  33506. set receiveShadows(value: boolean);
  33507. /** Defines color to use when rendering outline */
  33508. outlineColor: Color3;
  33509. /** Define width to use when rendering outline */
  33510. outlineWidth: number;
  33511. /** Defines color to use when rendering overlay */
  33512. overlayColor: Color3;
  33513. /** Defines alpha to use when rendering overlay */
  33514. overlayAlpha: number;
  33515. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33516. get hasVertexAlpha(): boolean;
  33517. set hasVertexAlpha(value: boolean);
  33518. /** 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) */
  33519. get useVertexColors(): boolean;
  33520. set useVertexColors(value: boolean);
  33521. /**
  33522. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33523. */
  33524. get computeBonesUsingShaders(): boolean;
  33525. set computeBonesUsingShaders(value: boolean);
  33526. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33527. get numBoneInfluencers(): number;
  33528. set numBoneInfluencers(value: number);
  33529. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33530. get applyFog(): boolean;
  33531. set applyFog(value: boolean);
  33532. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33533. useOctreeForRenderingSelection: boolean;
  33534. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33535. useOctreeForPicking: boolean;
  33536. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33537. useOctreeForCollisions: boolean;
  33538. /**
  33539. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33540. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33541. */
  33542. get layerMask(): number;
  33543. set layerMask(value: number);
  33544. /**
  33545. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33546. */
  33547. alwaysSelectAsActiveMesh: boolean;
  33548. /**
  33549. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33550. */
  33551. doNotSyncBoundingInfo: boolean;
  33552. /**
  33553. * Gets or sets the current action manager
  33554. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33555. */
  33556. actionManager: Nullable<AbstractActionManager>;
  33557. private _meshCollisionData;
  33558. /**
  33559. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33560. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33561. */
  33562. ellipsoid: Vector3;
  33563. /**
  33564. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33565. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33566. */
  33567. ellipsoidOffset: Vector3;
  33568. /**
  33569. * Gets or sets a collision mask used to mask collisions (default is -1).
  33570. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33571. */
  33572. get collisionMask(): number;
  33573. set collisionMask(mask: number);
  33574. /**
  33575. * Gets or sets a collision response flag (default is true).
  33576. * when collisionResponse is false, events are still triggered but colliding entity has no response
  33577. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  33578. * to respond to the collision.
  33579. */
  33580. get collisionResponse(): boolean;
  33581. set collisionResponse(response: boolean);
  33582. /**
  33583. * Gets or sets the current collision group mask (-1 by default).
  33584. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33585. */
  33586. get collisionGroup(): number;
  33587. set collisionGroup(mask: number);
  33588. /**
  33589. * Gets or sets current surrounding meshes (null by default).
  33590. *
  33591. * By default collision detection is tested against every mesh in the scene.
  33592. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33593. * meshes will be tested for the collision.
  33594. *
  33595. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33596. */
  33597. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33598. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33599. /**
  33600. * Defines edge width used when edgesRenderer is enabled
  33601. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33602. */
  33603. edgesWidth: number;
  33604. /**
  33605. * Defines edge color used when edgesRenderer is enabled
  33606. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33607. */
  33608. edgesColor: Color4;
  33609. /** @hidden */
  33610. _edgesRenderer: Nullable<IEdgesRenderer>;
  33611. /** @hidden */
  33612. _masterMesh: Nullable<AbstractMesh>;
  33613. /** @hidden */
  33614. _boundingInfo: Nullable<BoundingInfo>;
  33615. /** @hidden */
  33616. _renderId: number;
  33617. /**
  33618. * Gets or sets the list of subMeshes
  33619. * @see https://doc.babylonjs.com/how_to/multi_materials
  33620. */
  33621. subMeshes: SubMesh[];
  33622. /** @hidden */
  33623. _intersectionsInProgress: AbstractMesh[];
  33624. /** @hidden */
  33625. _unIndexed: boolean;
  33626. /** @hidden */
  33627. _lightSources: Light[];
  33628. /** Gets the list of lights affecting that mesh */
  33629. get lightSources(): Light[];
  33630. /** @hidden */
  33631. get _positions(): Nullable<Vector3[]>;
  33632. /** @hidden */
  33633. _waitingData: {
  33634. lods: Nullable<any>;
  33635. actions: Nullable<any>;
  33636. freezeWorldMatrix: Nullable<boolean>;
  33637. };
  33638. /** @hidden */
  33639. _bonesTransformMatrices: Nullable<Float32Array>;
  33640. /** @hidden */
  33641. _transformMatrixTexture: Nullable<RawTexture>;
  33642. /**
  33643. * Gets or sets a skeleton to apply skining transformations
  33644. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33645. */
  33646. set skeleton(value: Nullable<Skeleton>);
  33647. get skeleton(): Nullable<Skeleton>;
  33648. /**
  33649. * An event triggered when the mesh is rebuilt.
  33650. */
  33651. onRebuildObservable: Observable<AbstractMesh>;
  33652. /**
  33653. * Creates a new AbstractMesh
  33654. * @param name defines the name of the mesh
  33655. * @param scene defines the hosting scene
  33656. */
  33657. constructor(name: string, scene?: Nullable<Scene>);
  33658. /**
  33659. * Returns the string "AbstractMesh"
  33660. * @returns "AbstractMesh"
  33661. */
  33662. getClassName(): string;
  33663. /**
  33664. * Gets a string representation of the current mesh
  33665. * @param fullDetails defines a boolean indicating if full details must be included
  33666. * @returns a string representation of the current mesh
  33667. */
  33668. toString(fullDetails?: boolean): string;
  33669. /**
  33670. * @hidden
  33671. */
  33672. protected _getEffectiveParent(): Nullable<Node>;
  33673. /** @hidden */
  33674. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33675. /** @hidden */
  33676. _rebuild(): void;
  33677. /** @hidden */
  33678. _resyncLightSources(): void;
  33679. /** @hidden */
  33680. _resyncLightSource(light: Light): void;
  33681. /** @hidden */
  33682. _unBindEffect(): void;
  33683. /** @hidden */
  33684. _removeLightSource(light: Light, dispose: boolean): void;
  33685. private _markSubMeshesAsDirty;
  33686. /** @hidden */
  33687. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33688. /** @hidden */
  33689. _markSubMeshesAsAttributesDirty(): void;
  33690. /** @hidden */
  33691. _markSubMeshesAsMiscDirty(): void;
  33692. /**
  33693. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33694. */
  33695. get scaling(): Vector3;
  33696. set scaling(newScaling: Vector3);
  33697. /**
  33698. * Returns true if the mesh is blocked. Implemented by child classes
  33699. */
  33700. get isBlocked(): boolean;
  33701. /**
  33702. * Returns the mesh itself by default. Implemented by child classes
  33703. * @param camera defines the camera to use to pick the right LOD level
  33704. * @returns the currentAbstractMesh
  33705. */
  33706. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33707. /**
  33708. * Returns 0 by default. Implemented by child classes
  33709. * @returns an integer
  33710. */
  33711. getTotalVertices(): number;
  33712. /**
  33713. * Returns a positive integer : the total number of indices in this mesh geometry.
  33714. * @returns the numner of indices or zero if the mesh has no geometry.
  33715. */
  33716. getTotalIndices(): number;
  33717. /**
  33718. * Returns null by default. Implemented by child classes
  33719. * @returns null
  33720. */
  33721. getIndices(): Nullable<IndicesArray>;
  33722. /**
  33723. * Returns the array of the requested vertex data kind. Implemented by child classes
  33724. * @param kind defines the vertex data kind to use
  33725. * @returns null
  33726. */
  33727. getVerticesData(kind: string): Nullable<FloatArray>;
  33728. /**
  33729. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33730. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33731. * Note that a new underlying VertexBuffer object is created each call.
  33732. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33733. * @param kind defines vertex data kind:
  33734. * * VertexBuffer.PositionKind
  33735. * * VertexBuffer.UVKind
  33736. * * VertexBuffer.UV2Kind
  33737. * * VertexBuffer.UV3Kind
  33738. * * VertexBuffer.UV4Kind
  33739. * * VertexBuffer.UV5Kind
  33740. * * VertexBuffer.UV6Kind
  33741. * * VertexBuffer.ColorKind
  33742. * * VertexBuffer.MatricesIndicesKind
  33743. * * VertexBuffer.MatricesIndicesExtraKind
  33744. * * VertexBuffer.MatricesWeightsKind
  33745. * * VertexBuffer.MatricesWeightsExtraKind
  33746. * @param data defines the data source
  33747. * @param updatable defines if the data must be flagged as updatable (or static)
  33748. * @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
  33749. * @returns the current mesh
  33750. */
  33751. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33752. /**
  33753. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33754. * If the mesh has no geometry, it is simply returned as it is.
  33755. * @param kind defines vertex data kind:
  33756. * * VertexBuffer.PositionKind
  33757. * * VertexBuffer.UVKind
  33758. * * VertexBuffer.UV2Kind
  33759. * * VertexBuffer.UV3Kind
  33760. * * VertexBuffer.UV4Kind
  33761. * * VertexBuffer.UV5Kind
  33762. * * VertexBuffer.UV6Kind
  33763. * * VertexBuffer.ColorKind
  33764. * * VertexBuffer.MatricesIndicesKind
  33765. * * VertexBuffer.MatricesIndicesExtraKind
  33766. * * VertexBuffer.MatricesWeightsKind
  33767. * * VertexBuffer.MatricesWeightsExtraKind
  33768. * @param data defines the data source
  33769. * @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
  33770. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33771. * @returns the current mesh
  33772. */
  33773. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33774. /**
  33775. * Sets the mesh indices,
  33776. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33777. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33778. * @param totalVertices Defines the total number of vertices
  33779. * @returns the current mesh
  33780. */
  33781. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33782. /**
  33783. * Gets a boolean indicating if specific vertex data is present
  33784. * @param kind defines the vertex data kind to use
  33785. * @returns true is data kind is present
  33786. */
  33787. isVerticesDataPresent(kind: string): boolean;
  33788. /**
  33789. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33790. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33791. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33792. * @returns a BoundingInfo
  33793. */
  33794. getBoundingInfo(): BoundingInfo;
  33795. /**
  33796. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33797. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33798. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33799. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33800. * @returns the current mesh
  33801. */
  33802. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33803. /**
  33804. * Overwrite the current bounding info
  33805. * @param boundingInfo defines the new bounding info
  33806. * @returns the current mesh
  33807. */
  33808. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33809. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33810. get useBones(): boolean;
  33811. /** @hidden */
  33812. _preActivate(): void;
  33813. /** @hidden */
  33814. _preActivateForIntermediateRendering(renderId: number): void;
  33815. /** @hidden */
  33816. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33817. /** @hidden */
  33818. _postActivate(): void;
  33819. /** @hidden */
  33820. _freeze(): void;
  33821. /** @hidden */
  33822. _unFreeze(): void;
  33823. /**
  33824. * Gets the current world matrix
  33825. * @returns a Matrix
  33826. */
  33827. getWorldMatrix(): Matrix;
  33828. /** @hidden */
  33829. _getWorldMatrixDeterminant(): number;
  33830. /**
  33831. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33832. */
  33833. get isAnInstance(): boolean;
  33834. /**
  33835. * Gets a boolean indicating if this mesh has instances
  33836. */
  33837. get hasInstances(): boolean;
  33838. /**
  33839. * Gets a boolean indicating if this mesh has thin instances
  33840. */
  33841. get hasThinInstances(): boolean;
  33842. /**
  33843. * Perform relative position change from the point of view of behind the front of the mesh.
  33844. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33845. * Supports definition of mesh facing forward or backward
  33846. * @param amountRight defines the distance on the right axis
  33847. * @param amountUp defines the distance on the up axis
  33848. * @param amountForward defines the distance on the forward axis
  33849. * @returns the current mesh
  33850. */
  33851. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33852. /**
  33853. * Calculate relative position change from the point of view of behind the front of the mesh.
  33854. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33855. * Supports definition of mesh facing forward or backward
  33856. * @param amountRight defines the distance on the right axis
  33857. * @param amountUp defines the distance on the up axis
  33858. * @param amountForward defines the distance on the forward axis
  33859. * @returns the new displacement vector
  33860. */
  33861. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33862. /**
  33863. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33864. * Supports definition of mesh facing forward or backward
  33865. * @param flipBack defines the flip
  33866. * @param twirlClockwise defines the twirl
  33867. * @param tiltRight defines the tilt
  33868. * @returns the current mesh
  33869. */
  33870. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33871. /**
  33872. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33873. * Supports definition of mesh facing forward or backward.
  33874. * @param flipBack defines the flip
  33875. * @param twirlClockwise defines the twirl
  33876. * @param tiltRight defines the tilt
  33877. * @returns the new rotation vector
  33878. */
  33879. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33880. /**
  33881. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33882. * This means the mesh underlying bounding box and sphere are recomputed.
  33883. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33884. * @returns the current mesh
  33885. */
  33886. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33887. /** @hidden */
  33888. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33889. /** @hidden */
  33890. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33891. /** @hidden */
  33892. _updateBoundingInfo(): AbstractMesh;
  33893. /** @hidden */
  33894. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33895. /** @hidden */
  33896. protected _afterComputeWorldMatrix(): void;
  33897. /** @hidden */
  33898. get _effectiveMesh(): AbstractMesh;
  33899. /**
  33900. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33901. * A mesh is in the frustum if its bounding box intersects the frustum
  33902. * @param frustumPlanes defines the frustum to test
  33903. * @returns true if the mesh is in the frustum planes
  33904. */
  33905. isInFrustum(frustumPlanes: Plane[]): boolean;
  33906. /**
  33907. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33908. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33909. * @param frustumPlanes defines the frustum to test
  33910. * @returns true if the mesh is completely in the frustum planes
  33911. */
  33912. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33913. /**
  33914. * True if the mesh intersects another mesh or a SolidParticle object
  33915. * @param mesh defines a target mesh or SolidParticle to test
  33916. * @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)
  33917. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33918. * @returns true if there is an intersection
  33919. */
  33920. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33921. /**
  33922. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33923. * @param point defines the point to test
  33924. * @returns true if there is an intersection
  33925. */
  33926. intersectsPoint(point: Vector3): boolean;
  33927. /**
  33928. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33929. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33930. */
  33931. get checkCollisions(): boolean;
  33932. set checkCollisions(collisionEnabled: boolean);
  33933. /**
  33934. * Gets Collider object used to compute collisions (not physics)
  33935. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33936. */
  33937. get collider(): Nullable<Collider>;
  33938. /**
  33939. * Move the mesh using collision engine
  33940. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33941. * @param displacement defines the requested displacement vector
  33942. * @returns the current mesh
  33943. */
  33944. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33945. private _onCollisionPositionChange;
  33946. /** @hidden */
  33947. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33948. /** @hidden */
  33949. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33950. /** @hidden */
  33951. _checkCollision(collider: Collider): AbstractMesh;
  33952. /** @hidden */
  33953. _generatePointsArray(): boolean;
  33954. /**
  33955. * Checks if the passed Ray intersects with the mesh
  33956. * @param ray defines the ray to use
  33957. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33958. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33959. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33960. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33961. * @returns the picking info
  33962. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33963. */
  33964. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33965. /**
  33966. * Clones the current mesh
  33967. * @param name defines the mesh name
  33968. * @param newParent defines the new mesh parent
  33969. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33970. * @returns the new mesh
  33971. */
  33972. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33973. /**
  33974. * Disposes all the submeshes of the current meshnp
  33975. * @returns the current mesh
  33976. */
  33977. releaseSubMeshes(): AbstractMesh;
  33978. /**
  33979. * Releases resources associated with this abstract mesh.
  33980. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33981. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33982. */
  33983. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33984. /**
  33985. * Adds the passed mesh as a child to the current mesh
  33986. * @param mesh defines the child mesh
  33987. * @returns the current mesh
  33988. */
  33989. addChild(mesh: AbstractMesh): AbstractMesh;
  33990. /**
  33991. * Removes the passed mesh from the current mesh children list
  33992. * @param mesh defines the child mesh
  33993. * @returns the current mesh
  33994. */
  33995. removeChild(mesh: AbstractMesh): AbstractMesh;
  33996. /** @hidden */
  33997. private _initFacetData;
  33998. /**
  33999. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  34000. * This method can be called within the render loop.
  34001. * 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
  34002. * @returns the current mesh
  34003. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34004. */
  34005. updateFacetData(): AbstractMesh;
  34006. /**
  34007. * Returns the facetLocalNormals array.
  34008. * The normals are expressed in the mesh local spac
  34009. * @returns an array of Vector3
  34010. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34011. */
  34012. getFacetLocalNormals(): Vector3[];
  34013. /**
  34014. * Returns the facetLocalPositions array.
  34015. * The facet positions are expressed in the mesh local space
  34016. * @returns an array of Vector3
  34017. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34018. */
  34019. getFacetLocalPositions(): Vector3[];
  34020. /**
  34021. * Returns the facetLocalPartioning array
  34022. * @returns an array of array of numbers
  34023. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34024. */
  34025. getFacetLocalPartitioning(): number[][];
  34026. /**
  34027. * Returns the i-th facet position in the world system.
  34028. * This method allocates a new Vector3 per call
  34029. * @param i defines the facet index
  34030. * @returns a new Vector3
  34031. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34032. */
  34033. getFacetPosition(i: number): Vector3;
  34034. /**
  34035. * Sets the reference Vector3 with the i-th facet position in the world system
  34036. * @param i defines the facet index
  34037. * @param ref defines the target vector
  34038. * @returns the current mesh
  34039. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34040. */
  34041. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  34042. /**
  34043. * Returns the i-th facet normal in the world system.
  34044. * This method allocates a new Vector3 per call
  34045. * @param i defines the facet index
  34046. * @returns a new Vector3
  34047. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34048. */
  34049. getFacetNormal(i: number): Vector3;
  34050. /**
  34051. * Sets the reference Vector3 with the i-th facet normal in the world system
  34052. * @param i defines the facet index
  34053. * @param ref defines the target vector
  34054. * @returns the current mesh
  34055. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34056. */
  34057. getFacetNormalToRef(i: number, ref: Vector3): this;
  34058. /**
  34059. * 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)
  34060. * @param x defines x coordinate
  34061. * @param y defines y coordinate
  34062. * @param z defines z coordinate
  34063. * @returns the array of facet indexes
  34064. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34065. */
  34066. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  34067. /**
  34068. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  34069. * @param projected sets as the (x,y,z) world projection on the facet
  34070. * @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
  34071. * @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
  34072. * @param x defines x coordinate
  34073. * @param y defines y coordinate
  34074. * @param z defines z coordinate
  34075. * @returns the face index if found (or null instead)
  34076. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34077. */
  34078. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  34079. /**
  34080. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  34081. * @param projected sets as the (x,y,z) local projection on the facet
  34082. * @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
  34083. * @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
  34084. * @param x defines x coordinate
  34085. * @param y defines y coordinate
  34086. * @param z defines z coordinate
  34087. * @returns the face index if found (or null instead)
  34088. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34089. */
  34090. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  34091. /**
  34092. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  34093. * @returns the parameters
  34094. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34095. */
  34096. getFacetDataParameters(): any;
  34097. /**
  34098. * Disables the feature FacetData and frees the related memory
  34099. * @returns the current mesh
  34100. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34101. */
  34102. disableFacetData(): AbstractMesh;
  34103. /**
  34104. * Updates the AbstractMesh indices array
  34105. * @param indices defines the data source
  34106. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34107. * @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)
  34108. * @returns the current mesh
  34109. */
  34110. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34111. /**
  34112. * Creates new normals data for the mesh
  34113. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  34114. * @returns the current mesh
  34115. */
  34116. createNormals(updatable: boolean): AbstractMesh;
  34117. /**
  34118. * Align the mesh with a normal
  34119. * @param normal defines the normal to use
  34120. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  34121. * @returns the current mesh
  34122. */
  34123. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  34124. /** @hidden */
  34125. _checkOcclusionQuery(): boolean;
  34126. /**
  34127. * Disables the mesh edge rendering mode
  34128. * @returns the currentAbstractMesh
  34129. */
  34130. disableEdgesRendering(): AbstractMesh;
  34131. /**
  34132. * Enables the edge rendering mode on the mesh.
  34133. * This mode makes the mesh edges visible
  34134. * @param epsilon defines the maximal distance between two angles to detect a face
  34135. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34136. * @returns the currentAbstractMesh
  34137. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34138. */
  34139. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34140. /**
  34141. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  34142. * @returns an array of particle systems in the scene that use the mesh as an emitter
  34143. */
  34144. getConnectedParticleSystems(): IParticleSystem[];
  34145. }
  34146. }
  34147. declare module "babylonjs/Actions/actionEvent" {
  34148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34149. import { Nullable } from "babylonjs/types";
  34150. import { Sprite } from "babylonjs/Sprites/sprite";
  34151. import { Scene } from "babylonjs/scene";
  34152. import { Vector2 } from "babylonjs/Maths/math.vector";
  34153. /**
  34154. * Interface used to define ActionEvent
  34155. */
  34156. export interface IActionEvent {
  34157. /** The mesh or sprite that triggered the action */
  34158. source: any;
  34159. /** The X mouse cursor position at the time of the event */
  34160. pointerX: number;
  34161. /** The Y mouse cursor position at the time of the event */
  34162. pointerY: number;
  34163. /** The mesh that is currently pointed at (can be null) */
  34164. meshUnderPointer: Nullable<AbstractMesh>;
  34165. /** the original (browser) event that triggered the ActionEvent */
  34166. sourceEvent?: any;
  34167. /** additional data for the event */
  34168. additionalData?: any;
  34169. }
  34170. /**
  34171. * ActionEvent is the event being sent when an action is triggered.
  34172. */
  34173. export class ActionEvent implements IActionEvent {
  34174. /** The mesh or sprite that triggered the action */
  34175. source: any;
  34176. /** The X mouse cursor position at the time of the event */
  34177. pointerX: number;
  34178. /** The Y mouse cursor position at the time of the event */
  34179. pointerY: number;
  34180. /** The mesh that is currently pointed at (can be null) */
  34181. meshUnderPointer: Nullable<AbstractMesh>;
  34182. /** the original (browser) event that triggered the ActionEvent */
  34183. sourceEvent?: any;
  34184. /** additional data for the event */
  34185. additionalData?: any;
  34186. /**
  34187. * Creates a new ActionEvent
  34188. * @param source The mesh or sprite that triggered the action
  34189. * @param pointerX The X mouse cursor position at the time of the event
  34190. * @param pointerY The Y mouse cursor position at the time of the event
  34191. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  34192. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  34193. * @param additionalData additional data for the event
  34194. */
  34195. constructor(
  34196. /** The mesh or sprite that triggered the action */
  34197. source: any,
  34198. /** The X mouse cursor position at the time of the event */
  34199. pointerX: number,
  34200. /** The Y mouse cursor position at the time of the event */
  34201. pointerY: number,
  34202. /** The mesh that is currently pointed at (can be null) */
  34203. meshUnderPointer: Nullable<AbstractMesh>,
  34204. /** the original (browser) event that triggered the ActionEvent */
  34205. sourceEvent?: any,
  34206. /** additional data for the event */
  34207. additionalData?: any);
  34208. /**
  34209. * Helper function to auto-create an ActionEvent from a source mesh.
  34210. * @param source The source mesh that triggered the event
  34211. * @param evt The original (browser) event
  34212. * @param additionalData additional data for the event
  34213. * @returns the new ActionEvent
  34214. */
  34215. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34216. /**
  34217. * Helper function to auto-create an ActionEvent from a source sprite
  34218. * @param source The source sprite that triggered the event
  34219. * @param scene Scene associated with the sprite
  34220. * @param evt The original (browser) event
  34221. * @param additionalData additional data for the event
  34222. * @returns the new ActionEvent
  34223. */
  34224. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34225. /**
  34226. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34227. * @param scene the scene where the event occurred
  34228. * @param evt The original (browser) event
  34229. * @returns the new ActionEvent
  34230. */
  34231. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34232. /**
  34233. * Helper function to auto-create an ActionEvent from a primitive
  34234. * @param prim defines the target primitive
  34235. * @param pointerPos defines the pointer position
  34236. * @param evt The original (browser) event
  34237. * @param additionalData additional data for the event
  34238. * @returns the new ActionEvent
  34239. */
  34240. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34241. }
  34242. }
  34243. declare module "babylonjs/Actions/abstractActionManager" {
  34244. import { IDisposable } from "babylonjs/scene";
  34245. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34246. import { IAction } from "babylonjs/Actions/action";
  34247. import { Nullable } from "babylonjs/types";
  34248. /**
  34249. * Abstract class used to decouple action Manager from scene and meshes.
  34250. * Do not instantiate.
  34251. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34252. */
  34253. export abstract class AbstractActionManager implements IDisposable {
  34254. /** Gets the list of active triggers */
  34255. static Triggers: {
  34256. [key: string]: number;
  34257. };
  34258. /** Gets the cursor to use when hovering items */
  34259. hoverCursor: string;
  34260. /** Gets the list of actions */
  34261. actions: IAction[];
  34262. /**
  34263. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34264. */
  34265. isRecursive: boolean;
  34266. /**
  34267. * Releases all associated resources
  34268. */
  34269. abstract dispose(): void;
  34270. /**
  34271. * Does this action manager has pointer triggers
  34272. */
  34273. abstract get hasPointerTriggers(): boolean;
  34274. /**
  34275. * Does this action manager has pick triggers
  34276. */
  34277. abstract get hasPickTriggers(): boolean;
  34278. /**
  34279. * Process a specific trigger
  34280. * @param trigger defines the trigger to process
  34281. * @param evt defines the event details to be processed
  34282. */
  34283. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34284. /**
  34285. * Does this action manager handles actions of any of the given triggers
  34286. * @param triggers defines the triggers to be tested
  34287. * @return a boolean indicating whether one (or more) of the triggers is handled
  34288. */
  34289. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34290. /**
  34291. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34292. * speed.
  34293. * @param triggerA defines the trigger to be tested
  34294. * @param triggerB defines the trigger to be tested
  34295. * @return a boolean indicating whether one (or more) of the triggers is handled
  34296. */
  34297. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34298. /**
  34299. * Does this action manager handles actions of a given trigger
  34300. * @param trigger defines the trigger to be tested
  34301. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34302. * @return whether the trigger is handled
  34303. */
  34304. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34305. /**
  34306. * Serialize this manager to a JSON object
  34307. * @param name defines the property name to store this manager
  34308. * @returns a JSON representation of this manager
  34309. */
  34310. abstract serialize(name: string): any;
  34311. /**
  34312. * Registers an action to this action manager
  34313. * @param action defines the action to be registered
  34314. * @return the action amended (prepared) after registration
  34315. */
  34316. abstract registerAction(action: IAction): Nullable<IAction>;
  34317. /**
  34318. * Unregisters an action to this action manager
  34319. * @param action defines the action to be unregistered
  34320. * @return a boolean indicating whether the action has been unregistered
  34321. */
  34322. abstract unregisterAction(action: IAction): Boolean;
  34323. /**
  34324. * Does exist one action manager with at least one trigger
  34325. **/
  34326. static get HasTriggers(): boolean;
  34327. /**
  34328. * Does exist one action manager with at least one pick trigger
  34329. **/
  34330. static get HasPickTriggers(): boolean;
  34331. /**
  34332. * Does exist one action manager that handles actions of a given trigger
  34333. * @param trigger defines the trigger to be tested
  34334. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34335. **/
  34336. static HasSpecificTrigger(trigger: number): boolean;
  34337. }
  34338. }
  34339. declare module "babylonjs/node" {
  34340. import { Scene } from "babylonjs/scene";
  34341. import { Nullable } from "babylonjs/types";
  34342. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34343. import { Engine } from "babylonjs/Engines/engine";
  34344. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34345. import { Observable } from "babylonjs/Misc/observable";
  34346. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34347. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34348. import { Animatable } from "babylonjs/Animations/animatable";
  34349. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34350. import { Animation } from "babylonjs/Animations/animation";
  34351. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34353. /**
  34354. * Defines how a node can be built from a string name.
  34355. */
  34356. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34357. /**
  34358. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34359. */
  34360. export class Node implements IBehaviorAware<Node> {
  34361. /** @hidden */
  34362. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34363. private static _NodeConstructors;
  34364. /**
  34365. * Add a new node constructor
  34366. * @param type defines the type name of the node to construct
  34367. * @param constructorFunc defines the constructor function
  34368. */
  34369. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34370. /**
  34371. * Returns a node constructor based on type name
  34372. * @param type defines the type name
  34373. * @param name defines the new node name
  34374. * @param scene defines the hosting scene
  34375. * @param options defines optional options to transmit to constructors
  34376. * @returns the new constructor or null
  34377. */
  34378. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34379. /**
  34380. * Gets or sets the name of the node
  34381. */
  34382. name: string;
  34383. /**
  34384. * Gets or sets the id of the node
  34385. */
  34386. id: string;
  34387. /**
  34388. * Gets or sets the unique id of the node
  34389. */
  34390. uniqueId: number;
  34391. /**
  34392. * Gets or sets a string used to store user defined state for the node
  34393. */
  34394. state: string;
  34395. /**
  34396. * Gets or sets an object used to store user defined information for the node
  34397. */
  34398. metadata: any;
  34399. /**
  34400. * For internal use only. Please do not use.
  34401. */
  34402. reservedDataStore: any;
  34403. /**
  34404. * List of inspectable custom properties (used by the Inspector)
  34405. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34406. */
  34407. inspectableCustomProperties: IInspectable[];
  34408. private _doNotSerialize;
  34409. /**
  34410. * Gets or sets a boolean used to define if the node must be serialized
  34411. */
  34412. get doNotSerialize(): boolean;
  34413. set doNotSerialize(value: boolean);
  34414. /** @hidden */
  34415. _isDisposed: boolean;
  34416. /**
  34417. * Gets a list of Animations associated with the node
  34418. */
  34419. animations: import("babylonjs/Animations/animation").Animation[];
  34420. protected _ranges: {
  34421. [name: string]: Nullable<AnimationRange>;
  34422. };
  34423. /**
  34424. * Callback raised when the node is ready to be used
  34425. */
  34426. onReady: Nullable<(node: Node) => void>;
  34427. private _isEnabled;
  34428. private _isParentEnabled;
  34429. private _isReady;
  34430. /** @hidden */
  34431. _currentRenderId: number;
  34432. private _parentUpdateId;
  34433. /** @hidden */
  34434. _childUpdateId: number;
  34435. /** @hidden */
  34436. _waitingParentId: Nullable<string>;
  34437. /** @hidden */
  34438. _scene: Scene;
  34439. /** @hidden */
  34440. _cache: any;
  34441. private _parentNode;
  34442. private _children;
  34443. /** @hidden */
  34444. _worldMatrix: Matrix;
  34445. /** @hidden */
  34446. _worldMatrixDeterminant: number;
  34447. /** @hidden */
  34448. _worldMatrixDeterminantIsDirty: boolean;
  34449. /** @hidden */
  34450. private _sceneRootNodesIndex;
  34451. /**
  34452. * Gets a boolean indicating if the node has been disposed
  34453. * @returns true if the node was disposed
  34454. */
  34455. isDisposed(): boolean;
  34456. /**
  34457. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34458. * @see https://doc.babylonjs.com/how_to/parenting
  34459. */
  34460. set parent(parent: Nullable<Node>);
  34461. get parent(): Nullable<Node>;
  34462. /** @hidden */
  34463. _addToSceneRootNodes(): void;
  34464. /** @hidden */
  34465. _removeFromSceneRootNodes(): void;
  34466. private _animationPropertiesOverride;
  34467. /**
  34468. * Gets or sets the animation properties override
  34469. */
  34470. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34471. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34472. /**
  34473. * Gets a string identifying the name of the class
  34474. * @returns "Node" string
  34475. */
  34476. getClassName(): string;
  34477. /** @hidden */
  34478. readonly _isNode: boolean;
  34479. /**
  34480. * An event triggered when the mesh is disposed
  34481. */
  34482. onDisposeObservable: Observable<Node>;
  34483. private _onDisposeObserver;
  34484. /**
  34485. * Sets a callback that will be raised when the node will be disposed
  34486. */
  34487. set onDispose(callback: () => void);
  34488. /**
  34489. * Creates a new Node
  34490. * @param name the name and id to be given to this node
  34491. * @param scene the scene this node will be added to
  34492. */
  34493. constructor(name: string, scene?: Nullable<Scene>);
  34494. /**
  34495. * Gets the scene of the node
  34496. * @returns a scene
  34497. */
  34498. getScene(): Scene;
  34499. /**
  34500. * Gets the engine of the node
  34501. * @returns a Engine
  34502. */
  34503. getEngine(): Engine;
  34504. private _behaviors;
  34505. /**
  34506. * Attach a behavior to the node
  34507. * @see https://doc.babylonjs.com/features/behaviour
  34508. * @param behavior defines the behavior to attach
  34509. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34510. * @returns the current Node
  34511. */
  34512. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34513. /**
  34514. * Remove an attached behavior
  34515. * @see https://doc.babylonjs.com/features/behaviour
  34516. * @param behavior defines the behavior to attach
  34517. * @returns the current Node
  34518. */
  34519. removeBehavior(behavior: Behavior<Node>): Node;
  34520. /**
  34521. * Gets the list of attached behaviors
  34522. * @see https://doc.babylonjs.com/features/behaviour
  34523. */
  34524. get behaviors(): Behavior<Node>[];
  34525. /**
  34526. * Gets an attached behavior by name
  34527. * @param name defines the name of the behavior to look for
  34528. * @see https://doc.babylonjs.com/features/behaviour
  34529. * @returns null if behavior was not found else the requested behavior
  34530. */
  34531. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34532. /**
  34533. * Returns the latest update of the World matrix
  34534. * @returns a Matrix
  34535. */
  34536. getWorldMatrix(): Matrix;
  34537. /** @hidden */
  34538. _getWorldMatrixDeterminant(): number;
  34539. /**
  34540. * Returns directly the latest state of the mesh World matrix.
  34541. * A Matrix is returned.
  34542. */
  34543. get worldMatrixFromCache(): Matrix;
  34544. /** @hidden */
  34545. _initCache(): void;
  34546. /** @hidden */
  34547. updateCache(force?: boolean): void;
  34548. /** @hidden */
  34549. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34550. /** @hidden */
  34551. _updateCache(ignoreParentClass?: boolean): void;
  34552. /** @hidden */
  34553. _isSynchronized(): boolean;
  34554. /** @hidden */
  34555. _markSyncedWithParent(): void;
  34556. /** @hidden */
  34557. isSynchronizedWithParent(): boolean;
  34558. /** @hidden */
  34559. isSynchronized(): boolean;
  34560. /**
  34561. * Is this node ready to be used/rendered
  34562. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34563. * @return true if the node is ready
  34564. */
  34565. isReady(completeCheck?: boolean): boolean;
  34566. /**
  34567. * Is this node enabled?
  34568. * 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
  34569. * @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
  34570. * @return whether this node (and its parent) is enabled
  34571. */
  34572. isEnabled(checkAncestors?: boolean): boolean;
  34573. /** @hidden */
  34574. protected _syncParentEnabledState(): void;
  34575. /**
  34576. * Set the enabled state of this node
  34577. * @param value defines the new enabled state
  34578. */
  34579. setEnabled(value: boolean): void;
  34580. /**
  34581. * Is this node a descendant of the given node?
  34582. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34583. * @param ancestor defines the parent node to inspect
  34584. * @returns a boolean indicating if this node is a descendant of the given node
  34585. */
  34586. isDescendantOf(ancestor: Node): boolean;
  34587. /** @hidden */
  34588. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34589. /**
  34590. * Will return all nodes that have this node as ascendant
  34591. * @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
  34592. * @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
  34593. * @return all children nodes of all types
  34594. */
  34595. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34596. /**
  34597. * Get all child-meshes of this node
  34598. * @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)
  34599. * @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
  34600. * @returns an array of AbstractMesh
  34601. */
  34602. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34603. /**
  34604. * Get all direct children of this node
  34605. * @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
  34606. * @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)
  34607. * @returns an array of Node
  34608. */
  34609. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34610. /** @hidden */
  34611. _setReady(state: boolean): void;
  34612. /**
  34613. * Get an animation by name
  34614. * @param name defines the name of the animation to look for
  34615. * @returns null if not found else the requested animation
  34616. */
  34617. getAnimationByName(name: string): Nullable<Animation>;
  34618. /**
  34619. * Creates an animation range for this node
  34620. * @param name defines the name of the range
  34621. * @param from defines the starting key
  34622. * @param to defines the end key
  34623. */
  34624. createAnimationRange(name: string, from: number, to: number): void;
  34625. /**
  34626. * Delete a specific animation range
  34627. * @param name defines the name of the range to delete
  34628. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34629. */
  34630. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34631. /**
  34632. * Get an animation range by name
  34633. * @param name defines the name of the animation range to look for
  34634. * @returns null if not found else the requested animation range
  34635. */
  34636. getAnimationRange(name: string): Nullable<AnimationRange>;
  34637. /**
  34638. * Gets the list of all animation ranges defined on this node
  34639. * @returns an array
  34640. */
  34641. getAnimationRanges(): Nullable<AnimationRange>[];
  34642. /**
  34643. * Will start the animation sequence
  34644. * @param name defines the range frames for animation sequence
  34645. * @param loop defines if the animation should loop (false by default)
  34646. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34647. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34648. * @returns the object created for this animation. If range does not exist, it will return null
  34649. */
  34650. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34651. /**
  34652. * Serialize animation ranges into a JSON compatible object
  34653. * @returns serialization object
  34654. */
  34655. serializeAnimationRanges(): any;
  34656. /**
  34657. * Computes the world matrix of the node
  34658. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34659. * @returns the world matrix
  34660. */
  34661. computeWorldMatrix(force?: boolean): Matrix;
  34662. /**
  34663. * Releases resources associated with this node.
  34664. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34665. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34666. */
  34667. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34668. /**
  34669. * Parse animation range data from a serialization object and store them into a given node
  34670. * @param node defines where to store the animation ranges
  34671. * @param parsedNode defines the serialization object to read data from
  34672. * @param scene defines the hosting scene
  34673. */
  34674. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34675. /**
  34676. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34677. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34678. * @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
  34679. * @returns the new bounding vectors
  34680. */
  34681. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34682. min: Vector3;
  34683. max: Vector3;
  34684. };
  34685. }
  34686. }
  34687. declare module "babylonjs/Animations/animation" {
  34688. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34689. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34690. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34691. import { Nullable } from "babylonjs/types";
  34692. import { Scene } from "babylonjs/scene";
  34693. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34694. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34695. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34696. import { Node } from "babylonjs/node";
  34697. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34698. import { Size } from "babylonjs/Maths/math.size";
  34699. import { Animatable } from "babylonjs/Animations/animatable";
  34700. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34701. /**
  34702. * @hidden
  34703. */
  34704. export class _IAnimationState {
  34705. key: number;
  34706. repeatCount: number;
  34707. workValue?: any;
  34708. loopMode?: number;
  34709. offsetValue?: any;
  34710. highLimitValue?: any;
  34711. }
  34712. /**
  34713. * Class used to store any kind of animation
  34714. */
  34715. export class Animation {
  34716. /**Name of the animation */
  34717. name: string;
  34718. /**Property to animate */
  34719. targetProperty: string;
  34720. /**The frames per second of the animation */
  34721. framePerSecond: number;
  34722. /**The data type of the animation */
  34723. dataType: number;
  34724. /**The loop mode of the animation */
  34725. loopMode?: number | undefined;
  34726. /**Specifies if blending should be enabled */
  34727. enableBlending?: boolean | undefined;
  34728. /**
  34729. * Use matrix interpolation instead of using direct key value when animating matrices
  34730. */
  34731. static AllowMatricesInterpolation: boolean;
  34732. /**
  34733. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34734. */
  34735. static AllowMatrixDecomposeForInterpolation: boolean;
  34736. /** Define the Url to load snippets */
  34737. static SnippetUrl: string;
  34738. /** Snippet ID if the animation was created from the snippet server */
  34739. snippetId: string;
  34740. /**
  34741. * Stores the key frames of the animation
  34742. */
  34743. private _keys;
  34744. /**
  34745. * Stores the easing function of the animation
  34746. */
  34747. private _easingFunction;
  34748. /**
  34749. * @hidden Internal use only
  34750. */
  34751. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34752. /**
  34753. * The set of event that will be linked to this animation
  34754. */
  34755. private _events;
  34756. /**
  34757. * Stores an array of target property paths
  34758. */
  34759. targetPropertyPath: string[];
  34760. /**
  34761. * Stores the blending speed of the animation
  34762. */
  34763. blendingSpeed: number;
  34764. /**
  34765. * Stores the animation ranges for the animation
  34766. */
  34767. private _ranges;
  34768. /**
  34769. * @hidden Internal use
  34770. */
  34771. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34772. /**
  34773. * Sets up an animation
  34774. * @param property The property to animate
  34775. * @param animationType The animation type to apply
  34776. * @param framePerSecond The frames per second of the animation
  34777. * @param easingFunction The easing function used in the animation
  34778. * @returns The created animation
  34779. */
  34780. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34781. /**
  34782. * Create and start an animation on a node
  34783. * @param name defines the name of the global animation that will be run on all nodes
  34784. * @param node defines the root node where the animation will take place
  34785. * @param targetProperty defines property to animate
  34786. * @param framePerSecond defines the number of frame per second yo use
  34787. * @param totalFrame defines the number of frames in total
  34788. * @param from defines the initial value
  34789. * @param to defines the final value
  34790. * @param loopMode defines which loop mode you want to use (off by default)
  34791. * @param easingFunction defines the easing function to use (linear by default)
  34792. * @param onAnimationEnd defines the callback to call when animation end
  34793. * @returns the animatable created for this animation
  34794. */
  34795. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34796. /**
  34797. * Create and start an animation on a node and its descendants
  34798. * @param name defines the name of the global animation that will be run on all nodes
  34799. * @param node defines the root node where the animation will take place
  34800. * @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
  34801. * @param targetProperty defines property to animate
  34802. * @param framePerSecond defines the number of frame per second to use
  34803. * @param totalFrame defines the number of frames in total
  34804. * @param from defines the initial value
  34805. * @param to defines the final value
  34806. * @param loopMode defines which loop mode you want to use (off by default)
  34807. * @param easingFunction defines the easing function to use (linear by default)
  34808. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34809. * @returns the list of animatables created for all nodes
  34810. * @example https://www.babylonjs-playground.com/#MH0VLI
  34811. */
  34812. 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[]>;
  34813. /**
  34814. * Creates a new animation, merges it with the existing animations and starts it
  34815. * @param name Name of the animation
  34816. * @param node Node which contains the scene that begins the animations
  34817. * @param targetProperty Specifies which property to animate
  34818. * @param framePerSecond The frames per second of the animation
  34819. * @param totalFrame The total number of frames
  34820. * @param from The frame at the beginning of the animation
  34821. * @param to The frame at the end of the animation
  34822. * @param loopMode Specifies the loop mode of the animation
  34823. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34824. * @param onAnimationEnd Callback to run once the animation is complete
  34825. * @returns Nullable animation
  34826. */
  34827. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34828. /**
  34829. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34830. * @param sourceAnimation defines the Animation containing keyframes to convert
  34831. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34832. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34833. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34834. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34835. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34836. */
  34837. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34838. /**
  34839. * Transition property of an host to the target Value
  34840. * @param property The property to transition
  34841. * @param targetValue The target Value of the property
  34842. * @param host The object where the property to animate belongs
  34843. * @param scene Scene used to run the animation
  34844. * @param frameRate Framerate (in frame/s) to use
  34845. * @param transition The transition type we want to use
  34846. * @param duration The duration of the animation, in milliseconds
  34847. * @param onAnimationEnd Callback trigger at the end of the animation
  34848. * @returns Nullable animation
  34849. */
  34850. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34851. /**
  34852. * Return the array of runtime animations currently using this animation
  34853. */
  34854. get runtimeAnimations(): RuntimeAnimation[];
  34855. /**
  34856. * Specifies if any of the runtime animations are currently running
  34857. */
  34858. get hasRunningRuntimeAnimations(): boolean;
  34859. /**
  34860. * Initializes the animation
  34861. * @param name Name of the animation
  34862. * @param targetProperty Property to animate
  34863. * @param framePerSecond The frames per second of the animation
  34864. * @param dataType The data type of the animation
  34865. * @param loopMode The loop mode of the animation
  34866. * @param enableBlending Specifies if blending should be enabled
  34867. */
  34868. constructor(
  34869. /**Name of the animation */
  34870. name: string,
  34871. /**Property to animate */
  34872. targetProperty: string,
  34873. /**The frames per second of the animation */
  34874. framePerSecond: number,
  34875. /**The data type of the animation */
  34876. dataType: number,
  34877. /**The loop mode of the animation */
  34878. loopMode?: number | undefined,
  34879. /**Specifies if blending should be enabled */
  34880. enableBlending?: boolean | undefined);
  34881. /**
  34882. * Converts the animation to a string
  34883. * @param fullDetails support for multiple levels of logging within scene loading
  34884. * @returns String form of the animation
  34885. */
  34886. toString(fullDetails?: boolean): string;
  34887. /**
  34888. * Add an event to this animation
  34889. * @param event Event to add
  34890. */
  34891. addEvent(event: AnimationEvent): void;
  34892. /**
  34893. * Remove all events found at the given frame
  34894. * @param frame The frame to remove events from
  34895. */
  34896. removeEvents(frame: number): void;
  34897. /**
  34898. * Retrieves all the events from the animation
  34899. * @returns Events from the animation
  34900. */
  34901. getEvents(): AnimationEvent[];
  34902. /**
  34903. * Creates an animation range
  34904. * @param name Name of the animation range
  34905. * @param from Starting frame of the animation range
  34906. * @param to Ending frame of the animation
  34907. */
  34908. createRange(name: string, from: number, to: number): void;
  34909. /**
  34910. * Deletes an animation range by name
  34911. * @param name Name of the animation range to delete
  34912. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34913. */
  34914. deleteRange(name: string, deleteFrames?: boolean): void;
  34915. /**
  34916. * Gets the animation range by name, or null if not defined
  34917. * @param name Name of the animation range
  34918. * @returns Nullable animation range
  34919. */
  34920. getRange(name: string): Nullable<AnimationRange>;
  34921. /**
  34922. * Gets the key frames from the animation
  34923. * @returns The key frames of the animation
  34924. */
  34925. getKeys(): Array<IAnimationKey>;
  34926. /**
  34927. * Gets the highest frame rate of the animation
  34928. * @returns Highest frame rate of the animation
  34929. */
  34930. getHighestFrame(): number;
  34931. /**
  34932. * Gets the easing function of the animation
  34933. * @returns Easing function of the animation
  34934. */
  34935. getEasingFunction(): IEasingFunction;
  34936. /**
  34937. * Sets the easing function of the animation
  34938. * @param easingFunction A custom mathematical formula for animation
  34939. */
  34940. setEasingFunction(easingFunction: EasingFunction): void;
  34941. /**
  34942. * Interpolates a scalar linearly
  34943. * @param startValue Start value of the animation curve
  34944. * @param endValue End value of the animation curve
  34945. * @param gradient Scalar amount to interpolate
  34946. * @returns Interpolated scalar value
  34947. */
  34948. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34949. /**
  34950. * Interpolates a scalar cubically
  34951. * @param startValue Start value of the animation curve
  34952. * @param outTangent End tangent of the animation
  34953. * @param endValue End value of the animation curve
  34954. * @param inTangent Start tangent of the animation curve
  34955. * @param gradient Scalar amount to interpolate
  34956. * @returns Interpolated scalar value
  34957. */
  34958. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34959. /**
  34960. * Interpolates a quaternion using a spherical linear interpolation
  34961. * @param startValue Start value of the animation curve
  34962. * @param endValue End value of the animation curve
  34963. * @param gradient Scalar amount to interpolate
  34964. * @returns Interpolated quaternion value
  34965. */
  34966. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34967. /**
  34968. * Interpolates a quaternion cubically
  34969. * @param startValue Start value of the animation curve
  34970. * @param outTangent End tangent of the animation curve
  34971. * @param endValue End value of the animation curve
  34972. * @param inTangent Start tangent of the animation curve
  34973. * @param gradient Scalar amount to interpolate
  34974. * @returns Interpolated quaternion value
  34975. */
  34976. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34977. /**
  34978. * Interpolates a Vector3 linearl
  34979. * @param startValue Start value of the animation curve
  34980. * @param endValue End value of the animation curve
  34981. * @param gradient Scalar amount to interpolate
  34982. * @returns Interpolated scalar value
  34983. */
  34984. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34985. /**
  34986. * Interpolates a Vector3 cubically
  34987. * @param startValue Start value of the animation curve
  34988. * @param outTangent End tangent of the animation
  34989. * @param endValue End value of the animation curve
  34990. * @param inTangent Start tangent of the animation curve
  34991. * @param gradient Scalar amount to interpolate
  34992. * @returns InterpolatedVector3 value
  34993. */
  34994. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34995. /**
  34996. * Interpolates a Vector2 linearly
  34997. * @param startValue Start value of the animation curve
  34998. * @param endValue End value of the animation curve
  34999. * @param gradient Scalar amount to interpolate
  35000. * @returns Interpolated Vector2 value
  35001. */
  35002. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  35003. /**
  35004. * Interpolates a Vector2 cubically
  35005. * @param startValue Start value of the animation curve
  35006. * @param outTangent End tangent of the animation
  35007. * @param endValue End value of the animation curve
  35008. * @param inTangent Start tangent of the animation curve
  35009. * @param gradient Scalar amount to interpolate
  35010. * @returns Interpolated Vector2 value
  35011. */
  35012. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  35013. /**
  35014. * Interpolates a size linearly
  35015. * @param startValue Start value of the animation curve
  35016. * @param endValue End value of the animation curve
  35017. * @param gradient Scalar amount to interpolate
  35018. * @returns Interpolated Size value
  35019. */
  35020. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  35021. /**
  35022. * Interpolates a Color3 linearly
  35023. * @param startValue Start value of the animation curve
  35024. * @param endValue End value of the animation curve
  35025. * @param gradient Scalar amount to interpolate
  35026. * @returns Interpolated Color3 value
  35027. */
  35028. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  35029. /**
  35030. * Interpolates a Color4 linearly
  35031. * @param startValue Start value of the animation curve
  35032. * @param endValue End value of the animation curve
  35033. * @param gradient Scalar amount to interpolate
  35034. * @returns Interpolated Color3 value
  35035. */
  35036. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  35037. /**
  35038. * @hidden Internal use only
  35039. */
  35040. _getKeyValue(value: any): any;
  35041. /**
  35042. * @hidden Internal use only
  35043. */
  35044. _interpolate(currentFrame: number, state: _IAnimationState): any;
  35045. /**
  35046. * Defines the function to use to interpolate matrices
  35047. * @param startValue defines the start matrix
  35048. * @param endValue defines the end matrix
  35049. * @param gradient defines the gradient between both matrices
  35050. * @param result defines an optional target matrix where to store the interpolation
  35051. * @returns the interpolated matrix
  35052. */
  35053. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  35054. /**
  35055. * Makes a copy of the animation
  35056. * @returns Cloned animation
  35057. */
  35058. clone(): Animation;
  35059. /**
  35060. * Sets the key frames of the animation
  35061. * @param values The animation key frames to set
  35062. */
  35063. setKeys(values: Array<IAnimationKey>): void;
  35064. /**
  35065. * Serializes the animation to an object
  35066. * @returns Serialized object
  35067. */
  35068. serialize(): any;
  35069. /**
  35070. * Float animation type
  35071. */
  35072. static readonly ANIMATIONTYPE_FLOAT: number;
  35073. /**
  35074. * Vector3 animation type
  35075. */
  35076. static readonly ANIMATIONTYPE_VECTOR3: number;
  35077. /**
  35078. * Quaternion animation type
  35079. */
  35080. static readonly ANIMATIONTYPE_QUATERNION: number;
  35081. /**
  35082. * Matrix animation type
  35083. */
  35084. static readonly ANIMATIONTYPE_MATRIX: number;
  35085. /**
  35086. * Color3 animation type
  35087. */
  35088. static readonly ANIMATIONTYPE_COLOR3: number;
  35089. /**
  35090. * Color3 animation type
  35091. */
  35092. static readonly ANIMATIONTYPE_COLOR4: number;
  35093. /**
  35094. * Vector2 animation type
  35095. */
  35096. static readonly ANIMATIONTYPE_VECTOR2: number;
  35097. /**
  35098. * Size animation type
  35099. */
  35100. static readonly ANIMATIONTYPE_SIZE: number;
  35101. /**
  35102. * Relative Loop Mode
  35103. */
  35104. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  35105. /**
  35106. * Cycle Loop Mode
  35107. */
  35108. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  35109. /**
  35110. * Constant Loop Mode
  35111. */
  35112. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  35113. /** @hidden */
  35114. static _UniversalLerp(left: any, right: any, amount: number): any;
  35115. /**
  35116. * Parses an animation object and creates an animation
  35117. * @param parsedAnimation Parsed animation object
  35118. * @returns Animation object
  35119. */
  35120. static Parse(parsedAnimation: any): Animation;
  35121. /**
  35122. * Appends the serialized animations from the source animations
  35123. * @param source Source containing the animations
  35124. * @param destination Target to store the animations
  35125. */
  35126. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35127. /**
  35128. * Creates a new animation or an array of animations from a snippet saved in a remote file
  35129. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  35130. * @param url defines the url to load from
  35131. * @returns a promise that will resolve to the new animation or an array of animations
  35132. */
  35133. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  35134. /**
  35135. * Creates an animation or an array of animations from a snippet saved by the Inspector
  35136. * @param snippetId defines the snippet to load
  35137. * @returns a promise that will resolve to the new animation or a new array of animations
  35138. */
  35139. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  35140. }
  35141. }
  35142. declare module "babylonjs/Animations/animatable.interface" {
  35143. import { Nullable } from "babylonjs/types";
  35144. import { Animation } from "babylonjs/Animations/animation";
  35145. /**
  35146. * Interface containing an array of animations
  35147. */
  35148. export interface IAnimatable {
  35149. /**
  35150. * Array of animations
  35151. */
  35152. animations: Nullable<Array<Animation>>;
  35153. }
  35154. }
  35155. declare module "babylonjs/Misc/decorators" {
  35156. import { Nullable } from "babylonjs/types";
  35157. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35158. import { Scene } from "babylonjs/scene";
  35159. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35160. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  35161. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  35162. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35163. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  35164. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35165. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35166. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35167. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35168. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35169. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35170. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35171. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35172. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35173. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35174. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35175. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35176. /**
  35177. * Decorator used to define property that can be serialized as reference to a camera
  35178. * @param sourceName defines the name of the property to decorate
  35179. */
  35180. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35181. /**
  35182. * Class used to help serialization objects
  35183. */
  35184. export class SerializationHelper {
  35185. /** @hidden */
  35186. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  35187. /** @hidden */
  35188. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  35189. /** @hidden */
  35190. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  35191. /** @hidden */
  35192. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  35193. /**
  35194. * Appends the serialized animations from the source animations
  35195. * @param source Source containing the animations
  35196. * @param destination Target to store the animations
  35197. */
  35198. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35199. /**
  35200. * Static function used to serialized a specific entity
  35201. * @param entity defines the entity to serialize
  35202. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  35203. * @returns a JSON compatible object representing the serialization of the entity
  35204. */
  35205. static Serialize<T>(entity: T, serializationObject?: any): any;
  35206. /**
  35207. * Creates a new entity from a serialization data object
  35208. * @param creationFunction defines a function used to instanciated the new entity
  35209. * @param source defines the source serialization data
  35210. * @param scene defines the hosting scene
  35211. * @param rootUrl defines the root url for resources
  35212. * @returns a new entity
  35213. */
  35214. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35215. /**
  35216. * Clones an object
  35217. * @param creationFunction defines the function used to instanciate the new object
  35218. * @param source defines the source object
  35219. * @returns the cloned object
  35220. */
  35221. static Clone<T>(creationFunction: () => T, source: T): T;
  35222. /**
  35223. * Instanciates a new object based on a source one (some data will be shared between both object)
  35224. * @param creationFunction defines the function used to instanciate the new object
  35225. * @param source defines the source object
  35226. * @returns the new object
  35227. */
  35228. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35229. }
  35230. }
  35231. declare module "babylonjs/Materials/Textures/baseTexture" {
  35232. import { Observable } from "babylonjs/Misc/observable";
  35233. import { Nullable } from "babylonjs/types";
  35234. import { Scene } from "babylonjs/scene";
  35235. import { Matrix } from "babylonjs/Maths/math.vector";
  35236. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35237. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35238. import { ISize } from "babylonjs/Maths/math.size";
  35239. import "babylonjs/Misc/fileTools";
  35240. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35241. /**
  35242. * Base class of all the textures in babylon.
  35243. * It groups all the common properties the materials, post process, lights... might need
  35244. * in order to make a correct use of the texture.
  35245. */
  35246. export class BaseTexture implements IAnimatable {
  35247. /**
  35248. * Default anisotropic filtering level for the application.
  35249. * It is set to 4 as a good tradeoff between perf and quality.
  35250. */
  35251. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35252. /**
  35253. * Gets or sets the unique id of the texture
  35254. */
  35255. uniqueId: number;
  35256. /**
  35257. * Define the name of the texture.
  35258. */
  35259. name: string;
  35260. /**
  35261. * Gets or sets an object used to store user defined information.
  35262. */
  35263. metadata: any;
  35264. /**
  35265. * For internal use only. Please do not use.
  35266. */
  35267. reservedDataStore: any;
  35268. private _hasAlpha;
  35269. /**
  35270. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35271. */
  35272. set hasAlpha(value: boolean);
  35273. get hasAlpha(): boolean;
  35274. /**
  35275. * Defines if the alpha value should be determined via the rgb values.
  35276. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35277. */
  35278. getAlphaFromRGB: boolean;
  35279. /**
  35280. * Intensity or strength of the texture.
  35281. * It is commonly used by materials to fine tune the intensity of the texture
  35282. */
  35283. level: number;
  35284. /**
  35285. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35286. * This is part of the texture as textures usually maps to one uv set.
  35287. */
  35288. coordinatesIndex: number;
  35289. protected _coordinatesMode: number;
  35290. /**
  35291. * How a texture is mapped.
  35292. *
  35293. * | Value | Type | Description |
  35294. * | ----- | ----------------------------------- | ----------- |
  35295. * | 0 | EXPLICIT_MODE | |
  35296. * | 1 | SPHERICAL_MODE | |
  35297. * | 2 | PLANAR_MODE | |
  35298. * | 3 | CUBIC_MODE | |
  35299. * | 4 | PROJECTION_MODE | |
  35300. * | 5 | SKYBOX_MODE | |
  35301. * | 6 | INVCUBIC_MODE | |
  35302. * | 7 | EQUIRECTANGULAR_MODE | |
  35303. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35304. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35305. */
  35306. set coordinatesMode(value: number);
  35307. get coordinatesMode(): number;
  35308. private _wrapU;
  35309. /**
  35310. * | Value | Type | Description |
  35311. * | ----- | ------------------ | ----------- |
  35312. * | 0 | CLAMP_ADDRESSMODE | |
  35313. * | 1 | WRAP_ADDRESSMODE | |
  35314. * | 2 | MIRROR_ADDRESSMODE | |
  35315. */
  35316. get wrapU(): number;
  35317. set wrapU(value: number);
  35318. private _wrapV;
  35319. /**
  35320. * | Value | Type | Description |
  35321. * | ----- | ------------------ | ----------- |
  35322. * | 0 | CLAMP_ADDRESSMODE | |
  35323. * | 1 | WRAP_ADDRESSMODE | |
  35324. * | 2 | MIRROR_ADDRESSMODE | |
  35325. */
  35326. get wrapV(): number;
  35327. set wrapV(value: number);
  35328. /**
  35329. * | Value | Type | Description |
  35330. * | ----- | ------------------ | ----------- |
  35331. * | 0 | CLAMP_ADDRESSMODE | |
  35332. * | 1 | WRAP_ADDRESSMODE | |
  35333. * | 2 | MIRROR_ADDRESSMODE | |
  35334. */
  35335. wrapR: number;
  35336. /**
  35337. * With compliant hardware and browser (supporting anisotropic filtering)
  35338. * this defines the level of anisotropic filtering in the texture.
  35339. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35340. */
  35341. anisotropicFilteringLevel: number;
  35342. /**
  35343. * Define if the texture is a cube texture or if false a 2d texture.
  35344. */
  35345. get isCube(): boolean;
  35346. set isCube(value: boolean);
  35347. /**
  35348. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35349. */
  35350. get is3D(): boolean;
  35351. set is3D(value: boolean);
  35352. /**
  35353. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35354. */
  35355. get is2DArray(): boolean;
  35356. set is2DArray(value: boolean);
  35357. private _gammaSpace;
  35358. /**
  35359. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35360. * HDR texture are usually stored in linear space.
  35361. * This only impacts the PBR and Background materials
  35362. */
  35363. get gammaSpace(): boolean;
  35364. set gammaSpace(gamma: boolean);
  35365. /**
  35366. * Gets or sets whether or not the texture contains RGBD data.
  35367. */
  35368. get isRGBD(): boolean;
  35369. set isRGBD(value: boolean);
  35370. /**
  35371. * Is Z inverted in the texture (useful in a cube texture).
  35372. */
  35373. invertZ: boolean;
  35374. /**
  35375. * Are mip maps generated for this texture or not.
  35376. */
  35377. get noMipmap(): boolean;
  35378. /**
  35379. * @hidden
  35380. */
  35381. lodLevelInAlpha: boolean;
  35382. /**
  35383. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35384. */
  35385. get lodGenerationOffset(): number;
  35386. set lodGenerationOffset(value: number);
  35387. /**
  35388. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35389. */
  35390. get lodGenerationScale(): number;
  35391. set lodGenerationScale(value: number);
  35392. /**
  35393. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35394. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35395. * average roughness values.
  35396. */
  35397. get linearSpecularLOD(): boolean;
  35398. set linearSpecularLOD(value: boolean);
  35399. /**
  35400. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35401. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35402. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35403. */
  35404. get irradianceTexture(): Nullable<BaseTexture>;
  35405. set irradianceTexture(value: Nullable<BaseTexture>);
  35406. /**
  35407. * Define if the texture is a render target.
  35408. */
  35409. isRenderTarget: boolean;
  35410. /**
  35411. * Define the unique id of the texture in the scene.
  35412. */
  35413. get uid(): string;
  35414. /** @hidden */
  35415. _prefiltered: boolean;
  35416. /**
  35417. * Return a string representation of the texture.
  35418. * @returns the texture as a string
  35419. */
  35420. toString(): string;
  35421. /**
  35422. * Get the class name of the texture.
  35423. * @returns "BaseTexture"
  35424. */
  35425. getClassName(): string;
  35426. /**
  35427. * Define the list of animation attached to the texture.
  35428. */
  35429. animations: import("babylonjs/Animations/animation").Animation[];
  35430. /**
  35431. * An event triggered when the texture is disposed.
  35432. */
  35433. onDisposeObservable: Observable<BaseTexture>;
  35434. private _onDisposeObserver;
  35435. /**
  35436. * Callback triggered when the texture has been disposed.
  35437. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35438. */
  35439. set onDispose(callback: () => void);
  35440. /**
  35441. * Define the current state of the loading sequence when in delayed load mode.
  35442. */
  35443. delayLoadState: number;
  35444. protected _scene: Nullable<Scene>;
  35445. protected _engine: Nullable<ThinEngine>;
  35446. /** @hidden */
  35447. _texture: Nullable<InternalTexture>;
  35448. private _uid;
  35449. /**
  35450. * Define if the texture is preventinga material to render or not.
  35451. * If not and the texture is not ready, the engine will use a default black texture instead.
  35452. */
  35453. get isBlocking(): boolean;
  35454. /**
  35455. * Instantiates a new BaseTexture.
  35456. * Base class of all the textures in babylon.
  35457. * It groups all the common properties the materials, post process, lights... might need
  35458. * in order to make a correct use of the texture.
  35459. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35460. */
  35461. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35462. /**
  35463. * Get the scene the texture belongs to.
  35464. * @returns the scene or null if undefined
  35465. */
  35466. getScene(): Nullable<Scene>;
  35467. /** @hidden */
  35468. protected _getEngine(): Nullable<ThinEngine>;
  35469. /**
  35470. * Get the texture transform matrix used to offset tile the texture for istance.
  35471. * @returns the transformation matrix
  35472. */
  35473. getTextureMatrix(): Matrix;
  35474. /**
  35475. * Get the texture reflection matrix used to rotate/transform the reflection.
  35476. * @returns the reflection matrix
  35477. */
  35478. getReflectionTextureMatrix(): Matrix;
  35479. /**
  35480. * Get the underlying lower level texture from Babylon.
  35481. * @returns the insternal texture
  35482. */
  35483. getInternalTexture(): Nullable<InternalTexture>;
  35484. /**
  35485. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35486. * @returns true if ready or not blocking
  35487. */
  35488. isReadyOrNotBlocking(): boolean;
  35489. /**
  35490. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35491. * @returns true if fully ready
  35492. */
  35493. isReady(): boolean;
  35494. private _cachedSize;
  35495. /**
  35496. * Get the size of the texture.
  35497. * @returns the texture size.
  35498. */
  35499. getSize(): ISize;
  35500. /**
  35501. * Get the base size of the texture.
  35502. * It can be different from the size if the texture has been resized for POT for instance
  35503. * @returns the base size
  35504. */
  35505. getBaseSize(): ISize;
  35506. /**
  35507. * Update the sampling mode of the texture.
  35508. * Default is Trilinear mode.
  35509. *
  35510. * | Value | Type | Description |
  35511. * | ----- | ------------------ | ----------- |
  35512. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35513. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35514. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35515. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35516. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35517. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35518. * | 7 | NEAREST_LINEAR | |
  35519. * | 8 | NEAREST_NEAREST | |
  35520. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35521. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35522. * | 11 | LINEAR_LINEAR | |
  35523. * | 12 | LINEAR_NEAREST | |
  35524. *
  35525. * > _mag_: magnification filter (close to the viewer)
  35526. * > _min_: minification filter (far from the viewer)
  35527. * > _mip_: filter used between mip map levels
  35528. *@param samplingMode Define the new sampling mode of the texture
  35529. */
  35530. updateSamplingMode(samplingMode: number): void;
  35531. /**
  35532. * Scales the texture if is `canRescale()`
  35533. * @param ratio the resize factor we want to use to rescale
  35534. */
  35535. scale(ratio: number): void;
  35536. /**
  35537. * Get if the texture can rescale.
  35538. */
  35539. get canRescale(): boolean;
  35540. /** @hidden */
  35541. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35542. /** @hidden */
  35543. _rebuild(): void;
  35544. /**
  35545. * Triggers the load sequence in delayed load mode.
  35546. */
  35547. delayLoad(): void;
  35548. /**
  35549. * Clones the texture.
  35550. * @returns the cloned texture
  35551. */
  35552. clone(): Nullable<BaseTexture>;
  35553. /**
  35554. * Get the texture underlying type (INT, FLOAT...)
  35555. */
  35556. get textureType(): number;
  35557. /**
  35558. * Get the texture underlying format (RGB, RGBA...)
  35559. */
  35560. get textureFormat(): number;
  35561. /**
  35562. * Indicates that textures need to be re-calculated for all materials
  35563. */
  35564. protected _markAllSubMeshesAsTexturesDirty(): void;
  35565. /**
  35566. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35567. * This will returns an RGBA array buffer containing either in values (0-255) or
  35568. * float values (0-1) depending of the underlying buffer type.
  35569. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35570. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35571. * @param buffer defines a user defined buffer to fill with data (can be null)
  35572. * @returns The Array buffer containing the pixels data.
  35573. */
  35574. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35575. /**
  35576. * Release and destroy the underlying lower level texture aka internalTexture.
  35577. */
  35578. releaseInternalTexture(): void;
  35579. /** @hidden */
  35580. get _lodTextureHigh(): Nullable<BaseTexture>;
  35581. /** @hidden */
  35582. get _lodTextureMid(): Nullable<BaseTexture>;
  35583. /** @hidden */
  35584. get _lodTextureLow(): Nullable<BaseTexture>;
  35585. /**
  35586. * Dispose the texture and release its associated resources.
  35587. */
  35588. dispose(): void;
  35589. /**
  35590. * Serialize the texture into a JSON representation that can be parsed later on.
  35591. * @returns the JSON representation of the texture
  35592. */
  35593. serialize(): any;
  35594. /**
  35595. * Helper function to be called back once a list of texture contains only ready textures.
  35596. * @param textures Define the list of textures to wait for
  35597. * @param callback Define the callback triggered once the entire list will be ready
  35598. */
  35599. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35600. private static _isScene;
  35601. }
  35602. }
  35603. declare module "babylonjs/Materials/effect" {
  35604. import { Observable } from "babylonjs/Misc/observable";
  35605. import { Nullable } from "babylonjs/types";
  35606. import { IDisposable } from "babylonjs/scene";
  35607. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35608. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35609. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35610. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35611. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35612. import { Engine } from "babylonjs/Engines/engine";
  35613. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35614. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35615. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35616. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35617. /**
  35618. * Options to be used when creating an effect.
  35619. */
  35620. export interface IEffectCreationOptions {
  35621. /**
  35622. * Atrributes that will be used in the shader.
  35623. */
  35624. attributes: string[];
  35625. /**
  35626. * Uniform varible names that will be set in the shader.
  35627. */
  35628. uniformsNames: string[];
  35629. /**
  35630. * Uniform buffer variable names that will be set in the shader.
  35631. */
  35632. uniformBuffersNames: string[];
  35633. /**
  35634. * Sampler texture variable names that will be set in the shader.
  35635. */
  35636. samplers: string[];
  35637. /**
  35638. * Define statements that will be set in the shader.
  35639. */
  35640. defines: any;
  35641. /**
  35642. * Possible fallbacks for this effect to improve performance when needed.
  35643. */
  35644. fallbacks: Nullable<IEffectFallbacks>;
  35645. /**
  35646. * Callback that will be called when the shader is compiled.
  35647. */
  35648. onCompiled: Nullable<(effect: Effect) => void>;
  35649. /**
  35650. * Callback that will be called if an error occurs during shader compilation.
  35651. */
  35652. onError: Nullable<(effect: Effect, errors: string) => void>;
  35653. /**
  35654. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35655. */
  35656. indexParameters?: any;
  35657. /**
  35658. * Max number of lights that can be used in the shader.
  35659. */
  35660. maxSimultaneousLights?: number;
  35661. /**
  35662. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35663. */
  35664. transformFeedbackVaryings?: Nullable<string[]>;
  35665. /**
  35666. * 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
  35667. */
  35668. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35669. /**
  35670. * Is this effect rendering to several color attachments ?
  35671. */
  35672. multiTarget?: boolean;
  35673. }
  35674. /**
  35675. * Effect containing vertex and fragment shader that can be executed on an object.
  35676. */
  35677. export class Effect implements IDisposable {
  35678. /**
  35679. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35680. */
  35681. static ShadersRepository: string;
  35682. /**
  35683. * Enable logging of the shader code when a compilation error occurs
  35684. */
  35685. static LogShaderCodeOnCompilationError: boolean;
  35686. /**
  35687. * Name of the effect.
  35688. */
  35689. name: any;
  35690. /**
  35691. * String container all the define statements that should be set on the shader.
  35692. */
  35693. defines: string;
  35694. /**
  35695. * Callback that will be called when the shader is compiled.
  35696. */
  35697. onCompiled: Nullable<(effect: Effect) => void>;
  35698. /**
  35699. * Callback that will be called if an error occurs during shader compilation.
  35700. */
  35701. onError: Nullable<(effect: Effect, errors: string) => void>;
  35702. /**
  35703. * Callback that will be called when effect is bound.
  35704. */
  35705. onBind: Nullable<(effect: Effect) => void>;
  35706. /**
  35707. * Unique ID of the effect.
  35708. */
  35709. uniqueId: number;
  35710. /**
  35711. * Observable that will be called when the shader is compiled.
  35712. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35713. */
  35714. onCompileObservable: Observable<Effect>;
  35715. /**
  35716. * Observable that will be called if an error occurs during shader compilation.
  35717. */
  35718. onErrorObservable: Observable<Effect>;
  35719. /** @hidden */
  35720. _onBindObservable: Nullable<Observable<Effect>>;
  35721. /**
  35722. * @hidden
  35723. * Specifies if the effect was previously ready
  35724. */
  35725. _wasPreviouslyReady: boolean;
  35726. /**
  35727. * Observable that will be called when effect is bound.
  35728. */
  35729. get onBindObservable(): Observable<Effect>;
  35730. /** @hidden */
  35731. _bonesComputationForcedToCPU: boolean;
  35732. /** @hidden */
  35733. _multiTarget: boolean;
  35734. private static _uniqueIdSeed;
  35735. private _engine;
  35736. private _uniformBuffersNames;
  35737. private _uniformBuffersNamesList;
  35738. private _uniformsNames;
  35739. private _samplerList;
  35740. private _samplers;
  35741. private _isReady;
  35742. private _compilationError;
  35743. private _allFallbacksProcessed;
  35744. private _attributesNames;
  35745. private _attributes;
  35746. private _attributeLocationByName;
  35747. private _uniforms;
  35748. /**
  35749. * Key for the effect.
  35750. * @hidden
  35751. */
  35752. _key: string;
  35753. private _indexParameters;
  35754. private _fallbacks;
  35755. private _vertexSourceCode;
  35756. private _fragmentSourceCode;
  35757. private _vertexSourceCodeOverride;
  35758. private _fragmentSourceCodeOverride;
  35759. private _transformFeedbackVaryings;
  35760. /**
  35761. * Compiled shader to webGL program.
  35762. * @hidden
  35763. */
  35764. _pipelineContext: Nullable<IPipelineContext>;
  35765. private _valueCache;
  35766. private static _baseCache;
  35767. /**
  35768. * Instantiates an effect.
  35769. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35770. * @param baseName Name of the effect.
  35771. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35772. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35773. * @param samplers List of sampler variables that will be passed to the shader.
  35774. * @param engine Engine to be used to render the effect
  35775. * @param defines Define statements to be added to the shader.
  35776. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35777. * @param onCompiled Callback that will be called when the shader is compiled.
  35778. * @param onError Callback that will be called if an error occurs during shader compilation.
  35779. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35780. */
  35781. 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);
  35782. private _useFinalCode;
  35783. /**
  35784. * Unique key for this effect
  35785. */
  35786. get key(): string;
  35787. /**
  35788. * If the effect has been compiled and prepared.
  35789. * @returns if the effect is compiled and prepared.
  35790. */
  35791. isReady(): boolean;
  35792. private _isReadyInternal;
  35793. /**
  35794. * The engine the effect was initialized with.
  35795. * @returns the engine.
  35796. */
  35797. getEngine(): Engine;
  35798. /**
  35799. * The pipeline context for this effect
  35800. * @returns the associated pipeline context
  35801. */
  35802. getPipelineContext(): Nullable<IPipelineContext>;
  35803. /**
  35804. * The set of names of attribute variables for the shader.
  35805. * @returns An array of attribute names.
  35806. */
  35807. getAttributesNames(): string[];
  35808. /**
  35809. * Returns the attribute at the given index.
  35810. * @param index The index of the attribute.
  35811. * @returns The location of the attribute.
  35812. */
  35813. getAttributeLocation(index: number): number;
  35814. /**
  35815. * Returns the attribute based on the name of the variable.
  35816. * @param name of the attribute to look up.
  35817. * @returns the attribute location.
  35818. */
  35819. getAttributeLocationByName(name: string): number;
  35820. /**
  35821. * The number of attributes.
  35822. * @returns the numnber of attributes.
  35823. */
  35824. getAttributesCount(): number;
  35825. /**
  35826. * Gets the index of a uniform variable.
  35827. * @param uniformName of the uniform to look up.
  35828. * @returns the index.
  35829. */
  35830. getUniformIndex(uniformName: string): number;
  35831. /**
  35832. * Returns the attribute based on the name of the variable.
  35833. * @param uniformName of the uniform to look up.
  35834. * @returns the location of the uniform.
  35835. */
  35836. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35837. /**
  35838. * Returns an array of sampler variable names
  35839. * @returns The array of sampler variable names.
  35840. */
  35841. getSamplers(): string[];
  35842. /**
  35843. * Returns an array of uniform variable names
  35844. * @returns The array of uniform variable names.
  35845. */
  35846. getUniformNames(): string[];
  35847. /**
  35848. * Returns an array of uniform buffer variable names
  35849. * @returns The array of uniform buffer variable names.
  35850. */
  35851. getUniformBuffersNames(): string[];
  35852. /**
  35853. * Returns the index parameters used to create the effect
  35854. * @returns The index parameters object
  35855. */
  35856. getIndexParameters(): any;
  35857. /**
  35858. * The error from the last compilation.
  35859. * @returns the error string.
  35860. */
  35861. getCompilationError(): string;
  35862. /**
  35863. * Gets a boolean indicating that all fallbacks were used during compilation
  35864. * @returns true if all fallbacks were used
  35865. */
  35866. allFallbacksProcessed(): boolean;
  35867. /**
  35868. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35869. * @param func The callback to be used.
  35870. */
  35871. executeWhenCompiled(func: (effect: Effect) => void): void;
  35872. private _checkIsReady;
  35873. private _loadShader;
  35874. /**
  35875. * Gets the vertex shader source code of this effect
  35876. */
  35877. get vertexSourceCode(): string;
  35878. /**
  35879. * Gets the fragment shader source code of this effect
  35880. */
  35881. get fragmentSourceCode(): string;
  35882. /**
  35883. * Recompiles the webGL program
  35884. * @param vertexSourceCode The source code for the vertex shader.
  35885. * @param fragmentSourceCode The source code for the fragment shader.
  35886. * @param onCompiled Callback called when completed.
  35887. * @param onError Callback called on error.
  35888. * @hidden
  35889. */
  35890. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35891. /**
  35892. * Prepares the effect
  35893. * @hidden
  35894. */
  35895. _prepareEffect(): void;
  35896. private _getShaderCodeAndErrorLine;
  35897. private _processCompilationErrors;
  35898. /**
  35899. * Checks if the effect is supported. (Must be called after compilation)
  35900. */
  35901. get isSupported(): boolean;
  35902. /**
  35903. * Binds a texture to the engine to be used as output of the shader.
  35904. * @param channel Name of the output variable.
  35905. * @param texture Texture to bind.
  35906. * @hidden
  35907. */
  35908. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35909. /**
  35910. * Sets a texture on the engine to be used in the shader.
  35911. * @param channel Name of the sampler variable.
  35912. * @param texture Texture to set.
  35913. */
  35914. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35915. /**
  35916. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35917. * @param channel Name of the sampler variable.
  35918. * @param texture Texture to set.
  35919. */
  35920. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35921. /**
  35922. * Sets an array of textures on the engine to be used in the shader.
  35923. * @param channel Name of the variable.
  35924. * @param textures Textures to set.
  35925. */
  35926. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35927. /**
  35928. * 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)
  35929. * @param channel Name of the sampler variable.
  35930. * @param postProcess Post process to get the input texture from.
  35931. */
  35932. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35933. /**
  35934. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35935. * 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)
  35936. * @param channel Name of the sampler variable.
  35937. * @param postProcess Post process to get the output texture from.
  35938. */
  35939. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35940. /** @hidden */
  35941. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35942. /** @hidden */
  35943. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35944. /** @hidden */
  35945. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35946. /** @hidden */
  35947. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35948. /**
  35949. * Binds a buffer to a uniform.
  35950. * @param buffer Buffer to bind.
  35951. * @param name Name of the uniform variable to bind to.
  35952. */
  35953. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35954. /**
  35955. * Binds block to a uniform.
  35956. * @param blockName Name of the block to bind.
  35957. * @param index Index to bind.
  35958. */
  35959. bindUniformBlock(blockName: string, index: number): void;
  35960. /**
  35961. * Sets an interger value on a uniform variable.
  35962. * @param uniformName Name of the variable.
  35963. * @param value Value to be set.
  35964. * @returns this effect.
  35965. */
  35966. setInt(uniformName: string, value: number): Effect;
  35967. /**
  35968. * Sets an int array on a uniform variable.
  35969. * @param uniformName Name of the variable.
  35970. * @param array array to be set.
  35971. * @returns this effect.
  35972. */
  35973. setIntArray(uniformName: string, array: Int32Array): Effect;
  35974. /**
  35975. * 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)
  35976. * @param uniformName Name of the variable.
  35977. * @param array array to be set.
  35978. * @returns this effect.
  35979. */
  35980. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35981. /**
  35982. * 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)
  35983. * @param uniformName Name of the variable.
  35984. * @param array array to be set.
  35985. * @returns this effect.
  35986. */
  35987. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35988. /**
  35989. * 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)
  35990. * @param uniformName Name of the variable.
  35991. * @param array array to be set.
  35992. * @returns this effect.
  35993. */
  35994. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35995. /**
  35996. * Sets an float array on a uniform variable.
  35997. * @param uniformName Name of the variable.
  35998. * @param array array to be set.
  35999. * @returns this effect.
  36000. */
  36001. setFloatArray(uniformName: string, array: Float32Array): Effect;
  36002. /**
  36003. * 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)
  36004. * @param uniformName Name of the variable.
  36005. * @param array array to be set.
  36006. * @returns this effect.
  36007. */
  36008. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  36009. /**
  36010. * 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)
  36011. * @param uniformName Name of the variable.
  36012. * @param array array to be set.
  36013. * @returns this effect.
  36014. */
  36015. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  36016. /**
  36017. * 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)
  36018. * @param uniformName Name of the variable.
  36019. * @param array array to be set.
  36020. * @returns this effect.
  36021. */
  36022. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  36023. /**
  36024. * Sets an array on a uniform variable.
  36025. * @param uniformName Name of the variable.
  36026. * @param array array to be set.
  36027. * @returns this effect.
  36028. */
  36029. setArray(uniformName: string, array: number[]): Effect;
  36030. /**
  36031. * 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)
  36032. * @param uniformName Name of the variable.
  36033. * @param array array to be set.
  36034. * @returns this effect.
  36035. */
  36036. setArray2(uniformName: string, array: number[]): Effect;
  36037. /**
  36038. * 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)
  36039. * @param uniformName Name of the variable.
  36040. * @param array array to be set.
  36041. * @returns this effect.
  36042. */
  36043. setArray3(uniformName: string, array: number[]): Effect;
  36044. /**
  36045. * 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)
  36046. * @param uniformName Name of the variable.
  36047. * @param array array to be set.
  36048. * @returns this effect.
  36049. */
  36050. setArray4(uniformName: string, array: number[]): Effect;
  36051. /**
  36052. * Sets matrices on a uniform variable.
  36053. * @param uniformName Name of the variable.
  36054. * @param matrices matrices to be set.
  36055. * @returns this effect.
  36056. */
  36057. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  36058. /**
  36059. * Sets matrix on a uniform variable.
  36060. * @param uniformName Name of the variable.
  36061. * @param matrix matrix to be set.
  36062. * @returns this effect.
  36063. */
  36064. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  36065. /**
  36066. * 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)
  36067. * @param uniformName Name of the variable.
  36068. * @param matrix matrix to be set.
  36069. * @returns this effect.
  36070. */
  36071. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  36072. /**
  36073. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  36074. * @param uniformName Name of the variable.
  36075. * @param matrix matrix to be set.
  36076. * @returns this effect.
  36077. */
  36078. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  36079. /**
  36080. * Sets a float on a uniform variable.
  36081. * @param uniformName Name of the variable.
  36082. * @param value value to be set.
  36083. * @returns this effect.
  36084. */
  36085. setFloat(uniformName: string, value: number): Effect;
  36086. /**
  36087. * Sets a boolean on a uniform variable.
  36088. * @param uniformName Name of the variable.
  36089. * @param bool value to be set.
  36090. * @returns this effect.
  36091. */
  36092. setBool(uniformName: string, bool: boolean): Effect;
  36093. /**
  36094. * Sets a Vector2 on a uniform variable.
  36095. * @param uniformName Name of the variable.
  36096. * @param vector2 vector2 to be set.
  36097. * @returns this effect.
  36098. */
  36099. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  36100. /**
  36101. * Sets a float2 on a uniform variable.
  36102. * @param uniformName Name of the variable.
  36103. * @param x First float in float2.
  36104. * @param y Second float in float2.
  36105. * @returns this effect.
  36106. */
  36107. setFloat2(uniformName: string, x: number, y: number): Effect;
  36108. /**
  36109. * Sets a Vector3 on a uniform variable.
  36110. * @param uniformName Name of the variable.
  36111. * @param vector3 Value to be set.
  36112. * @returns this effect.
  36113. */
  36114. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  36115. /**
  36116. * Sets a float3 on a uniform variable.
  36117. * @param uniformName Name of the variable.
  36118. * @param x First float in float3.
  36119. * @param y Second float in float3.
  36120. * @param z Third float in float3.
  36121. * @returns this effect.
  36122. */
  36123. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  36124. /**
  36125. * Sets a Vector4 on a uniform variable.
  36126. * @param uniformName Name of the variable.
  36127. * @param vector4 Value to be set.
  36128. * @returns this effect.
  36129. */
  36130. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  36131. /**
  36132. * Sets a float4 on a uniform variable.
  36133. * @param uniformName Name of the variable.
  36134. * @param x First float in float4.
  36135. * @param y Second float in float4.
  36136. * @param z Third float in float4.
  36137. * @param w Fourth float in float4.
  36138. * @returns this effect.
  36139. */
  36140. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  36141. /**
  36142. * Sets a Color3 on a uniform variable.
  36143. * @param uniformName Name of the variable.
  36144. * @param color3 Value to be set.
  36145. * @returns this effect.
  36146. */
  36147. setColor3(uniformName: string, color3: IColor3Like): Effect;
  36148. /**
  36149. * Sets a Color4 on a uniform variable.
  36150. * @param uniformName Name of the variable.
  36151. * @param color3 Value to be set.
  36152. * @param alpha Alpha value to be set.
  36153. * @returns this effect.
  36154. */
  36155. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  36156. /**
  36157. * Sets a Color4 on a uniform variable
  36158. * @param uniformName defines the name of the variable
  36159. * @param color4 defines the value to be set
  36160. * @returns this effect.
  36161. */
  36162. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  36163. /** Release all associated resources */
  36164. dispose(): void;
  36165. /**
  36166. * This function will add a new shader to the shader store
  36167. * @param name the name of the shader
  36168. * @param pixelShader optional pixel shader content
  36169. * @param vertexShader optional vertex shader content
  36170. */
  36171. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  36172. /**
  36173. * Store of each shader (The can be looked up using effect.key)
  36174. */
  36175. static ShadersStore: {
  36176. [key: string]: string;
  36177. };
  36178. /**
  36179. * Store of each included file for a shader (The can be looked up using effect.key)
  36180. */
  36181. static IncludesShadersStore: {
  36182. [key: string]: string;
  36183. };
  36184. /**
  36185. * Resets the cache of effects.
  36186. */
  36187. static ResetCache(): void;
  36188. }
  36189. }
  36190. declare module "babylonjs/Engines/engineCapabilities" {
  36191. /**
  36192. * Interface used to describe the capabilities of the engine relatively to the current browser
  36193. */
  36194. export interface EngineCapabilities {
  36195. /** Maximum textures units per fragment shader */
  36196. maxTexturesImageUnits: number;
  36197. /** Maximum texture units per vertex shader */
  36198. maxVertexTextureImageUnits: number;
  36199. /** Maximum textures units in the entire pipeline */
  36200. maxCombinedTexturesImageUnits: number;
  36201. /** Maximum texture size */
  36202. maxTextureSize: number;
  36203. /** Maximum texture samples */
  36204. maxSamples?: number;
  36205. /** Maximum cube texture size */
  36206. maxCubemapTextureSize: number;
  36207. /** Maximum render texture size */
  36208. maxRenderTextureSize: number;
  36209. /** Maximum number of vertex attributes */
  36210. maxVertexAttribs: number;
  36211. /** Maximum number of varyings */
  36212. maxVaryingVectors: number;
  36213. /** Maximum number of uniforms per vertex shader */
  36214. maxVertexUniformVectors: number;
  36215. /** Maximum number of uniforms per fragment shader */
  36216. maxFragmentUniformVectors: number;
  36217. /** Defines if standard derivates (dx/dy) are supported */
  36218. standardDerivatives: boolean;
  36219. /** Defines if s3tc texture compression is supported */
  36220. s3tc?: WEBGL_compressed_texture_s3tc;
  36221. /** Defines if pvrtc texture compression is supported */
  36222. pvrtc: any;
  36223. /** Defines if etc1 texture compression is supported */
  36224. etc1: any;
  36225. /** Defines if etc2 texture compression is supported */
  36226. etc2: any;
  36227. /** Defines if astc texture compression is supported */
  36228. astc: any;
  36229. /** Defines if bptc texture compression is supported */
  36230. bptc: any;
  36231. /** Defines if float textures are supported */
  36232. textureFloat: boolean;
  36233. /** Defines if vertex array objects are supported */
  36234. vertexArrayObject: boolean;
  36235. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36236. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36237. /** Gets the maximum level of anisotropy supported */
  36238. maxAnisotropy: number;
  36239. /** Defines if instancing is supported */
  36240. instancedArrays: boolean;
  36241. /** Defines if 32 bits indices are supported */
  36242. uintIndices: boolean;
  36243. /** Defines if high precision shaders are supported */
  36244. highPrecisionShaderSupported: boolean;
  36245. /** Defines if depth reading in the fragment shader is supported */
  36246. fragmentDepthSupported: boolean;
  36247. /** Defines if float texture linear filtering is supported*/
  36248. textureFloatLinearFiltering: boolean;
  36249. /** Defines if rendering to float textures is supported */
  36250. textureFloatRender: boolean;
  36251. /** Defines if half float textures are supported*/
  36252. textureHalfFloat: boolean;
  36253. /** Defines if half float texture linear filtering is supported*/
  36254. textureHalfFloatLinearFiltering: boolean;
  36255. /** Defines if rendering to half float textures is supported */
  36256. textureHalfFloatRender: boolean;
  36257. /** Defines if textureLOD shader command is supported */
  36258. textureLOD: boolean;
  36259. /** Defines if draw buffers extension is supported */
  36260. drawBuffersExtension: boolean;
  36261. /** Defines if depth textures are supported */
  36262. depthTextureExtension: boolean;
  36263. /** Defines if float color buffer are supported */
  36264. colorBufferFloat: boolean;
  36265. /** Gets disjoint timer query extension (null if not supported) */
  36266. timerQuery?: EXT_disjoint_timer_query;
  36267. /** Defines if timestamp can be used with timer query */
  36268. canUseTimestampForTimerQuery: boolean;
  36269. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36270. multiview?: any;
  36271. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36272. oculusMultiview?: any;
  36273. /** Function used to let the system compiles shaders in background */
  36274. parallelShaderCompile?: {
  36275. COMPLETION_STATUS_KHR: number;
  36276. };
  36277. /** Max number of texture samples for MSAA */
  36278. maxMSAASamples: number;
  36279. /** Defines if the blend min max extension is supported */
  36280. blendMinMax: boolean;
  36281. }
  36282. }
  36283. declare module "babylonjs/States/depthCullingState" {
  36284. import { Nullable } from "babylonjs/types";
  36285. /**
  36286. * @hidden
  36287. **/
  36288. export class DepthCullingState {
  36289. private _isDepthTestDirty;
  36290. private _isDepthMaskDirty;
  36291. private _isDepthFuncDirty;
  36292. private _isCullFaceDirty;
  36293. private _isCullDirty;
  36294. private _isZOffsetDirty;
  36295. private _isFrontFaceDirty;
  36296. private _depthTest;
  36297. private _depthMask;
  36298. private _depthFunc;
  36299. private _cull;
  36300. private _cullFace;
  36301. private _zOffset;
  36302. private _frontFace;
  36303. /**
  36304. * Initializes the state.
  36305. */
  36306. constructor();
  36307. get isDirty(): boolean;
  36308. get zOffset(): number;
  36309. set zOffset(value: number);
  36310. get cullFace(): Nullable<number>;
  36311. set cullFace(value: Nullable<number>);
  36312. get cull(): Nullable<boolean>;
  36313. set cull(value: Nullable<boolean>);
  36314. get depthFunc(): Nullable<number>;
  36315. set depthFunc(value: Nullable<number>);
  36316. get depthMask(): boolean;
  36317. set depthMask(value: boolean);
  36318. get depthTest(): boolean;
  36319. set depthTest(value: boolean);
  36320. get frontFace(): Nullable<number>;
  36321. set frontFace(value: Nullable<number>);
  36322. reset(): void;
  36323. apply(gl: WebGLRenderingContext): void;
  36324. }
  36325. }
  36326. declare module "babylonjs/States/stencilState" {
  36327. /**
  36328. * @hidden
  36329. **/
  36330. export class StencilState {
  36331. /** 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 */
  36332. static readonly ALWAYS: number;
  36333. /** Passed to stencilOperation to specify that stencil value must be kept */
  36334. static readonly KEEP: number;
  36335. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36336. static readonly REPLACE: number;
  36337. private _isStencilTestDirty;
  36338. private _isStencilMaskDirty;
  36339. private _isStencilFuncDirty;
  36340. private _isStencilOpDirty;
  36341. private _stencilTest;
  36342. private _stencilMask;
  36343. private _stencilFunc;
  36344. private _stencilFuncRef;
  36345. private _stencilFuncMask;
  36346. private _stencilOpStencilFail;
  36347. private _stencilOpDepthFail;
  36348. private _stencilOpStencilDepthPass;
  36349. get isDirty(): boolean;
  36350. get stencilFunc(): number;
  36351. set stencilFunc(value: number);
  36352. get stencilFuncRef(): number;
  36353. set stencilFuncRef(value: number);
  36354. get stencilFuncMask(): number;
  36355. set stencilFuncMask(value: number);
  36356. get stencilOpStencilFail(): number;
  36357. set stencilOpStencilFail(value: number);
  36358. get stencilOpDepthFail(): number;
  36359. set stencilOpDepthFail(value: number);
  36360. get stencilOpStencilDepthPass(): number;
  36361. set stencilOpStencilDepthPass(value: number);
  36362. get stencilMask(): number;
  36363. set stencilMask(value: number);
  36364. get stencilTest(): boolean;
  36365. set stencilTest(value: boolean);
  36366. constructor();
  36367. reset(): void;
  36368. apply(gl: WebGLRenderingContext): void;
  36369. }
  36370. }
  36371. declare module "babylonjs/States/alphaCullingState" {
  36372. /**
  36373. * @hidden
  36374. **/
  36375. export class AlphaState {
  36376. private _isAlphaBlendDirty;
  36377. private _isBlendFunctionParametersDirty;
  36378. private _isBlendEquationParametersDirty;
  36379. private _isBlendConstantsDirty;
  36380. private _alphaBlend;
  36381. private _blendFunctionParameters;
  36382. private _blendEquationParameters;
  36383. private _blendConstants;
  36384. /**
  36385. * Initializes the state.
  36386. */
  36387. constructor();
  36388. get isDirty(): boolean;
  36389. get alphaBlend(): boolean;
  36390. set alphaBlend(value: boolean);
  36391. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36392. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36393. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36394. reset(): void;
  36395. apply(gl: WebGLRenderingContext): void;
  36396. }
  36397. }
  36398. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36399. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36400. /** @hidden */
  36401. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36402. attributeProcessor(attribute: string): string;
  36403. varyingProcessor(varying: string, isFragment: boolean): string;
  36404. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36405. }
  36406. }
  36407. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36408. /**
  36409. * Interface for attribute information associated with buffer instanciation
  36410. */
  36411. export interface InstancingAttributeInfo {
  36412. /**
  36413. * Name of the GLSL attribute
  36414. * if attribute index is not specified, this is used to retrieve the index from the effect
  36415. */
  36416. attributeName: string;
  36417. /**
  36418. * Index/offset of the attribute in the vertex shader
  36419. * if not specified, this will be computes from the name.
  36420. */
  36421. index?: number;
  36422. /**
  36423. * size of the attribute, 1, 2, 3 or 4
  36424. */
  36425. attributeSize: number;
  36426. /**
  36427. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36428. */
  36429. offset: number;
  36430. /**
  36431. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36432. * default to 1
  36433. */
  36434. divisor?: number;
  36435. /**
  36436. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36437. * default is FLOAT
  36438. */
  36439. attributeType?: number;
  36440. /**
  36441. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36442. */
  36443. normalized?: boolean;
  36444. }
  36445. }
  36446. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36448. import { Nullable } from "babylonjs/types";
  36449. module "babylonjs/Engines/thinEngine" {
  36450. interface ThinEngine {
  36451. /**
  36452. * Update a video texture
  36453. * @param texture defines the texture to update
  36454. * @param video defines the video element to use
  36455. * @param invertY defines if data must be stored with Y axis inverted
  36456. */
  36457. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36458. }
  36459. }
  36460. }
  36461. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36462. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36463. import { Nullable } from "babylonjs/types";
  36464. module "babylonjs/Engines/thinEngine" {
  36465. interface ThinEngine {
  36466. /**
  36467. * Creates a dynamic texture
  36468. * @param width defines the width of the texture
  36469. * @param height defines the height of the texture
  36470. * @param generateMipMaps defines if the engine should generate the mip levels
  36471. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36472. * @returns the dynamic texture inside an InternalTexture
  36473. */
  36474. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36475. /**
  36476. * Update the content of a dynamic texture
  36477. * @param texture defines the texture to update
  36478. * @param canvas defines the canvas containing the source
  36479. * @param invertY defines if data must be stored with Y axis inverted
  36480. * @param premulAlpha defines if alpha is stored as premultiplied
  36481. * @param format defines the format of the data
  36482. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36483. */
  36484. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36485. }
  36486. }
  36487. }
  36488. declare module "babylonjs/Materials/Textures/videoTexture" {
  36489. import { Observable } from "babylonjs/Misc/observable";
  36490. import { Nullable } from "babylonjs/types";
  36491. import { Scene } from "babylonjs/scene";
  36492. import { Texture } from "babylonjs/Materials/Textures/texture";
  36493. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36494. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36495. /**
  36496. * Settings for finer control over video usage
  36497. */
  36498. export interface VideoTextureSettings {
  36499. /**
  36500. * Applies `autoplay` to video, if specified
  36501. */
  36502. autoPlay?: boolean;
  36503. /**
  36504. * Applies `muted` to video, if specified
  36505. */
  36506. muted?: boolean;
  36507. /**
  36508. * Applies `loop` to video, if specified
  36509. */
  36510. loop?: boolean;
  36511. /**
  36512. * Automatically updates internal texture from video at every frame in the render loop
  36513. */
  36514. autoUpdateTexture: boolean;
  36515. /**
  36516. * Image src displayed during the video loading or until the user interacts with the video.
  36517. */
  36518. poster?: string;
  36519. }
  36520. /**
  36521. * If you want to display a video in your scene, this is the special texture for that.
  36522. * This special texture works similar to other textures, with the exception of a few parameters.
  36523. * @see https://doc.babylonjs.com/how_to/video_texture
  36524. */
  36525. export class VideoTexture extends Texture {
  36526. /**
  36527. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36528. */
  36529. readonly autoUpdateTexture: boolean;
  36530. /**
  36531. * The video instance used by the texture internally
  36532. */
  36533. readonly video: HTMLVideoElement;
  36534. private _onUserActionRequestedObservable;
  36535. /**
  36536. * Event triggerd when a dom action is required by the user to play the video.
  36537. * This happens due to recent changes in browser policies preventing video to auto start.
  36538. */
  36539. get onUserActionRequestedObservable(): Observable<Texture>;
  36540. private _generateMipMaps;
  36541. private _stillImageCaptured;
  36542. private _displayingPosterTexture;
  36543. private _settings;
  36544. private _createInternalTextureOnEvent;
  36545. private _frameId;
  36546. private _currentSrc;
  36547. /**
  36548. * Creates a video texture.
  36549. * If you want to display a video in your scene, this is the special texture for that.
  36550. * This special texture works similar to other textures, with the exception of a few parameters.
  36551. * @see https://doc.babylonjs.com/how_to/video_texture
  36552. * @param name optional name, will detect from video source, if not defined
  36553. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36554. * @param scene is obviously the current scene.
  36555. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36556. * @param invertY is false by default but can be used to invert video on Y axis
  36557. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36558. * @param settings allows finer control over video usage
  36559. */
  36560. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36561. private _getName;
  36562. private _getVideo;
  36563. private _createInternalTexture;
  36564. private reset;
  36565. /**
  36566. * @hidden Internal method to initiate `update`.
  36567. */
  36568. _rebuild(): void;
  36569. /**
  36570. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36571. */
  36572. update(): void;
  36573. /**
  36574. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36575. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36576. */
  36577. updateTexture(isVisible: boolean): void;
  36578. protected _updateInternalTexture: () => void;
  36579. /**
  36580. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36581. * @param url New url.
  36582. */
  36583. updateURL(url: string): void;
  36584. /**
  36585. * Clones the texture.
  36586. * @returns the cloned texture
  36587. */
  36588. clone(): VideoTexture;
  36589. /**
  36590. * Dispose the texture and release its associated resources.
  36591. */
  36592. dispose(): void;
  36593. /**
  36594. * Creates a video texture straight from a stream.
  36595. * @param scene Define the scene the texture should be created in
  36596. * @param stream Define the stream the texture should be created from
  36597. * @returns The created video texture as a promise
  36598. */
  36599. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36600. /**
  36601. * Creates a video texture straight from your WebCam video feed.
  36602. * @param scene Define the scene the texture should be created in
  36603. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36604. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36605. * @returns The created video texture as a promise
  36606. */
  36607. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36608. minWidth: number;
  36609. maxWidth: number;
  36610. minHeight: number;
  36611. maxHeight: number;
  36612. deviceId: string;
  36613. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36614. /**
  36615. * Creates a video texture straight from your WebCam video feed.
  36616. * @param scene Define the scene the texture should be created in
  36617. * @param onReady Define a callback to triggered once the texture will be ready
  36618. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36619. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36620. */
  36621. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36622. minWidth: number;
  36623. maxWidth: number;
  36624. minHeight: number;
  36625. maxHeight: number;
  36626. deviceId: string;
  36627. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36628. }
  36629. }
  36630. declare module "babylonjs/Engines/thinEngine" {
  36631. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36632. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36633. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36634. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36635. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36636. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36637. import { Observable } from "babylonjs/Misc/observable";
  36638. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36639. import { StencilState } from "babylonjs/States/stencilState";
  36640. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36641. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36642. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36643. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36644. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36645. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36646. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36647. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36648. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36649. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36650. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36651. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36652. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36653. import { WebRequest } from "babylonjs/Misc/webRequest";
  36654. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36655. /**
  36656. * Defines the interface used by objects working like Scene
  36657. * @hidden
  36658. */
  36659. export interface ISceneLike {
  36660. _addPendingData(data: any): void;
  36661. _removePendingData(data: any): void;
  36662. offlineProvider: IOfflineProvider;
  36663. }
  36664. /**
  36665. * Information about the current host
  36666. */
  36667. export interface HostInformation {
  36668. /**
  36669. * Defines if the current host is a mobile
  36670. */
  36671. isMobile: boolean;
  36672. }
  36673. /** Interface defining initialization parameters for Engine class */
  36674. export interface EngineOptions extends WebGLContextAttributes {
  36675. /**
  36676. * Defines if the engine should no exceed a specified device ratio
  36677. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36678. */
  36679. limitDeviceRatio?: number;
  36680. /**
  36681. * Defines if webvr should be enabled automatically
  36682. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36683. */
  36684. autoEnableWebVR?: boolean;
  36685. /**
  36686. * Defines if webgl2 should be turned off even if supported
  36687. * @see https://doc.babylonjs.com/features/webgl2
  36688. */
  36689. disableWebGL2Support?: boolean;
  36690. /**
  36691. * Defines if webaudio should be initialized as well
  36692. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36693. */
  36694. audioEngine?: boolean;
  36695. /**
  36696. * Defines if animations should run using a deterministic lock step
  36697. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36698. */
  36699. deterministicLockstep?: boolean;
  36700. /** Defines the maximum steps to use with deterministic lock step mode */
  36701. lockstepMaxSteps?: number;
  36702. /** Defines the seconds between each deterministic lock step */
  36703. timeStep?: number;
  36704. /**
  36705. * Defines that engine should ignore context lost events
  36706. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36707. */
  36708. doNotHandleContextLost?: boolean;
  36709. /**
  36710. * Defines that engine should ignore modifying touch action attribute and style
  36711. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36712. */
  36713. doNotHandleTouchAction?: boolean;
  36714. /**
  36715. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36716. */
  36717. useHighPrecisionFloats?: boolean;
  36718. /**
  36719. * Make the canvas XR Compatible for XR sessions
  36720. */
  36721. xrCompatible?: boolean;
  36722. /**
  36723. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36724. */
  36725. useHighPrecisionMatrix?: boolean;
  36726. /**
  36727. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  36728. */
  36729. failIfMajorPerformanceCaveat?: boolean;
  36730. }
  36731. /**
  36732. * The base engine class (root of all engines)
  36733. */
  36734. export class ThinEngine {
  36735. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36736. static ExceptionList: ({
  36737. key: string;
  36738. capture: string;
  36739. captureConstraint: number;
  36740. targets: string[];
  36741. } | {
  36742. key: string;
  36743. capture: null;
  36744. captureConstraint: null;
  36745. targets: string[];
  36746. })[];
  36747. /** @hidden */
  36748. static _TextureLoaders: IInternalTextureLoader[];
  36749. /**
  36750. * Returns the current npm package of the sdk
  36751. */
  36752. static get NpmPackage(): string;
  36753. /**
  36754. * Returns the current version of the framework
  36755. */
  36756. static get Version(): string;
  36757. /**
  36758. * Returns a string describing the current engine
  36759. */
  36760. get description(): string;
  36761. /**
  36762. * Gets or sets the epsilon value used by collision engine
  36763. */
  36764. static CollisionsEpsilon: number;
  36765. /**
  36766. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36767. */
  36768. static get ShadersRepository(): string;
  36769. static set ShadersRepository(value: string);
  36770. /** @hidden */
  36771. _shaderProcessor: IShaderProcessor;
  36772. /**
  36773. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36774. */
  36775. forcePOTTextures: boolean;
  36776. /**
  36777. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36778. */
  36779. isFullscreen: boolean;
  36780. /**
  36781. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36782. */
  36783. cullBackFaces: boolean;
  36784. /**
  36785. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36786. */
  36787. renderEvenInBackground: boolean;
  36788. /**
  36789. * Gets or sets a boolean indicating that cache can be kept between frames
  36790. */
  36791. preventCacheWipeBetweenFrames: boolean;
  36792. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36793. validateShaderPrograms: boolean;
  36794. /**
  36795. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36796. * This can provide greater z depth for distant objects.
  36797. */
  36798. useReverseDepthBuffer: boolean;
  36799. /**
  36800. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36801. */
  36802. disableUniformBuffers: boolean;
  36803. /** @hidden */
  36804. _uniformBuffers: UniformBuffer[];
  36805. /**
  36806. * Gets a boolean indicating that the engine supports uniform buffers
  36807. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36808. */
  36809. get supportsUniformBuffers(): boolean;
  36810. /** @hidden */
  36811. _gl: WebGLRenderingContext;
  36812. /** @hidden */
  36813. _webGLVersion: number;
  36814. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36815. protected _windowIsBackground: boolean;
  36816. protected _creationOptions: EngineOptions;
  36817. protected _highPrecisionShadersAllowed: boolean;
  36818. /** @hidden */
  36819. get _shouldUseHighPrecisionShader(): boolean;
  36820. /**
  36821. * Gets a boolean indicating that only power of 2 textures are supported
  36822. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36823. */
  36824. get needPOTTextures(): boolean;
  36825. /** @hidden */
  36826. _badOS: boolean;
  36827. /** @hidden */
  36828. _badDesktopOS: boolean;
  36829. private _hardwareScalingLevel;
  36830. /** @hidden */
  36831. _caps: EngineCapabilities;
  36832. private _isStencilEnable;
  36833. private _glVersion;
  36834. private _glRenderer;
  36835. private _glVendor;
  36836. /** @hidden */
  36837. _videoTextureSupported: boolean;
  36838. protected _renderingQueueLaunched: boolean;
  36839. protected _activeRenderLoops: (() => void)[];
  36840. /**
  36841. * Observable signaled when a context lost event is raised
  36842. */
  36843. onContextLostObservable: Observable<ThinEngine>;
  36844. /**
  36845. * Observable signaled when a context restored event is raised
  36846. */
  36847. onContextRestoredObservable: Observable<ThinEngine>;
  36848. private _onContextLost;
  36849. private _onContextRestored;
  36850. protected _contextWasLost: boolean;
  36851. /** @hidden */
  36852. _doNotHandleContextLost: boolean;
  36853. /**
  36854. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36855. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36856. */
  36857. get doNotHandleContextLost(): boolean;
  36858. set doNotHandleContextLost(value: boolean);
  36859. /**
  36860. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36861. */
  36862. disableVertexArrayObjects: boolean;
  36863. /** @hidden */
  36864. protected _colorWrite: boolean;
  36865. /** @hidden */
  36866. protected _colorWriteChanged: boolean;
  36867. /** @hidden */
  36868. protected _depthCullingState: DepthCullingState;
  36869. /** @hidden */
  36870. protected _stencilState: StencilState;
  36871. /** @hidden */
  36872. _alphaState: AlphaState;
  36873. /** @hidden */
  36874. _alphaMode: number;
  36875. /** @hidden */
  36876. _alphaEquation: number;
  36877. /** @hidden */
  36878. _internalTexturesCache: InternalTexture[];
  36879. /** @hidden */
  36880. protected _activeChannel: number;
  36881. private _currentTextureChannel;
  36882. /** @hidden */
  36883. protected _boundTexturesCache: {
  36884. [key: string]: Nullable<InternalTexture>;
  36885. };
  36886. /** @hidden */
  36887. protected _currentEffect: Nullable<Effect>;
  36888. /** @hidden */
  36889. protected _currentProgram: Nullable<WebGLProgram>;
  36890. private _compiledEffects;
  36891. private _vertexAttribArraysEnabled;
  36892. /** @hidden */
  36893. protected _cachedViewport: Nullable<IViewportLike>;
  36894. private _cachedVertexArrayObject;
  36895. /** @hidden */
  36896. protected _cachedVertexBuffers: any;
  36897. /** @hidden */
  36898. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36899. /** @hidden */
  36900. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36901. /** @hidden */
  36902. _currentRenderTarget: Nullable<InternalTexture>;
  36903. private _uintIndicesCurrentlySet;
  36904. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36905. /** @hidden */
  36906. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36907. /** @hidden */
  36908. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36909. private _currentBufferPointers;
  36910. private _currentInstanceLocations;
  36911. private _currentInstanceBuffers;
  36912. private _textureUnits;
  36913. /** @hidden */
  36914. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36915. /** @hidden */
  36916. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36917. /** @hidden */
  36918. _boundRenderFunction: any;
  36919. private _vaoRecordInProgress;
  36920. private _mustWipeVertexAttributes;
  36921. private _emptyTexture;
  36922. private _emptyCubeTexture;
  36923. private _emptyTexture3D;
  36924. private _emptyTexture2DArray;
  36925. /** @hidden */
  36926. _frameHandler: number;
  36927. private _nextFreeTextureSlots;
  36928. private _maxSimultaneousTextures;
  36929. private _activeRequests;
  36930. /** @hidden */
  36931. _transformTextureUrl: Nullable<(url: string) => string>;
  36932. /**
  36933. * Gets information about the current host
  36934. */
  36935. hostInformation: HostInformation;
  36936. protected get _supportsHardwareTextureRescaling(): boolean;
  36937. private _framebufferDimensionsObject;
  36938. /**
  36939. * sets the object from which width and height will be taken from when getting render width and height
  36940. * Will fallback to the gl object
  36941. * @param dimensions the framebuffer width and height that will be used.
  36942. */
  36943. set framebufferDimensionsObject(dimensions: Nullable<{
  36944. framebufferWidth: number;
  36945. framebufferHeight: number;
  36946. }>);
  36947. /**
  36948. * Gets the current viewport
  36949. */
  36950. get currentViewport(): Nullable<IViewportLike>;
  36951. /**
  36952. * Gets the default empty texture
  36953. */
  36954. get emptyTexture(): InternalTexture;
  36955. /**
  36956. * Gets the default empty 3D texture
  36957. */
  36958. get emptyTexture3D(): InternalTexture;
  36959. /**
  36960. * Gets the default empty 2D array texture
  36961. */
  36962. get emptyTexture2DArray(): InternalTexture;
  36963. /**
  36964. * Gets the default empty cube texture
  36965. */
  36966. get emptyCubeTexture(): InternalTexture;
  36967. /**
  36968. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36969. */
  36970. readonly premultipliedAlpha: boolean;
  36971. /**
  36972. * Observable event triggered before each texture is initialized
  36973. */
  36974. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36975. /**
  36976. * Creates a new engine
  36977. * @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
  36978. * @param antialias defines enable antialiasing (default: false)
  36979. * @param options defines further options to be sent to the getContext() function
  36980. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36981. */
  36982. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36983. private _rebuildInternalTextures;
  36984. private _rebuildEffects;
  36985. /**
  36986. * Gets a boolean indicating if all created effects are ready
  36987. * @returns true if all effects are ready
  36988. */
  36989. areAllEffectsReady(): boolean;
  36990. protected _rebuildBuffers(): void;
  36991. protected _initGLContext(): void;
  36992. /**
  36993. * Gets version of the current webGL context
  36994. */
  36995. get webGLVersion(): number;
  36996. /**
  36997. * Gets a string identifying the name of the class
  36998. * @returns "Engine" string
  36999. */
  37000. getClassName(): string;
  37001. /**
  37002. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  37003. */
  37004. get isStencilEnable(): boolean;
  37005. /** @hidden */
  37006. _prepareWorkingCanvas(): void;
  37007. /**
  37008. * Reset the texture cache to empty state
  37009. */
  37010. resetTextureCache(): void;
  37011. /**
  37012. * Gets an object containing information about the current webGL context
  37013. * @returns an object containing the vender, the renderer and the version of the current webGL context
  37014. */
  37015. getGlInfo(): {
  37016. vendor: string;
  37017. renderer: string;
  37018. version: string;
  37019. };
  37020. /**
  37021. * Defines the hardware scaling level.
  37022. * By default the hardware scaling level is computed from the window device ratio.
  37023. * 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.
  37024. * @param level defines the level to use
  37025. */
  37026. setHardwareScalingLevel(level: number): void;
  37027. /**
  37028. * Gets the current hardware scaling level.
  37029. * By default the hardware scaling level is computed from the window device ratio.
  37030. * 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.
  37031. * @returns a number indicating the current hardware scaling level
  37032. */
  37033. getHardwareScalingLevel(): number;
  37034. /**
  37035. * Gets the list of loaded textures
  37036. * @returns an array containing all loaded textures
  37037. */
  37038. getLoadedTexturesCache(): InternalTexture[];
  37039. /**
  37040. * Gets the object containing all engine capabilities
  37041. * @returns the EngineCapabilities object
  37042. */
  37043. getCaps(): EngineCapabilities;
  37044. /**
  37045. * stop executing a render loop function and remove it from the execution array
  37046. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  37047. */
  37048. stopRenderLoop(renderFunction?: () => void): void;
  37049. /** @hidden */
  37050. _renderLoop(): void;
  37051. /**
  37052. * Gets the HTML canvas attached with the current webGL context
  37053. * @returns a HTML canvas
  37054. */
  37055. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  37056. /**
  37057. * Gets host window
  37058. * @returns the host window object
  37059. */
  37060. getHostWindow(): Nullable<Window>;
  37061. /**
  37062. * Gets the current render width
  37063. * @param useScreen defines if screen size must be used (or the current render target if any)
  37064. * @returns a number defining the current render width
  37065. */
  37066. getRenderWidth(useScreen?: boolean): number;
  37067. /**
  37068. * Gets the current render height
  37069. * @param useScreen defines if screen size must be used (or the current render target if any)
  37070. * @returns a number defining the current render height
  37071. */
  37072. getRenderHeight(useScreen?: boolean): number;
  37073. /**
  37074. * Can be used to override the current requestAnimationFrame requester.
  37075. * @hidden
  37076. */
  37077. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  37078. /**
  37079. * Register and execute a render loop. The engine can have more than one render function
  37080. * @param renderFunction defines the function to continuously execute
  37081. */
  37082. runRenderLoop(renderFunction: () => void): void;
  37083. /**
  37084. * Clear the current render buffer or the current render target (if any is set up)
  37085. * @param color defines the color to use
  37086. * @param backBuffer defines if the back buffer must be cleared
  37087. * @param depth defines if the depth buffer must be cleared
  37088. * @param stencil defines if the stencil buffer must be cleared
  37089. */
  37090. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  37091. private _viewportCached;
  37092. /** @hidden */
  37093. _viewport(x: number, y: number, width: number, height: number): void;
  37094. /**
  37095. * Set the WebGL's viewport
  37096. * @param viewport defines the viewport element to be used
  37097. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  37098. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  37099. */
  37100. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  37101. /**
  37102. * Begin a new frame
  37103. */
  37104. beginFrame(): void;
  37105. /**
  37106. * Enf the current frame
  37107. */
  37108. endFrame(): void;
  37109. /**
  37110. * Resize the view according to the canvas' size
  37111. */
  37112. resize(): void;
  37113. /**
  37114. * Force a specific size of the canvas
  37115. * @param width defines the new canvas' width
  37116. * @param height defines the new canvas' height
  37117. * @returns true if the size was changed
  37118. */
  37119. setSize(width: number, height: number): boolean;
  37120. /**
  37121. * Binds the frame buffer to the specified texture.
  37122. * @param texture The texture to render to or null for the default canvas
  37123. * @param faceIndex The face of the texture to render to in case of cube texture
  37124. * @param requiredWidth The width of the target to render to
  37125. * @param requiredHeight The height of the target to render to
  37126. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  37127. * @param lodLevel defines the lod level to bind to the frame buffer
  37128. * @param layer defines the 2d array index to bind to frame buffer to
  37129. */
  37130. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  37131. /** @hidden */
  37132. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  37133. /**
  37134. * Unbind the current render target texture from the webGL context
  37135. * @param texture defines the render target texture to unbind
  37136. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  37137. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  37138. */
  37139. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  37140. /**
  37141. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  37142. */
  37143. flushFramebuffer(): void;
  37144. /**
  37145. * Unbind the current render target and bind the default framebuffer
  37146. */
  37147. restoreDefaultFramebuffer(): void;
  37148. /** @hidden */
  37149. protected _resetVertexBufferBinding(): void;
  37150. /**
  37151. * Creates a vertex buffer
  37152. * @param data the data for the vertex buffer
  37153. * @returns the new WebGL static buffer
  37154. */
  37155. createVertexBuffer(data: DataArray): DataBuffer;
  37156. private _createVertexBuffer;
  37157. /**
  37158. * Creates a dynamic vertex buffer
  37159. * @param data the data for the dynamic vertex buffer
  37160. * @returns the new WebGL dynamic buffer
  37161. */
  37162. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  37163. protected _resetIndexBufferBinding(): void;
  37164. /**
  37165. * Creates a new index buffer
  37166. * @param indices defines the content of the index buffer
  37167. * @param updatable defines if the index buffer must be updatable
  37168. * @returns a new webGL buffer
  37169. */
  37170. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  37171. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  37172. /**
  37173. * Bind a webGL buffer to the webGL context
  37174. * @param buffer defines the buffer to bind
  37175. */
  37176. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  37177. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  37178. private bindBuffer;
  37179. /**
  37180. * update the bound buffer with the given data
  37181. * @param data defines the data to update
  37182. */
  37183. updateArrayBuffer(data: Float32Array): void;
  37184. private _vertexAttribPointer;
  37185. /** @hidden */
  37186. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  37187. private _bindVertexBuffersAttributes;
  37188. /**
  37189. * Records a vertex array object
  37190. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37191. * @param vertexBuffers defines the list of vertex buffers to store
  37192. * @param indexBuffer defines the index buffer to store
  37193. * @param effect defines the effect to store
  37194. * @returns the new vertex array object
  37195. */
  37196. recordVertexArrayObject(vertexBuffers: {
  37197. [key: string]: VertexBuffer;
  37198. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  37199. /**
  37200. * Bind a specific vertex array object
  37201. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37202. * @param vertexArrayObject defines the vertex array object to bind
  37203. * @param indexBuffer defines the index buffer to bind
  37204. */
  37205. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  37206. /**
  37207. * Bind webGl buffers directly to the webGL context
  37208. * @param vertexBuffer defines the vertex buffer to bind
  37209. * @param indexBuffer defines the index buffer to bind
  37210. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  37211. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  37212. * @param effect defines the effect associated with the vertex buffer
  37213. */
  37214. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  37215. private _unbindVertexArrayObject;
  37216. /**
  37217. * Bind a list of vertex buffers to the webGL context
  37218. * @param vertexBuffers defines the list of vertex buffers to bind
  37219. * @param indexBuffer defines the index buffer to bind
  37220. * @param effect defines the effect associated with the vertex buffers
  37221. */
  37222. bindBuffers(vertexBuffers: {
  37223. [key: string]: Nullable<VertexBuffer>;
  37224. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37225. /**
  37226. * Unbind all instance attributes
  37227. */
  37228. unbindInstanceAttributes(): void;
  37229. /**
  37230. * Release and free the memory of a vertex array object
  37231. * @param vao defines the vertex array object to delete
  37232. */
  37233. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37234. /** @hidden */
  37235. _releaseBuffer(buffer: DataBuffer): boolean;
  37236. protected _deleteBuffer(buffer: DataBuffer): void;
  37237. /**
  37238. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37239. * @param instancesBuffer defines the webGL buffer to update and bind
  37240. * @param data defines the data to store in the buffer
  37241. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37242. */
  37243. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37244. /**
  37245. * Bind the content of a webGL buffer used with instantiation
  37246. * @param instancesBuffer defines the webGL buffer to bind
  37247. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37248. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37249. */
  37250. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37251. /**
  37252. * Disable the instance attribute corresponding to the name in parameter
  37253. * @param name defines the name of the attribute to disable
  37254. */
  37255. disableInstanceAttributeByName(name: string): void;
  37256. /**
  37257. * Disable the instance attribute corresponding to the location in parameter
  37258. * @param attributeLocation defines the attribute location of the attribute to disable
  37259. */
  37260. disableInstanceAttribute(attributeLocation: number): void;
  37261. /**
  37262. * Disable the attribute corresponding to the location in parameter
  37263. * @param attributeLocation defines the attribute location of the attribute to disable
  37264. */
  37265. disableAttributeByIndex(attributeLocation: number): void;
  37266. /**
  37267. * Send a draw order
  37268. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37269. * @param indexStart defines the starting index
  37270. * @param indexCount defines the number of index to draw
  37271. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37272. */
  37273. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37274. /**
  37275. * Draw a list of points
  37276. * @param verticesStart defines the index of first vertex to draw
  37277. * @param verticesCount defines the count of vertices to draw
  37278. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37279. */
  37280. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37281. /**
  37282. * Draw a list of unindexed primitives
  37283. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37284. * @param verticesStart defines the index of first vertex to draw
  37285. * @param verticesCount defines the count of vertices to draw
  37286. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37287. */
  37288. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37289. /**
  37290. * Draw a list of indexed primitives
  37291. * @param fillMode defines the primitive to use
  37292. * @param indexStart defines the starting index
  37293. * @param indexCount defines the number of index to draw
  37294. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37295. */
  37296. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37297. /**
  37298. * Draw a list of unindexed primitives
  37299. * @param fillMode defines the primitive to use
  37300. * @param verticesStart defines the index of first vertex to draw
  37301. * @param verticesCount defines the count of vertices to draw
  37302. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37303. */
  37304. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37305. private _drawMode;
  37306. /** @hidden */
  37307. protected _reportDrawCall(): void;
  37308. /** @hidden */
  37309. _releaseEffect(effect: Effect): void;
  37310. /** @hidden */
  37311. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37312. /**
  37313. * Create a new effect (used to store vertex/fragment shaders)
  37314. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37315. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37316. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37317. * @param samplers defines an array of string used to represent textures
  37318. * @param defines defines the string containing the defines to use to compile the shaders
  37319. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37320. * @param onCompiled defines a function to call when the effect creation is successful
  37321. * @param onError defines a function to call when the effect creation has failed
  37322. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37323. * @returns the new Effect
  37324. */
  37325. 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;
  37326. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37327. private _compileShader;
  37328. private _compileRawShader;
  37329. /** @hidden */
  37330. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37331. /**
  37332. * Directly creates a webGL program
  37333. * @param pipelineContext defines the pipeline context to attach to
  37334. * @param vertexCode defines the vertex shader code to use
  37335. * @param fragmentCode defines the fragment shader code to use
  37336. * @param context defines the webGL context to use (if not set, the current one will be used)
  37337. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37338. * @returns the new webGL program
  37339. */
  37340. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37341. /**
  37342. * Creates a webGL program
  37343. * @param pipelineContext defines the pipeline context to attach to
  37344. * @param vertexCode defines the vertex shader code to use
  37345. * @param fragmentCode defines the fragment shader code to use
  37346. * @param defines defines the string containing the defines to use to compile the shaders
  37347. * @param context defines the webGL context to use (if not set, the current one will be used)
  37348. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37349. * @returns the new webGL program
  37350. */
  37351. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37352. /**
  37353. * Creates a new pipeline context
  37354. * @returns the new pipeline
  37355. */
  37356. createPipelineContext(): IPipelineContext;
  37357. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37358. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37359. /** @hidden */
  37360. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37361. /** @hidden */
  37362. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37363. /** @hidden */
  37364. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37365. /**
  37366. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37367. * @param pipelineContext defines the pipeline context to use
  37368. * @param uniformsNames defines the list of uniform names
  37369. * @returns an array of webGL uniform locations
  37370. */
  37371. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37372. /**
  37373. * Gets the lsit of active attributes for a given webGL program
  37374. * @param pipelineContext defines the pipeline context to use
  37375. * @param attributesNames defines the list of attribute names to get
  37376. * @returns an array of indices indicating the offset of each attribute
  37377. */
  37378. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37379. /**
  37380. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37381. * @param effect defines the effect to activate
  37382. */
  37383. enableEffect(effect: Nullable<Effect>): void;
  37384. /**
  37385. * Set the value of an uniform to a number (int)
  37386. * @param uniform defines the webGL uniform location where to store the value
  37387. * @param value defines the int number to store
  37388. * @returns true if the value was set
  37389. */
  37390. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37391. /**
  37392. * Set the value of an uniform to an array of int32
  37393. * @param uniform defines the webGL uniform location where to store the value
  37394. * @param array defines the array of int32 to store
  37395. * @returns true if the value was set
  37396. */
  37397. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37398. /**
  37399. * Set the value of an uniform to an array of int32 (stored as vec2)
  37400. * @param uniform defines the webGL uniform location where to store the value
  37401. * @param array defines the array of int32 to store
  37402. * @returns true if the value was set
  37403. */
  37404. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37405. /**
  37406. * Set the value of an uniform to an array of int32 (stored as vec3)
  37407. * @param uniform defines the webGL uniform location where to store the value
  37408. * @param array defines the array of int32 to store
  37409. * @returns true if the value was set
  37410. */
  37411. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37412. /**
  37413. * Set the value of an uniform to an array of int32 (stored as vec4)
  37414. * @param uniform defines the webGL uniform location where to store the value
  37415. * @param array defines the array of int32 to store
  37416. * @returns true if the value was set
  37417. */
  37418. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37419. /**
  37420. * Set the value of an uniform to an array of number
  37421. * @param uniform defines the webGL uniform location where to store the value
  37422. * @param array defines the array of number to store
  37423. * @returns true if the value was set
  37424. */
  37425. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37426. /**
  37427. * Set the value of an uniform to an array of number (stored as vec2)
  37428. * @param uniform defines the webGL uniform location where to store the value
  37429. * @param array defines the array of number to store
  37430. * @returns true if the value was set
  37431. */
  37432. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37433. /**
  37434. * Set the value of an uniform to an array of number (stored as vec3)
  37435. * @param uniform defines the webGL uniform location where to store the value
  37436. * @param array defines the array of number to store
  37437. * @returns true if the value was set
  37438. */
  37439. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37440. /**
  37441. * Set the value of an uniform to an array of number (stored as vec4)
  37442. * @param uniform defines the webGL uniform location where to store the value
  37443. * @param array defines the array of number to store
  37444. * @returns true if the value was set
  37445. */
  37446. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37447. /**
  37448. * Set the value of an uniform to an array of float32 (stored as matrices)
  37449. * @param uniform defines the webGL uniform location where to store the value
  37450. * @param matrices defines the array of float32 to store
  37451. * @returns true if the value was set
  37452. */
  37453. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  37454. /**
  37455. * Set the value of an uniform to a matrix (3x3)
  37456. * @param uniform defines the webGL uniform location where to store the value
  37457. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37458. * @returns true if the value was set
  37459. */
  37460. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37461. /**
  37462. * Set the value of an uniform to a matrix (2x2)
  37463. * @param uniform defines the webGL uniform location where to store the value
  37464. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37465. * @returns true if the value was set
  37466. */
  37467. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37468. /**
  37469. * Set the value of an uniform to a number (float)
  37470. * @param uniform defines the webGL uniform location where to store the value
  37471. * @param value defines the float number to store
  37472. * @returns true if the value was transfered
  37473. */
  37474. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37475. /**
  37476. * Set the value of an uniform to a vec2
  37477. * @param uniform defines the webGL uniform location where to store the value
  37478. * @param x defines the 1st component of the value
  37479. * @param y defines the 2nd component of the value
  37480. * @returns true if the value was set
  37481. */
  37482. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  37483. /**
  37484. * Set the value of an uniform to a vec3
  37485. * @param uniform defines the webGL uniform location where to store the value
  37486. * @param x defines the 1st component of the value
  37487. * @param y defines the 2nd component of the value
  37488. * @param z defines the 3rd component of the value
  37489. * @returns true if the value was set
  37490. */
  37491. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  37492. /**
  37493. * Set the value of an uniform to a vec4
  37494. * @param uniform defines the webGL uniform location where to store the value
  37495. * @param x defines the 1st component of the value
  37496. * @param y defines the 2nd component of the value
  37497. * @param z defines the 3rd component of the value
  37498. * @param w defines the 4th component of the value
  37499. * @returns true if the value was set
  37500. */
  37501. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  37502. /**
  37503. * Apply all cached states (depth, culling, stencil and alpha)
  37504. */
  37505. applyStates(): void;
  37506. /**
  37507. * Enable or disable color writing
  37508. * @param enable defines the state to set
  37509. */
  37510. setColorWrite(enable: boolean): void;
  37511. /**
  37512. * Gets a boolean indicating if color writing is enabled
  37513. * @returns the current color writing state
  37514. */
  37515. getColorWrite(): boolean;
  37516. /**
  37517. * Gets the depth culling state manager
  37518. */
  37519. get depthCullingState(): DepthCullingState;
  37520. /**
  37521. * Gets the alpha state manager
  37522. */
  37523. get alphaState(): AlphaState;
  37524. /**
  37525. * Gets the stencil state manager
  37526. */
  37527. get stencilState(): StencilState;
  37528. /**
  37529. * Clears the list of texture accessible through engine.
  37530. * This can help preventing texture load conflict due to name collision.
  37531. */
  37532. clearInternalTexturesCache(): void;
  37533. /**
  37534. * Force the entire cache to be cleared
  37535. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37536. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37537. */
  37538. wipeCaches(bruteForce?: boolean): void;
  37539. /** @hidden */
  37540. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37541. min: number;
  37542. mag: number;
  37543. };
  37544. /** @hidden */
  37545. _createTexture(): WebGLTexture;
  37546. /**
  37547. * Usually called from Texture.ts.
  37548. * Passed information to create a WebGLTexture
  37549. * @param url defines a value which contains one of the following:
  37550. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37551. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37552. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37553. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37554. * @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)
  37555. * @param scene needed for loading to the correct scene
  37556. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37557. * @param onLoad optional callback to be called upon successful completion
  37558. * @param onError optional callback to be called upon failure
  37559. * @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
  37560. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37561. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37562. * @param forcedExtension defines the extension to use to pick the right loader
  37563. * @param mimeType defines an optional mime type
  37564. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37565. */
  37566. 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;
  37567. /**
  37568. * Loads an image as an HTMLImageElement.
  37569. * @param input url string, ArrayBuffer, or Blob to load
  37570. * @param onLoad callback called when the image successfully loads
  37571. * @param onError callback called when the image fails to load
  37572. * @param offlineProvider offline provider for caching
  37573. * @param mimeType optional mime type
  37574. * @returns the HTMLImageElement of the loaded image
  37575. * @hidden
  37576. */
  37577. 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>;
  37578. /**
  37579. * @hidden
  37580. */
  37581. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37582. private _unpackFlipYCached;
  37583. /**
  37584. * In case you are sharing the context with other applications, it might
  37585. * be interested to not cache the unpack flip y state to ensure a consistent
  37586. * value would be set.
  37587. */
  37588. enableUnpackFlipYCached: boolean;
  37589. /** @hidden */
  37590. _unpackFlipY(value: boolean): void;
  37591. /** @hidden */
  37592. _getUnpackAlignement(): number;
  37593. private _getTextureTarget;
  37594. /**
  37595. * Update the sampling mode of a given texture
  37596. * @param samplingMode defines the required sampling mode
  37597. * @param texture defines the texture to update
  37598. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37599. */
  37600. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37601. /**
  37602. * Update the sampling mode of a given texture
  37603. * @param texture defines the texture to update
  37604. * @param wrapU defines the texture wrap mode of the u coordinates
  37605. * @param wrapV defines the texture wrap mode of the v coordinates
  37606. * @param wrapR defines the texture wrap mode of the r coordinates
  37607. */
  37608. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37609. /** @hidden */
  37610. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37611. width: number;
  37612. height: number;
  37613. layers?: number;
  37614. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37615. /** @hidden */
  37616. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37617. /** @hidden */
  37618. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37619. /**
  37620. * Update a portion of an internal texture
  37621. * @param texture defines the texture to update
  37622. * @param imageData defines the data to store into the texture
  37623. * @param xOffset defines the x coordinates of the update rectangle
  37624. * @param yOffset defines the y coordinates of the update rectangle
  37625. * @param width defines the width of the update rectangle
  37626. * @param height defines the height of the update rectangle
  37627. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37628. * @param lod defines the lod level to update (0 by default)
  37629. */
  37630. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37631. /** @hidden */
  37632. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37633. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37634. private _prepareWebGLTexture;
  37635. /** @hidden */
  37636. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37637. private _getDepthStencilBuffer;
  37638. /** @hidden */
  37639. _releaseFramebufferObjects(texture: InternalTexture): void;
  37640. /** @hidden */
  37641. _releaseTexture(texture: InternalTexture): void;
  37642. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37643. protected _setProgram(program: WebGLProgram): void;
  37644. protected _boundUniforms: {
  37645. [key: number]: WebGLUniformLocation;
  37646. };
  37647. /**
  37648. * Binds an effect to the webGL context
  37649. * @param effect defines the effect to bind
  37650. */
  37651. bindSamplers(effect: Effect): void;
  37652. private _activateCurrentTexture;
  37653. /** @hidden */
  37654. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37655. /** @hidden */
  37656. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37657. /**
  37658. * Unbind all textures from the webGL context
  37659. */
  37660. unbindAllTextures(): void;
  37661. /**
  37662. * Sets a texture to the according uniform.
  37663. * @param channel The texture channel
  37664. * @param uniform The uniform to set
  37665. * @param texture The texture to apply
  37666. */
  37667. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37668. private _bindSamplerUniformToChannel;
  37669. private _getTextureWrapMode;
  37670. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37671. /**
  37672. * Sets an array of texture to the webGL context
  37673. * @param channel defines the channel where the texture array must be set
  37674. * @param uniform defines the associated uniform location
  37675. * @param textures defines the array of textures to bind
  37676. */
  37677. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37678. /** @hidden */
  37679. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37680. private _setTextureParameterFloat;
  37681. private _setTextureParameterInteger;
  37682. /**
  37683. * Unbind all vertex attributes from the webGL context
  37684. */
  37685. unbindAllAttributes(): void;
  37686. /**
  37687. * 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
  37688. */
  37689. releaseEffects(): void;
  37690. /**
  37691. * Dispose and release all associated resources
  37692. */
  37693. dispose(): void;
  37694. /**
  37695. * Attach a new callback raised when context lost event is fired
  37696. * @param callback defines the callback to call
  37697. */
  37698. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37699. /**
  37700. * Attach a new callback raised when context restored event is fired
  37701. * @param callback defines the callback to call
  37702. */
  37703. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37704. /**
  37705. * Get the current error code of the webGL context
  37706. * @returns the error code
  37707. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37708. */
  37709. getError(): number;
  37710. private _canRenderToFloatFramebuffer;
  37711. private _canRenderToHalfFloatFramebuffer;
  37712. private _canRenderToFramebuffer;
  37713. /** @hidden */
  37714. _getWebGLTextureType(type: number): number;
  37715. /** @hidden */
  37716. _getInternalFormat(format: number): number;
  37717. /** @hidden */
  37718. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37719. /** @hidden */
  37720. _getRGBAMultiSampleBufferFormat(type: number): number;
  37721. /** @hidden */
  37722. _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;
  37723. /**
  37724. * Loads a file from a url
  37725. * @param url url to load
  37726. * @param onSuccess callback called when the file successfully loads
  37727. * @param onProgress callback called while file is loading (if the server supports this mode)
  37728. * @param offlineProvider defines the offline provider for caching
  37729. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37730. * @param onError callback called when the file fails to load
  37731. * @returns a file request object
  37732. * @hidden
  37733. */
  37734. 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;
  37735. /**
  37736. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37737. * @param x defines the x coordinate of the rectangle where pixels must be read
  37738. * @param y defines the y coordinate of the rectangle where pixels must be read
  37739. * @param width defines the width of the rectangle where pixels must be read
  37740. * @param height defines the height of the rectangle where pixels must be read
  37741. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37742. * @returns a Uint8Array containing RGBA colors
  37743. */
  37744. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37745. private static _IsSupported;
  37746. private static _HasMajorPerformanceCaveat;
  37747. /**
  37748. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37749. */
  37750. static get IsSupported(): boolean;
  37751. /**
  37752. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37753. * @returns true if the engine can be created
  37754. * @ignorenaming
  37755. */
  37756. static isSupported(): boolean;
  37757. /**
  37758. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  37759. */
  37760. static get HasMajorPerformanceCaveat(): boolean;
  37761. /**
  37762. * Find the next highest power of two.
  37763. * @param x Number to start search from.
  37764. * @return Next highest power of two.
  37765. */
  37766. static CeilingPOT(x: number): number;
  37767. /**
  37768. * Find the next lowest power of two.
  37769. * @param x Number to start search from.
  37770. * @return Next lowest power of two.
  37771. */
  37772. static FloorPOT(x: number): number;
  37773. /**
  37774. * Find the nearest power of two.
  37775. * @param x Number to start search from.
  37776. * @return Next nearest power of two.
  37777. */
  37778. static NearestPOT(x: number): number;
  37779. /**
  37780. * Get the closest exponent of two
  37781. * @param value defines the value to approximate
  37782. * @param max defines the maximum value to return
  37783. * @param mode defines how to define the closest value
  37784. * @returns closest exponent of two of the given value
  37785. */
  37786. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37787. /**
  37788. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37789. * @param func - the function to be called
  37790. * @param requester - the object that will request the next frame. Falls back to window.
  37791. * @returns frame number
  37792. */
  37793. static QueueNewFrame(func: () => void, requester?: any): number;
  37794. /**
  37795. * Gets host document
  37796. * @returns the host document object
  37797. */
  37798. getHostDocument(): Nullable<Document>;
  37799. }
  37800. }
  37801. declare module "babylonjs/Maths/sphericalPolynomial" {
  37802. import { Vector3 } from "babylonjs/Maths/math.vector";
  37803. import { Color3 } from "babylonjs/Maths/math.color";
  37804. /**
  37805. * Class representing spherical harmonics coefficients to the 3rd degree
  37806. */
  37807. export class SphericalHarmonics {
  37808. /**
  37809. * Defines whether or not the harmonics have been prescaled for rendering.
  37810. */
  37811. preScaled: boolean;
  37812. /**
  37813. * The l0,0 coefficients of the spherical harmonics
  37814. */
  37815. l00: Vector3;
  37816. /**
  37817. * The l1,-1 coefficients of the spherical harmonics
  37818. */
  37819. l1_1: Vector3;
  37820. /**
  37821. * The l1,0 coefficients of the spherical harmonics
  37822. */
  37823. l10: Vector3;
  37824. /**
  37825. * The l1,1 coefficients of the spherical harmonics
  37826. */
  37827. l11: Vector3;
  37828. /**
  37829. * The l2,-2 coefficients of the spherical harmonics
  37830. */
  37831. l2_2: Vector3;
  37832. /**
  37833. * The l2,-1 coefficients of the spherical harmonics
  37834. */
  37835. l2_1: Vector3;
  37836. /**
  37837. * The l2,0 coefficients of the spherical harmonics
  37838. */
  37839. l20: Vector3;
  37840. /**
  37841. * The l2,1 coefficients of the spherical harmonics
  37842. */
  37843. l21: Vector3;
  37844. /**
  37845. * The l2,2 coefficients of the spherical harmonics
  37846. */
  37847. l22: Vector3;
  37848. /**
  37849. * Adds a light to the spherical harmonics
  37850. * @param direction the direction of the light
  37851. * @param color the color of the light
  37852. * @param deltaSolidAngle the delta solid angle of the light
  37853. */
  37854. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37855. /**
  37856. * Scales the spherical harmonics by the given amount
  37857. * @param scale the amount to scale
  37858. */
  37859. scaleInPlace(scale: number): void;
  37860. /**
  37861. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37862. *
  37863. * ```
  37864. * E_lm = A_l * L_lm
  37865. * ```
  37866. *
  37867. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37868. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37869. * the scaling factors are given in equation 9.
  37870. */
  37871. convertIncidentRadianceToIrradiance(): void;
  37872. /**
  37873. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37874. *
  37875. * ```
  37876. * L = (1/pi) * E * rho
  37877. * ```
  37878. *
  37879. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37880. */
  37881. convertIrradianceToLambertianRadiance(): void;
  37882. /**
  37883. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37884. * required operations at run time.
  37885. *
  37886. * This is simply done by scaling back the SH with Ylm constants parameter.
  37887. * The trigonometric part being applied by the shader at run time.
  37888. */
  37889. preScaleForRendering(): void;
  37890. /**
  37891. * Constructs a spherical harmonics from an array.
  37892. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37893. * @returns the spherical harmonics
  37894. */
  37895. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37896. /**
  37897. * Gets the spherical harmonics from polynomial
  37898. * @param polynomial the spherical polynomial
  37899. * @returns the spherical harmonics
  37900. */
  37901. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37902. }
  37903. /**
  37904. * Class representing spherical polynomial coefficients to the 3rd degree
  37905. */
  37906. export class SphericalPolynomial {
  37907. private _harmonics;
  37908. /**
  37909. * The spherical harmonics used to create the polynomials.
  37910. */
  37911. get preScaledHarmonics(): SphericalHarmonics;
  37912. /**
  37913. * The x coefficients of the spherical polynomial
  37914. */
  37915. x: Vector3;
  37916. /**
  37917. * The y coefficients of the spherical polynomial
  37918. */
  37919. y: Vector3;
  37920. /**
  37921. * The z coefficients of the spherical polynomial
  37922. */
  37923. z: Vector3;
  37924. /**
  37925. * The xx coefficients of the spherical polynomial
  37926. */
  37927. xx: Vector3;
  37928. /**
  37929. * The yy coefficients of the spherical polynomial
  37930. */
  37931. yy: Vector3;
  37932. /**
  37933. * The zz coefficients of the spherical polynomial
  37934. */
  37935. zz: Vector3;
  37936. /**
  37937. * The xy coefficients of the spherical polynomial
  37938. */
  37939. xy: Vector3;
  37940. /**
  37941. * The yz coefficients of the spherical polynomial
  37942. */
  37943. yz: Vector3;
  37944. /**
  37945. * The zx coefficients of the spherical polynomial
  37946. */
  37947. zx: Vector3;
  37948. /**
  37949. * Adds an ambient color to the spherical polynomial
  37950. * @param color the color to add
  37951. */
  37952. addAmbient(color: Color3): void;
  37953. /**
  37954. * Scales the spherical polynomial by the given amount
  37955. * @param scale the amount to scale
  37956. */
  37957. scaleInPlace(scale: number): void;
  37958. /**
  37959. * Gets the spherical polynomial from harmonics
  37960. * @param harmonics the spherical harmonics
  37961. * @returns the spherical polynomial
  37962. */
  37963. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37964. /**
  37965. * Constructs a spherical polynomial from an array.
  37966. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37967. * @returns the spherical polynomial
  37968. */
  37969. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37970. }
  37971. }
  37972. declare module "babylonjs/Materials/Textures/internalTexture" {
  37973. import { Observable } from "babylonjs/Misc/observable";
  37974. import { Nullable, int } from "babylonjs/types";
  37975. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37976. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37977. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37978. /**
  37979. * Defines the source of the internal texture
  37980. */
  37981. export enum InternalTextureSource {
  37982. /**
  37983. * The source of the texture data is unknown
  37984. */
  37985. Unknown = 0,
  37986. /**
  37987. * Texture data comes from an URL
  37988. */
  37989. Url = 1,
  37990. /**
  37991. * Texture data is only used for temporary storage
  37992. */
  37993. Temp = 2,
  37994. /**
  37995. * Texture data comes from raw data (ArrayBuffer)
  37996. */
  37997. Raw = 3,
  37998. /**
  37999. * Texture content is dynamic (video or dynamic texture)
  38000. */
  38001. Dynamic = 4,
  38002. /**
  38003. * Texture content is generated by rendering to it
  38004. */
  38005. RenderTarget = 5,
  38006. /**
  38007. * Texture content is part of a multi render target process
  38008. */
  38009. MultiRenderTarget = 6,
  38010. /**
  38011. * Texture data comes from a cube data file
  38012. */
  38013. Cube = 7,
  38014. /**
  38015. * Texture data comes from a raw cube data
  38016. */
  38017. CubeRaw = 8,
  38018. /**
  38019. * Texture data come from a prefiltered cube data file
  38020. */
  38021. CubePrefiltered = 9,
  38022. /**
  38023. * Texture content is raw 3D data
  38024. */
  38025. Raw3D = 10,
  38026. /**
  38027. * Texture content is raw 2D array data
  38028. */
  38029. Raw2DArray = 11,
  38030. /**
  38031. * Texture content is a depth texture
  38032. */
  38033. Depth = 12,
  38034. /**
  38035. * Texture data comes from a raw cube data encoded with RGBD
  38036. */
  38037. CubeRawRGBD = 13
  38038. }
  38039. /**
  38040. * Class used to store data associated with WebGL texture data for the engine
  38041. * This class should not be used directly
  38042. */
  38043. export class InternalTexture {
  38044. /** @hidden */
  38045. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  38046. /**
  38047. * Defines if the texture is ready
  38048. */
  38049. isReady: boolean;
  38050. /**
  38051. * Defines if the texture is a cube texture
  38052. */
  38053. isCube: boolean;
  38054. /**
  38055. * Defines if the texture contains 3D data
  38056. */
  38057. is3D: boolean;
  38058. /**
  38059. * Defines if the texture contains 2D array data
  38060. */
  38061. is2DArray: boolean;
  38062. /**
  38063. * Defines if the texture contains multiview data
  38064. */
  38065. isMultiview: boolean;
  38066. /**
  38067. * Gets the URL used to load this texture
  38068. */
  38069. url: string;
  38070. /**
  38071. * Gets the sampling mode of the texture
  38072. */
  38073. samplingMode: number;
  38074. /**
  38075. * Gets a boolean indicating if the texture needs mipmaps generation
  38076. */
  38077. generateMipMaps: boolean;
  38078. /**
  38079. * Gets the number of samples used by the texture (WebGL2+ only)
  38080. */
  38081. samples: number;
  38082. /**
  38083. * Gets the type of the texture (int, float...)
  38084. */
  38085. type: number;
  38086. /**
  38087. * Gets the format of the texture (RGB, RGBA...)
  38088. */
  38089. format: number;
  38090. /**
  38091. * Observable called when the texture is loaded
  38092. */
  38093. onLoadedObservable: Observable<InternalTexture>;
  38094. /**
  38095. * Gets the width of the texture
  38096. */
  38097. width: number;
  38098. /**
  38099. * Gets the height of the texture
  38100. */
  38101. height: number;
  38102. /**
  38103. * Gets the depth of the texture
  38104. */
  38105. depth: number;
  38106. /**
  38107. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  38108. */
  38109. baseWidth: number;
  38110. /**
  38111. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  38112. */
  38113. baseHeight: number;
  38114. /**
  38115. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  38116. */
  38117. baseDepth: number;
  38118. /**
  38119. * Gets a boolean indicating if the texture is inverted on Y axis
  38120. */
  38121. invertY: boolean;
  38122. /** @hidden */
  38123. _invertVScale: boolean;
  38124. /** @hidden */
  38125. _associatedChannel: number;
  38126. /** @hidden */
  38127. _source: InternalTextureSource;
  38128. /** @hidden */
  38129. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  38130. /** @hidden */
  38131. _bufferView: Nullable<ArrayBufferView>;
  38132. /** @hidden */
  38133. _bufferViewArray: Nullable<ArrayBufferView[]>;
  38134. /** @hidden */
  38135. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  38136. /** @hidden */
  38137. _size: number;
  38138. /** @hidden */
  38139. _extension: string;
  38140. /** @hidden */
  38141. _files: Nullable<string[]>;
  38142. /** @hidden */
  38143. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38144. /** @hidden */
  38145. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38146. /** @hidden */
  38147. _framebuffer: Nullable<WebGLFramebuffer>;
  38148. /** @hidden */
  38149. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  38150. /** @hidden */
  38151. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  38152. /** @hidden */
  38153. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  38154. /** @hidden */
  38155. _attachments: Nullable<number[]>;
  38156. /** @hidden */
  38157. _textureArray: Nullable<InternalTexture[]>;
  38158. /** @hidden */
  38159. _cachedCoordinatesMode: Nullable<number>;
  38160. /** @hidden */
  38161. _cachedWrapU: Nullable<number>;
  38162. /** @hidden */
  38163. _cachedWrapV: Nullable<number>;
  38164. /** @hidden */
  38165. _cachedWrapR: Nullable<number>;
  38166. /** @hidden */
  38167. _cachedAnisotropicFilteringLevel: Nullable<number>;
  38168. /** @hidden */
  38169. _isDisabled: boolean;
  38170. /** @hidden */
  38171. _compression: Nullable<string>;
  38172. /** @hidden */
  38173. _generateStencilBuffer: boolean;
  38174. /** @hidden */
  38175. _generateDepthBuffer: boolean;
  38176. /** @hidden */
  38177. _comparisonFunction: number;
  38178. /** @hidden */
  38179. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38180. /** @hidden */
  38181. _lodGenerationScale: number;
  38182. /** @hidden */
  38183. _lodGenerationOffset: number;
  38184. /** @hidden */
  38185. _depthStencilTexture: Nullable<InternalTexture>;
  38186. /** @hidden */
  38187. _colorTextureArray: Nullable<WebGLTexture>;
  38188. /** @hidden */
  38189. _depthStencilTextureArray: Nullable<WebGLTexture>;
  38190. /** @hidden */
  38191. _lodTextureHigh: Nullable<BaseTexture>;
  38192. /** @hidden */
  38193. _lodTextureMid: Nullable<BaseTexture>;
  38194. /** @hidden */
  38195. _lodTextureLow: Nullable<BaseTexture>;
  38196. /** @hidden */
  38197. _isRGBD: boolean;
  38198. /** @hidden */
  38199. _linearSpecularLOD: boolean;
  38200. /** @hidden */
  38201. _irradianceTexture: Nullable<BaseTexture>;
  38202. /** @hidden */
  38203. _webGLTexture: Nullable<WebGLTexture>;
  38204. /** @hidden */
  38205. _references: number;
  38206. /** @hidden */
  38207. _gammaSpace: Nullable<boolean>;
  38208. private _engine;
  38209. /**
  38210. * Gets the Engine the texture belongs to.
  38211. * @returns The babylon engine
  38212. */
  38213. getEngine(): ThinEngine;
  38214. /**
  38215. * Gets the data source type of the texture
  38216. */
  38217. get source(): InternalTextureSource;
  38218. /**
  38219. * Creates a new InternalTexture
  38220. * @param engine defines the engine to use
  38221. * @param source defines the type of data that will be used
  38222. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38223. */
  38224. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  38225. /**
  38226. * Increments the number of references (ie. the number of Texture that point to it)
  38227. */
  38228. incrementReferences(): void;
  38229. /**
  38230. * Change the size of the texture (not the size of the content)
  38231. * @param width defines the new width
  38232. * @param height defines the new height
  38233. * @param depth defines the new depth (1 by default)
  38234. */
  38235. updateSize(width: int, height: int, depth?: int): void;
  38236. /** @hidden */
  38237. _rebuild(): void;
  38238. /** @hidden */
  38239. _swapAndDie(target: InternalTexture): void;
  38240. /**
  38241. * Dispose the current allocated resources
  38242. */
  38243. dispose(): void;
  38244. }
  38245. }
  38246. declare module "babylonjs/Audio/analyser" {
  38247. import { Scene } from "babylonjs/scene";
  38248. /**
  38249. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38250. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38251. */
  38252. export class Analyser {
  38253. /**
  38254. * Gets or sets the smoothing
  38255. * @ignorenaming
  38256. */
  38257. SMOOTHING: number;
  38258. /**
  38259. * Gets or sets the FFT table size
  38260. * @ignorenaming
  38261. */
  38262. FFT_SIZE: number;
  38263. /**
  38264. * Gets or sets the bar graph amplitude
  38265. * @ignorenaming
  38266. */
  38267. BARGRAPHAMPLITUDE: number;
  38268. /**
  38269. * Gets or sets the position of the debug canvas
  38270. * @ignorenaming
  38271. */
  38272. DEBUGCANVASPOS: {
  38273. x: number;
  38274. y: number;
  38275. };
  38276. /**
  38277. * Gets or sets the debug canvas size
  38278. * @ignorenaming
  38279. */
  38280. DEBUGCANVASSIZE: {
  38281. width: number;
  38282. height: number;
  38283. };
  38284. private _byteFreqs;
  38285. private _byteTime;
  38286. private _floatFreqs;
  38287. private _webAudioAnalyser;
  38288. private _debugCanvas;
  38289. private _debugCanvasContext;
  38290. private _scene;
  38291. private _registerFunc;
  38292. private _audioEngine;
  38293. /**
  38294. * Creates a new analyser
  38295. * @param scene defines hosting scene
  38296. */
  38297. constructor(scene: Scene);
  38298. /**
  38299. * Get the number of data values you will have to play with for the visualization
  38300. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38301. * @returns a number
  38302. */
  38303. getFrequencyBinCount(): number;
  38304. /**
  38305. * Gets the current frequency data as a byte array
  38306. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38307. * @returns a Uint8Array
  38308. */
  38309. getByteFrequencyData(): Uint8Array;
  38310. /**
  38311. * Gets the current waveform as a byte array
  38312. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38313. * @returns a Uint8Array
  38314. */
  38315. getByteTimeDomainData(): Uint8Array;
  38316. /**
  38317. * Gets the current frequency data as a float array
  38318. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38319. * @returns a Float32Array
  38320. */
  38321. getFloatFrequencyData(): Float32Array;
  38322. /**
  38323. * Renders the debug canvas
  38324. */
  38325. drawDebugCanvas(): void;
  38326. /**
  38327. * Stops rendering the debug canvas and removes it
  38328. */
  38329. stopDebugCanvas(): void;
  38330. /**
  38331. * Connects two audio nodes
  38332. * @param inputAudioNode defines first node to connect
  38333. * @param outputAudioNode defines second node to connect
  38334. */
  38335. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38336. /**
  38337. * Releases all associated resources
  38338. */
  38339. dispose(): void;
  38340. }
  38341. }
  38342. declare module "babylonjs/Audio/audioEngine" {
  38343. import { IDisposable } from "babylonjs/scene";
  38344. import { Analyser } from "babylonjs/Audio/analyser";
  38345. import { Nullable } from "babylonjs/types";
  38346. import { Observable } from "babylonjs/Misc/observable";
  38347. /**
  38348. * This represents an audio engine and it is responsible
  38349. * to play, synchronize and analyse sounds throughout the application.
  38350. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38351. */
  38352. export interface IAudioEngine extends IDisposable {
  38353. /**
  38354. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38355. */
  38356. readonly canUseWebAudio: boolean;
  38357. /**
  38358. * Gets the current AudioContext if available.
  38359. */
  38360. readonly audioContext: Nullable<AudioContext>;
  38361. /**
  38362. * The master gain node defines the global audio volume of your audio engine.
  38363. */
  38364. readonly masterGain: GainNode;
  38365. /**
  38366. * Gets whether or not mp3 are supported by your browser.
  38367. */
  38368. readonly isMP3supported: boolean;
  38369. /**
  38370. * Gets whether or not ogg are supported by your browser.
  38371. */
  38372. readonly isOGGsupported: boolean;
  38373. /**
  38374. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38375. * @ignoreNaming
  38376. */
  38377. WarnedWebAudioUnsupported: boolean;
  38378. /**
  38379. * Defines if the audio engine relies on a custom unlocked button.
  38380. * In this case, the embedded button will not be displayed.
  38381. */
  38382. useCustomUnlockedButton: boolean;
  38383. /**
  38384. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38385. */
  38386. readonly unlocked: boolean;
  38387. /**
  38388. * Event raised when audio has been unlocked on the browser.
  38389. */
  38390. onAudioUnlockedObservable: Observable<AudioEngine>;
  38391. /**
  38392. * Event raised when audio has been locked on the browser.
  38393. */
  38394. onAudioLockedObservable: Observable<AudioEngine>;
  38395. /**
  38396. * Flags the audio engine in Locked state.
  38397. * This happens due to new browser policies preventing audio to autoplay.
  38398. */
  38399. lock(): void;
  38400. /**
  38401. * Unlocks the audio engine once a user action has been done on the dom.
  38402. * This is helpful to resume play once browser policies have been satisfied.
  38403. */
  38404. unlock(): void;
  38405. /**
  38406. * Gets the global volume sets on the master gain.
  38407. * @returns the global volume if set or -1 otherwise
  38408. */
  38409. getGlobalVolume(): number;
  38410. /**
  38411. * Sets the global volume of your experience (sets on the master gain).
  38412. * @param newVolume Defines the new global volume of the application
  38413. */
  38414. setGlobalVolume(newVolume: number): void;
  38415. /**
  38416. * Connect the audio engine to an audio analyser allowing some amazing
  38417. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38418. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38419. * @param analyser The analyser to connect to the engine
  38420. */
  38421. connectToAnalyser(analyser: Analyser): void;
  38422. }
  38423. /**
  38424. * This represents the default audio engine used in babylon.
  38425. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38426. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38427. */
  38428. export class AudioEngine implements IAudioEngine {
  38429. private _audioContext;
  38430. private _audioContextInitialized;
  38431. private _muteButton;
  38432. private _hostElement;
  38433. /**
  38434. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38435. */
  38436. canUseWebAudio: boolean;
  38437. /**
  38438. * The master gain node defines the global audio volume of your audio engine.
  38439. */
  38440. masterGain: GainNode;
  38441. /**
  38442. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38443. * @ignoreNaming
  38444. */
  38445. WarnedWebAudioUnsupported: boolean;
  38446. /**
  38447. * Gets whether or not mp3 are supported by your browser.
  38448. */
  38449. isMP3supported: boolean;
  38450. /**
  38451. * Gets whether or not ogg are supported by your browser.
  38452. */
  38453. isOGGsupported: boolean;
  38454. /**
  38455. * Gets whether audio has been unlocked on the device.
  38456. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38457. * a user interaction has happened.
  38458. */
  38459. unlocked: boolean;
  38460. /**
  38461. * Defines if the audio engine relies on a custom unlocked button.
  38462. * In this case, the embedded button will not be displayed.
  38463. */
  38464. useCustomUnlockedButton: boolean;
  38465. /**
  38466. * Event raised when audio has been unlocked on the browser.
  38467. */
  38468. onAudioUnlockedObservable: Observable<AudioEngine>;
  38469. /**
  38470. * Event raised when audio has been locked on the browser.
  38471. */
  38472. onAudioLockedObservable: Observable<AudioEngine>;
  38473. /**
  38474. * Gets the current AudioContext if available.
  38475. */
  38476. get audioContext(): Nullable<AudioContext>;
  38477. private _connectedAnalyser;
  38478. /**
  38479. * Instantiates a new audio engine.
  38480. *
  38481. * There should be only one per page as some browsers restrict the number
  38482. * of audio contexts you can create.
  38483. * @param hostElement defines the host element where to display the mute icon if necessary
  38484. */
  38485. constructor(hostElement?: Nullable<HTMLElement>);
  38486. /**
  38487. * Flags the audio engine in Locked state.
  38488. * This happens due to new browser policies preventing audio to autoplay.
  38489. */
  38490. lock(): void;
  38491. /**
  38492. * Unlocks the audio engine once a user action has been done on the dom.
  38493. * This is helpful to resume play once browser policies have been satisfied.
  38494. */
  38495. unlock(): void;
  38496. private _resumeAudioContext;
  38497. private _initializeAudioContext;
  38498. private _tryToRun;
  38499. private _triggerRunningState;
  38500. private _triggerSuspendedState;
  38501. private _displayMuteButton;
  38502. private _moveButtonToTopLeft;
  38503. private _onResize;
  38504. private _hideMuteButton;
  38505. /**
  38506. * Destroy and release the resources associated with the audio ccontext.
  38507. */
  38508. dispose(): void;
  38509. /**
  38510. * Gets the global volume sets on the master gain.
  38511. * @returns the global volume if set or -1 otherwise
  38512. */
  38513. getGlobalVolume(): number;
  38514. /**
  38515. * Sets the global volume of your experience (sets on the master gain).
  38516. * @param newVolume Defines the new global volume of the application
  38517. */
  38518. setGlobalVolume(newVolume: number): void;
  38519. /**
  38520. * Connect the audio engine to an audio analyser allowing some amazing
  38521. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38522. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38523. * @param analyser The analyser to connect to the engine
  38524. */
  38525. connectToAnalyser(analyser: Analyser): void;
  38526. }
  38527. }
  38528. declare module "babylonjs/Loading/loadingScreen" {
  38529. /**
  38530. * Interface used to present a loading screen while loading a scene
  38531. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38532. */
  38533. export interface ILoadingScreen {
  38534. /**
  38535. * Function called to display the loading screen
  38536. */
  38537. displayLoadingUI: () => void;
  38538. /**
  38539. * Function called to hide the loading screen
  38540. */
  38541. hideLoadingUI: () => void;
  38542. /**
  38543. * Gets or sets the color to use for the background
  38544. */
  38545. loadingUIBackgroundColor: string;
  38546. /**
  38547. * Gets or sets the text to display while loading
  38548. */
  38549. loadingUIText: string;
  38550. }
  38551. /**
  38552. * Class used for the default loading screen
  38553. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38554. */
  38555. export class DefaultLoadingScreen implements ILoadingScreen {
  38556. private _renderingCanvas;
  38557. private _loadingText;
  38558. private _loadingDivBackgroundColor;
  38559. private _loadingDiv;
  38560. private _loadingTextDiv;
  38561. /** Gets or sets the logo url to use for the default loading screen */
  38562. static DefaultLogoUrl: string;
  38563. /** Gets or sets the spinner url to use for the default loading screen */
  38564. static DefaultSpinnerUrl: string;
  38565. /**
  38566. * Creates a new default loading screen
  38567. * @param _renderingCanvas defines the canvas used to render the scene
  38568. * @param _loadingText defines the default text to display
  38569. * @param _loadingDivBackgroundColor defines the default background color
  38570. */
  38571. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38572. /**
  38573. * Function called to display the loading screen
  38574. */
  38575. displayLoadingUI(): void;
  38576. /**
  38577. * Function called to hide the loading screen
  38578. */
  38579. hideLoadingUI(): void;
  38580. /**
  38581. * Gets or sets the text to display while loading
  38582. */
  38583. set loadingUIText(text: string);
  38584. get loadingUIText(): string;
  38585. /**
  38586. * Gets or sets the color to use for the background
  38587. */
  38588. get loadingUIBackgroundColor(): string;
  38589. set loadingUIBackgroundColor(color: string);
  38590. private _resizeLoadingUI;
  38591. }
  38592. }
  38593. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38594. /**
  38595. * Interface for any object that can request an animation frame
  38596. */
  38597. export interface ICustomAnimationFrameRequester {
  38598. /**
  38599. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38600. */
  38601. renderFunction?: Function;
  38602. /**
  38603. * Called to request the next frame to render to
  38604. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38605. */
  38606. requestAnimationFrame: Function;
  38607. /**
  38608. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38609. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38610. */
  38611. requestID?: number;
  38612. }
  38613. }
  38614. declare module "babylonjs/Misc/performanceMonitor" {
  38615. /**
  38616. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38617. */
  38618. export class PerformanceMonitor {
  38619. private _enabled;
  38620. private _rollingFrameTime;
  38621. private _lastFrameTimeMs;
  38622. /**
  38623. * constructor
  38624. * @param frameSampleSize The number of samples required to saturate the sliding window
  38625. */
  38626. constructor(frameSampleSize?: number);
  38627. /**
  38628. * Samples current frame
  38629. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38630. */
  38631. sampleFrame(timeMs?: number): void;
  38632. /**
  38633. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38634. */
  38635. get averageFrameTime(): number;
  38636. /**
  38637. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38638. */
  38639. get averageFrameTimeVariance(): number;
  38640. /**
  38641. * Returns the frame time of the most recent frame
  38642. */
  38643. get instantaneousFrameTime(): number;
  38644. /**
  38645. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38646. */
  38647. get averageFPS(): number;
  38648. /**
  38649. * Returns the average framerate in frames per second using the most recent frame time
  38650. */
  38651. get instantaneousFPS(): number;
  38652. /**
  38653. * Returns true if enough samples have been taken to completely fill the sliding window
  38654. */
  38655. get isSaturated(): boolean;
  38656. /**
  38657. * Enables contributions to the sliding window sample set
  38658. */
  38659. enable(): void;
  38660. /**
  38661. * Disables contributions to the sliding window sample set
  38662. * Samples will not be interpolated over the disabled period
  38663. */
  38664. disable(): void;
  38665. /**
  38666. * Returns true if sampling is enabled
  38667. */
  38668. get isEnabled(): boolean;
  38669. /**
  38670. * Resets performance monitor
  38671. */
  38672. reset(): void;
  38673. }
  38674. /**
  38675. * RollingAverage
  38676. *
  38677. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38678. */
  38679. export class RollingAverage {
  38680. /**
  38681. * Current average
  38682. */
  38683. average: number;
  38684. /**
  38685. * Current variance
  38686. */
  38687. variance: number;
  38688. protected _samples: Array<number>;
  38689. protected _sampleCount: number;
  38690. protected _pos: number;
  38691. protected _m2: number;
  38692. /**
  38693. * constructor
  38694. * @param length The number of samples required to saturate the sliding window
  38695. */
  38696. constructor(length: number);
  38697. /**
  38698. * Adds a sample to the sample set
  38699. * @param v The sample value
  38700. */
  38701. add(v: number): void;
  38702. /**
  38703. * Returns previously added values or null if outside of history or outside the sliding window domain
  38704. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38705. * @return Value previously recorded with add() or null if outside of range
  38706. */
  38707. history(i: number): number;
  38708. /**
  38709. * Returns true if enough samples have been taken to completely fill the sliding window
  38710. * @return true if sample-set saturated
  38711. */
  38712. isSaturated(): boolean;
  38713. /**
  38714. * Resets the rolling average (equivalent to 0 samples taken so far)
  38715. */
  38716. reset(): void;
  38717. /**
  38718. * Wraps a value around the sample range boundaries
  38719. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38720. * @return Wrapped position in sample range
  38721. */
  38722. protected _wrapPosition(i: number): number;
  38723. }
  38724. }
  38725. declare module "babylonjs/Misc/perfCounter" {
  38726. /**
  38727. * This class is used to track a performance counter which is number based.
  38728. * The user has access to many properties which give statistics of different nature.
  38729. *
  38730. * The implementer can track two kinds of Performance Counter: time and count.
  38731. * 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.
  38732. * 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.
  38733. */
  38734. export class PerfCounter {
  38735. /**
  38736. * Gets or sets a global boolean to turn on and off all the counters
  38737. */
  38738. static Enabled: boolean;
  38739. /**
  38740. * Returns the smallest value ever
  38741. */
  38742. get min(): number;
  38743. /**
  38744. * Returns the biggest value ever
  38745. */
  38746. get max(): number;
  38747. /**
  38748. * Returns the average value since the performance counter is running
  38749. */
  38750. get average(): number;
  38751. /**
  38752. * Returns the average value of the last second the counter was monitored
  38753. */
  38754. get lastSecAverage(): number;
  38755. /**
  38756. * Returns the current value
  38757. */
  38758. get current(): number;
  38759. /**
  38760. * Gets the accumulated total
  38761. */
  38762. get total(): number;
  38763. /**
  38764. * Gets the total value count
  38765. */
  38766. get count(): number;
  38767. /**
  38768. * Creates a new counter
  38769. */
  38770. constructor();
  38771. /**
  38772. * Call this method to start monitoring a new frame.
  38773. * 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.
  38774. */
  38775. fetchNewFrame(): void;
  38776. /**
  38777. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38778. * @param newCount the count value to add to the monitored count
  38779. * @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.
  38780. */
  38781. addCount(newCount: number, fetchResult: boolean): void;
  38782. /**
  38783. * Start monitoring this performance counter
  38784. */
  38785. beginMonitoring(): void;
  38786. /**
  38787. * Compute the time lapsed since the previous beginMonitoring() call.
  38788. * @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
  38789. */
  38790. endMonitoring(newFrame?: boolean): void;
  38791. private _fetchResult;
  38792. private _startMonitoringTime;
  38793. private _min;
  38794. private _max;
  38795. private _average;
  38796. private _current;
  38797. private _totalValueCount;
  38798. private _totalAccumulated;
  38799. private _lastSecAverage;
  38800. private _lastSecAccumulated;
  38801. private _lastSecTime;
  38802. private _lastSecValueCount;
  38803. }
  38804. }
  38805. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38806. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38807. import { Nullable } from "babylonjs/types";
  38808. module "babylonjs/Engines/thinEngine" {
  38809. interface ThinEngine {
  38810. /** @hidden */
  38811. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38812. }
  38813. }
  38814. }
  38815. declare module "babylonjs/Engines/engine" {
  38816. import { Observable } from "babylonjs/Misc/observable";
  38817. import { Nullable } from "babylonjs/types";
  38818. import { Scene } from "babylonjs/scene";
  38819. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38820. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38821. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38822. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38823. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38824. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38825. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38826. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38827. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38828. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38829. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38830. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38831. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38832. import "babylonjs/Engines/Extensions/engine.alpha";
  38833. import "babylonjs/Engines/Extensions/engine.readTexture";
  38834. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38835. import { Material } from "babylonjs/Materials/material";
  38836. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38837. /**
  38838. * Defines the interface used by display changed events
  38839. */
  38840. export interface IDisplayChangedEventArgs {
  38841. /** Gets the vrDisplay object (if any) */
  38842. vrDisplay: Nullable<any>;
  38843. /** Gets a boolean indicating if webVR is supported */
  38844. vrSupported: boolean;
  38845. }
  38846. /**
  38847. * Defines the interface used by objects containing a viewport (like a camera)
  38848. */
  38849. interface IViewportOwnerLike {
  38850. /**
  38851. * Gets or sets the viewport
  38852. */
  38853. viewport: IViewportLike;
  38854. }
  38855. /**
  38856. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38857. */
  38858. export class Engine extends ThinEngine {
  38859. /** Defines that alpha blending is disabled */
  38860. static readonly ALPHA_DISABLE: number;
  38861. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38862. static readonly ALPHA_ADD: number;
  38863. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38864. static readonly ALPHA_COMBINE: number;
  38865. /** Defines that alpha blending to DEST - SRC * DEST */
  38866. static readonly ALPHA_SUBTRACT: number;
  38867. /** Defines that alpha blending to SRC * DEST */
  38868. static readonly ALPHA_MULTIPLY: number;
  38869. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38870. static readonly ALPHA_MAXIMIZED: number;
  38871. /** Defines that alpha blending to SRC + DEST */
  38872. static readonly ALPHA_ONEONE: number;
  38873. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38874. static readonly ALPHA_PREMULTIPLIED: number;
  38875. /**
  38876. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38877. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38878. */
  38879. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38880. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38881. static readonly ALPHA_INTERPOLATE: number;
  38882. /**
  38883. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38884. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38885. */
  38886. static readonly ALPHA_SCREENMODE: number;
  38887. /** Defines that the ressource is not delayed*/
  38888. static readonly DELAYLOADSTATE_NONE: number;
  38889. /** Defines that the ressource was successfully delay loaded */
  38890. static readonly DELAYLOADSTATE_LOADED: number;
  38891. /** Defines that the ressource is currently delay loading */
  38892. static readonly DELAYLOADSTATE_LOADING: number;
  38893. /** Defines that the ressource is delayed and has not started loading */
  38894. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38895. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38896. static readonly NEVER: number;
  38897. /** 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 */
  38898. static readonly ALWAYS: number;
  38899. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38900. static readonly LESS: number;
  38901. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38902. static readonly EQUAL: number;
  38903. /** 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 */
  38904. static readonly LEQUAL: number;
  38905. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38906. static readonly GREATER: number;
  38907. /** 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 */
  38908. static readonly GEQUAL: number;
  38909. /** 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 */
  38910. static readonly NOTEQUAL: number;
  38911. /** Passed to stencilOperation to specify that stencil value must be kept */
  38912. static readonly KEEP: number;
  38913. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38914. static readonly REPLACE: number;
  38915. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38916. static readonly INCR: number;
  38917. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38918. static readonly DECR: number;
  38919. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38920. static readonly INVERT: number;
  38921. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38922. static readonly INCR_WRAP: number;
  38923. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38924. static readonly DECR_WRAP: number;
  38925. /** Texture is not repeating outside of 0..1 UVs */
  38926. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38927. /** Texture is repeating outside of 0..1 UVs */
  38928. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38929. /** Texture is repeating and mirrored */
  38930. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38931. /** ALPHA */
  38932. static readonly TEXTUREFORMAT_ALPHA: number;
  38933. /** LUMINANCE */
  38934. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38935. /** LUMINANCE_ALPHA */
  38936. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38937. /** RGB */
  38938. static readonly TEXTUREFORMAT_RGB: number;
  38939. /** RGBA */
  38940. static readonly TEXTUREFORMAT_RGBA: number;
  38941. /** RED */
  38942. static readonly TEXTUREFORMAT_RED: number;
  38943. /** RED (2nd reference) */
  38944. static readonly TEXTUREFORMAT_R: number;
  38945. /** RG */
  38946. static readonly TEXTUREFORMAT_RG: number;
  38947. /** RED_INTEGER */
  38948. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38949. /** RED_INTEGER (2nd reference) */
  38950. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38951. /** RG_INTEGER */
  38952. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38953. /** RGB_INTEGER */
  38954. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38955. /** RGBA_INTEGER */
  38956. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38957. /** UNSIGNED_BYTE */
  38958. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38959. /** UNSIGNED_BYTE (2nd reference) */
  38960. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38961. /** FLOAT */
  38962. static readonly TEXTURETYPE_FLOAT: number;
  38963. /** HALF_FLOAT */
  38964. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38965. /** BYTE */
  38966. static readonly TEXTURETYPE_BYTE: number;
  38967. /** SHORT */
  38968. static readonly TEXTURETYPE_SHORT: number;
  38969. /** UNSIGNED_SHORT */
  38970. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38971. /** INT */
  38972. static readonly TEXTURETYPE_INT: number;
  38973. /** UNSIGNED_INT */
  38974. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38975. /** UNSIGNED_SHORT_4_4_4_4 */
  38976. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38977. /** UNSIGNED_SHORT_5_5_5_1 */
  38978. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38979. /** UNSIGNED_SHORT_5_6_5 */
  38980. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38981. /** UNSIGNED_INT_2_10_10_10_REV */
  38982. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38983. /** UNSIGNED_INT_24_8 */
  38984. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38985. /** UNSIGNED_INT_10F_11F_11F_REV */
  38986. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38987. /** UNSIGNED_INT_5_9_9_9_REV */
  38988. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38989. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38990. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38991. /** nearest is mag = nearest and min = nearest and mip = linear */
  38992. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38993. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38994. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38995. /** Trilinear is mag = linear and min = linear and mip = linear */
  38996. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38997. /** nearest is mag = nearest and min = nearest and mip = linear */
  38998. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38999. /** Bilinear is mag = linear and min = linear and mip = nearest */
  39000. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  39001. /** Trilinear is mag = linear and min = linear and mip = linear */
  39002. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  39003. /** mag = nearest and min = nearest and mip = nearest */
  39004. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  39005. /** mag = nearest and min = linear and mip = nearest */
  39006. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  39007. /** mag = nearest and min = linear and mip = linear */
  39008. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  39009. /** mag = nearest and min = linear and mip = none */
  39010. static readonly TEXTURE_NEAREST_LINEAR: number;
  39011. /** mag = nearest and min = nearest and mip = none */
  39012. static readonly TEXTURE_NEAREST_NEAREST: number;
  39013. /** mag = linear and min = nearest and mip = nearest */
  39014. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  39015. /** mag = linear and min = nearest and mip = linear */
  39016. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  39017. /** mag = linear and min = linear and mip = none */
  39018. static readonly TEXTURE_LINEAR_LINEAR: number;
  39019. /** mag = linear and min = nearest and mip = none */
  39020. static readonly TEXTURE_LINEAR_NEAREST: number;
  39021. /** Explicit coordinates mode */
  39022. static readonly TEXTURE_EXPLICIT_MODE: number;
  39023. /** Spherical coordinates mode */
  39024. static readonly TEXTURE_SPHERICAL_MODE: number;
  39025. /** Planar coordinates mode */
  39026. static readonly TEXTURE_PLANAR_MODE: number;
  39027. /** Cubic coordinates mode */
  39028. static readonly TEXTURE_CUBIC_MODE: number;
  39029. /** Projection coordinates mode */
  39030. static readonly TEXTURE_PROJECTION_MODE: number;
  39031. /** Skybox coordinates mode */
  39032. static readonly TEXTURE_SKYBOX_MODE: number;
  39033. /** Inverse Cubic coordinates mode */
  39034. static readonly TEXTURE_INVCUBIC_MODE: number;
  39035. /** Equirectangular coordinates mode */
  39036. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  39037. /** Equirectangular Fixed coordinates mode */
  39038. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  39039. /** Equirectangular Fixed Mirrored coordinates mode */
  39040. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  39041. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  39042. static readonly SCALEMODE_FLOOR: number;
  39043. /** Defines that texture rescaling will look for the nearest power of 2 size */
  39044. static readonly SCALEMODE_NEAREST: number;
  39045. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  39046. static readonly SCALEMODE_CEILING: number;
  39047. /**
  39048. * Returns the current npm package of the sdk
  39049. */
  39050. static get NpmPackage(): string;
  39051. /**
  39052. * Returns the current version of the framework
  39053. */
  39054. static get Version(): string;
  39055. /** Gets the list of created engines */
  39056. static get Instances(): Engine[];
  39057. /**
  39058. * Gets the latest created engine
  39059. */
  39060. static get LastCreatedEngine(): Nullable<Engine>;
  39061. /**
  39062. * Gets the latest created scene
  39063. */
  39064. static get LastCreatedScene(): Nullable<Scene>;
  39065. /**
  39066. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  39067. * @param flag defines which part of the materials must be marked as dirty
  39068. * @param predicate defines a predicate used to filter which materials should be affected
  39069. */
  39070. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  39071. /**
  39072. * Method called to create the default loading screen.
  39073. * This can be overriden in your own app.
  39074. * @param canvas The rendering canvas element
  39075. * @returns The loading screen
  39076. */
  39077. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  39078. /**
  39079. * Method called to create the default rescale post process on each engine.
  39080. */
  39081. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  39082. /**
  39083. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  39084. **/
  39085. enableOfflineSupport: boolean;
  39086. /**
  39087. * 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)
  39088. **/
  39089. disableManifestCheck: boolean;
  39090. /**
  39091. * Gets the list of created scenes
  39092. */
  39093. scenes: Scene[];
  39094. /**
  39095. * Event raised when a new scene is created
  39096. */
  39097. onNewSceneAddedObservable: Observable<Scene>;
  39098. /**
  39099. * Gets the list of created postprocesses
  39100. */
  39101. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  39102. /**
  39103. * Gets a boolean indicating if the pointer is currently locked
  39104. */
  39105. isPointerLock: boolean;
  39106. /**
  39107. * Observable event triggered each time the rendering canvas is resized
  39108. */
  39109. onResizeObservable: Observable<Engine>;
  39110. /**
  39111. * Observable event triggered each time the canvas loses focus
  39112. */
  39113. onCanvasBlurObservable: Observable<Engine>;
  39114. /**
  39115. * Observable event triggered each time the canvas gains focus
  39116. */
  39117. onCanvasFocusObservable: Observable<Engine>;
  39118. /**
  39119. * Observable event triggered each time the canvas receives pointerout event
  39120. */
  39121. onCanvasPointerOutObservable: Observable<PointerEvent>;
  39122. /**
  39123. * Observable raised when the engine begins a new frame
  39124. */
  39125. onBeginFrameObservable: Observable<Engine>;
  39126. /**
  39127. * If set, will be used to request the next animation frame for the render loop
  39128. */
  39129. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  39130. /**
  39131. * Observable raised when the engine ends the current frame
  39132. */
  39133. onEndFrameObservable: Observable<Engine>;
  39134. /**
  39135. * Observable raised when the engine is about to compile a shader
  39136. */
  39137. onBeforeShaderCompilationObservable: Observable<Engine>;
  39138. /**
  39139. * Observable raised when the engine has jsut compiled a shader
  39140. */
  39141. onAfterShaderCompilationObservable: Observable<Engine>;
  39142. /**
  39143. * Gets the audio engine
  39144. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39145. * @ignorenaming
  39146. */
  39147. static audioEngine: IAudioEngine;
  39148. /**
  39149. * Default AudioEngine factory responsible of creating the Audio Engine.
  39150. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  39151. */
  39152. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  39153. /**
  39154. * Default offline support factory responsible of creating a tool used to store data locally.
  39155. * By default, this will create a Database object if the workload has been embedded.
  39156. */
  39157. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  39158. private _loadingScreen;
  39159. private _pointerLockRequested;
  39160. private _rescalePostProcess;
  39161. private _deterministicLockstep;
  39162. private _lockstepMaxSteps;
  39163. private _timeStep;
  39164. protected get _supportsHardwareTextureRescaling(): boolean;
  39165. private _fps;
  39166. private _deltaTime;
  39167. /** @hidden */
  39168. _drawCalls: PerfCounter;
  39169. /** 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 */
  39170. canvasTabIndex: number;
  39171. /**
  39172. * Turn this value on if you want to pause FPS computation when in background
  39173. */
  39174. disablePerformanceMonitorInBackground: boolean;
  39175. private _performanceMonitor;
  39176. /**
  39177. * Gets the performance monitor attached to this engine
  39178. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39179. */
  39180. get performanceMonitor(): PerformanceMonitor;
  39181. private _onFocus;
  39182. private _onBlur;
  39183. private _onCanvasPointerOut;
  39184. private _onCanvasBlur;
  39185. private _onCanvasFocus;
  39186. private _onFullscreenChange;
  39187. private _onPointerLockChange;
  39188. /**
  39189. * Gets the HTML element used to attach event listeners
  39190. * @returns a HTML element
  39191. */
  39192. getInputElement(): Nullable<HTMLElement>;
  39193. /**
  39194. * Creates a new engine
  39195. * @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
  39196. * @param antialias defines enable antialiasing (default: false)
  39197. * @param options defines further options to be sent to the getContext() function
  39198. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39199. */
  39200. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39201. /**
  39202. * Gets current aspect ratio
  39203. * @param viewportOwner defines the camera to use to get the aspect ratio
  39204. * @param useScreen defines if screen size must be used (or the current render target if any)
  39205. * @returns a number defining the aspect ratio
  39206. */
  39207. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  39208. /**
  39209. * Gets current screen aspect ratio
  39210. * @returns a number defining the aspect ratio
  39211. */
  39212. getScreenAspectRatio(): number;
  39213. /**
  39214. * Gets the client rect of the HTML canvas attached with the current webGL context
  39215. * @returns a client rectanglee
  39216. */
  39217. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  39218. /**
  39219. * Gets the client rect of the HTML element used for events
  39220. * @returns a client rectanglee
  39221. */
  39222. getInputElementClientRect(): Nullable<ClientRect>;
  39223. /**
  39224. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  39225. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39226. * @returns true if engine is in deterministic lock step mode
  39227. */
  39228. isDeterministicLockStep(): boolean;
  39229. /**
  39230. * Gets the max steps when engine is running in deterministic lock step
  39231. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39232. * @returns the max steps
  39233. */
  39234. getLockstepMaxSteps(): number;
  39235. /**
  39236. * Returns the time in ms between steps when using deterministic lock step.
  39237. * @returns time step in (ms)
  39238. */
  39239. getTimeStep(): number;
  39240. /**
  39241. * Force the mipmap generation for the given render target texture
  39242. * @param texture defines the render target texture to use
  39243. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39244. */
  39245. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39246. /** States */
  39247. /**
  39248. * Set various states to the webGL context
  39249. * @param culling defines backface culling state
  39250. * @param zOffset defines the value to apply to zOffset (0 by default)
  39251. * @param force defines if states must be applied even if cache is up to date
  39252. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39253. */
  39254. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39255. /**
  39256. * Set the z offset to apply to current rendering
  39257. * @param value defines the offset to apply
  39258. */
  39259. setZOffset(value: number): void;
  39260. /**
  39261. * Gets the current value of the zOffset
  39262. * @returns the current zOffset state
  39263. */
  39264. getZOffset(): number;
  39265. /**
  39266. * Enable or disable depth buffering
  39267. * @param enable defines the state to set
  39268. */
  39269. setDepthBuffer(enable: boolean): void;
  39270. /**
  39271. * Gets a boolean indicating if depth writing is enabled
  39272. * @returns the current depth writing state
  39273. */
  39274. getDepthWrite(): boolean;
  39275. /**
  39276. * Enable or disable depth writing
  39277. * @param enable defines the state to set
  39278. */
  39279. setDepthWrite(enable: boolean): void;
  39280. /**
  39281. * Gets a boolean indicating if stencil buffer is enabled
  39282. * @returns the current stencil buffer state
  39283. */
  39284. getStencilBuffer(): boolean;
  39285. /**
  39286. * Enable or disable the stencil buffer
  39287. * @param enable defines if the stencil buffer must be enabled or disabled
  39288. */
  39289. setStencilBuffer(enable: boolean): void;
  39290. /**
  39291. * Gets the current stencil mask
  39292. * @returns a number defining the new stencil mask to use
  39293. */
  39294. getStencilMask(): number;
  39295. /**
  39296. * Sets the current stencil mask
  39297. * @param mask defines the new stencil mask to use
  39298. */
  39299. setStencilMask(mask: number): void;
  39300. /**
  39301. * Gets the current stencil function
  39302. * @returns a number defining the stencil function to use
  39303. */
  39304. getStencilFunction(): number;
  39305. /**
  39306. * Gets the current stencil reference value
  39307. * @returns a number defining the stencil reference value to use
  39308. */
  39309. getStencilFunctionReference(): number;
  39310. /**
  39311. * Gets the current stencil mask
  39312. * @returns a number defining the stencil mask to use
  39313. */
  39314. getStencilFunctionMask(): number;
  39315. /**
  39316. * Sets the current stencil function
  39317. * @param stencilFunc defines the new stencil function to use
  39318. */
  39319. setStencilFunction(stencilFunc: number): void;
  39320. /**
  39321. * Sets the current stencil reference
  39322. * @param reference defines the new stencil reference to use
  39323. */
  39324. setStencilFunctionReference(reference: number): void;
  39325. /**
  39326. * Sets the current stencil mask
  39327. * @param mask defines the new stencil mask to use
  39328. */
  39329. setStencilFunctionMask(mask: number): void;
  39330. /**
  39331. * Gets the current stencil operation when stencil fails
  39332. * @returns a number defining stencil operation to use when stencil fails
  39333. */
  39334. getStencilOperationFail(): number;
  39335. /**
  39336. * Gets the current stencil operation when depth fails
  39337. * @returns a number defining stencil operation to use when depth fails
  39338. */
  39339. getStencilOperationDepthFail(): number;
  39340. /**
  39341. * Gets the current stencil operation when stencil passes
  39342. * @returns a number defining stencil operation to use when stencil passes
  39343. */
  39344. getStencilOperationPass(): number;
  39345. /**
  39346. * Sets the stencil operation to use when stencil fails
  39347. * @param operation defines the stencil operation to use when stencil fails
  39348. */
  39349. setStencilOperationFail(operation: number): void;
  39350. /**
  39351. * Sets the stencil operation to use when depth fails
  39352. * @param operation defines the stencil operation to use when depth fails
  39353. */
  39354. setStencilOperationDepthFail(operation: number): void;
  39355. /**
  39356. * Sets the stencil operation to use when stencil passes
  39357. * @param operation defines the stencil operation to use when stencil passes
  39358. */
  39359. setStencilOperationPass(operation: number): void;
  39360. /**
  39361. * Sets a boolean indicating if the dithering state is enabled or disabled
  39362. * @param value defines the dithering state
  39363. */
  39364. setDitheringState(value: boolean): void;
  39365. /**
  39366. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39367. * @param value defines the rasterizer state
  39368. */
  39369. setRasterizerState(value: boolean): void;
  39370. /**
  39371. * Gets the current depth function
  39372. * @returns a number defining the depth function
  39373. */
  39374. getDepthFunction(): Nullable<number>;
  39375. /**
  39376. * Sets the current depth function
  39377. * @param depthFunc defines the function to use
  39378. */
  39379. setDepthFunction(depthFunc: number): void;
  39380. /**
  39381. * Sets the current depth function to GREATER
  39382. */
  39383. setDepthFunctionToGreater(): void;
  39384. /**
  39385. * Sets the current depth function to GEQUAL
  39386. */
  39387. setDepthFunctionToGreaterOrEqual(): void;
  39388. /**
  39389. * Sets the current depth function to LESS
  39390. */
  39391. setDepthFunctionToLess(): void;
  39392. /**
  39393. * Sets the current depth function to LEQUAL
  39394. */
  39395. setDepthFunctionToLessOrEqual(): void;
  39396. private _cachedStencilBuffer;
  39397. private _cachedStencilFunction;
  39398. private _cachedStencilMask;
  39399. private _cachedStencilOperationPass;
  39400. private _cachedStencilOperationFail;
  39401. private _cachedStencilOperationDepthFail;
  39402. private _cachedStencilReference;
  39403. /**
  39404. * Caches the the state of the stencil buffer
  39405. */
  39406. cacheStencilState(): void;
  39407. /**
  39408. * Restores the state of the stencil buffer
  39409. */
  39410. restoreStencilState(): void;
  39411. /**
  39412. * Directly set the WebGL Viewport
  39413. * @param x defines the x coordinate of the viewport (in screen space)
  39414. * @param y defines the y coordinate of the viewport (in screen space)
  39415. * @param width defines the width of the viewport (in screen space)
  39416. * @param height defines the height of the viewport (in screen space)
  39417. * @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
  39418. */
  39419. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39420. /**
  39421. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39422. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39423. * @param y defines the y-coordinate of the corner of the clear rectangle
  39424. * @param width defines the width of the clear rectangle
  39425. * @param height defines the height of the clear rectangle
  39426. * @param clearColor defines the clear color
  39427. */
  39428. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39429. /**
  39430. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39431. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39432. * @param y defines the y-coordinate of the corner of the clear rectangle
  39433. * @param width defines the width of the clear rectangle
  39434. * @param height defines the height of the clear rectangle
  39435. */
  39436. enableScissor(x: number, y: number, width: number, height: number): void;
  39437. /**
  39438. * Disable previously set scissor test rectangle
  39439. */
  39440. disableScissor(): void;
  39441. protected _reportDrawCall(): void;
  39442. /**
  39443. * Initializes a webVR display and starts listening to display change events
  39444. * The onVRDisplayChangedObservable will be notified upon these changes
  39445. * @returns The onVRDisplayChangedObservable
  39446. */
  39447. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39448. /** @hidden */
  39449. _prepareVRComponent(): void;
  39450. /** @hidden */
  39451. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39452. /** @hidden */
  39453. _submitVRFrame(): void;
  39454. /**
  39455. * Call this function to leave webVR mode
  39456. * Will do nothing if webVR is not supported or if there is no webVR device
  39457. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39458. */
  39459. disableVR(): void;
  39460. /**
  39461. * Gets a boolean indicating that the system is in VR mode and is presenting
  39462. * @returns true if VR mode is engaged
  39463. */
  39464. isVRPresenting(): boolean;
  39465. /** @hidden */
  39466. _requestVRFrame(): void;
  39467. /** @hidden */
  39468. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39469. /**
  39470. * Gets the source code of the vertex shader associated with a specific webGL program
  39471. * @param program defines the program to use
  39472. * @returns a string containing the source code of the vertex shader associated with the program
  39473. */
  39474. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39475. /**
  39476. * Gets the source code of the fragment shader associated with a specific webGL program
  39477. * @param program defines the program to use
  39478. * @returns a string containing the source code of the fragment shader associated with the program
  39479. */
  39480. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39481. /**
  39482. * Sets a depth stencil texture from a render target to the according uniform.
  39483. * @param channel The texture channel
  39484. * @param uniform The uniform to set
  39485. * @param texture The render target texture containing the depth stencil texture to apply
  39486. */
  39487. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39488. /**
  39489. * Sets a texture to the webGL context from a postprocess
  39490. * @param channel defines the channel to use
  39491. * @param postProcess defines the source postprocess
  39492. */
  39493. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39494. /**
  39495. * Binds the output of the passed in post process to the texture channel specified
  39496. * @param channel The channel the texture should be bound to
  39497. * @param postProcess The post process which's output should be bound
  39498. */
  39499. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39500. protected _rebuildBuffers(): void;
  39501. /** @hidden */
  39502. _renderFrame(): void;
  39503. _renderLoop(): void;
  39504. /** @hidden */
  39505. _renderViews(): boolean;
  39506. /**
  39507. * Toggle full screen mode
  39508. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39509. */
  39510. switchFullscreen(requestPointerLock: boolean): void;
  39511. /**
  39512. * Enters full screen mode
  39513. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39514. */
  39515. enterFullscreen(requestPointerLock: boolean): void;
  39516. /**
  39517. * Exits full screen mode
  39518. */
  39519. exitFullscreen(): void;
  39520. /**
  39521. * Enters Pointerlock mode
  39522. */
  39523. enterPointerlock(): void;
  39524. /**
  39525. * Exits Pointerlock mode
  39526. */
  39527. exitPointerlock(): void;
  39528. /**
  39529. * Begin a new frame
  39530. */
  39531. beginFrame(): void;
  39532. /**
  39533. * Enf the current frame
  39534. */
  39535. endFrame(): void;
  39536. resize(): void;
  39537. /**
  39538. * Force a specific size of the canvas
  39539. * @param width defines the new canvas' width
  39540. * @param height defines the new canvas' height
  39541. * @returns true if the size was changed
  39542. */
  39543. setSize(width: number, height: number): boolean;
  39544. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39545. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39546. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39547. _releaseTexture(texture: InternalTexture): void;
  39548. /**
  39549. * @hidden
  39550. * Rescales a texture
  39551. * @param source input texutre
  39552. * @param destination destination texture
  39553. * @param scene scene to use to render the resize
  39554. * @param internalFormat format to use when resizing
  39555. * @param onComplete callback to be called when resize has completed
  39556. */
  39557. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39558. /**
  39559. * Gets the current framerate
  39560. * @returns a number representing the framerate
  39561. */
  39562. getFps(): number;
  39563. /**
  39564. * Gets the time spent between current and previous frame
  39565. * @returns a number representing the delta time in ms
  39566. */
  39567. getDeltaTime(): number;
  39568. private _measureFps;
  39569. /** @hidden */
  39570. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39571. /**
  39572. * Updates the sample count of a render target texture
  39573. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39574. * @param texture defines the texture to update
  39575. * @param samples defines the sample count to set
  39576. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39577. */
  39578. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39579. /**
  39580. * Updates a depth texture Comparison Mode and Function.
  39581. * If the comparison Function is equal to 0, the mode will be set to none.
  39582. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39583. * @param texture The texture to set the comparison function for
  39584. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39585. */
  39586. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39587. /**
  39588. * Creates a webGL buffer to use with instanciation
  39589. * @param capacity defines the size of the buffer
  39590. * @returns the webGL buffer
  39591. */
  39592. createInstancesBuffer(capacity: number): DataBuffer;
  39593. /**
  39594. * Delete a webGL buffer used with instanciation
  39595. * @param buffer defines the webGL buffer to delete
  39596. */
  39597. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39598. private _clientWaitAsync;
  39599. /** @hidden */
  39600. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39601. dispose(): void;
  39602. private _disableTouchAction;
  39603. /**
  39604. * Display the loading screen
  39605. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39606. */
  39607. displayLoadingUI(): void;
  39608. /**
  39609. * Hide the loading screen
  39610. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39611. */
  39612. hideLoadingUI(): void;
  39613. /**
  39614. * Gets the current loading screen object
  39615. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39616. */
  39617. get loadingScreen(): ILoadingScreen;
  39618. /**
  39619. * Sets the current loading screen object
  39620. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39621. */
  39622. set loadingScreen(loadingScreen: ILoadingScreen);
  39623. /**
  39624. * Sets the current loading screen text
  39625. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39626. */
  39627. set loadingUIText(text: string);
  39628. /**
  39629. * Sets the current loading screen background color
  39630. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39631. */
  39632. set loadingUIBackgroundColor(color: string);
  39633. /** Pointerlock and fullscreen */
  39634. /**
  39635. * Ask the browser to promote the current element to pointerlock mode
  39636. * @param element defines the DOM element to promote
  39637. */
  39638. static _RequestPointerlock(element: HTMLElement): void;
  39639. /**
  39640. * Asks the browser to exit pointerlock mode
  39641. */
  39642. static _ExitPointerlock(): void;
  39643. /**
  39644. * Ask the browser to promote the current element to fullscreen rendering mode
  39645. * @param element defines the DOM element to promote
  39646. */
  39647. static _RequestFullscreen(element: HTMLElement): void;
  39648. /**
  39649. * Asks the browser to exit fullscreen mode
  39650. */
  39651. static _ExitFullscreen(): void;
  39652. }
  39653. }
  39654. declare module "babylonjs/Engines/engineStore" {
  39655. import { Nullable } from "babylonjs/types";
  39656. import { Engine } from "babylonjs/Engines/engine";
  39657. import { Scene } from "babylonjs/scene";
  39658. /**
  39659. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39660. * during the life time of the application.
  39661. */
  39662. export class EngineStore {
  39663. /** Gets the list of created engines */
  39664. static Instances: import("babylonjs/Engines/engine").Engine[];
  39665. /** @hidden */
  39666. static _LastCreatedScene: Nullable<Scene>;
  39667. /**
  39668. * Gets the latest created engine
  39669. */
  39670. static get LastCreatedEngine(): Nullable<Engine>;
  39671. /**
  39672. * Gets the latest created scene
  39673. */
  39674. static get LastCreatedScene(): Nullable<Scene>;
  39675. /**
  39676. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39677. * @ignorenaming
  39678. */
  39679. static UseFallbackTexture: boolean;
  39680. /**
  39681. * Texture content used if a texture cannot loaded
  39682. * @ignorenaming
  39683. */
  39684. static FallbackTexture: string;
  39685. }
  39686. }
  39687. declare module "babylonjs/Misc/promise" {
  39688. /**
  39689. * Helper class that provides a small promise polyfill
  39690. */
  39691. export class PromisePolyfill {
  39692. /**
  39693. * Static function used to check if the polyfill is required
  39694. * If this is the case then the function will inject the polyfill to window.Promise
  39695. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39696. */
  39697. static Apply(force?: boolean): void;
  39698. }
  39699. }
  39700. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39701. /**
  39702. * Interface for screenshot methods with describe argument called `size` as object with options
  39703. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39704. */
  39705. export interface IScreenshotSize {
  39706. /**
  39707. * number in pixels for canvas height
  39708. */
  39709. height?: number;
  39710. /**
  39711. * multiplier allowing render at a higher or lower resolution
  39712. * If value is defined then height and width will be ignored and taken from camera
  39713. */
  39714. precision?: number;
  39715. /**
  39716. * number in pixels for canvas width
  39717. */
  39718. width?: number;
  39719. }
  39720. }
  39721. declare module "babylonjs/Misc/tools" {
  39722. import { Nullable, float } from "babylonjs/types";
  39723. import { DomManagement } from "babylonjs/Misc/domManagement";
  39724. import { WebRequest } from "babylonjs/Misc/webRequest";
  39725. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39726. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39727. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39728. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39729. import { Camera } from "babylonjs/Cameras/camera";
  39730. import { Engine } from "babylonjs/Engines/engine";
  39731. interface IColor4Like {
  39732. r: float;
  39733. g: float;
  39734. b: float;
  39735. a: float;
  39736. }
  39737. /**
  39738. * Class containing a set of static utilities functions
  39739. */
  39740. export class Tools {
  39741. /**
  39742. * Gets or sets the base URL to use to load assets
  39743. */
  39744. static get BaseUrl(): string;
  39745. static set BaseUrl(value: string);
  39746. /**
  39747. * Enable/Disable Custom HTTP Request Headers globally.
  39748. * default = false
  39749. * @see CustomRequestHeaders
  39750. */
  39751. static UseCustomRequestHeaders: boolean;
  39752. /**
  39753. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39754. * i.e. when loading files, where the server/service expects an Authorization header
  39755. */
  39756. static CustomRequestHeaders: {
  39757. [key: string]: string;
  39758. };
  39759. /**
  39760. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39761. */
  39762. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39763. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39764. /**
  39765. * Default behaviour for cors in the application.
  39766. * It can be a string if the expected behavior is identical in the entire app.
  39767. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39768. */
  39769. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39770. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39771. /**
  39772. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39773. * @ignorenaming
  39774. */
  39775. static get UseFallbackTexture(): boolean;
  39776. static set UseFallbackTexture(value: boolean);
  39777. /**
  39778. * Use this object to register external classes like custom textures or material
  39779. * to allow the laoders to instantiate them
  39780. */
  39781. static get RegisteredExternalClasses(): {
  39782. [key: string]: Object;
  39783. };
  39784. static set RegisteredExternalClasses(classes: {
  39785. [key: string]: Object;
  39786. });
  39787. /**
  39788. * Texture content used if a texture cannot loaded
  39789. * @ignorenaming
  39790. */
  39791. static get fallbackTexture(): string;
  39792. static set fallbackTexture(value: string);
  39793. /**
  39794. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39795. * @param u defines the coordinate on X axis
  39796. * @param v defines the coordinate on Y axis
  39797. * @param width defines the width of the source data
  39798. * @param height defines the height of the source data
  39799. * @param pixels defines the source byte array
  39800. * @param color defines the output color
  39801. */
  39802. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39803. /**
  39804. * Interpolates between a and b via alpha
  39805. * @param a The lower value (returned when alpha = 0)
  39806. * @param b The upper value (returned when alpha = 1)
  39807. * @param alpha The interpolation-factor
  39808. * @return The mixed value
  39809. */
  39810. static Mix(a: number, b: number, alpha: number): number;
  39811. /**
  39812. * Tries to instantiate a new object from a given class name
  39813. * @param className defines the class name to instantiate
  39814. * @returns the new object or null if the system was not able to do the instantiation
  39815. */
  39816. static Instantiate(className: string): any;
  39817. /**
  39818. * Provides a slice function that will work even on IE
  39819. * @param data defines the array to slice
  39820. * @param start defines the start of the data (optional)
  39821. * @param end defines the end of the data (optional)
  39822. * @returns the new sliced array
  39823. */
  39824. static Slice<T>(data: T, start?: number, end?: number): T;
  39825. /**
  39826. * Polyfill for setImmediate
  39827. * @param action defines the action to execute after the current execution block
  39828. */
  39829. static SetImmediate(action: () => void): void;
  39830. /**
  39831. * Function indicating if a number is an exponent of 2
  39832. * @param value defines the value to test
  39833. * @returns true if the value is an exponent of 2
  39834. */
  39835. static IsExponentOfTwo(value: number): boolean;
  39836. private static _tmpFloatArray;
  39837. /**
  39838. * Returns the nearest 32-bit single precision float representation of a Number
  39839. * @param value A Number. If the parameter is of a different type, it will get converted
  39840. * to a number or to NaN if it cannot be converted
  39841. * @returns number
  39842. */
  39843. static FloatRound(value: number): number;
  39844. /**
  39845. * Extracts the filename from a path
  39846. * @param path defines the path to use
  39847. * @returns the filename
  39848. */
  39849. static GetFilename(path: string): string;
  39850. /**
  39851. * Extracts the "folder" part of a path (everything before the filename).
  39852. * @param uri The URI to extract the info from
  39853. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39854. * @returns The "folder" part of the path
  39855. */
  39856. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39857. /**
  39858. * Extracts text content from a DOM element hierarchy
  39859. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39860. */
  39861. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39862. /**
  39863. * Convert an angle in radians to degrees
  39864. * @param angle defines the angle to convert
  39865. * @returns the angle in degrees
  39866. */
  39867. static ToDegrees(angle: number): number;
  39868. /**
  39869. * Convert an angle in degrees to radians
  39870. * @param angle defines the angle to convert
  39871. * @returns the angle in radians
  39872. */
  39873. static ToRadians(angle: number): number;
  39874. /**
  39875. * Returns an array if obj is not an array
  39876. * @param obj defines the object to evaluate as an array
  39877. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39878. * @returns either obj directly if obj is an array or a new array containing obj
  39879. */
  39880. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39881. /**
  39882. * Gets the pointer prefix to use
  39883. * @param engine defines the engine we are finding the prefix for
  39884. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39885. */
  39886. static GetPointerPrefix(engine: Engine): string;
  39887. /**
  39888. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39889. * @param url define the url we are trying
  39890. * @param element define the dom element where to configure the cors policy
  39891. */
  39892. static SetCorsBehavior(url: string | string[], element: {
  39893. crossOrigin: string | null;
  39894. }): void;
  39895. /**
  39896. * Removes unwanted characters from an url
  39897. * @param url defines the url to clean
  39898. * @returns the cleaned url
  39899. */
  39900. static CleanUrl(url: string): string;
  39901. /**
  39902. * Gets or sets a function used to pre-process url before using them to load assets
  39903. */
  39904. static get PreprocessUrl(): (url: string) => string;
  39905. static set PreprocessUrl(processor: (url: string) => string);
  39906. /**
  39907. * Loads an image as an HTMLImageElement.
  39908. * @param input url string, ArrayBuffer, or Blob to load
  39909. * @param onLoad callback called when the image successfully loads
  39910. * @param onError callback called when the image fails to load
  39911. * @param offlineProvider offline provider for caching
  39912. * @param mimeType optional mime type
  39913. * @returns the HTMLImageElement of the loaded image
  39914. */
  39915. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39916. /**
  39917. * Loads a file from a url
  39918. * @param url url string, ArrayBuffer, or Blob to load
  39919. * @param onSuccess callback called when the file successfully loads
  39920. * @param onProgress callback called while file is loading (if the server supports this mode)
  39921. * @param offlineProvider defines the offline provider for caching
  39922. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39923. * @param onError callback called when the file fails to load
  39924. * @returns a file request object
  39925. */
  39926. 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;
  39927. /**
  39928. * Loads a file from a url
  39929. * @param url the file url to load
  39930. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39931. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39932. */
  39933. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39934. /**
  39935. * Load a script (identified by an url). When the url returns, the
  39936. * content of this file is added into a new script element, attached to the DOM (body element)
  39937. * @param scriptUrl defines the url of the script to laod
  39938. * @param onSuccess defines the callback called when the script is loaded
  39939. * @param onError defines the callback to call if an error occurs
  39940. * @param scriptId defines the id of the script element
  39941. */
  39942. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39943. /**
  39944. * Load an asynchronous script (identified by an url). When the url returns, the
  39945. * content of this file is added into a new script element, attached to the DOM (body element)
  39946. * @param scriptUrl defines the url of the script to laod
  39947. * @param scriptId defines the id of the script element
  39948. * @returns a promise request object
  39949. */
  39950. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39951. /**
  39952. * Loads a file from a blob
  39953. * @param fileToLoad defines the blob to use
  39954. * @param callback defines the callback to call when data is loaded
  39955. * @param progressCallback defines the callback to call during loading process
  39956. * @returns a file request object
  39957. */
  39958. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39959. /**
  39960. * Reads a file from a File object
  39961. * @param file defines the file to load
  39962. * @param onSuccess defines the callback to call when data is loaded
  39963. * @param onProgress defines the callback to call during loading process
  39964. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39965. * @param onError defines the callback to call when an error occurs
  39966. * @returns a file request object
  39967. */
  39968. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39969. /**
  39970. * Creates a data url from a given string content
  39971. * @param content defines the content to convert
  39972. * @returns the new data url link
  39973. */
  39974. static FileAsURL(content: string): string;
  39975. /**
  39976. * Format the given number to a specific decimal format
  39977. * @param value defines the number to format
  39978. * @param decimals defines the number of decimals to use
  39979. * @returns the formatted string
  39980. */
  39981. static Format(value: number, decimals?: number): string;
  39982. /**
  39983. * Tries to copy an object by duplicating every property
  39984. * @param source defines the source object
  39985. * @param destination defines the target object
  39986. * @param doNotCopyList defines a list of properties to avoid
  39987. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39988. */
  39989. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39990. /**
  39991. * Gets a boolean indicating if the given object has no own property
  39992. * @param obj defines the object to test
  39993. * @returns true if object has no own property
  39994. */
  39995. static IsEmpty(obj: any): boolean;
  39996. /**
  39997. * Function used to register events at window level
  39998. * @param windowElement defines the Window object to use
  39999. * @param events defines the events to register
  40000. */
  40001. static RegisterTopRootEvents(windowElement: Window, events: {
  40002. name: string;
  40003. handler: Nullable<(e: FocusEvent) => any>;
  40004. }[]): void;
  40005. /**
  40006. * Function used to unregister events from window level
  40007. * @param windowElement defines the Window object to use
  40008. * @param events defines the events to unregister
  40009. */
  40010. static UnregisterTopRootEvents(windowElement: Window, events: {
  40011. name: string;
  40012. handler: Nullable<(e: FocusEvent) => any>;
  40013. }[]): void;
  40014. /**
  40015. * @ignore
  40016. */
  40017. static _ScreenshotCanvas: HTMLCanvasElement;
  40018. /**
  40019. * Dumps the current bound framebuffer
  40020. * @param width defines the rendering width
  40021. * @param height defines the rendering height
  40022. * @param engine defines the hosting engine
  40023. * @param successCallback defines the callback triggered once the data are available
  40024. * @param mimeType defines the mime type of the result
  40025. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  40026. */
  40027. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40028. /**
  40029. * Converts the canvas data to blob.
  40030. * This acts as a polyfill for browsers not supporting the to blob function.
  40031. * @param canvas Defines the canvas to extract the data from
  40032. * @param successCallback Defines the callback triggered once the data are available
  40033. * @param mimeType Defines the mime type of the result
  40034. */
  40035. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  40036. /**
  40037. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  40038. * @param successCallback defines the callback triggered once the data are available
  40039. * @param mimeType defines the mime type of the result
  40040. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  40041. */
  40042. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40043. /**
  40044. * Downloads a blob in the browser
  40045. * @param blob defines the blob to download
  40046. * @param fileName defines the name of the downloaded file
  40047. */
  40048. static Download(blob: Blob, fileName: string): void;
  40049. /**
  40050. * Captures a screenshot of the current rendering
  40051. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40052. * @param engine defines the rendering engine
  40053. * @param camera defines the source camera
  40054. * @param size This parameter can be set to a single number or to an object with the
  40055. * following (optional) properties: precision, width, height. If a single number is passed,
  40056. * it will be used for both width and height. If an object is passed, the screenshot size
  40057. * will be derived from the parameters. The precision property is a multiplier allowing
  40058. * rendering at a higher or lower resolution
  40059. * @param successCallback defines the callback receives a single parameter which contains the
  40060. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40061. * src parameter of an <img> to display it
  40062. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40063. * Check your browser for supported MIME types
  40064. */
  40065. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  40066. /**
  40067. * Captures a screenshot of the current rendering
  40068. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40069. * @param engine defines the rendering engine
  40070. * @param camera defines the source camera
  40071. * @param size This parameter can be set to a single number or to an object with the
  40072. * following (optional) properties: precision, width, height. If a single number is passed,
  40073. * it will be used for both width and height. If an object is passed, the screenshot size
  40074. * will be derived from the parameters. The precision property is a multiplier allowing
  40075. * rendering at a higher or lower resolution
  40076. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40077. * Check your browser for supported MIME types
  40078. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  40079. * to the src parameter of an <img> to display it
  40080. */
  40081. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  40082. /**
  40083. * Generates an image screenshot from the specified camera.
  40084. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40085. * @param engine The engine to use for rendering
  40086. * @param camera The camera to use for rendering
  40087. * @param size This parameter can be set to a single number or to an object with the
  40088. * following (optional) properties: precision, width, height. If a single number is passed,
  40089. * it will be used for both width and height. If an object is passed, the screenshot size
  40090. * will be derived from the parameters. The precision property is a multiplier allowing
  40091. * rendering at a higher or lower resolution
  40092. * @param successCallback The callback receives a single parameter which contains the
  40093. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40094. * src parameter of an <img> to display it
  40095. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40096. * Check your browser for supported MIME types
  40097. * @param samples Texture samples (default: 1)
  40098. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40099. * @param fileName A name for for the downloaded file.
  40100. */
  40101. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  40102. /**
  40103. * Generates an image screenshot from the specified camera.
  40104. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40105. * @param engine The engine to use for rendering
  40106. * @param camera The camera to use for rendering
  40107. * @param size This parameter can be set to a single number or to an object with the
  40108. * following (optional) properties: precision, width, height. If a single number is passed,
  40109. * it will be used for both width and height. If an object is passed, the screenshot size
  40110. * will be derived from the parameters. The precision property is a multiplier allowing
  40111. * rendering at a higher or lower resolution
  40112. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40113. * Check your browser for supported MIME types
  40114. * @param samples Texture samples (default: 1)
  40115. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40116. * @param fileName A name for for the downloaded file.
  40117. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  40118. * to the src parameter of an <img> to display it
  40119. */
  40120. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  40121. /**
  40122. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  40123. * Be aware Math.random() could cause collisions, but:
  40124. * "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"
  40125. * @returns a pseudo random id
  40126. */
  40127. static RandomId(): string;
  40128. /**
  40129. * Test if the given uri is a base64 string
  40130. * @param uri The uri to test
  40131. * @return True if the uri is a base64 string or false otherwise
  40132. */
  40133. static IsBase64(uri: string): boolean;
  40134. /**
  40135. * Decode the given base64 uri.
  40136. * @param uri The uri to decode
  40137. * @return The decoded base64 data.
  40138. */
  40139. static DecodeBase64(uri: string): ArrayBuffer;
  40140. /**
  40141. * Gets the absolute url.
  40142. * @param url the input url
  40143. * @return the absolute url
  40144. */
  40145. static GetAbsoluteUrl(url: string): string;
  40146. /**
  40147. * No log
  40148. */
  40149. static readonly NoneLogLevel: number;
  40150. /**
  40151. * Only message logs
  40152. */
  40153. static readonly MessageLogLevel: number;
  40154. /**
  40155. * Only warning logs
  40156. */
  40157. static readonly WarningLogLevel: number;
  40158. /**
  40159. * Only error logs
  40160. */
  40161. static readonly ErrorLogLevel: number;
  40162. /**
  40163. * All logs
  40164. */
  40165. static readonly AllLogLevel: number;
  40166. /**
  40167. * Gets a value indicating the number of loading errors
  40168. * @ignorenaming
  40169. */
  40170. static get errorsCount(): number;
  40171. /**
  40172. * Callback called when a new log is added
  40173. */
  40174. static OnNewCacheEntry: (entry: string) => void;
  40175. /**
  40176. * Log a message to the console
  40177. * @param message defines the message to log
  40178. */
  40179. static Log(message: string): void;
  40180. /**
  40181. * Write a warning message to the console
  40182. * @param message defines the message to log
  40183. */
  40184. static Warn(message: string): void;
  40185. /**
  40186. * Write an error message to the console
  40187. * @param message defines the message to log
  40188. */
  40189. static Error(message: string): void;
  40190. /**
  40191. * Gets current log cache (list of logs)
  40192. */
  40193. static get LogCache(): string;
  40194. /**
  40195. * Clears the log cache
  40196. */
  40197. static ClearLogCache(): void;
  40198. /**
  40199. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40200. */
  40201. static set LogLevels(level: number);
  40202. /**
  40203. * Checks if the window object exists
  40204. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  40205. */
  40206. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  40207. /**
  40208. * No performance log
  40209. */
  40210. static readonly PerformanceNoneLogLevel: number;
  40211. /**
  40212. * Use user marks to log performance
  40213. */
  40214. static readonly PerformanceUserMarkLogLevel: number;
  40215. /**
  40216. * Log performance to the console
  40217. */
  40218. static readonly PerformanceConsoleLogLevel: number;
  40219. private static _performance;
  40220. /**
  40221. * Sets the current performance log level
  40222. */
  40223. static set PerformanceLogLevel(level: number);
  40224. private static _StartPerformanceCounterDisabled;
  40225. private static _EndPerformanceCounterDisabled;
  40226. private static _StartUserMark;
  40227. private static _EndUserMark;
  40228. private static _StartPerformanceConsole;
  40229. private static _EndPerformanceConsole;
  40230. /**
  40231. * Starts a performance counter
  40232. */
  40233. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40234. /**
  40235. * Ends a specific performance coutner
  40236. */
  40237. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40238. /**
  40239. * Gets either window.performance.now() if supported or Date.now() else
  40240. */
  40241. static get Now(): number;
  40242. /**
  40243. * This method will return the name of the class used to create the instance of the given object.
  40244. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40245. * @param object the object to get the class name from
  40246. * @param isType defines if the object is actually a type
  40247. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40248. */
  40249. static GetClassName(object: any, isType?: boolean): string;
  40250. /**
  40251. * Gets the first element of an array satisfying a given predicate
  40252. * @param array defines the array to browse
  40253. * @param predicate defines the predicate to use
  40254. * @returns null if not found or the element
  40255. */
  40256. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40257. /**
  40258. * This method will return the name of the full name of the class, including its owning module (if any).
  40259. * 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).
  40260. * @param object the object to get the class name from
  40261. * @param isType defines if the object is actually a type
  40262. * @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.
  40263. * @ignorenaming
  40264. */
  40265. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40266. /**
  40267. * Returns a promise that resolves after the given amount of time.
  40268. * @param delay Number of milliseconds to delay
  40269. * @returns Promise that resolves after the given amount of time
  40270. */
  40271. static DelayAsync(delay: number): Promise<void>;
  40272. /**
  40273. * Utility function to detect if the current user agent is Safari
  40274. * @returns whether or not the current user agent is safari
  40275. */
  40276. static IsSafari(): boolean;
  40277. }
  40278. /**
  40279. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40280. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40281. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40282. * @param name The name of the class, case should be preserved
  40283. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40284. */
  40285. export function className(name: string, module?: string): (target: Object) => void;
  40286. /**
  40287. * An implementation of a loop for asynchronous functions.
  40288. */
  40289. export class AsyncLoop {
  40290. /**
  40291. * Defines the number of iterations for the loop
  40292. */
  40293. iterations: number;
  40294. /**
  40295. * Defines the current index of the loop.
  40296. */
  40297. index: number;
  40298. private _done;
  40299. private _fn;
  40300. private _successCallback;
  40301. /**
  40302. * Constructor.
  40303. * @param iterations the number of iterations.
  40304. * @param func the function to run each iteration
  40305. * @param successCallback the callback that will be called upon succesful execution
  40306. * @param offset starting offset.
  40307. */
  40308. constructor(
  40309. /**
  40310. * Defines the number of iterations for the loop
  40311. */
  40312. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40313. /**
  40314. * Execute the next iteration. Must be called after the last iteration was finished.
  40315. */
  40316. executeNext(): void;
  40317. /**
  40318. * Break the loop and run the success callback.
  40319. */
  40320. breakLoop(): void;
  40321. /**
  40322. * Create and run an async loop.
  40323. * @param iterations the number of iterations.
  40324. * @param fn the function to run each iteration
  40325. * @param successCallback the callback that will be called upon succesful execution
  40326. * @param offset starting offset.
  40327. * @returns the created async loop object
  40328. */
  40329. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40330. /**
  40331. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40332. * @param iterations total number of iterations
  40333. * @param syncedIterations number of synchronous iterations in each async iteration.
  40334. * @param fn the function to call each iteration.
  40335. * @param callback a success call back that will be called when iterating stops.
  40336. * @param breakFunction a break condition (optional)
  40337. * @param timeout timeout settings for the setTimeout function. default - 0.
  40338. * @returns the created async loop object
  40339. */
  40340. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40341. }
  40342. }
  40343. declare module "babylonjs/Misc/stringDictionary" {
  40344. import { Nullable } from "babylonjs/types";
  40345. /**
  40346. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40347. * The underlying implementation relies on an associative array to ensure the best performances.
  40348. * The value can be anything including 'null' but except 'undefined'
  40349. */
  40350. export class StringDictionary<T> {
  40351. /**
  40352. * This will clear this dictionary and copy the content from the 'source' one.
  40353. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40354. * @param source the dictionary to take the content from and copy to this dictionary
  40355. */
  40356. copyFrom(source: StringDictionary<T>): void;
  40357. /**
  40358. * Get a value based from its key
  40359. * @param key the given key to get the matching value from
  40360. * @return the value if found, otherwise undefined is returned
  40361. */
  40362. get(key: string): T | undefined;
  40363. /**
  40364. * Get a value from its key or add it if it doesn't exist.
  40365. * This method will ensure you that a given key/data will be present in the dictionary.
  40366. * @param key the given key to get the matching value from
  40367. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40368. * The factory will only be invoked if there's no data for the given key.
  40369. * @return the value corresponding to the key.
  40370. */
  40371. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40372. /**
  40373. * Get a value from its key if present in the dictionary otherwise add it
  40374. * @param key the key to get the value from
  40375. * @param val if there's no such key/value pair in the dictionary add it with this value
  40376. * @return the value corresponding to the key
  40377. */
  40378. getOrAdd(key: string, val: T): T;
  40379. /**
  40380. * Check if there's a given key in the dictionary
  40381. * @param key the key to check for
  40382. * @return true if the key is present, false otherwise
  40383. */
  40384. contains(key: string): boolean;
  40385. /**
  40386. * Add a new key and its corresponding value
  40387. * @param key the key to add
  40388. * @param value the value corresponding to the key
  40389. * @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
  40390. */
  40391. add(key: string, value: T): boolean;
  40392. /**
  40393. * Update a specific value associated to a key
  40394. * @param key defines the key to use
  40395. * @param value defines the value to store
  40396. * @returns true if the value was updated (or false if the key was not found)
  40397. */
  40398. set(key: string, value: T): boolean;
  40399. /**
  40400. * Get the element of the given key and remove it from the dictionary
  40401. * @param key defines the key to search
  40402. * @returns the value associated with the key or null if not found
  40403. */
  40404. getAndRemove(key: string): Nullable<T>;
  40405. /**
  40406. * Remove a key/value from the dictionary.
  40407. * @param key the key to remove
  40408. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40409. */
  40410. remove(key: string): boolean;
  40411. /**
  40412. * Clear the whole content of the dictionary
  40413. */
  40414. clear(): void;
  40415. /**
  40416. * Gets the current count
  40417. */
  40418. get count(): number;
  40419. /**
  40420. * Execute a callback on each key/val of the dictionary.
  40421. * Note that you can remove any element in this dictionary in the callback implementation
  40422. * @param callback the callback to execute on a given key/value pair
  40423. */
  40424. forEach(callback: (key: string, val: T) => void): void;
  40425. /**
  40426. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40427. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40428. * Note that you can remove any element in this dictionary in the callback implementation
  40429. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40430. * @returns the first item
  40431. */
  40432. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40433. private _count;
  40434. private _data;
  40435. }
  40436. }
  40437. declare module "babylonjs/Collisions/collisionCoordinator" {
  40438. import { Nullable } from "babylonjs/types";
  40439. import { Scene } from "babylonjs/scene";
  40440. import { Vector3 } from "babylonjs/Maths/math.vector";
  40441. import { Collider } from "babylonjs/Collisions/collider";
  40442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40443. /** @hidden */
  40444. export interface ICollisionCoordinator {
  40445. createCollider(): Collider;
  40446. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40447. init(scene: Scene): void;
  40448. }
  40449. /** @hidden */
  40450. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40451. private _scene;
  40452. private _scaledPosition;
  40453. private _scaledVelocity;
  40454. private _finalPosition;
  40455. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40456. createCollider(): Collider;
  40457. init(scene: Scene): void;
  40458. private _collideWithWorld;
  40459. }
  40460. }
  40461. declare module "babylonjs/Inputs/scene.inputManager" {
  40462. import { Nullable } from "babylonjs/types";
  40463. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40464. import { Vector2 } from "babylonjs/Maths/math.vector";
  40465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40466. import { Scene } from "babylonjs/scene";
  40467. /**
  40468. * Class used to manage all inputs for the scene.
  40469. */
  40470. export class InputManager {
  40471. /** The distance in pixel that you have to move to prevent some events */
  40472. static DragMovementThreshold: number;
  40473. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40474. static LongPressDelay: number;
  40475. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40476. static DoubleClickDelay: number;
  40477. /** If you need to check double click without raising a single click at first click, enable this flag */
  40478. static ExclusiveDoubleClickMode: boolean;
  40479. /** 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. */
  40480. private _alreadyAttached;
  40481. private _wheelEventName;
  40482. private _onPointerMove;
  40483. private _onPointerDown;
  40484. private _onPointerUp;
  40485. private _initClickEvent;
  40486. private _initActionManager;
  40487. private _delayedSimpleClick;
  40488. private _delayedSimpleClickTimeout;
  40489. private _previousDelayedSimpleClickTimeout;
  40490. private _meshPickProceed;
  40491. private _previousButtonPressed;
  40492. private _currentPickResult;
  40493. private _previousPickResult;
  40494. private _totalPointersPressed;
  40495. private _doubleClickOccured;
  40496. private _pointerOverMesh;
  40497. private _pickedDownMesh;
  40498. private _pickedUpMesh;
  40499. private _pointerX;
  40500. private _pointerY;
  40501. private _unTranslatedPointerX;
  40502. private _unTranslatedPointerY;
  40503. private _startingPointerPosition;
  40504. private _previousStartingPointerPosition;
  40505. private _startingPointerTime;
  40506. private _previousStartingPointerTime;
  40507. private _pointerCaptures;
  40508. private _meshUnderPointerId;
  40509. private _onKeyDown;
  40510. private _onKeyUp;
  40511. private _onCanvasFocusObserver;
  40512. private _onCanvasBlurObserver;
  40513. private _scene;
  40514. /**
  40515. * Creates a new InputManager
  40516. * @param scene defines the hosting scene
  40517. */
  40518. constructor(scene: Scene);
  40519. /**
  40520. * Gets the mesh that is currently under the pointer
  40521. */
  40522. get meshUnderPointer(): Nullable<AbstractMesh>;
  40523. /**
  40524. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40525. * @param pointerId the pointer id to use
  40526. * @returns The mesh under this pointer id or null if not found
  40527. */
  40528. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40529. /**
  40530. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40531. */
  40532. get unTranslatedPointer(): Vector2;
  40533. /**
  40534. * Gets or sets the current on-screen X position of the pointer
  40535. */
  40536. get pointerX(): number;
  40537. set pointerX(value: number);
  40538. /**
  40539. * Gets or sets the current on-screen Y position of the pointer
  40540. */
  40541. get pointerY(): number;
  40542. set pointerY(value: number);
  40543. private _updatePointerPosition;
  40544. private _processPointerMove;
  40545. private _setRayOnPointerInfo;
  40546. private _checkPrePointerObservable;
  40547. /**
  40548. * Use this method to simulate a pointer move on a mesh
  40549. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40550. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40551. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40552. */
  40553. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40554. /**
  40555. * Use this method to simulate a pointer down on a mesh
  40556. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40557. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40558. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40559. */
  40560. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40561. private _processPointerDown;
  40562. /** @hidden */
  40563. _isPointerSwiping(): boolean;
  40564. /**
  40565. * Use this method to simulate a pointer up on a mesh
  40566. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40567. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40568. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40569. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40570. */
  40571. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40572. private _processPointerUp;
  40573. /**
  40574. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40575. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40576. * @returns true if the pointer was captured
  40577. */
  40578. isPointerCaptured(pointerId?: number): boolean;
  40579. /**
  40580. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40581. * @param attachUp defines if you want to attach events to pointerup
  40582. * @param attachDown defines if you want to attach events to pointerdown
  40583. * @param attachMove defines if you want to attach events to pointermove
  40584. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40585. */
  40586. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40587. /**
  40588. * Detaches all event handlers
  40589. */
  40590. detachControl(): void;
  40591. /**
  40592. * Force the value of meshUnderPointer
  40593. * @param mesh defines the mesh to use
  40594. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40595. */
  40596. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40597. /**
  40598. * Gets the mesh under the pointer
  40599. * @returns a Mesh or null if no mesh is under the pointer
  40600. */
  40601. getPointerOverMesh(): Nullable<AbstractMesh>;
  40602. }
  40603. }
  40604. declare module "babylonjs/Animations/animationGroup" {
  40605. import { Animatable } from "babylonjs/Animations/animatable";
  40606. import { Animation } from "babylonjs/Animations/animation";
  40607. import { Scene, IDisposable } from "babylonjs/scene";
  40608. import { Observable } from "babylonjs/Misc/observable";
  40609. import { Nullable } from "babylonjs/types";
  40610. import "babylonjs/Animations/animatable";
  40611. /**
  40612. * This class defines the direct association between an animation and a target
  40613. */
  40614. export class TargetedAnimation {
  40615. /**
  40616. * Animation to perform
  40617. */
  40618. animation: Animation;
  40619. /**
  40620. * Target to animate
  40621. */
  40622. target: any;
  40623. /**
  40624. * Returns the string "TargetedAnimation"
  40625. * @returns "TargetedAnimation"
  40626. */
  40627. getClassName(): string;
  40628. /**
  40629. * Serialize the object
  40630. * @returns the JSON object representing the current entity
  40631. */
  40632. serialize(): any;
  40633. }
  40634. /**
  40635. * Use this class to create coordinated animations on multiple targets
  40636. */
  40637. export class AnimationGroup implements IDisposable {
  40638. /** The name of the animation group */
  40639. name: string;
  40640. private _scene;
  40641. private _targetedAnimations;
  40642. private _animatables;
  40643. private _from;
  40644. private _to;
  40645. private _isStarted;
  40646. private _isPaused;
  40647. private _speedRatio;
  40648. private _loopAnimation;
  40649. private _isAdditive;
  40650. /**
  40651. * Gets or sets the unique id of the node
  40652. */
  40653. uniqueId: number;
  40654. /**
  40655. * This observable will notify when one animation have ended
  40656. */
  40657. onAnimationEndObservable: Observable<TargetedAnimation>;
  40658. /**
  40659. * Observer raised when one animation loops
  40660. */
  40661. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40662. /**
  40663. * Observer raised when all animations have looped
  40664. */
  40665. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40666. /**
  40667. * This observable will notify when all animations have ended.
  40668. */
  40669. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40670. /**
  40671. * This observable will notify when all animations have paused.
  40672. */
  40673. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40674. /**
  40675. * This observable will notify when all animations are playing.
  40676. */
  40677. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40678. /**
  40679. * Gets the first frame
  40680. */
  40681. get from(): number;
  40682. /**
  40683. * Gets the last frame
  40684. */
  40685. get to(): number;
  40686. /**
  40687. * Define if the animations are started
  40688. */
  40689. get isStarted(): boolean;
  40690. /**
  40691. * Gets a value indicating that the current group is playing
  40692. */
  40693. get isPlaying(): boolean;
  40694. /**
  40695. * Gets or sets the speed ratio to use for all animations
  40696. */
  40697. get speedRatio(): number;
  40698. /**
  40699. * Gets or sets the speed ratio to use for all animations
  40700. */
  40701. set speedRatio(value: number);
  40702. /**
  40703. * Gets or sets if all animations should loop or not
  40704. */
  40705. get loopAnimation(): boolean;
  40706. set loopAnimation(value: boolean);
  40707. /**
  40708. * Gets or sets if all animations should be evaluated additively
  40709. */
  40710. get isAdditive(): boolean;
  40711. set isAdditive(value: boolean);
  40712. /**
  40713. * Gets the targeted animations for this animation group
  40714. */
  40715. get targetedAnimations(): Array<TargetedAnimation>;
  40716. /**
  40717. * returning the list of animatables controlled by this animation group.
  40718. */
  40719. get animatables(): Array<Animatable>;
  40720. /**
  40721. * Gets the list of target animations
  40722. */
  40723. get children(): TargetedAnimation[];
  40724. /**
  40725. * Instantiates a new Animation Group.
  40726. * This helps managing several animations at once.
  40727. * @see https://doc.babylonjs.com/how_to/group
  40728. * @param name Defines the name of the group
  40729. * @param scene Defines the scene the group belongs to
  40730. */
  40731. constructor(
  40732. /** The name of the animation group */
  40733. name: string, scene?: Nullable<Scene>);
  40734. /**
  40735. * Add an animation (with its target) in the group
  40736. * @param animation defines the animation we want to add
  40737. * @param target defines the target of the animation
  40738. * @returns the TargetedAnimation object
  40739. */
  40740. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40741. /**
  40742. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40743. * It can add constant keys at begin or end
  40744. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40745. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40746. * @returns the animation group
  40747. */
  40748. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40749. private _animationLoopCount;
  40750. private _animationLoopFlags;
  40751. private _processLoop;
  40752. /**
  40753. * Start all animations on given targets
  40754. * @param loop defines if animations must loop
  40755. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40756. * @param from defines the from key (optional)
  40757. * @param to defines the to key (optional)
  40758. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40759. * @returns the current animation group
  40760. */
  40761. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40762. /**
  40763. * Pause all animations
  40764. * @returns the animation group
  40765. */
  40766. pause(): AnimationGroup;
  40767. /**
  40768. * Play all animations to initial state
  40769. * This function will start() the animations if they were not started or will restart() them if they were paused
  40770. * @param loop defines if animations must loop
  40771. * @returns the animation group
  40772. */
  40773. play(loop?: boolean): AnimationGroup;
  40774. /**
  40775. * Reset all animations to initial state
  40776. * @returns the animation group
  40777. */
  40778. reset(): AnimationGroup;
  40779. /**
  40780. * Restart animations from key 0
  40781. * @returns the animation group
  40782. */
  40783. restart(): AnimationGroup;
  40784. /**
  40785. * Stop all animations
  40786. * @returns the animation group
  40787. */
  40788. stop(): AnimationGroup;
  40789. /**
  40790. * Set animation weight for all animatables
  40791. * @param weight defines the weight to use
  40792. * @return the animationGroup
  40793. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40794. */
  40795. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40796. /**
  40797. * Synchronize and normalize all animatables with a source animatable
  40798. * @param root defines the root animatable to synchronize with
  40799. * @return the animationGroup
  40800. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40801. */
  40802. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40803. /**
  40804. * Goes to a specific frame in this animation group
  40805. * @param frame the frame number to go to
  40806. * @return the animationGroup
  40807. */
  40808. goToFrame(frame: number): AnimationGroup;
  40809. /**
  40810. * Dispose all associated resources
  40811. */
  40812. dispose(): void;
  40813. private _checkAnimationGroupEnded;
  40814. /**
  40815. * Clone the current animation group and returns a copy
  40816. * @param newName defines the name of the new group
  40817. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40818. * @returns the new aniamtion group
  40819. */
  40820. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40821. /**
  40822. * Serializes the animationGroup to an object
  40823. * @returns Serialized object
  40824. */
  40825. serialize(): any;
  40826. /**
  40827. * Returns a new AnimationGroup object parsed from the source provided.
  40828. * @param parsedAnimationGroup defines the source
  40829. * @param scene defines the scene that will receive the animationGroup
  40830. * @returns a new AnimationGroup
  40831. */
  40832. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40833. /**
  40834. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40835. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40836. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40837. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40838. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40839. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40840. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40841. */
  40842. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40843. /**
  40844. * Returns the string "AnimationGroup"
  40845. * @returns "AnimationGroup"
  40846. */
  40847. getClassName(): string;
  40848. /**
  40849. * Creates a detailled string about the object
  40850. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40851. * @returns a string representing the object
  40852. */
  40853. toString(fullDetails?: boolean): string;
  40854. }
  40855. }
  40856. declare module "babylonjs/scene" {
  40857. import { Nullable } from "babylonjs/types";
  40858. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40859. import { Observable } from "babylonjs/Misc/observable";
  40860. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40861. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40862. import { Geometry } from "babylonjs/Meshes/geometry";
  40863. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40864. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40866. import { Mesh } from "babylonjs/Meshes/mesh";
  40867. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40868. import { Bone } from "babylonjs/Bones/bone";
  40869. import { Skeleton } from "babylonjs/Bones/skeleton";
  40870. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40871. import { Camera } from "babylonjs/Cameras/camera";
  40872. import { AbstractScene } from "babylonjs/abstractScene";
  40873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40874. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40875. import { Material } from "babylonjs/Materials/material";
  40876. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40877. import { Effect } from "babylonjs/Materials/effect";
  40878. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40879. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40880. import { Light } from "babylonjs/Lights/light";
  40881. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40882. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40883. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40884. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40885. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40886. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40887. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40888. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40889. import { Engine } from "babylonjs/Engines/engine";
  40890. import { Node } from "babylonjs/node";
  40891. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40892. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40893. import { WebRequest } from "babylonjs/Misc/webRequest";
  40894. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40895. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40896. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40897. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40898. import { Plane } from "babylonjs/Maths/math.plane";
  40899. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40900. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40901. import { Ray } from "babylonjs/Culling/ray";
  40902. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40903. import { Animation } from "babylonjs/Animations/animation";
  40904. import { Animatable } from "babylonjs/Animations/animatable";
  40905. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40906. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40907. import { Collider } from "babylonjs/Collisions/collider";
  40908. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40909. /**
  40910. * Define an interface for all classes that will hold resources
  40911. */
  40912. export interface IDisposable {
  40913. /**
  40914. * Releases all held resources
  40915. */
  40916. dispose(): void;
  40917. }
  40918. /** Interface defining initialization parameters for Scene class */
  40919. export interface SceneOptions {
  40920. /**
  40921. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40922. * It will improve performance when the number of geometries becomes important.
  40923. */
  40924. useGeometryUniqueIdsMap?: boolean;
  40925. /**
  40926. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40927. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40928. */
  40929. useMaterialMeshMap?: boolean;
  40930. /**
  40931. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40932. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40933. */
  40934. useClonedMeshMap?: boolean;
  40935. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40936. virtual?: boolean;
  40937. }
  40938. /**
  40939. * Represents a scene to be rendered by the engine.
  40940. * @see https://doc.babylonjs.com/features/scene
  40941. */
  40942. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40943. /** The fog is deactivated */
  40944. static readonly FOGMODE_NONE: number;
  40945. /** The fog density is following an exponential function */
  40946. static readonly FOGMODE_EXP: number;
  40947. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40948. static readonly FOGMODE_EXP2: number;
  40949. /** The fog density is following a linear function. */
  40950. static readonly FOGMODE_LINEAR: number;
  40951. /**
  40952. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40953. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40954. */
  40955. static MinDeltaTime: number;
  40956. /**
  40957. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40958. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40959. */
  40960. static MaxDeltaTime: number;
  40961. /**
  40962. * Factory used to create the default material.
  40963. * @param name The name of the material to create
  40964. * @param scene The scene to create the material for
  40965. * @returns The default material
  40966. */
  40967. static DefaultMaterialFactory(scene: Scene): Material;
  40968. /**
  40969. * Factory used to create the a collision coordinator.
  40970. * @returns The collision coordinator
  40971. */
  40972. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40973. /** @hidden */
  40974. _inputManager: InputManager;
  40975. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40976. cameraToUseForPointers: Nullable<Camera>;
  40977. /** @hidden */
  40978. readonly _isScene: boolean;
  40979. /** @hidden */
  40980. _blockEntityCollection: boolean;
  40981. /**
  40982. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40983. */
  40984. autoClear: boolean;
  40985. /**
  40986. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40987. */
  40988. autoClearDepthAndStencil: boolean;
  40989. /**
  40990. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40991. */
  40992. clearColor: Color4;
  40993. /**
  40994. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40995. */
  40996. ambientColor: Color3;
  40997. /**
  40998. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40999. * It should only be one of the following (if not the default embedded one):
  41000. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  41001. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  41002. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  41003. * The material properties need to be setup according to the type of texture in use.
  41004. */
  41005. environmentBRDFTexture: BaseTexture;
  41006. /**
  41007. * Texture used in all pbr material as the reflection texture.
  41008. * As in the majority of the scene they are the same (exception for multi room and so on),
  41009. * this is easier to reference from here than from all the materials.
  41010. */
  41011. get environmentTexture(): Nullable<BaseTexture>;
  41012. /**
  41013. * Texture used in all pbr material as the reflection texture.
  41014. * As in the majority of the scene they are the same (exception for multi room and so on),
  41015. * this is easier to set here than in all the materials.
  41016. */
  41017. set environmentTexture(value: Nullable<BaseTexture>);
  41018. /** @hidden */
  41019. protected _environmentIntensity: number;
  41020. /**
  41021. * Intensity of the environment in all pbr material.
  41022. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  41023. * As in the majority of the scene they are the same (exception for multi room and so on),
  41024. * this is easier to reference from here than from all the materials.
  41025. */
  41026. get environmentIntensity(): number;
  41027. /**
  41028. * Intensity of the environment in all pbr material.
  41029. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  41030. * As in the majority of the scene they are the same (exception for multi room and so on),
  41031. * this is easier to set here than in all the materials.
  41032. */
  41033. set environmentIntensity(value: number);
  41034. /** @hidden */
  41035. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41036. /**
  41037. * Default image processing configuration used either in the rendering
  41038. * Forward main pass or through the imageProcessingPostProcess if present.
  41039. * As in the majority of the scene they are the same (exception for multi camera),
  41040. * this is easier to reference from here than from all the materials and post process.
  41041. *
  41042. * No setter as we it is a shared configuration, you can set the values instead.
  41043. */
  41044. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  41045. private _forceWireframe;
  41046. /**
  41047. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  41048. */
  41049. set forceWireframe(value: boolean);
  41050. get forceWireframe(): boolean;
  41051. private _skipFrustumClipping;
  41052. /**
  41053. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  41054. */
  41055. set skipFrustumClipping(value: boolean);
  41056. get skipFrustumClipping(): boolean;
  41057. private _forcePointsCloud;
  41058. /**
  41059. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  41060. */
  41061. set forcePointsCloud(value: boolean);
  41062. get forcePointsCloud(): boolean;
  41063. /**
  41064. * Gets or sets the active clipplane 1
  41065. */
  41066. clipPlane: Nullable<Plane>;
  41067. /**
  41068. * Gets or sets the active clipplane 2
  41069. */
  41070. clipPlane2: Nullable<Plane>;
  41071. /**
  41072. * Gets or sets the active clipplane 3
  41073. */
  41074. clipPlane3: Nullable<Plane>;
  41075. /**
  41076. * Gets or sets the active clipplane 4
  41077. */
  41078. clipPlane4: Nullable<Plane>;
  41079. /**
  41080. * Gets or sets the active clipplane 5
  41081. */
  41082. clipPlane5: Nullable<Plane>;
  41083. /**
  41084. * Gets or sets the active clipplane 6
  41085. */
  41086. clipPlane6: Nullable<Plane>;
  41087. /**
  41088. * Gets or sets a boolean indicating if animations are enabled
  41089. */
  41090. animationsEnabled: boolean;
  41091. private _animationPropertiesOverride;
  41092. /**
  41093. * Gets or sets the animation properties override
  41094. */
  41095. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  41096. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  41097. /**
  41098. * Gets or sets a boolean indicating if a constant deltatime has to be used
  41099. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  41100. */
  41101. useConstantAnimationDeltaTime: boolean;
  41102. /**
  41103. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  41104. * Please note that it requires to run a ray cast through the scene on every frame
  41105. */
  41106. constantlyUpdateMeshUnderPointer: boolean;
  41107. /**
  41108. * Defines the HTML cursor to use when hovering over interactive elements
  41109. */
  41110. hoverCursor: string;
  41111. /**
  41112. * Defines the HTML default cursor to use (empty by default)
  41113. */
  41114. defaultCursor: string;
  41115. /**
  41116. * Defines whether cursors are handled by the scene.
  41117. */
  41118. doNotHandleCursors: boolean;
  41119. /**
  41120. * This is used to call preventDefault() on pointer down
  41121. * in order to block unwanted artifacts like system double clicks
  41122. */
  41123. preventDefaultOnPointerDown: boolean;
  41124. /**
  41125. * This is used to call preventDefault() on pointer up
  41126. * in order to block unwanted artifacts like system double clicks
  41127. */
  41128. preventDefaultOnPointerUp: boolean;
  41129. /**
  41130. * Gets or sets user defined metadata
  41131. */
  41132. metadata: any;
  41133. /**
  41134. * For internal use only. Please do not use.
  41135. */
  41136. reservedDataStore: any;
  41137. /**
  41138. * Gets the name of the plugin used to load this scene (null by default)
  41139. */
  41140. loadingPluginName: string;
  41141. /**
  41142. * Use this array to add regular expressions used to disable offline support for specific urls
  41143. */
  41144. disableOfflineSupportExceptionRules: RegExp[];
  41145. /**
  41146. * An event triggered when the scene is disposed.
  41147. */
  41148. onDisposeObservable: Observable<Scene>;
  41149. private _onDisposeObserver;
  41150. /** Sets a function to be executed when this scene is disposed. */
  41151. set onDispose(callback: () => void);
  41152. /**
  41153. * An event triggered before rendering the scene (right after animations and physics)
  41154. */
  41155. onBeforeRenderObservable: Observable<Scene>;
  41156. private _onBeforeRenderObserver;
  41157. /** Sets a function to be executed before rendering this scene */
  41158. set beforeRender(callback: Nullable<() => void>);
  41159. /**
  41160. * An event triggered after rendering the scene
  41161. */
  41162. onAfterRenderObservable: Observable<Scene>;
  41163. /**
  41164. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  41165. */
  41166. onAfterRenderCameraObservable: Observable<Camera>;
  41167. private _onAfterRenderObserver;
  41168. /** Sets a function to be executed after rendering this scene */
  41169. set afterRender(callback: Nullable<() => void>);
  41170. /**
  41171. * An event triggered before animating the scene
  41172. */
  41173. onBeforeAnimationsObservable: Observable<Scene>;
  41174. /**
  41175. * An event triggered after animations processing
  41176. */
  41177. onAfterAnimationsObservable: Observable<Scene>;
  41178. /**
  41179. * An event triggered before draw calls are ready to be sent
  41180. */
  41181. onBeforeDrawPhaseObservable: Observable<Scene>;
  41182. /**
  41183. * An event triggered after draw calls have been sent
  41184. */
  41185. onAfterDrawPhaseObservable: Observable<Scene>;
  41186. /**
  41187. * An event triggered when the scene is ready
  41188. */
  41189. onReadyObservable: Observable<Scene>;
  41190. /**
  41191. * An event triggered before rendering a camera
  41192. */
  41193. onBeforeCameraRenderObservable: Observable<Camera>;
  41194. private _onBeforeCameraRenderObserver;
  41195. /** Sets a function to be executed before rendering a camera*/
  41196. set beforeCameraRender(callback: () => void);
  41197. /**
  41198. * An event triggered after rendering a camera
  41199. */
  41200. onAfterCameraRenderObservable: Observable<Camera>;
  41201. private _onAfterCameraRenderObserver;
  41202. /** Sets a function to be executed after rendering a camera*/
  41203. set afterCameraRender(callback: () => void);
  41204. /**
  41205. * An event triggered when active meshes evaluation is about to start
  41206. */
  41207. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  41208. /**
  41209. * An event triggered when active meshes evaluation is done
  41210. */
  41211. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  41212. /**
  41213. * An event triggered when particles rendering is about to start
  41214. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41215. */
  41216. onBeforeParticlesRenderingObservable: Observable<Scene>;
  41217. /**
  41218. * An event triggered when particles rendering is done
  41219. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41220. */
  41221. onAfterParticlesRenderingObservable: Observable<Scene>;
  41222. /**
  41223. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  41224. */
  41225. onDataLoadedObservable: Observable<Scene>;
  41226. /**
  41227. * An event triggered when a camera is created
  41228. */
  41229. onNewCameraAddedObservable: Observable<Camera>;
  41230. /**
  41231. * An event triggered when a camera is removed
  41232. */
  41233. onCameraRemovedObservable: Observable<Camera>;
  41234. /**
  41235. * An event triggered when a light is created
  41236. */
  41237. onNewLightAddedObservable: Observable<Light>;
  41238. /**
  41239. * An event triggered when a light is removed
  41240. */
  41241. onLightRemovedObservable: Observable<Light>;
  41242. /**
  41243. * An event triggered when a geometry is created
  41244. */
  41245. onNewGeometryAddedObservable: Observable<Geometry>;
  41246. /**
  41247. * An event triggered when a geometry is removed
  41248. */
  41249. onGeometryRemovedObservable: Observable<Geometry>;
  41250. /**
  41251. * An event triggered when a transform node is created
  41252. */
  41253. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41254. /**
  41255. * An event triggered when a transform node is removed
  41256. */
  41257. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41258. /**
  41259. * An event triggered when a mesh is created
  41260. */
  41261. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41262. /**
  41263. * An event triggered when a mesh is removed
  41264. */
  41265. onMeshRemovedObservable: Observable<AbstractMesh>;
  41266. /**
  41267. * An event triggered when a skeleton is created
  41268. */
  41269. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41270. /**
  41271. * An event triggered when a skeleton is removed
  41272. */
  41273. onSkeletonRemovedObservable: Observable<Skeleton>;
  41274. /**
  41275. * An event triggered when a material is created
  41276. */
  41277. onNewMaterialAddedObservable: Observable<Material>;
  41278. /**
  41279. * An event triggered when a material is removed
  41280. */
  41281. onMaterialRemovedObservable: Observable<Material>;
  41282. /**
  41283. * An event triggered when a texture is created
  41284. */
  41285. onNewTextureAddedObservable: Observable<BaseTexture>;
  41286. /**
  41287. * An event triggered when a texture is removed
  41288. */
  41289. onTextureRemovedObservable: Observable<BaseTexture>;
  41290. /**
  41291. * An event triggered when render targets are about to be rendered
  41292. * Can happen multiple times per frame.
  41293. */
  41294. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41295. /**
  41296. * An event triggered when render targets were rendered.
  41297. * Can happen multiple times per frame.
  41298. */
  41299. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41300. /**
  41301. * An event triggered before calculating deterministic simulation step
  41302. */
  41303. onBeforeStepObservable: Observable<Scene>;
  41304. /**
  41305. * An event triggered after calculating deterministic simulation step
  41306. */
  41307. onAfterStepObservable: Observable<Scene>;
  41308. /**
  41309. * An event triggered when the activeCamera property is updated
  41310. */
  41311. onActiveCameraChanged: Observable<Scene>;
  41312. /**
  41313. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41314. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41315. * 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)
  41316. */
  41317. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41318. /**
  41319. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41320. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41321. * 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)
  41322. */
  41323. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41324. /**
  41325. * This Observable will when a mesh has been imported into the scene.
  41326. */
  41327. onMeshImportedObservable: Observable<AbstractMesh>;
  41328. /**
  41329. * This Observable will when an animation file has been imported into the scene.
  41330. */
  41331. onAnimationFileImportedObservable: Observable<Scene>;
  41332. /**
  41333. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41334. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41335. */
  41336. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41337. /** @hidden */
  41338. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41339. /**
  41340. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41341. */
  41342. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41343. /**
  41344. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41345. */
  41346. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41347. /**
  41348. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41349. */
  41350. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41351. /** Callback called when a pointer move is detected */
  41352. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41353. /** Callback called when a pointer down is detected */
  41354. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41355. /** Callback called when a pointer up is detected */
  41356. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41357. /** Callback called when a pointer pick is detected */
  41358. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41359. /**
  41360. * 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).
  41361. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41362. */
  41363. onPrePointerObservable: Observable<PointerInfoPre>;
  41364. /**
  41365. * Observable event triggered each time an input event is received from the rendering canvas
  41366. */
  41367. onPointerObservable: Observable<PointerInfo>;
  41368. /**
  41369. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41370. */
  41371. get unTranslatedPointer(): Vector2;
  41372. /**
  41373. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41374. */
  41375. static get DragMovementThreshold(): number;
  41376. static set DragMovementThreshold(value: number);
  41377. /**
  41378. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41379. */
  41380. static get LongPressDelay(): number;
  41381. static set LongPressDelay(value: number);
  41382. /**
  41383. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41384. */
  41385. static get DoubleClickDelay(): number;
  41386. static set DoubleClickDelay(value: number);
  41387. /** If you need to check double click without raising a single click at first click, enable this flag */
  41388. static get ExclusiveDoubleClickMode(): boolean;
  41389. static set ExclusiveDoubleClickMode(value: boolean);
  41390. /** @hidden */
  41391. _mirroredCameraPosition: Nullable<Vector3>;
  41392. /**
  41393. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41394. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41395. */
  41396. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41397. /**
  41398. * Observable event triggered each time an keyboard event is received from the hosting window
  41399. */
  41400. onKeyboardObservable: Observable<KeyboardInfo>;
  41401. private _useRightHandedSystem;
  41402. /**
  41403. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41404. */
  41405. set useRightHandedSystem(value: boolean);
  41406. get useRightHandedSystem(): boolean;
  41407. private _timeAccumulator;
  41408. private _currentStepId;
  41409. private _currentInternalStep;
  41410. /**
  41411. * Sets the step Id used by deterministic lock step
  41412. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41413. * @param newStepId defines the step Id
  41414. */
  41415. setStepId(newStepId: number): void;
  41416. /**
  41417. * Gets the step Id used by deterministic lock step
  41418. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41419. * @returns the step Id
  41420. */
  41421. getStepId(): number;
  41422. /**
  41423. * Gets the internal step used by deterministic lock step
  41424. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41425. * @returns the internal step
  41426. */
  41427. getInternalStep(): number;
  41428. private _fogEnabled;
  41429. /**
  41430. * Gets or sets a boolean indicating if fog is enabled on this scene
  41431. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41432. * (Default is true)
  41433. */
  41434. set fogEnabled(value: boolean);
  41435. get fogEnabled(): boolean;
  41436. private _fogMode;
  41437. /**
  41438. * Gets or sets the fog mode to use
  41439. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41440. * | mode | value |
  41441. * | --- | --- |
  41442. * | FOGMODE_NONE | 0 |
  41443. * | FOGMODE_EXP | 1 |
  41444. * | FOGMODE_EXP2 | 2 |
  41445. * | FOGMODE_LINEAR | 3 |
  41446. */
  41447. set fogMode(value: number);
  41448. get fogMode(): number;
  41449. /**
  41450. * Gets or sets the fog color to use
  41451. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41452. * (Default is Color3(0.2, 0.2, 0.3))
  41453. */
  41454. fogColor: Color3;
  41455. /**
  41456. * Gets or sets the fog density to use
  41457. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41458. * (Default is 0.1)
  41459. */
  41460. fogDensity: number;
  41461. /**
  41462. * Gets or sets the fog start distance to use
  41463. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41464. * (Default is 0)
  41465. */
  41466. fogStart: number;
  41467. /**
  41468. * Gets or sets the fog end distance to use
  41469. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41470. * (Default is 1000)
  41471. */
  41472. fogEnd: number;
  41473. /**
  41474. * Flag indicating that the frame buffer binding is handled by another component
  41475. */
  41476. prePass: boolean;
  41477. private _shadowsEnabled;
  41478. /**
  41479. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41480. */
  41481. set shadowsEnabled(value: boolean);
  41482. get shadowsEnabled(): boolean;
  41483. private _lightsEnabled;
  41484. /**
  41485. * Gets or sets a boolean indicating if lights are enabled on this scene
  41486. */
  41487. set lightsEnabled(value: boolean);
  41488. get lightsEnabled(): boolean;
  41489. /** All of the active cameras added to this scene. */
  41490. activeCameras: Camera[];
  41491. /** @hidden */
  41492. _activeCamera: Nullable<Camera>;
  41493. /** Gets or sets the current active camera */
  41494. get activeCamera(): Nullable<Camera>;
  41495. set activeCamera(value: Nullable<Camera>);
  41496. private _defaultMaterial;
  41497. /** The default material used on meshes when no material is affected */
  41498. get defaultMaterial(): Material;
  41499. /** The default material used on meshes when no material is affected */
  41500. set defaultMaterial(value: Material);
  41501. private _texturesEnabled;
  41502. /**
  41503. * Gets or sets a boolean indicating if textures are enabled on this scene
  41504. */
  41505. set texturesEnabled(value: boolean);
  41506. get texturesEnabled(): boolean;
  41507. /**
  41508. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41509. */
  41510. physicsEnabled: boolean;
  41511. /**
  41512. * Gets or sets a boolean indicating if particles are enabled on this scene
  41513. */
  41514. particlesEnabled: boolean;
  41515. /**
  41516. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41517. */
  41518. spritesEnabled: boolean;
  41519. private _skeletonsEnabled;
  41520. /**
  41521. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41522. */
  41523. set skeletonsEnabled(value: boolean);
  41524. get skeletonsEnabled(): boolean;
  41525. /**
  41526. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41527. */
  41528. lensFlaresEnabled: boolean;
  41529. /**
  41530. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41531. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41532. */
  41533. collisionsEnabled: boolean;
  41534. private _collisionCoordinator;
  41535. /** @hidden */
  41536. get collisionCoordinator(): ICollisionCoordinator;
  41537. /**
  41538. * Defines the gravity applied to this scene (used only for collisions)
  41539. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41540. */
  41541. gravity: Vector3;
  41542. /**
  41543. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41544. */
  41545. postProcessesEnabled: boolean;
  41546. /**
  41547. * Gets the current postprocess manager
  41548. */
  41549. postProcessManager: PostProcessManager;
  41550. /**
  41551. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41552. */
  41553. renderTargetsEnabled: boolean;
  41554. /**
  41555. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41556. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41557. */
  41558. dumpNextRenderTargets: boolean;
  41559. /**
  41560. * The list of user defined render targets added to the scene
  41561. */
  41562. customRenderTargets: RenderTargetTexture[];
  41563. /**
  41564. * Defines if texture loading must be delayed
  41565. * If true, textures will only be loaded when they need to be rendered
  41566. */
  41567. useDelayedTextureLoading: boolean;
  41568. /**
  41569. * Gets the list of meshes imported to the scene through SceneLoader
  41570. */
  41571. importedMeshesFiles: String[];
  41572. /**
  41573. * Gets or sets a boolean indicating if probes are enabled on this scene
  41574. */
  41575. probesEnabled: boolean;
  41576. /**
  41577. * Gets or sets the current offline provider to use to store scene data
  41578. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41579. */
  41580. offlineProvider: IOfflineProvider;
  41581. /**
  41582. * Gets or sets the action manager associated with the scene
  41583. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41584. */
  41585. actionManager: AbstractActionManager;
  41586. private _meshesForIntersections;
  41587. /**
  41588. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41589. */
  41590. proceduralTexturesEnabled: boolean;
  41591. private _engine;
  41592. private _totalVertices;
  41593. /** @hidden */
  41594. _activeIndices: PerfCounter;
  41595. /** @hidden */
  41596. _activeParticles: PerfCounter;
  41597. /** @hidden */
  41598. _activeBones: PerfCounter;
  41599. private _animationRatio;
  41600. /** @hidden */
  41601. _animationTimeLast: number;
  41602. /** @hidden */
  41603. _animationTime: number;
  41604. /**
  41605. * Gets or sets a general scale for animation speed
  41606. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41607. */
  41608. animationTimeScale: number;
  41609. /** @hidden */
  41610. _cachedMaterial: Nullable<Material>;
  41611. /** @hidden */
  41612. _cachedEffect: Nullable<Effect>;
  41613. /** @hidden */
  41614. _cachedVisibility: Nullable<number>;
  41615. private _renderId;
  41616. private _frameId;
  41617. private _executeWhenReadyTimeoutId;
  41618. private _intermediateRendering;
  41619. private _viewUpdateFlag;
  41620. private _projectionUpdateFlag;
  41621. /** @hidden */
  41622. _toBeDisposed: Nullable<IDisposable>[];
  41623. private _activeRequests;
  41624. /** @hidden */
  41625. _pendingData: any[];
  41626. private _isDisposed;
  41627. /**
  41628. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41629. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41630. */
  41631. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41632. private _activeMeshes;
  41633. private _processedMaterials;
  41634. private _renderTargets;
  41635. /** @hidden */
  41636. _activeParticleSystems: SmartArray<IParticleSystem>;
  41637. private _activeSkeletons;
  41638. private _softwareSkinnedMeshes;
  41639. private _renderingManager;
  41640. /** @hidden */
  41641. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41642. private _transformMatrix;
  41643. private _sceneUbo;
  41644. /** @hidden */
  41645. _viewMatrix: Matrix;
  41646. private _projectionMatrix;
  41647. /** @hidden */
  41648. _forcedViewPosition: Nullable<Vector3>;
  41649. /** @hidden */
  41650. _frustumPlanes: Plane[];
  41651. /**
  41652. * Gets the list of frustum planes (built from the active camera)
  41653. */
  41654. get frustumPlanes(): Plane[];
  41655. /**
  41656. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41657. * This is useful if there are more lights that the maximum simulteanous authorized
  41658. */
  41659. requireLightSorting: boolean;
  41660. /** @hidden */
  41661. readonly useMaterialMeshMap: boolean;
  41662. /** @hidden */
  41663. readonly useClonedMeshMap: boolean;
  41664. private _externalData;
  41665. private _uid;
  41666. /**
  41667. * @hidden
  41668. * Backing store of defined scene components.
  41669. */
  41670. _components: ISceneComponent[];
  41671. /**
  41672. * @hidden
  41673. * Backing store of defined scene components.
  41674. */
  41675. _serializableComponents: ISceneSerializableComponent[];
  41676. /**
  41677. * List of components to register on the next registration step.
  41678. */
  41679. private _transientComponents;
  41680. /**
  41681. * Registers the transient components if needed.
  41682. */
  41683. private _registerTransientComponents;
  41684. /**
  41685. * @hidden
  41686. * Add a component to the scene.
  41687. * Note that the ccomponent could be registered on th next frame if this is called after
  41688. * the register component stage.
  41689. * @param component Defines the component to add to the scene
  41690. */
  41691. _addComponent(component: ISceneComponent): void;
  41692. /**
  41693. * @hidden
  41694. * Gets a component from the scene.
  41695. * @param name defines the name of the component to retrieve
  41696. * @returns the component or null if not present
  41697. */
  41698. _getComponent(name: string): Nullable<ISceneComponent>;
  41699. /**
  41700. * @hidden
  41701. * Defines the actions happening before camera updates.
  41702. */
  41703. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41704. /**
  41705. * @hidden
  41706. * Defines the actions happening before clear the canvas.
  41707. */
  41708. _beforeClearStage: Stage<SimpleStageAction>;
  41709. /**
  41710. * @hidden
  41711. * Defines the actions when collecting render targets for the frame.
  41712. */
  41713. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41714. /**
  41715. * @hidden
  41716. * Defines the actions happening for one camera in the frame.
  41717. */
  41718. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41719. /**
  41720. * @hidden
  41721. * Defines the actions happening during the per mesh ready checks.
  41722. */
  41723. _isReadyForMeshStage: Stage<MeshStageAction>;
  41724. /**
  41725. * @hidden
  41726. * Defines the actions happening before evaluate active mesh checks.
  41727. */
  41728. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41729. /**
  41730. * @hidden
  41731. * Defines the actions happening during the evaluate sub mesh checks.
  41732. */
  41733. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41734. /**
  41735. * @hidden
  41736. * Defines the actions happening during the active mesh stage.
  41737. */
  41738. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41739. /**
  41740. * @hidden
  41741. * Defines the actions happening during the per camera render target step.
  41742. */
  41743. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41744. /**
  41745. * @hidden
  41746. * Defines the actions happening just before the active camera is drawing.
  41747. */
  41748. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41749. /**
  41750. * @hidden
  41751. * Defines the actions happening just before a render target is drawing.
  41752. */
  41753. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41754. /**
  41755. * @hidden
  41756. * Defines the actions happening just before a rendering group is drawing.
  41757. */
  41758. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41759. /**
  41760. * @hidden
  41761. * Defines the actions happening just before a mesh is drawing.
  41762. */
  41763. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41764. /**
  41765. * @hidden
  41766. * Defines the actions happening just after a mesh has been drawn.
  41767. */
  41768. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41769. /**
  41770. * @hidden
  41771. * Defines the actions happening just after a rendering group has been drawn.
  41772. */
  41773. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41774. /**
  41775. * @hidden
  41776. * Defines the actions happening just after the active camera has been drawn.
  41777. */
  41778. _afterCameraDrawStage: Stage<CameraStageAction>;
  41779. /**
  41780. * @hidden
  41781. * Defines the actions happening just after a render target has been drawn.
  41782. */
  41783. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41784. /**
  41785. * @hidden
  41786. * Defines the actions happening just after rendering all cameras and computing intersections.
  41787. */
  41788. _afterRenderStage: Stage<SimpleStageAction>;
  41789. /**
  41790. * @hidden
  41791. * Defines the actions happening when a pointer move event happens.
  41792. */
  41793. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41794. /**
  41795. * @hidden
  41796. * Defines the actions happening when a pointer down event happens.
  41797. */
  41798. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41799. /**
  41800. * @hidden
  41801. * Defines the actions happening when a pointer up event happens.
  41802. */
  41803. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41804. /**
  41805. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41806. */
  41807. private geometriesByUniqueId;
  41808. /**
  41809. * Creates a new Scene
  41810. * @param engine defines the engine to use to render this scene
  41811. * @param options defines the scene options
  41812. */
  41813. constructor(engine: Engine, options?: SceneOptions);
  41814. /**
  41815. * Gets a string identifying the name of the class
  41816. * @returns "Scene" string
  41817. */
  41818. getClassName(): string;
  41819. private _defaultMeshCandidates;
  41820. /**
  41821. * @hidden
  41822. */
  41823. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41824. private _defaultSubMeshCandidates;
  41825. /**
  41826. * @hidden
  41827. */
  41828. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41829. /**
  41830. * Sets the default candidate providers for the scene.
  41831. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41832. * and getCollidingSubMeshCandidates to their default function
  41833. */
  41834. setDefaultCandidateProviders(): void;
  41835. /**
  41836. * Gets the mesh that is currently under the pointer
  41837. */
  41838. get meshUnderPointer(): Nullable<AbstractMesh>;
  41839. /**
  41840. * Gets or sets the current on-screen X position of the pointer
  41841. */
  41842. get pointerX(): number;
  41843. set pointerX(value: number);
  41844. /**
  41845. * Gets or sets the current on-screen Y position of the pointer
  41846. */
  41847. get pointerY(): number;
  41848. set pointerY(value: number);
  41849. /**
  41850. * Gets the cached material (ie. the latest rendered one)
  41851. * @returns the cached material
  41852. */
  41853. getCachedMaterial(): Nullable<Material>;
  41854. /**
  41855. * Gets the cached effect (ie. the latest rendered one)
  41856. * @returns the cached effect
  41857. */
  41858. getCachedEffect(): Nullable<Effect>;
  41859. /**
  41860. * Gets the cached visibility state (ie. the latest rendered one)
  41861. * @returns the cached visibility state
  41862. */
  41863. getCachedVisibility(): Nullable<number>;
  41864. /**
  41865. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41866. * @param material defines the current material
  41867. * @param effect defines the current effect
  41868. * @param visibility defines the current visibility state
  41869. * @returns true if one parameter is not cached
  41870. */
  41871. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41872. /**
  41873. * Gets the engine associated with the scene
  41874. * @returns an Engine
  41875. */
  41876. getEngine(): Engine;
  41877. /**
  41878. * Gets the total number of vertices rendered per frame
  41879. * @returns the total number of vertices rendered per frame
  41880. */
  41881. getTotalVertices(): number;
  41882. /**
  41883. * Gets the performance counter for total vertices
  41884. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41885. */
  41886. get totalVerticesPerfCounter(): PerfCounter;
  41887. /**
  41888. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41889. * @returns the total number of active indices rendered per frame
  41890. */
  41891. getActiveIndices(): number;
  41892. /**
  41893. * Gets the performance counter for active indices
  41894. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41895. */
  41896. get totalActiveIndicesPerfCounter(): PerfCounter;
  41897. /**
  41898. * Gets the total number of active particles rendered per frame
  41899. * @returns the total number of active particles rendered per frame
  41900. */
  41901. getActiveParticles(): number;
  41902. /**
  41903. * Gets the performance counter for active particles
  41904. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41905. */
  41906. get activeParticlesPerfCounter(): PerfCounter;
  41907. /**
  41908. * Gets the total number of active bones rendered per frame
  41909. * @returns the total number of active bones rendered per frame
  41910. */
  41911. getActiveBones(): number;
  41912. /**
  41913. * Gets the performance counter for active bones
  41914. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41915. */
  41916. get activeBonesPerfCounter(): PerfCounter;
  41917. /**
  41918. * Gets the array of active meshes
  41919. * @returns an array of AbstractMesh
  41920. */
  41921. getActiveMeshes(): SmartArray<AbstractMesh>;
  41922. /**
  41923. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41924. * @returns a number
  41925. */
  41926. getAnimationRatio(): number;
  41927. /**
  41928. * Gets an unique Id for the current render phase
  41929. * @returns a number
  41930. */
  41931. getRenderId(): number;
  41932. /**
  41933. * Gets an unique Id for the current frame
  41934. * @returns a number
  41935. */
  41936. getFrameId(): number;
  41937. /** Call this function if you want to manually increment the render Id*/
  41938. incrementRenderId(): void;
  41939. private _createUbo;
  41940. /**
  41941. * Use this method to simulate a pointer move on a mesh
  41942. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41943. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41944. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41945. * @returns the current scene
  41946. */
  41947. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41948. /**
  41949. * Use this method to simulate a pointer down on a mesh
  41950. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41951. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41952. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41953. * @returns the current scene
  41954. */
  41955. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41956. /**
  41957. * Use this method to simulate a pointer up on a mesh
  41958. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41959. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41960. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41961. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41962. * @returns the current scene
  41963. */
  41964. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41965. /**
  41966. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41967. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41968. * @returns true if the pointer was captured
  41969. */
  41970. isPointerCaptured(pointerId?: number): boolean;
  41971. /**
  41972. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41973. * @param attachUp defines if you want to attach events to pointerup
  41974. * @param attachDown defines if you want to attach events to pointerdown
  41975. * @param attachMove defines if you want to attach events to pointermove
  41976. */
  41977. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41978. /** Detaches all event handlers*/
  41979. detachControl(): void;
  41980. /**
  41981. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41982. * Delay loaded resources are not taking in account
  41983. * @return true if all required resources are ready
  41984. */
  41985. isReady(): boolean;
  41986. /** Resets all cached information relative to material (including effect and visibility) */
  41987. resetCachedMaterial(): void;
  41988. /**
  41989. * Registers a function to be called before every frame render
  41990. * @param func defines the function to register
  41991. */
  41992. registerBeforeRender(func: () => void): void;
  41993. /**
  41994. * Unregisters a function called before every frame render
  41995. * @param func defines the function to unregister
  41996. */
  41997. unregisterBeforeRender(func: () => void): void;
  41998. /**
  41999. * Registers a function to be called after every frame render
  42000. * @param func defines the function to register
  42001. */
  42002. registerAfterRender(func: () => void): void;
  42003. /**
  42004. * Unregisters a function called after every frame render
  42005. * @param func defines the function to unregister
  42006. */
  42007. unregisterAfterRender(func: () => void): void;
  42008. private _executeOnceBeforeRender;
  42009. /**
  42010. * The provided function will run before render once and will be disposed afterwards.
  42011. * A timeout delay can be provided so that the function will be executed in N ms.
  42012. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  42013. * @param func The function to be executed.
  42014. * @param timeout optional delay in ms
  42015. */
  42016. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  42017. /** @hidden */
  42018. _addPendingData(data: any): void;
  42019. /** @hidden */
  42020. _removePendingData(data: any): void;
  42021. /**
  42022. * Returns the number of items waiting to be loaded
  42023. * @returns the number of items waiting to be loaded
  42024. */
  42025. getWaitingItemsCount(): number;
  42026. /**
  42027. * Returns a boolean indicating if the scene is still loading data
  42028. */
  42029. get isLoading(): boolean;
  42030. /**
  42031. * Registers a function to be executed when the scene is ready
  42032. * @param {Function} func - the function to be executed
  42033. */
  42034. executeWhenReady(func: () => void): void;
  42035. /**
  42036. * Returns a promise that resolves when the scene is ready
  42037. * @returns A promise that resolves when the scene is ready
  42038. */
  42039. whenReadyAsync(): Promise<void>;
  42040. /** @hidden */
  42041. _checkIsReady(): void;
  42042. /**
  42043. * Gets all animatable attached to the scene
  42044. */
  42045. get animatables(): Animatable[];
  42046. /**
  42047. * Resets the last animation time frame.
  42048. * Useful to override when animations start running when loading a scene for the first time.
  42049. */
  42050. resetLastAnimationTimeFrame(): void;
  42051. /**
  42052. * Gets the current view matrix
  42053. * @returns a Matrix
  42054. */
  42055. getViewMatrix(): Matrix;
  42056. /**
  42057. * Gets the current projection matrix
  42058. * @returns a Matrix
  42059. */
  42060. getProjectionMatrix(): Matrix;
  42061. /**
  42062. * Gets the current transform matrix
  42063. * @returns a Matrix made of View * Projection
  42064. */
  42065. getTransformMatrix(): Matrix;
  42066. /**
  42067. * Sets the current transform matrix
  42068. * @param viewL defines the View matrix to use
  42069. * @param projectionL defines the Projection matrix to use
  42070. * @param viewR defines the right View matrix to use (if provided)
  42071. * @param projectionR defines the right Projection matrix to use (if provided)
  42072. */
  42073. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  42074. /**
  42075. * Gets the uniform buffer used to store scene data
  42076. * @returns a UniformBuffer
  42077. */
  42078. getSceneUniformBuffer(): UniformBuffer;
  42079. /**
  42080. * Gets an unique (relatively to the current scene) Id
  42081. * @returns an unique number for the scene
  42082. */
  42083. getUniqueId(): number;
  42084. /**
  42085. * Add a mesh to the list of scene's meshes
  42086. * @param newMesh defines the mesh to add
  42087. * @param recursive if all child meshes should also be added to the scene
  42088. */
  42089. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  42090. /**
  42091. * Remove a mesh for the list of scene's meshes
  42092. * @param toRemove defines the mesh to remove
  42093. * @param recursive if all child meshes should also be removed from the scene
  42094. * @returns the index where the mesh was in the mesh list
  42095. */
  42096. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  42097. /**
  42098. * Add a transform node to the list of scene's transform nodes
  42099. * @param newTransformNode defines the transform node to add
  42100. */
  42101. addTransformNode(newTransformNode: TransformNode): void;
  42102. /**
  42103. * Remove a transform node for the list of scene's transform nodes
  42104. * @param toRemove defines the transform node to remove
  42105. * @returns the index where the transform node was in the transform node list
  42106. */
  42107. removeTransformNode(toRemove: TransformNode): number;
  42108. /**
  42109. * Remove a skeleton for the list of scene's skeletons
  42110. * @param toRemove defines the skeleton to remove
  42111. * @returns the index where the skeleton was in the skeleton list
  42112. */
  42113. removeSkeleton(toRemove: Skeleton): number;
  42114. /**
  42115. * Remove a morph target for the list of scene's morph targets
  42116. * @param toRemove defines the morph target to remove
  42117. * @returns the index where the morph target was in the morph target list
  42118. */
  42119. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  42120. /**
  42121. * Remove a light for the list of scene's lights
  42122. * @param toRemove defines the light to remove
  42123. * @returns the index where the light was in the light list
  42124. */
  42125. removeLight(toRemove: Light): number;
  42126. /**
  42127. * Remove a camera for the list of scene's cameras
  42128. * @param toRemove defines the camera to remove
  42129. * @returns the index where the camera was in the camera list
  42130. */
  42131. removeCamera(toRemove: Camera): number;
  42132. /**
  42133. * Remove a particle system for the list of scene's particle systems
  42134. * @param toRemove defines the particle system to remove
  42135. * @returns the index where the particle system was in the particle system list
  42136. */
  42137. removeParticleSystem(toRemove: IParticleSystem): number;
  42138. /**
  42139. * Remove a animation for the list of scene's animations
  42140. * @param toRemove defines the animation to remove
  42141. * @returns the index where the animation was in the animation list
  42142. */
  42143. removeAnimation(toRemove: Animation): number;
  42144. /**
  42145. * Will stop the animation of the given target
  42146. * @param target - the target
  42147. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  42148. * @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)
  42149. */
  42150. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  42151. /**
  42152. * Removes the given animation group from this scene.
  42153. * @param toRemove The animation group to remove
  42154. * @returns The index of the removed animation group
  42155. */
  42156. removeAnimationGroup(toRemove: AnimationGroup): number;
  42157. /**
  42158. * Removes the given multi-material from this scene.
  42159. * @param toRemove The multi-material to remove
  42160. * @returns The index of the removed multi-material
  42161. */
  42162. removeMultiMaterial(toRemove: MultiMaterial): number;
  42163. /**
  42164. * Removes the given material from this scene.
  42165. * @param toRemove The material to remove
  42166. * @returns The index of the removed material
  42167. */
  42168. removeMaterial(toRemove: Material): number;
  42169. /**
  42170. * Removes the given action manager from this scene.
  42171. * @param toRemove The action manager to remove
  42172. * @returns The index of the removed action manager
  42173. */
  42174. removeActionManager(toRemove: AbstractActionManager): number;
  42175. /**
  42176. * Removes the given texture from this scene.
  42177. * @param toRemove The texture to remove
  42178. * @returns The index of the removed texture
  42179. */
  42180. removeTexture(toRemove: BaseTexture): number;
  42181. /**
  42182. * Adds the given light to this scene
  42183. * @param newLight The light to add
  42184. */
  42185. addLight(newLight: Light): void;
  42186. /**
  42187. * Sorts the list list based on light priorities
  42188. */
  42189. sortLightsByPriority(): void;
  42190. /**
  42191. * Adds the given camera to this scene
  42192. * @param newCamera The camera to add
  42193. */
  42194. addCamera(newCamera: Camera): void;
  42195. /**
  42196. * Adds the given skeleton to this scene
  42197. * @param newSkeleton The skeleton to add
  42198. */
  42199. addSkeleton(newSkeleton: Skeleton): void;
  42200. /**
  42201. * Adds the given particle system to this scene
  42202. * @param newParticleSystem The particle system to add
  42203. */
  42204. addParticleSystem(newParticleSystem: IParticleSystem): void;
  42205. /**
  42206. * Adds the given animation to this scene
  42207. * @param newAnimation The animation to add
  42208. */
  42209. addAnimation(newAnimation: Animation): void;
  42210. /**
  42211. * Adds the given animation group to this scene.
  42212. * @param newAnimationGroup The animation group to add
  42213. */
  42214. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  42215. /**
  42216. * Adds the given multi-material to this scene
  42217. * @param newMultiMaterial The multi-material to add
  42218. */
  42219. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  42220. /**
  42221. * Adds the given material to this scene
  42222. * @param newMaterial The material to add
  42223. */
  42224. addMaterial(newMaterial: Material): void;
  42225. /**
  42226. * Adds the given morph target to this scene
  42227. * @param newMorphTargetManager The morph target to add
  42228. */
  42229. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  42230. /**
  42231. * Adds the given geometry to this scene
  42232. * @param newGeometry The geometry to add
  42233. */
  42234. addGeometry(newGeometry: Geometry): void;
  42235. /**
  42236. * Adds the given action manager to this scene
  42237. * @param newActionManager The action manager to add
  42238. */
  42239. addActionManager(newActionManager: AbstractActionManager): void;
  42240. /**
  42241. * Adds the given texture to this scene.
  42242. * @param newTexture The texture to add
  42243. */
  42244. addTexture(newTexture: BaseTexture): void;
  42245. /**
  42246. * Switch active camera
  42247. * @param newCamera defines the new active camera
  42248. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42249. */
  42250. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42251. /**
  42252. * sets the active camera of the scene using its ID
  42253. * @param id defines the camera's ID
  42254. * @return the new active camera or null if none found.
  42255. */
  42256. setActiveCameraByID(id: string): Nullable<Camera>;
  42257. /**
  42258. * sets the active camera of the scene using its name
  42259. * @param name defines the camera's name
  42260. * @returns the new active camera or null if none found.
  42261. */
  42262. setActiveCameraByName(name: string): Nullable<Camera>;
  42263. /**
  42264. * get an animation group using its name
  42265. * @param name defines the material's name
  42266. * @return the animation group or null if none found.
  42267. */
  42268. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42269. /**
  42270. * Get a material using its unique id
  42271. * @param uniqueId defines the material's unique id
  42272. * @return the material or null if none found.
  42273. */
  42274. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42275. /**
  42276. * get a material using its id
  42277. * @param id defines the material's ID
  42278. * @return the material or null if none found.
  42279. */
  42280. getMaterialByID(id: string): Nullable<Material>;
  42281. /**
  42282. * Gets a the last added material using a given id
  42283. * @param id defines the material's ID
  42284. * @return the last material with the given id or null if none found.
  42285. */
  42286. getLastMaterialByID(id: string): Nullable<Material>;
  42287. /**
  42288. * Gets a material using its name
  42289. * @param name defines the material's name
  42290. * @return the material or null if none found.
  42291. */
  42292. getMaterialByName(name: string): Nullable<Material>;
  42293. /**
  42294. * Get a texture using its unique id
  42295. * @param uniqueId defines the texture's unique id
  42296. * @return the texture or null if none found.
  42297. */
  42298. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42299. /**
  42300. * Gets a camera using its id
  42301. * @param id defines the id to look for
  42302. * @returns the camera or null if not found
  42303. */
  42304. getCameraByID(id: string): Nullable<Camera>;
  42305. /**
  42306. * Gets a camera using its unique id
  42307. * @param uniqueId defines the unique id to look for
  42308. * @returns the camera or null if not found
  42309. */
  42310. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42311. /**
  42312. * Gets a camera using its name
  42313. * @param name defines the camera's name
  42314. * @return the camera or null if none found.
  42315. */
  42316. getCameraByName(name: string): Nullable<Camera>;
  42317. /**
  42318. * Gets a bone using its id
  42319. * @param id defines the bone's id
  42320. * @return the bone or null if not found
  42321. */
  42322. getBoneByID(id: string): Nullable<Bone>;
  42323. /**
  42324. * Gets a bone using its id
  42325. * @param name defines the bone's name
  42326. * @return the bone or null if not found
  42327. */
  42328. getBoneByName(name: string): Nullable<Bone>;
  42329. /**
  42330. * Gets a light node using its name
  42331. * @param name defines the the light's name
  42332. * @return the light or null if none found.
  42333. */
  42334. getLightByName(name: string): Nullable<Light>;
  42335. /**
  42336. * Gets a light node using its id
  42337. * @param id defines the light's id
  42338. * @return the light or null if none found.
  42339. */
  42340. getLightByID(id: string): Nullable<Light>;
  42341. /**
  42342. * Gets a light node using its scene-generated unique ID
  42343. * @param uniqueId defines the light's unique id
  42344. * @return the light or null if none found.
  42345. */
  42346. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42347. /**
  42348. * Gets a particle system by id
  42349. * @param id defines the particle system id
  42350. * @return the corresponding system or null if none found
  42351. */
  42352. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42353. /**
  42354. * Gets a geometry using its ID
  42355. * @param id defines the geometry's id
  42356. * @return the geometry or null if none found.
  42357. */
  42358. getGeometryByID(id: string): Nullable<Geometry>;
  42359. private _getGeometryByUniqueID;
  42360. /**
  42361. * Add a new geometry to this scene
  42362. * @param geometry defines the geometry to be added to the scene.
  42363. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42364. * @return a boolean defining if the geometry was added or not
  42365. */
  42366. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42367. /**
  42368. * Removes an existing geometry
  42369. * @param geometry defines the geometry to be removed from the scene
  42370. * @return a boolean defining if the geometry was removed or not
  42371. */
  42372. removeGeometry(geometry: Geometry): boolean;
  42373. /**
  42374. * Gets the list of geometries attached to the scene
  42375. * @returns an array of Geometry
  42376. */
  42377. getGeometries(): Geometry[];
  42378. /**
  42379. * Gets the first added mesh found of a given ID
  42380. * @param id defines the id to search for
  42381. * @return the mesh found or null if not found at all
  42382. */
  42383. getMeshByID(id: string): Nullable<AbstractMesh>;
  42384. /**
  42385. * Gets a list of meshes using their id
  42386. * @param id defines the id to search for
  42387. * @returns a list of meshes
  42388. */
  42389. getMeshesByID(id: string): Array<AbstractMesh>;
  42390. /**
  42391. * Gets the first added transform node found of a given ID
  42392. * @param id defines the id to search for
  42393. * @return the found transform node or null if not found at all.
  42394. */
  42395. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42396. /**
  42397. * Gets a transform node with its auto-generated unique id
  42398. * @param uniqueId efines the unique id to search for
  42399. * @return the found transform node or null if not found at all.
  42400. */
  42401. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42402. /**
  42403. * Gets a list of transform nodes using their id
  42404. * @param id defines the id to search for
  42405. * @returns a list of transform nodes
  42406. */
  42407. getTransformNodesByID(id: string): Array<TransformNode>;
  42408. /**
  42409. * Gets a mesh with its auto-generated unique id
  42410. * @param uniqueId defines the unique id to search for
  42411. * @return the found mesh or null if not found at all.
  42412. */
  42413. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42414. /**
  42415. * Gets a the last added mesh using a given id
  42416. * @param id defines the id to search for
  42417. * @return the found mesh or null if not found at all.
  42418. */
  42419. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42420. /**
  42421. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42422. * @param id defines the id to search for
  42423. * @return the found node or null if not found at all
  42424. */
  42425. getLastEntryByID(id: string): Nullable<Node>;
  42426. /**
  42427. * Gets a node (Mesh, Camera, Light) using a given id
  42428. * @param id defines the id to search for
  42429. * @return the found node or null if not found at all
  42430. */
  42431. getNodeByID(id: string): Nullable<Node>;
  42432. /**
  42433. * Gets a node (Mesh, Camera, Light) using a given name
  42434. * @param name defines the name to search for
  42435. * @return the found node or null if not found at all.
  42436. */
  42437. getNodeByName(name: string): Nullable<Node>;
  42438. /**
  42439. * Gets a mesh using a given name
  42440. * @param name defines the name to search for
  42441. * @return the found mesh or null if not found at all.
  42442. */
  42443. getMeshByName(name: string): Nullable<AbstractMesh>;
  42444. /**
  42445. * Gets a transform node using a given name
  42446. * @param name defines the name to search for
  42447. * @return the found transform node or null if not found at all.
  42448. */
  42449. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42450. /**
  42451. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42452. * @param id defines the id to search for
  42453. * @return the found skeleton or null if not found at all.
  42454. */
  42455. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42456. /**
  42457. * Gets a skeleton using a given auto generated unique id
  42458. * @param uniqueId defines the unique id to search for
  42459. * @return the found skeleton or null if not found at all.
  42460. */
  42461. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42462. /**
  42463. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42464. * @param id defines the id to search for
  42465. * @return the found skeleton or null if not found at all.
  42466. */
  42467. getSkeletonById(id: string): Nullable<Skeleton>;
  42468. /**
  42469. * Gets a skeleton using a given name
  42470. * @param name defines the name to search for
  42471. * @return the found skeleton or null if not found at all.
  42472. */
  42473. getSkeletonByName(name: string): Nullable<Skeleton>;
  42474. /**
  42475. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42476. * @param id defines the id to search for
  42477. * @return the found morph target manager or null if not found at all.
  42478. */
  42479. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42480. /**
  42481. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42482. * @param id defines the id to search for
  42483. * @return the found morph target or null if not found at all.
  42484. */
  42485. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42486. /**
  42487. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42488. * @param name defines the name to search for
  42489. * @return the found morph target or null if not found at all.
  42490. */
  42491. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42492. /**
  42493. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42494. * @param name defines the name to search for
  42495. * @return the found post process or null if not found at all.
  42496. */
  42497. getPostProcessByName(name: string): Nullable<PostProcess>;
  42498. /**
  42499. * Gets a boolean indicating if the given mesh is active
  42500. * @param mesh defines the mesh to look for
  42501. * @returns true if the mesh is in the active list
  42502. */
  42503. isActiveMesh(mesh: AbstractMesh): boolean;
  42504. /**
  42505. * Return a unique id as a string which can serve as an identifier for the scene
  42506. */
  42507. get uid(): string;
  42508. /**
  42509. * Add an externaly attached data from its key.
  42510. * This method call will fail and return false, if such key already exists.
  42511. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42512. * @param key the unique key that identifies the data
  42513. * @param data the data object to associate to the key for this Engine instance
  42514. * @return true if no such key were already present and the data was added successfully, false otherwise
  42515. */
  42516. addExternalData<T>(key: string, data: T): boolean;
  42517. /**
  42518. * Get an externaly attached data from its key
  42519. * @param key the unique key that identifies the data
  42520. * @return the associated data, if present (can be null), or undefined if not present
  42521. */
  42522. getExternalData<T>(key: string): Nullable<T>;
  42523. /**
  42524. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42525. * @param key the unique key that identifies the data
  42526. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42527. * @return the associated data, can be null if the factory returned null.
  42528. */
  42529. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42530. /**
  42531. * Remove an externaly attached data from the Engine instance
  42532. * @param key the unique key that identifies the data
  42533. * @return true if the data was successfully removed, false if it doesn't exist
  42534. */
  42535. removeExternalData(key: string): boolean;
  42536. private _evaluateSubMesh;
  42537. /**
  42538. * Clear the processed materials smart array preventing retention point in material dispose.
  42539. */
  42540. freeProcessedMaterials(): void;
  42541. private _preventFreeActiveMeshesAndRenderingGroups;
  42542. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42543. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42544. * when disposing several meshes in a row or a hierarchy of meshes.
  42545. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42546. */
  42547. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42548. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42549. /**
  42550. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42551. */
  42552. freeActiveMeshes(): void;
  42553. /**
  42554. * Clear the info related to rendering groups preventing retention points during dispose.
  42555. */
  42556. freeRenderingGroups(): void;
  42557. /** @hidden */
  42558. _isInIntermediateRendering(): boolean;
  42559. /**
  42560. * Lambda returning the list of potentially active meshes.
  42561. */
  42562. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42563. /**
  42564. * Lambda returning the list of potentially active sub meshes.
  42565. */
  42566. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42567. /**
  42568. * Lambda returning the list of potentially intersecting sub meshes.
  42569. */
  42570. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42571. /**
  42572. * Lambda returning the list of potentially colliding sub meshes.
  42573. */
  42574. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42575. private _activeMeshesFrozen;
  42576. private _skipEvaluateActiveMeshesCompletely;
  42577. /**
  42578. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42579. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42580. * @param onSuccess optional success callback
  42581. * @param onError optional error callback
  42582. * @returns the current scene
  42583. */
  42584. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  42585. /**
  42586. * Use this function to restart evaluating active meshes on every frame
  42587. * @returns the current scene
  42588. */
  42589. unfreezeActiveMeshes(): Scene;
  42590. private _evaluateActiveMeshes;
  42591. private _activeMesh;
  42592. /**
  42593. * Update the transform matrix to update from the current active camera
  42594. * @param force defines a boolean used to force the update even if cache is up to date
  42595. */
  42596. updateTransformMatrix(force?: boolean): void;
  42597. private _bindFrameBuffer;
  42598. /** @hidden */
  42599. _allowPostProcessClearColor: boolean;
  42600. /** @hidden */
  42601. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42602. private _processSubCameras;
  42603. private _checkIntersections;
  42604. /** @hidden */
  42605. _advancePhysicsEngineStep(step: number): void;
  42606. /**
  42607. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42608. */
  42609. getDeterministicFrameTime: () => number;
  42610. /** @hidden */
  42611. _animate(): void;
  42612. /** Execute all animations (for a frame) */
  42613. animate(): void;
  42614. /**
  42615. * Render the scene
  42616. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42617. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42618. */
  42619. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42620. /**
  42621. * Freeze all materials
  42622. * A frozen material will not be updatable but should be faster to render
  42623. */
  42624. freezeMaterials(): void;
  42625. /**
  42626. * Unfreeze all materials
  42627. * A frozen material will not be updatable but should be faster to render
  42628. */
  42629. unfreezeMaterials(): void;
  42630. /**
  42631. * Releases all held ressources
  42632. */
  42633. dispose(): void;
  42634. /**
  42635. * Gets if the scene is already disposed
  42636. */
  42637. get isDisposed(): boolean;
  42638. /**
  42639. * Call this function to reduce memory footprint of the scene.
  42640. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42641. */
  42642. clearCachedVertexData(): void;
  42643. /**
  42644. * This function will remove the local cached buffer data from texture.
  42645. * It will save memory but will prevent the texture from being rebuilt
  42646. */
  42647. cleanCachedTextureBuffer(): void;
  42648. /**
  42649. * Get the world extend vectors with an optional filter
  42650. *
  42651. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42652. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42653. */
  42654. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42655. min: Vector3;
  42656. max: Vector3;
  42657. };
  42658. /**
  42659. * Creates a ray that can be used to pick in the scene
  42660. * @param x defines the x coordinate of the origin (on-screen)
  42661. * @param y defines the y coordinate of the origin (on-screen)
  42662. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42663. * @param camera defines the camera to use for the picking
  42664. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42665. * @returns a Ray
  42666. */
  42667. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42668. /**
  42669. * Creates a ray that can be used to pick in the scene
  42670. * @param x defines the x coordinate of the origin (on-screen)
  42671. * @param y defines the y coordinate of the origin (on-screen)
  42672. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42673. * @param result defines the ray where to store the picking ray
  42674. * @param camera defines the camera to use for the picking
  42675. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42676. * @returns the current scene
  42677. */
  42678. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42679. /**
  42680. * Creates a ray that can be used to pick in the scene
  42681. * @param x defines the x coordinate of the origin (on-screen)
  42682. * @param y defines the y coordinate of the origin (on-screen)
  42683. * @param camera defines the camera to use for the picking
  42684. * @returns a Ray
  42685. */
  42686. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42687. /**
  42688. * Creates a ray that can be used to pick in the scene
  42689. * @param x defines the x coordinate of the origin (on-screen)
  42690. * @param y defines the y coordinate of the origin (on-screen)
  42691. * @param result defines the ray where to store the picking ray
  42692. * @param camera defines the camera to use for the picking
  42693. * @returns the current scene
  42694. */
  42695. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42696. /** Launch a ray to try to pick a mesh in the scene
  42697. * @param x position on screen
  42698. * @param y position on screen
  42699. * @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
  42700. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42701. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42702. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42703. * @returns a PickingInfo
  42704. */
  42705. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42706. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42707. * @param x position on screen
  42708. * @param y position on screen
  42709. * @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
  42710. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42711. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42712. * @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)
  42713. */
  42714. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42715. /** Use the given ray to pick a mesh in the scene
  42716. * @param ray The ray to use to pick meshes
  42717. * @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
  42718. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42719. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42720. * @returns a PickingInfo
  42721. */
  42722. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42723. /**
  42724. * Launch a ray to try to pick a mesh in the scene
  42725. * @param x X position on screen
  42726. * @param y Y position on screen
  42727. * @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
  42728. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42729. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42730. * @returns an array of PickingInfo
  42731. */
  42732. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42733. /**
  42734. * Launch a ray to try to pick a mesh in the scene
  42735. * @param ray Ray to use
  42736. * @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
  42737. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42738. * @returns an array of PickingInfo
  42739. */
  42740. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42741. /**
  42742. * Force the value of meshUnderPointer
  42743. * @param mesh defines the mesh to use
  42744. * @param pointerId optional pointer id when using more than one pointer
  42745. */
  42746. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42747. /**
  42748. * Gets the mesh under the pointer
  42749. * @returns a Mesh or null if no mesh is under the pointer
  42750. */
  42751. getPointerOverMesh(): Nullable<AbstractMesh>;
  42752. /** @hidden */
  42753. _rebuildGeometries(): void;
  42754. /** @hidden */
  42755. _rebuildTextures(): void;
  42756. private _getByTags;
  42757. /**
  42758. * Get a list of meshes by tags
  42759. * @param tagsQuery defines the tags query to use
  42760. * @param forEach defines a predicate used to filter results
  42761. * @returns an array of Mesh
  42762. */
  42763. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42764. /**
  42765. * Get a list of cameras by tags
  42766. * @param tagsQuery defines the tags query to use
  42767. * @param forEach defines a predicate used to filter results
  42768. * @returns an array of Camera
  42769. */
  42770. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42771. /**
  42772. * Get a list of lights by tags
  42773. * @param tagsQuery defines the tags query to use
  42774. * @param forEach defines a predicate used to filter results
  42775. * @returns an array of Light
  42776. */
  42777. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42778. /**
  42779. * Get a list of materials by tags
  42780. * @param tagsQuery defines the tags query to use
  42781. * @param forEach defines a predicate used to filter results
  42782. * @returns an array of Material
  42783. */
  42784. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42785. /**
  42786. * Get a list of transform nodes by tags
  42787. * @param tagsQuery defines the tags query to use
  42788. * @param forEach defines a predicate used to filter results
  42789. * @returns an array of TransformNode
  42790. */
  42791. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42792. /**
  42793. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42794. * This allowed control for front to back rendering or reversly depending of the special needs.
  42795. *
  42796. * @param renderingGroupId The rendering group id corresponding to its index
  42797. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42798. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42799. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42800. */
  42801. 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;
  42802. /**
  42803. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42804. *
  42805. * @param renderingGroupId The rendering group id corresponding to its index
  42806. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42807. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42808. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42809. */
  42810. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42811. /**
  42812. * Gets the current auto clear configuration for one rendering group of the rendering
  42813. * manager.
  42814. * @param index the rendering group index to get the information for
  42815. * @returns The auto clear setup for the requested rendering group
  42816. */
  42817. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42818. private _blockMaterialDirtyMechanism;
  42819. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42820. get blockMaterialDirtyMechanism(): boolean;
  42821. set blockMaterialDirtyMechanism(value: boolean);
  42822. /**
  42823. * Will flag all materials as dirty to trigger new shader compilation
  42824. * @param flag defines the flag used to specify which material part must be marked as dirty
  42825. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42826. */
  42827. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42828. /** @hidden */
  42829. _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;
  42830. /** @hidden */
  42831. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42832. /** @hidden */
  42833. _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;
  42834. /** @hidden */
  42835. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42836. /** @hidden */
  42837. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42838. /** @hidden */
  42839. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42840. }
  42841. }
  42842. declare module "babylonjs/assetContainer" {
  42843. import { AbstractScene } from "babylonjs/abstractScene";
  42844. import { Scene } from "babylonjs/scene";
  42845. import { Mesh } from "babylonjs/Meshes/mesh";
  42846. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42847. import { Skeleton } from "babylonjs/Bones/skeleton";
  42848. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42849. import { Animatable } from "babylonjs/Animations/animatable";
  42850. import { Nullable } from "babylonjs/types";
  42851. import { Node } from "babylonjs/node";
  42852. /**
  42853. * Set of assets to keep when moving a scene into an asset container.
  42854. */
  42855. export class KeepAssets extends AbstractScene {
  42856. }
  42857. /**
  42858. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42859. */
  42860. export class InstantiatedEntries {
  42861. /**
  42862. * List of new root nodes (eg. nodes with no parent)
  42863. */
  42864. rootNodes: TransformNode[];
  42865. /**
  42866. * List of new skeletons
  42867. */
  42868. skeletons: Skeleton[];
  42869. /**
  42870. * List of new animation groups
  42871. */
  42872. animationGroups: AnimationGroup[];
  42873. }
  42874. /**
  42875. * Container with a set of assets that can be added or removed from a scene.
  42876. */
  42877. export class AssetContainer extends AbstractScene {
  42878. private _wasAddedToScene;
  42879. /**
  42880. * The scene the AssetContainer belongs to.
  42881. */
  42882. scene: Scene;
  42883. /**
  42884. * Instantiates an AssetContainer.
  42885. * @param scene The scene the AssetContainer belongs to.
  42886. */
  42887. constructor(scene: Scene);
  42888. /**
  42889. * Instantiate or clone all meshes and add the new ones to the scene.
  42890. * Skeletons and animation groups will all be cloned
  42891. * @param nameFunction defines an optional function used to get new names for clones
  42892. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42893. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42894. */
  42895. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42896. /**
  42897. * Adds all the assets from the container to the scene.
  42898. */
  42899. addAllToScene(): void;
  42900. /**
  42901. * Removes all the assets in the container from the scene
  42902. */
  42903. removeAllFromScene(): void;
  42904. /**
  42905. * Disposes all the assets in the container
  42906. */
  42907. dispose(): void;
  42908. private _moveAssets;
  42909. /**
  42910. * Removes all the assets contained in the scene and adds them to the container.
  42911. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42912. */
  42913. moveAllFromScene(keepAssets?: KeepAssets): void;
  42914. /**
  42915. * 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.
  42916. * @returns the root mesh
  42917. */
  42918. createRootMesh(): Mesh;
  42919. /**
  42920. * Merge animations (direct and animation groups) from this asset container into a scene
  42921. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42922. * @param animatables set of animatables to retarget to a node from the scene
  42923. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42924. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42925. */
  42926. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42927. }
  42928. }
  42929. declare module "babylonjs/abstractScene" {
  42930. import { Scene } from "babylonjs/scene";
  42931. import { Nullable } from "babylonjs/types";
  42932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42933. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42934. import { Geometry } from "babylonjs/Meshes/geometry";
  42935. import { Skeleton } from "babylonjs/Bones/skeleton";
  42936. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42937. import { AssetContainer } from "babylonjs/assetContainer";
  42938. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42939. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42940. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42941. import { Material } from "babylonjs/Materials/material";
  42942. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42943. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42944. import { Camera } from "babylonjs/Cameras/camera";
  42945. import { Light } from "babylonjs/Lights/light";
  42946. import { Node } from "babylonjs/node";
  42947. import { Animation } from "babylonjs/Animations/animation";
  42948. /**
  42949. * Defines how the parser contract is defined.
  42950. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42951. */
  42952. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42953. /**
  42954. * Defines how the individual parser contract is defined.
  42955. * These parser can parse an individual asset
  42956. */
  42957. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42958. /**
  42959. * Base class of the scene acting as a container for the different elements composing a scene.
  42960. * This class is dynamically extended by the different components of the scene increasing
  42961. * flexibility and reducing coupling
  42962. */
  42963. export abstract class AbstractScene {
  42964. /**
  42965. * Stores the list of available parsers in the application.
  42966. */
  42967. private static _BabylonFileParsers;
  42968. /**
  42969. * Stores the list of available individual parsers in the application.
  42970. */
  42971. private static _IndividualBabylonFileParsers;
  42972. /**
  42973. * Adds a parser in the list of available ones
  42974. * @param name Defines the name of the parser
  42975. * @param parser Defines the parser to add
  42976. */
  42977. static AddParser(name: string, parser: BabylonFileParser): void;
  42978. /**
  42979. * Gets a general parser from the list of avaialble ones
  42980. * @param name Defines the name of the parser
  42981. * @returns the requested parser or null
  42982. */
  42983. static GetParser(name: string): Nullable<BabylonFileParser>;
  42984. /**
  42985. * Adds n individual parser in the list of available ones
  42986. * @param name Defines the name of the parser
  42987. * @param parser Defines the parser to add
  42988. */
  42989. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42990. /**
  42991. * Gets an individual parser from the list of avaialble ones
  42992. * @param name Defines the name of the parser
  42993. * @returns the requested parser or null
  42994. */
  42995. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42996. /**
  42997. * Parser json data and populate both a scene and its associated container object
  42998. * @param jsonData Defines the data to parse
  42999. * @param scene Defines the scene to parse the data for
  43000. * @param container Defines the container attached to the parsing sequence
  43001. * @param rootUrl Defines the root url of the data
  43002. */
  43003. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  43004. /**
  43005. * Gets the list of root nodes (ie. nodes with no parent)
  43006. */
  43007. rootNodes: Node[];
  43008. /** All of the cameras added to this scene
  43009. * @see https://doc.babylonjs.com/babylon101/cameras
  43010. */
  43011. cameras: Camera[];
  43012. /**
  43013. * All of the lights added to this scene
  43014. * @see https://doc.babylonjs.com/babylon101/lights
  43015. */
  43016. lights: Light[];
  43017. /**
  43018. * All of the (abstract) meshes added to this scene
  43019. */
  43020. meshes: AbstractMesh[];
  43021. /**
  43022. * The list of skeletons added to the scene
  43023. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  43024. */
  43025. skeletons: Skeleton[];
  43026. /**
  43027. * All of the particle systems added to this scene
  43028. * @see https://doc.babylonjs.com/babylon101/particles
  43029. */
  43030. particleSystems: IParticleSystem[];
  43031. /**
  43032. * Gets a list of Animations associated with the scene
  43033. */
  43034. animations: Animation[];
  43035. /**
  43036. * All of the animation groups added to this scene
  43037. * @see https://doc.babylonjs.com/how_to/group
  43038. */
  43039. animationGroups: AnimationGroup[];
  43040. /**
  43041. * All of the multi-materials added to this scene
  43042. * @see https://doc.babylonjs.com/how_to/multi_materials
  43043. */
  43044. multiMaterials: MultiMaterial[];
  43045. /**
  43046. * All of the materials added to this scene
  43047. * In the context of a Scene, it is not supposed to be modified manually.
  43048. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  43049. * Note also that the order of the Material within the array is not significant and might change.
  43050. * @see https://doc.babylonjs.com/babylon101/materials
  43051. */
  43052. materials: Material[];
  43053. /**
  43054. * The list of morph target managers added to the scene
  43055. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  43056. */
  43057. morphTargetManagers: MorphTargetManager[];
  43058. /**
  43059. * The list of geometries used in the scene.
  43060. */
  43061. geometries: Geometry[];
  43062. /**
  43063. * All of the tranform nodes added to this scene
  43064. * In the context of a Scene, it is not supposed to be modified manually.
  43065. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  43066. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  43067. * @see https://doc.babylonjs.com/how_to/transformnode
  43068. */
  43069. transformNodes: TransformNode[];
  43070. /**
  43071. * ActionManagers available on the scene.
  43072. */
  43073. actionManagers: AbstractActionManager[];
  43074. /**
  43075. * Textures to keep.
  43076. */
  43077. textures: BaseTexture[];
  43078. /** @hidden */
  43079. protected _environmentTexture: Nullable<BaseTexture>;
  43080. /**
  43081. * Texture used in all pbr material as the reflection texture.
  43082. * As in the majority of the scene they are the same (exception for multi room and so on),
  43083. * this is easier to reference from here than from all the materials.
  43084. */
  43085. get environmentTexture(): Nullable<BaseTexture>;
  43086. set environmentTexture(value: Nullable<BaseTexture>);
  43087. /**
  43088. * The list of postprocesses added to the scene
  43089. */
  43090. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  43091. /**
  43092. * @returns all meshes, lights, cameras, transformNodes and bones
  43093. */
  43094. getNodes(): Array<Node>;
  43095. }
  43096. }
  43097. declare module "babylonjs/Audio/sound" {
  43098. import { Observable } from "babylonjs/Misc/observable";
  43099. import { Vector3 } from "babylonjs/Maths/math.vector";
  43100. import { Nullable } from "babylonjs/types";
  43101. import { Scene } from "babylonjs/scene";
  43102. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43103. /**
  43104. * Interface used to define options for Sound class
  43105. */
  43106. export interface ISoundOptions {
  43107. /**
  43108. * Does the sound autoplay once loaded.
  43109. */
  43110. autoplay?: boolean;
  43111. /**
  43112. * Does the sound loop after it finishes playing once.
  43113. */
  43114. loop?: boolean;
  43115. /**
  43116. * Sound's volume
  43117. */
  43118. volume?: number;
  43119. /**
  43120. * Is it a spatial sound?
  43121. */
  43122. spatialSound?: boolean;
  43123. /**
  43124. * Maximum distance to hear that sound
  43125. */
  43126. maxDistance?: number;
  43127. /**
  43128. * Uses user defined attenuation function
  43129. */
  43130. useCustomAttenuation?: boolean;
  43131. /**
  43132. * Define the roll off factor of spatial sounds.
  43133. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43134. */
  43135. rolloffFactor?: number;
  43136. /**
  43137. * Define the reference distance the sound should be heard perfectly.
  43138. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43139. */
  43140. refDistance?: number;
  43141. /**
  43142. * Define the distance attenuation model the sound will follow.
  43143. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43144. */
  43145. distanceModel?: string;
  43146. /**
  43147. * Defines the playback speed (1 by default)
  43148. */
  43149. playbackRate?: number;
  43150. /**
  43151. * Defines if the sound is from a streaming source
  43152. */
  43153. streaming?: boolean;
  43154. /**
  43155. * Defines an optional length (in seconds) inside the sound file
  43156. */
  43157. length?: number;
  43158. /**
  43159. * Defines an optional offset (in seconds) inside the sound file
  43160. */
  43161. offset?: number;
  43162. /**
  43163. * If true, URLs will not be required to state the audio file codec to use.
  43164. */
  43165. skipCodecCheck?: boolean;
  43166. }
  43167. /**
  43168. * Defines a sound that can be played in the application.
  43169. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  43170. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43171. */
  43172. export class Sound {
  43173. /**
  43174. * The name of the sound in the scene.
  43175. */
  43176. name: string;
  43177. /**
  43178. * Does the sound autoplay once loaded.
  43179. */
  43180. autoplay: boolean;
  43181. /**
  43182. * Does the sound loop after it finishes playing once.
  43183. */
  43184. loop: boolean;
  43185. /**
  43186. * Does the sound use a custom attenuation curve to simulate the falloff
  43187. * happening when the source gets further away from the camera.
  43188. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43189. */
  43190. useCustomAttenuation: boolean;
  43191. /**
  43192. * The sound track id this sound belongs to.
  43193. */
  43194. soundTrackId: number;
  43195. /**
  43196. * Is this sound currently played.
  43197. */
  43198. isPlaying: boolean;
  43199. /**
  43200. * Is this sound currently paused.
  43201. */
  43202. isPaused: boolean;
  43203. /**
  43204. * Does this sound enables spatial sound.
  43205. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43206. */
  43207. spatialSound: boolean;
  43208. /**
  43209. * Define the reference distance the sound should be heard perfectly.
  43210. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43211. */
  43212. refDistance: number;
  43213. /**
  43214. * Define the roll off factor of spatial sounds.
  43215. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43216. */
  43217. rolloffFactor: number;
  43218. /**
  43219. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  43220. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43221. */
  43222. maxDistance: number;
  43223. /**
  43224. * Define the distance attenuation model the sound will follow.
  43225. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43226. */
  43227. distanceModel: string;
  43228. /**
  43229. * @hidden
  43230. * Back Compat
  43231. **/
  43232. onended: () => any;
  43233. /**
  43234. * Gets or sets an object used to store user defined information for the sound.
  43235. */
  43236. metadata: any;
  43237. /**
  43238. * Observable event when the current playing sound finishes.
  43239. */
  43240. onEndedObservable: Observable<Sound>;
  43241. private _panningModel;
  43242. private _playbackRate;
  43243. private _streaming;
  43244. private _startTime;
  43245. private _startOffset;
  43246. private _position;
  43247. /** @hidden */
  43248. _positionInEmitterSpace: boolean;
  43249. private _localDirection;
  43250. private _volume;
  43251. private _isReadyToPlay;
  43252. private _isDirectional;
  43253. private _readyToPlayCallback;
  43254. private _audioBuffer;
  43255. private _soundSource;
  43256. private _streamingSource;
  43257. private _soundPanner;
  43258. private _soundGain;
  43259. private _inputAudioNode;
  43260. private _outputAudioNode;
  43261. private _coneInnerAngle;
  43262. private _coneOuterAngle;
  43263. private _coneOuterGain;
  43264. private _scene;
  43265. private _connectedTransformNode;
  43266. private _customAttenuationFunction;
  43267. private _registerFunc;
  43268. private _isOutputConnected;
  43269. private _htmlAudioElement;
  43270. private _urlType;
  43271. private _length?;
  43272. private _offset?;
  43273. /** @hidden */
  43274. static _SceneComponentInitialization: (scene: Scene) => void;
  43275. /**
  43276. * Create a sound and attach it to a scene
  43277. * @param name Name of your sound
  43278. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43279. * @param scene defines the scene the sound belongs to
  43280. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43281. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43282. */
  43283. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43284. /**
  43285. * Release the sound and its associated resources
  43286. */
  43287. dispose(): void;
  43288. /**
  43289. * Gets if the sounds is ready to be played or not.
  43290. * @returns true if ready, otherwise false
  43291. */
  43292. isReady(): boolean;
  43293. private _soundLoaded;
  43294. /**
  43295. * Sets the data of the sound from an audiobuffer
  43296. * @param audioBuffer The audioBuffer containing the data
  43297. */
  43298. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43299. /**
  43300. * Updates the current sounds options such as maxdistance, loop...
  43301. * @param options A JSON object containing values named as the object properties
  43302. */
  43303. updateOptions(options: ISoundOptions): void;
  43304. private _createSpatialParameters;
  43305. private _updateSpatialParameters;
  43306. /**
  43307. * Switch the panning model to HRTF:
  43308. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43309. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43310. */
  43311. switchPanningModelToHRTF(): void;
  43312. /**
  43313. * Switch the panning model to Equal Power:
  43314. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43315. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43316. */
  43317. switchPanningModelToEqualPower(): void;
  43318. private _switchPanningModel;
  43319. /**
  43320. * Connect this sound to a sound track audio node like gain...
  43321. * @param soundTrackAudioNode the sound track audio node to connect to
  43322. */
  43323. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43324. /**
  43325. * Transform this sound into a directional source
  43326. * @param coneInnerAngle Size of the inner cone in degree
  43327. * @param coneOuterAngle Size of the outer cone in degree
  43328. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43329. */
  43330. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43331. /**
  43332. * Gets or sets the inner angle for the directional cone.
  43333. */
  43334. get directionalConeInnerAngle(): number;
  43335. /**
  43336. * Gets or sets the inner angle for the directional cone.
  43337. */
  43338. set directionalConeInnerAngle(value: number);
  43339. /**
  43340. * Gets or sets the outer angle for the directional cone.
  43341. */
  43342. get directionalConeOuterAngle(): number;
  43343. /**
  43344. * Gets or sets the outer angle for the directional cone.
  43345. */
  43346. set directionalConeOuterAngle(value: number);
  43347. /**
  43348. * Sets the position of the emitter if spatial sound is enabled
  43349. * @param newPosition Defines the new posisiton
  43350. */
  43351. setPosition(newPosition: Vector3): void;
  43352. /**
  43353. * Sets the local direction of the emitter if spatial sound is enabled
  43354. * @param newLocalDirection Defines the new local direction
  43355. */
  43356. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43357. private _updateDirection;
  43358. /** @hidden */
  43359. updateDistanceFromListener(): void;
  43360. /**
  43361. * Sets a new custom attenuation function for the sound.
  43362. * @param callback Defines the function used for the attenuation
  43363. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43364. */
  43365. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43366. /**
  43367. * Play the sound
  43368. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43369. * @param offset (optional) Start the sound at a specific time in seconds
  43370. * @param length (optional) Sound duration (in seconds)
  43371. */
  43372. play(time?: number, offset?: number, length?: number): void;
  43373. private _onended;
  43374. /**
  43375. * Stop the sound
  43376. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43377. */
  43378. stop(time?: number): void;
  43379. /**
  43380. * Put the sound in pause
  43381. */
  43382. pause(): void;
  43383. /**
  43384. * Sets a dedicated volume for this sounds
  43385. * @param newVolume Define the new volume of the sound
  43386. * @param time Define time for gradual change to new volume
  43387. */
  43388. setVolume(newVolume: number, time?: number): void;
  43389. /**
  43390. * Set the sound play back rate
  43391. * @param newPlaybackRate Define the playback rate the sound should be played at
  43392. */
  43393. setPlaybackRate(newPlaybackRate: number): void;
  43394. /**
  43395. * Gets the volume of the sound.
  43396. * @returns the volume of the sound
  43397. */
  43398. getVolume(): number;
  43399. /**
  43400. * Attach the sound to a dedicated mesh
  43401. * @param transformNode The transform node to connect the sound with
  43402. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43403. */
  43404. attachToMesh(transformNode: TransformNode): void;
  43405. /**
  43406. * Detach the sound from the previously attached mesh
  43407. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43408. */
  43409. detachFromMesh(): void;
  43410. private _onRegisterAfterWorldMatrixUpdate;
  43411. /**
  43412. * Clone the current sound in the scene.
  43413. * @returns the new sound clone
  43414. */
  43415. clone(): Nullable<Sound>;
  43416. /**
  43417. * Gets the current underlying audio buffer containing the data
  43418. * @returns the audio buffer
  43419. */
  43420. getAudioBuffer(): Nullable<AudioBuffer>;
  43421. /**
  43422. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43423. * @returns the source node
  43424. */
  43425. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43426. /**
  43427. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43428. * @returns the gain node
  43429. */
  43430. getSoundGain(): Nullable<GainNode>;
  43431. /**
  43432. * Serializes the Sound in a JSON representation
  43433. * @returns the JSON representation of the sound
  43434. */
  43435. serialize(): any;
  43436. /**
  43437. * Parse a JSON representation of a sound to innstantiate in a given scene
  43438. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43439. * @param scene Define the scene the new parsed sound should be created in
  43440. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43441. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43442. * @returns the newly parsed sound
  43443. */
  43444. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43445. }
  43446. }
  43447. declare module "babylonjs/Actions/directAudioActions" {
  43448. import { Action } from "babylonjs/Actions/action";
  43449. import { Condition } from "babylonjs/Actions/condition";
  43450. import { Sound } from "babylonjs/Audio/sound";
  43451. /**
  43452. * This defines an action helpful to play a defined sound on a triggered action.
  43453. */
  43454. export class PlaySoundAction extends Action {
  43455. private _sound;
  43456. /**
  43457. * Instantiate the action
  43458. * @param triggerOptions defines the trigger options
  43459. * @param sound defines the sound to play
  43460. * @param condition defines the trigger related conditions
  43461. */
  43462. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43463. /** @hidden */
  43464. _prepare(): void;
  43465. /**
  43466. * Execute the action and play the sound.
  43467. */
  43468. execute(): void;
  43469. /**
  43470. * Serializes the actions and its related information.
  43471. * @param parent defines the object to serialize in
  43472. * @returns the serialized object
  43473. */
  43474. serialize(parent: any): any;
  43475. }
  43476. /**
  43477. * This defines an action helpful to stop a defined sound on a triggered action.
  43478. */
  43479. export class StopSoundAction extends Action {
  43480. private _sound;
  43481. /**
  43482. * Instantiate the action
  43483. * @param triggerOptions defines the trigger options
  43484. * @param sound defines the sound to stop
  43485. * @param condition defines the trigger related conditions
  43486. */
  43487. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43488. /** @hidden */
  43489. _prepare(): void;
  43490. /**
  43491. * Execute the action and stop the sound.
  43492. */
  43493. execute(): void;
  43494. /**
  43495. * Serializes the actions and its related information.
  43496. * @param parent defines the object to serialize in
  43497. * @returns the serialized object
  43498. */
  43499. serialize(parent: any): any;
  43500. }
  43501. }
  43502. declare module "babylonjs/Actions/interpolateValueAction" {
  43503. import { Action } from "babylonjs/Actions/action";
  43504. import { Condition } from "babylonjs/Actions/condition";
  43505. import { Observable } from "babylonjs/Misc/observable";
  43506. /**
  43507. * This defines an action responsible to change the value of a property
  43508. * by interpolating between its current value and the newly set one once triggered.
  43509. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43510. */
  43511. export class InterpolateValueAction extends Action {
  43512. /**
  43513. * Defines the path of the property where the value should be interpolated
  43514. */
  43515. propertyPath: string;
  43516. /**
  43517. * Defines the target value at the end of the interpolation.
  43518. */
  43519. value: any;
  43520. /**
  43521. * Defines the time it will take for the property to interpolate to the value.
  43522. */
  43523. duration: number;
  43524. /**
  43525. * Defines if the other scene animations should be stopped when the action has been triggered
  43526. */
  43527. stopOtherAnimations?: boolean;
  43528. /**
  43529. * Defines a callback raised once the interpolation animation has been done.
  43530. */
  43531. onInterpolationDone?: () => void;
  43532. /**
  43533. * Observable triggered once the interpolation animation has been done.
  43534. */
  43535. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43536. private _target;
  43537. private _effectiveTarget;
  43538. private _property;
  43539. /**
  43540. * Instantiate the action
  43541. * @param triggerOptions defines the trigger options
  43542. * @param target defines the object containing the value to interpolate
  43543. * @param propertyPath defines the path to the property in the target object
  43544. * @param value defines the target value at the end of the interpolation
  43545. * @param duration deines the time it will take for the property to interpolate to the value.
  43546. * @param condition defines the trigger related conditions
  43547. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43548. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43549. */
  43550. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43551. /** @hidden */
  43552. _prepare(): void;
  43553. /**
  43554. * Execute the action starts the value interpolation.
  43555. */
  43556. execute(): void;
  43557. /**
  43558. * Serializes the actions and its related information.
  43559. * @param parent defines the object to serialize in
  43560. * @returns the serialized object
  43561. */
  43562. serialize(parent: any): any;
  43563. }
  43564. }
  43565. declare module "babylonjs/Actions/index" {
  43566. export * from "babylonjs/Actions/abstractActionManager";
  43567. export * from "babylonjs/Actions/action";
  43568. export * from "babylonjs/Actions/actionEvent";
  43569. export * from "babylonjs/Actions/actionManager";
  43570. export * from "babylonjs/Actions/condition";
  43571. export * from "babylonjs/Actions/directActions";
  43572. export * from "babylonjs/Actions/directAudioActions";
  43573. export * from "babylonjs/Actions/interpolateValueAction";
  43574. }
  43575. declare module "babylonjs/Animations/index" {
  43576. export * from "babylonjs/Animations/animatable";
  43577. export * from "babylonjs/Animations/animation";
  43578. export * from "babylonjs/Animations/animationGroup";
  43579. export * from "babylonjs/Animations/animationPropertiesOverride";
  43580. export * from "babylonjs/Animations/easing";
  43581. export * from "babylonjs/Animations/runtimeAnimation";
  43582. export * from "babylonjs/Animations/animationEvent";
  43583. export * from "babylonjs/Animations/animationGroup";
  43584. export * from "babylonjs/Animations/animationKey";
  43585. export * from "babylonjs/Animations/animationRange";
  43586. export * from "babylonjs/Animations/animatable.interface";
  43587. }
  43588. declare module "babylonjs/Audio/soundTrack" {
  43589. import { Sound } from "babylonjs/Audio/sound";
  43590. import { Analyser } from "babylonjs/Audio/analyser";
  43591. import { Scene } from "babylonjs/scene";
  43592. /**
  43593. * Options allowed during the creation of a sound track.
  43594. */
  43595. export interface ISoundTrackOptions {
  43596. /**
  43597. * The volume the sound track should take during creation
  43598. */
  43599. volume?: number;
  43600. /**
  43601. * Define if the sound track is the main sound track of the scene
  43602. */
  43603. mainTrack?: boolean;
  43604. }
  43605. /**
  43606. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43607. * It will be also used in a future release to apply effects on a specific track.
  43608. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43609. */
  43610. export class SoundTrack {
  43611. /**
  43612. * The unique identifier of the sound track in the scene.
  43613. */
  43614. id: number;
  43615. /**
  43616. * The list of sounds included in the sound track.
  43617. */
  43618. soundCollection: Array<Sound>;
  43619. private _outputAudioNode;
  43620. private _scene;
  43621. private _connectedAnalyser;
  43622. private _options;
  43623. private _isInitialized;
  43624. /**
  43625. * Creates a new sound track.
  43626. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43627. * @param scene Define the scene the sound track belongs to
  43628. * @param options
  43629. */
  43630. constructor(scene: Scene, options?: ISoundTrackOptions);
  43631. private _initializeSoundTrackAudioGraph;
  43632. /**
  43633. * Release the sound track and its associated resources
  43634. */
  43635. dispose(): void;
  43636. /**
  43637. * Adds a sound to this sound track
  43638. * @param sound define the cound to add
  43639. * @ignoreNaming
  43640. */
  43641. AddSound(sound: Sound): void;
  43642. /**
  43643. * Removes a sound to this sound track
  43644. * @param sound define the cound to remove
  43645. * @ignoreNaming
  43646. */
  43647. RemoveSound(sound: Sound): void;
  43648. /**
  43649. * Set a global volume for the full sound track.
  43650. * @param newVolume Define the new volume of the sound track
  43651. */
  43652. setVolume(newVolume: number): void;
  43653. /**
  43654. * Switch the panning model to HRTF:
  43655. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43656. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43657. */
  43658. switchPanningModelToHRTF(): void;
  43659. /**
  43660. * Switch the panning model to Equal Power:
  43661. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43662. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43663. */
  43664. switchPanningModelToEqualPower(): void;
  43665. /**
  43666. * Connect the sound track to an audio analyser allowing some amazing
  43667. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43668. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43669. * @param analyser The analyser to connect to the engine
  43670. */
  43671. connectToAnalyser(analyser: Analyser): void;
  43672. }
  43673. }
  43674. declare module "babylonjs/Audio/audioSceneComponent" {
  43675. import { Sound } from "babylonjs/Audio/sound";
  43676. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43677. import { Nullable } from "babylonjs/types";
  43678. import { Vector3 } from "babylonjs/Maths/math.vector";
  43679. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43680. import { Scene } from "babylonjs/scene";
  43681. import { AbstractScene } from "babylonjs/abstractScene";
  43682. import "babylonjs/Audio/audioEngine";
  43683. module "babylonjs/abstractScene" {
  43684. interface AbstractScene {
  43685. /**
  43686. * The list of sounds used in the scene.
  43687. */
  43688. sounds: Nullable<Array<Sound>>;
  43689. }
  43690. }
  43691. module "babylonjs/scene" {
  43692. interface Scene {
  43693. /**
  43694. * @hidden
  43695. * Backing field
  43696. */
  43697. _mainSoundTrack: SoundTrack;
  43698. /**
  43699. * The main sound track played by the scene.
  43700. * It cotains your primary collection of sounds.
  43701. */
  43702. mainSoundTrack: SoundTrack;
  43703. /**
  43704. * The list of sound tracks added to the scene
  43705. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43706. */
  43707. soundTracks: Nullable<Array<SoundTrack>>;
  43708. /**
  43709. * Gets a sound using a given name
  43710. * @param name defines the name to search for
  43711. * @return the found sound or null if not found at all.
  43712. */
  43713. getSoundByName(name: string): Nullable<Sound>;
  43714. /**
  43715. * Gets or sets if audio support is enabled
  43716. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43717. */
  43718. audioEnabled: boolean;
  43719. /**
  43720. * Gets or sets if audio will be output to headphones
  43721. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43722. */
  43723. headphone: boolean;
  43724. /**
  43725. * Gets or sets custom audio listener position provider
  43726. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43727. */
  43728. audioListenerPositionProvider: Nullable<() => Vector3>;
  43729. /**
  43730. * Gets or sets a refresh rate when using 3D audio positioning
  43731. */
  43732. audioPositioningRefreshRate: number;
  43733. }
  43734. }
  43735. /**
  43736. * Defines the sound scene component responsible to manage any sounds
  43737. * in a given scene.
  43738. */
  43739. export class AudioSceneComponent implements ISceneSerializableComponent {
  43740. private static _CameraDirectionLH;
  43741. private static _CameraDirectionRH;
  43742. /**
  43743. * The component name helpfull to identify the component in the list of scene components.
  43744. */
  43745. readonly name: string;
  43746. /**
  43747. * The scene the component belongs to.
  43748. */
  43749. scene: Scene;
  43750. private _audioEnabled;
  43751. /**
  43752. * Gets whether audio is enabled or not.
  43753. * Please use related enable/disable method to switch state.
  43754. */
  43755. get audioEnabled(): boolean;
  43756. private _headphone;
  43757. /**
  43758. * Gets whether audio is outputing to headphone or not.
  43759. * Please use the according Switch methods to change output.
  43760. */
  43761. get headphone(): boolean;
  43762. /**
  43763. * Gets or sets a refresh rate when using 3D audio positioning
  43764. */
  43765. audioPositioningRefreshRate: number;
  43766. private _audioListenerPositionProvider;
  43767. /**
  43768. * Gets the current audio listener position provider
  43769. */
  43770. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43771. /**
  43772. * Sets a custom listener position for all sounds in the scene
  43773. * By default, this is the position of the first active camera
  43774. */
  43775. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43776. /**
  43777. * Creates a new instance of the component for the given scene
  43778. * @param scene Defines the scene to register the component in
  43779. */
  43780. constructor(scene: Scene);
  43781. /**
  43782. * Registers the component in a given scene
  43783. */
  43784. register(): void;
  43785. /**
  43786. * Rebuilds the elements related to this component in case of
  43787. * context lost for instance.
  43788. */
  43789. rebuild(): void;
  43790. /**
  43791. * Serializes the component data to the specified json object
  43792. * @param serializationObject The object to serialize to
  43793. */
  43794. serialize(serializationObject: any): void;
  43795. /**
  43796. * Adds all the elements from the container to the scene
  43797. * @param container the container holding the elements
  43798. */
  43799. addFromContainer(container: AbstractScene): void;
  43800. /**
  43801. * Removes all the elements in the container from the scene
  43802. * @param container contains the elements to remove
  43803. * @param dispose if the removed element should be disposed (default: false)
  43804. */
  43805. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43806. /**
  43807. * Disposes the component and the associated ressources.
  43808. */
  43809. dispose(): void;
  43810. /**
  43811. * Disables audio in the associated scene.
  43812. */
  43813. disableAudio(): void;
  43814. /**
  43815. * Enables audio in the associated scene.
  43816. */
  43817. enableAudio(): void;
  43818. /**
  43819. * Switch audio to headphone output.
  43820. */
  43821. switchAudioModeForHeadphones(): void;
  43822. /**
  43823. * Switch audio to normal speakers.
  43824. */
  43825. switchAudioModeForNormalSpeakers(): void;
  43826. private _cachedCameraDirection;
  43827. private _cachedCameraPosition;
  43828. private _lastCheck;
  43829. private _afterRender;
  43830. }
  43831. }
  43832. declare module "babylonjs/Audio/weightedsound" {
  43833. import { Sound } from "babylonjs/Audio/sound";
  43834. /**
  43835. * Wraps one or more Sound objects and selects one with random weight for playback.
  43836. */
  43837. export class WeightedSound {
  43838. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43839. loop: boolean;
  43840. private _coneInnerAngle;
  43841. private _coneOuterAngle;
  43842. private _volume;
  43843. /** A Sound is currently playing. */
  43844. isPlaying: boolean;
  43845. /** A Sound is currently paused. */
  43846. isPaused: boolean;
  43847. private _sounds;
  43848. private _weights;
  43849. private _currentIndex?;
  43850. /**
  43851. * Creates a new WeightedSound from the list of sounds given.
  43852. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43853. * @param sounds Array of Sounds that will be selected from.
  43854. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43855. */
  43856. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43857. /**
  43858. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43859. */
  43860. get directionalConeInnerAngle(): number;
  43861. /**
  43862. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43863. */
  43864. set directionalConeInnerAngle(value: number);
  43865. /**
  43866. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43867. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43868. */
  43869. get directionalConeOuterAngle(): number;
  43870. /**
  43871. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43872. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43873. */
  43874. set directionalConeOuterAngle(value: number);
  43875. /**
  43876. * Playback volume.
  43877. */
  43878. get volume(): number;
  43879. /**
  43880. * Playback volume.
  43881. */
  43882. set volume(value: number);
  43883. private _onended;
  43884. /**
  43885. * Suspend playback
  43886. */
  43887. pause(): void;
  43888. /**
  43889. * Stop playback
  43890. */
  43891. stop(): void;
  43892. /**
  43893. * Start playback.
  43894. * @param startOffset Position the clip head at a specific time in seconds.
  43895. */
  43896. play(startOffset?: number): void;
  43897. }
  43898. }
  43899. declare module "babylonjs/Audio/index" {
  43900. export * from "babylonjs/Audio/analyser";
  43901. export * from "babylonjs/Audio/audioEngine";
  43902. export * from "babylonjs/Audio/audioSceneComponent";
  43903. export * from "babylonjs/Audio/sound";
  43904. export * from "babylonjs/Audio/soundTrack";
  43905. export * from "babylonjs/Audio/weightedsound";
  43906. }
  43907. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43908. import { Behavior } from "babylonjs/Behaviors/behavior";
  43909. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43910. import { BackEase } from "babylonjs/Animations/easing";
  43911. /**
  43912. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43913. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43914. */
  43915. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43916. /**
  43917. * Gets the name of the behavior.
  43918. */
  43919. get name(): string;
  43920. /**
  43921. * The easing function used by animations
  43922. */
  43923. static EasingFunction: BackEase;
  43924. /**
  43925. * The easing mode used by animations
  43926. */
  43927. static EasingMode: number;
  43928. /**
  43929. * The duration of the animation, in milliseconds
  43930. */
  43931. transitionDuration: number;
  43932. /**
  43933. * Length of the distance animated by the transition when lower radius is reached
  43934. */
  43935. lowerRadiusTransitionRange: number;
  43936. /**
  43937. * Length of the distance animated by the transition when upper radius is reached
  43938. */
  43939. upperRadiusTransitionRange: number;
  43940. private _autoTransitionRange;
  43941. /**
  43942. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43943. */
  43944. get autoTransitionRange(): boolean;
  43945. /**
  43946. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43947. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43948. */
  43949. set autoTransitionRange(value: boolean);
  43950. private _attachedCamera;
  43951. private _onAfterCheckInputsObserver;
  43952. private _onMeshTargetChangedObserver;
  43953. /**
  43954. * Initializes the behavior.
  43955. */
  43956. init(): void;
  43957. /**
  43958. * Attaches the behavior to its arc rotate camera.
  43959. * @param camera Defines the camera to attach the behavior to
  43960. */
  43961. attach(camera: ArcRotateCamera): void;
  43962. /**
  43963. * Detaches the behavior from its current arc rotate camera.
  43964. */
  43965. detach(): void;
  43966. private _radiusIsAnimating;
  43967. private _radiusBounceTransition;
  43968. private _animatables;
  43969. private _cachedWheelPrecision;
  43970. /**
  43971. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43972. * @param radiusLimit The limit to check against.
  43973. * @return Bool to indicate if at limit.
  43974. */
  43975. private _isRadiusAtLimit;
  43976. /**
  43977. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43978. * @param radiusDelta The delta by which to animate to. Can be negative.
  43979. */
  43980. private _applyBoundRadiusAnimation;
  43981. /**
  43982. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43983. */
  43984. protected _clearAnimationLocks(): void;
  43985. /**
  43986. * Stops and removes all animations that have been applied to the camera
  43987. */
  43988. stopAllAnimations(): void;
  43989. }
  43990. }
  43991. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43992. import { Behavior } from "babylonjs/Behaviors/behavior";
  43993. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43994. import { ExponentialEase } from "babylonjs/Animations/easing";
  43995. import { Nullable } from "babylonjs/types";
  43996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43997. import { Vector3 } from "babylonjs/Maths/math.vector";
  43998. /**
  43999. * 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.
  44000. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44001. */
  44002. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  44003. /**
  44004. * Gets the name of the behavior.
  44005. */
  44006. get name(): string;
  44007. private _mode;
  44008. private _radiusScale;
  44009. private _positionScale;
  44010. private _defaultElevation;
  44011. private _elevationReturnTime;
  44012. private _elevationReturnWaitTime;
  44013. private _zoomStopsAnimation;
  44014. private _framingTime;
  44015. /**
  44016. * The easing function used by animations
  44017. */
  44018. static EasingFunction: ExponentialEase;
  44019. /**
  44020. * The easing mode used by animations
  44021. */
  44022. static EasingMode: number;
  44023. /**
  44024. * Sets the current mode used by the behavior
  44025. */
  44026. set mode(mode: number);
  44027. /**
  44028. * Gets current mode used by the behavior.
  44029. */
  44030. get mode(): number;
  44031. /**
  44032. * Sets the scale applied to the radius (1 by default)
  44033. */
  44034. set radiusScale(radius: number);
  44035. /**
  44036. * Gets the scale applied to the radius
  44037. */
  44038. get radiusScale(): number;
  44039. /**
  44040. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  44041. */
  44042. set positionScale(scale: number);
  44043. /**
  44044. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  44045. */
  44046. get positionScale(): number;
  44047. /**
  44048. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  44049. * behaviour is triggered, in radians.
  44050. */
  44051. set defaultElevation(elevation: number);
  44052. /**
  44053. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  44054. * behaviour is triggered, in radians.
  44055. */
  44056. get defaultElevation(): number;
  44057. /**
  44058. * Sets the time (in milliseconds) taken to return to the default beta position.
  44059. * Negative value indicates camera should not return to default.
  44060. */
  44061. set elevationReturnTime(speed: number);
  44062. /**
  44063. * Gets the time (in milliseconds) taken to return to the default beta position.
  44064. * Negative value indicates camera should not return to default.
  44065. */
  44066. get elevationReturnTime(): number;
  44067. /**
  44068. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  44069. */
  44070. set elevationReturnWaitTime(time: number);
  44071. /**
  44072. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  44073. */
  44074. get elevationReturnWaitTime(): number;
  44075. /**
  44076. * Sets the flag that indicates if user zooming should stop animation.
  44077. */
  44078. set zoomStopsAnimation(flag: boolean);
  44079. /**
  44080. * Gets the flag that indicates if user zooming should stop animation.
  44081. */
  44082. get zoomStopsAnimation(): boolean;
  44083. /**
  44084. * Sets the transition time when framing the mesh, in milliseconds
  44085. */
  44086. set framingTime(time: number);
  44087. /**
  44088. * Gets the transition time when framing the mesh, in milliseconds
  44089. */
  44090. get framingTime(): number;
  44091. /**
  44092. * Define if the behavior should automatically change the configured
  44093. * camera limits and sensibilities.
  44094. */
  44095. autoCorrectCameraLimitsAndSensibility: boolean;
  44096. private _onPrePointerObservableObserver;
  44097. private _onAfterCheckInputsObserver;
  44098. private _onMeshTargetChangedObserver;
  44099. private _attachedCamera;
  44100. private _isPointerDown;
  44101. private _lastInteractionTime;
  44102. /**
  44103. * Initializes the behavior.
  44104. */
  44105. init(): void;
  44106. /**
  44107. * Attaches the behavior to its arc rotate camera.
  44108. * @param camera Defines the camera to attach the behavior to
  44109. */
  44110. attach(camera: ArcRotateCamera): void;
  44111. /**
  44112. * Detaches the behavior from its current arc rotate camera.
  44113. */
  44114. detach(): void;
  44115. private _animatables;
  44116. private _betaIsAnimating;
  44117. private _betaTransition;
  44118. private _radiusTransition;
  44119. private _vectorTransition;
  44120. /**
  44121. * Targets the given mesh and updates zoom level accordingly.
  44122. * @param mesh The mesh to target.
  44123. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44124. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44125. */
  44126. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44127. /**
  44128. * Targets the given mesh with its children and updates zoom level accordingly.
  44129. * @param mesh The mesh to target.
  44130. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44131. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44132. */
  44133. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44134. /**
  44135. * Targets the given meshes with their children and updates zoom level accordingly.
  44136. * @param meshes The mesh to target.
  44137. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44138. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44139. */
  44140. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44141. /**
  44142. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  44143. * @param minimumWorld Determines the smaller position of the bounding box extend
  44144. * @param maximumWorld Determines the bigger position of the bounding box extend
  44145. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44146. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44147. */
  44148. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44149. /**
  44150. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  44151. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  44152. * frustum width.
  44153. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  44154. * to fully enclose the mesh in the viewing frustum.
  44155. */
  44156. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  44157. /**
  44158. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  44159. * is automatically returned to its default position (expected to be above ground plane).
  44160. */
  44161. private _maintainCameraAboveGround;
  44162. /**
  44163. * Returns the frustum slope based on the canvas ratio and camera FOV
  44164. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  44165. */
  44166. private _getFrustumSlope;
  44167. /**
  44168. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  44169. */
  44170. private _clearAnimationLocks;
  44171. /**
  44172. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44173. */
  44174. private _applyUserInteraction;
  44175. /**
  44176. * Stops and removes all animations that have been applied to the camera
  44177. */
  44178. stopAllAnimations(): void;
  44179. /**
  44180. * Gets a value indicating if the user is moving the camera
  44181. */
  44182. get isUserIsMoving(): boolean;
  44183. /**
  44184. * The camera can move all the way towards the mesh.
  44185. */
  44186. static IgnoreBoundsSizeMode: number;
  44187. /**
  44188. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  44189. */
  44190. static FitFrustumSidesMode: number;
  44191. }
  44192. }
  44193. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  44194. import { Nullable } from "babylonjs/types";
  44195. import { Camera } from "babylonjs/Cameras/camera";
  44196. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44197. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44198. /**
  44199. * Base class for Camera Pointer Inputs.
  44200. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  44201. * for example usage.
  44202. */
  44203. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  44204. /**
  44205. * Defines the camera the input is attached to.
  44206. */
  44207. abstract camera: Camera;
  44208. /**
  44209. * Whether keyboard modifier keys are pressed at time of last mouse event.
  44210. */
  44211. protected _altKey: boolean;
  44212. protected _ctrlKey: boolean;
  44213. protected _metaKey: boolean;
  44214. protected _shiftKey: boolean;
  44215. /**
  44216. * Which mouse buttons were pressed at time of last mouse event.
  44217. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  44218. */
  44219. protected _buttonsPressed: number;
  44220. /**
  44221. * Defines the buttons associated with the input to handle camera move.
  44222. */
  44223. buttons: number[];
  44224. /**
  44225. * Attach the input controls to a specific dom element to get the input from.
  44226. * @param element Defines the element the controls should be listened from
  44227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44228. */
  44229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44230. /**
  44231. * Detach the current controls from the specified dom element.
  44232. * @param element Defines the element to stop listening the inputs from
  44233. */
  44234. detachControl(element: Nullable<HTMLElement>): void;
  44235. /**
  44236. * Gets the class name of the current input.
  44237. * @returns the class name
  44238. */
  44239. getClassName(): string;
  44240. /**
  44241. * Get the friendly name associated with the input class.
  44242. * @returns the input friendly name
  44243. */
  44244. getSimpleName(): string;
  44245. /**
  44246. * Called on pointer POINTERDOUBLETAP event.
  44247. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44248. */
  44249. protected onDoubleTap(type: string): void;
  44250. /**
  44251. * Called on pointer POINTERMOVE event if only a single touch is active.
  44252. * Override this method to provide functionality.
  44253. */
  44254. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44255. /**
  44256. * Called on pointer POINTERMOVE event if multiple touches are active.
  44257. * Override this method to provide functionality.
  44258. */
  44259. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44260. /**
  44261. * Called on JS contextmenu event.
  44262. * Override this method to provide functionality.
  44263. */
  44264. protected onContextMenu(evt: PointerEvent): void;
  44265. /**
  44266. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44267. * press.
  44268. * Override this method to provide functionality.
  44269. */
  44270. protected onButtonDown(evt: PointerEvent): void;
  44271. /**
  44272. * Called each time a new POINTERUP event occurs. Ie, for each button
  44273. * release.
  44274. * Override this method to provide functionality.
  44275. */
  44276. protected onButtonUp(evt: PointerEvent): void;
  44277. /**
  44278. * Called when window becomes inactive.
  44279. * Override this method to provide functionality.
  44280. */
  44281. protected onLostFocus(): void;
  44282. private _pointerInput;
  44283. private _observer;
  44284. private _onLostFocus;
  44285. private pointA;
  44286. private pointB;
  44287. }
  44288. }
  44289. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44290. import { Nullable } from "babylonjs/types";
  44291. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44292. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44293. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44294. /**
  44295. * Manage the pointers inputs to control an arc rotate camera.
  44296. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44297. */
  44298. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44299. /**
  44300. * Defines the camera the input is attached to.
  44301. */
  44302. camera: ArcRotateCamera;
  44303. /**
  44304. * Gets the class name of the current input.
  44305. * @returns the class name
  44306. */
  44307. getClassName(): string;
  44308. /**
  44309. * Defines the buttons associated with the input to handle camera move.
  44310. */
  44311. buttons: number[];
  44312. /**
  44313. * Defines the pointer angular sensibility along the X axis or how fast is
  44314. * the camera rotating.
  44315. */
  44316. angularSensibilityX: number;
  44317. /**
  44318. * Defines the pointer angular sensibility along the Y axis or how fast is
  44319. * the camera rotating.
  44320. */
  44321. angularSensibilityY: number;
  44322. /**
  44323. * Defines the pointer pinch precision or how fast is the camera zooming.
  44324. */
  44325. pinchPrecision: number;
  44326. /**
  44327. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44328. * from 0.
  44329. * It defines the percentage of current camera.radius to use as delta when
  44330. * pinch zoom is used.
  44331. */
  44332. pinchDeltaPercentage: number;
  44333. /**
  44334. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44335. * that any object in the plane at the camera's target point will scale
  44336. * perfectly with finger motion.
  44337. * Overrides pinchDeltaPercentage and pinchPrecision.
  44338. */
  44339. useNaturalPinchZoom: boolean;
  44340. /**
  44341. * Defines the pointer panning sensibility or how fast is the camera moving.
  44342. */
  44343. panningSensibility: number;
  44344. /**
  44345. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44346. */
  44347. multiTouchPanning: boolean;
  44348. /**
  44349. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44350. * zoom (pinch) through multitouch.
  44351. */
  44352. multiTouchPanAndZoom: boolean;
  44353. /**
  44354. * Revers pinch action direction.
  44355. */
  44356. pinchInwards: boolean;
  44357. private _isPanClick;
  44358. private _twoFingerActivityCount;
  44359. private _isPinching;
  44360. /**
  44361. * Called on pointer POINTERMOVE event if only a single touch is active.
  44362. */
  44363. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44364. /**
  44365. * Called on pointer POINTERDOUBLETAP event.
  44366. */
  44367. protected onDoubleTap(type: string): void;
  44368. /**
  44369. * Called on pointer POINTERMOVE event if multiple touches are active.
  44370. */
  44371. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44372. /**
  44373. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44374. * press.
  44375. */
  44376. protected onButtonDown(evt: PointerEvent): void;
  44377. /**
  44378. * Called each time a new POINTERUP event occurs. Ie, for each button
  44379. * release.
  44380. */
  44381. protected onButtonUp(evt: PointerEvent): void;
  44382. /**
  44383. * Called when window becomes inactive.
  44384. */
  44385. protected onLostFocus(): void;
  44386. }
  44387. }
  44388. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44389. import { Nullable } from "babylonjs/types";
  44390. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44391. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44392. /**
  44393. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44394. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44395. */
  44396. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44397. /**
  44398. * Defines the camera the input is attached to.
  44399. */
  44400. camera: ArcRotateCamera;
  44401. /**
  44402. * Defines the list of key codes associated with the up action (increase alpha)
  44403. */
  44404. keysUp: number[];
  44405. /**
  44406. * Defines the list of key codes associated with the down action (decrease alpha)
  44407. */
  44408. keysDown: number[];
  44409. /**
  44410. * Defines the list of key codes associated with the left action (increase beta)
  44411. */
  44412. keysLeft: number[];
  44413. /**
  44414. * Defines the list of key codes associated with the right action (decrease beta)
  44415. */
  44416. keysRight: number[];
  44417. /**
  44418. * Defines the list of key codes associated with the reset action.
  44419. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44420. */
  44421. keysReset: number[];
  44422. /**
  44423. * Defines the panning sensibility of the inputs.
  44424. * (How fast is the camera panning)
  44425. */
  44426. panningSensibility: number;
  44427. /**
  44428. * Defines the zooming sensibility of the inputs.
  44429. * (How fast is the camera zooming)
  44430. */
  44431. zoomingSensibility: number;
  44432. /**
  44433. * Defines whether maintaining the alt key down switch the movement mode from
  44434. * orientation to zoom.
  44435. */
  44436. useAltToZoom: boolean;
  44437. /**
  44438. * Rotation speed of the camera
  44439. */
  44440. angularSpeed: number;
  44441. private _keys;
  44442. private _ctrlPressed;
  44443. private _altPressed;
  44444. private _onCanvasBlurObserver;
  44445. private _onKeyboardObserver;
  44446. private _engine;
  44447. private _scene;
  44448. /**
  44449. * Attach the input controls to a specific dom element to get the input from.
  44450. * @param element Defines the element the controls should be listened from
  44451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44452. */
  44453. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44454. /**
  44455. * Detach the current controls from the specified dom element.
  44456. * @param element Defines the element to stop listening the inputs from
  44457. */
  44458. detachControl(element: Nullable<HTMLElement>): void;
  44459. /**
  44460. * Update the current camera state depending on the inputs that have been used this frame.
  44461. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44462. */
  44463. checkInputs(): void;
  44464. /**
  44465. * Gets the class name of the current intput.
  44466. * @returns the class name
  44467. */
  44468. getClassName(): string;
  44469. /**
  44470. * Get the friendly name associated with the input class.
  44471. * @returns the input friendly name
  44472. */
  44473. getSimpleName(): string;
  44474. }
  44475. }
  44476. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44477. import { Nullable } from "babylonjs/types";
  44478. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44479. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44480. /**
  44481. * Manage the mouse wheel inputs to control an arc rotate camera.
  44482. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44483. */
  44484. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44485. /**
  44486. * Defines the camera the input is attached to.
  44487. */
  44488. camera: ArcRotateCamera;
  44489. /**
  44490. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44491. */
  44492. wheelPrecision: number;
  44493. /**
  44494. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44495. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44496. */
  44497. wheelDeltaPercentage: number;
  44498. private _wheel;
  44499. private _observer;
  44500. private computeDeltaFromMouseWheelLegacyEvent;
  44501. /**
  44502. * Attach the input controls to a specific dom element to get the input from.
  44503. * @param element Defines the element the controls should be listened from
  44504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44505. */
  44506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44507. /**
  44508. * Detach the current controls from the specified dom element.
  44509. * @param element Defines the element to stop listening the inputs from
  44510. */
  44511. detachControl(element: Nullable<HTMLElement>): void;
  44512. /**
  44513. * Gets the class name of the current intput.
  44514. * @returns the class name
  44515. */
  44516. getClassName(): string;
  44517. /**
  44518. * Get the friendly name associated with the input class.
  44519. * @returns the input friendly name
  44520. */
  44521. getSimpleName(): string;
  44522. }
  44523. }
  44524. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44525. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44526. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44527. /**
  44528. * Default Inputs manager for the ArcRotateCamera.
  44529. * It groups all the default supported inputs for ease of use.
  44530. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44531. */
  44532. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44533. /**
  44534. * Instantiates a new ArcRotateCameraInputsManager.
  44535. * @param camera Defines the camera the inputs belong to
  44536. */
  44537. constructor(camera: ArcRotateCamera);
  44538. /**
  44539. * Add mouse wheel input support to the input manager.
  44540. * @returns the current input manager
  44541. */
  44542. addMouseWheel(): ArcRotateCameraInputsManager;
  44543. /**
  44544. * Add pointers input support to the input manager.
  44545. * @returns the current input manager
  44546. */
  44547. addPointers(): ArcRotateCameraInputsManager;
  44548. /**
  44549. * Add keyboard input support to the input manager.
  44550. * @returns the current input manager
  44551. */
  44552. addKeyboard(): ArcRotateCameraInputsManager;
  44553. }
  44554. }
  44555. declare module "babylonjs/Cameras/arcRotateCamera" {
  44556. import { Observable } from "babylonjs/Misc/observable";
  44557. import { Nullable } from "babylonjs/types";
  44558. import { Scene } from "babylonjs/scene";
  44559. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44561. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44562. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44563. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44564. import { Camera } from "babylonjs/Cameras/camera";
  44565. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44566. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44567. import { Collider } from "babylonjs/Collisions/collider";
  44568. /**
  44569. * This represents an orbital type of camera.
  44570. *
  44571. * 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.
  44572. * 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.
  44573. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44574. */
  44575. export class ArcRotateCamera extends TargetCamera {
  44576. /**
  44577. * Defines the rotation angle of the camera along the longitudinal axis.
  44578. */
  44579. alpha: number;
  44580. /**
  44581. * Defines the rotation angle of the camera along the latitudinal axis.
  44582. */
  44583. beta: number;
  44584. /**
  44585. * Defines the radius of the camera from it s target point.
  44586. */
  44587. radius: number;
  44588. protected _target: Vector3;
  44589. protected _targetHost: Nullable<AbstractMesh>;
  44590. /**
  44591. * Defines the target point of the camera.
  44592. * The camera looks towards it form the radius distance.
  44593. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44594. */
  44595. get target(): Vector3;
  44596. set target(value: Vector3);
  44597. /**
  44598. * Define the current local position of the camera in the scene
  44599. */
  44600. get position(): Vector3;
  44601. set position(newPosition: Vector3);
  44602. protected _upToYMatrix: Matrix;
  44603. protected _YToUpMatrix: Matrix;
  44604. /**
  44605. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44606. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44607. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44608. */
  44609. set upVector(vec: Vector3);
  44610. get upVector(): Vector3;
  44611. /**
  44612. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44613. */
  44614. setMatUp(): void;
  44615. /**
  44616. * Current inertia value on the longitudinal axis.
  44617. * The bigger this number the longer it will take for the camera to stop.
  44618. */
  44619. inertialAlphaOffset: number;
  44620. /**
  44621. * Current inertia value on the latitudinal axis.
  44622. * The bigger this number the longer it will take for the camera to stop.
  44623. */
  44624. inertialBetaOffset: number;
  44625. /**
  44626. * Current inertia value on the radius axis.
  44627. * The bigger this number the longer it will take for the camera to stop.
  44628. */
  44629. inertialRadiusOffset: number;
  44630. /**
  44631. * Minimum allowed angle on the longitudinal axis.
  44632. * This can help limiting how the Camera is able to move in the scene.
  44633. */
  44634. lowerAlphaLimit: Nullable<number>;
  44635. /**
  44636. * Maximum allowed angle on the longitudinal axis.
  44637. * This can help limiting how the Camera is able to move in the scene.
  44638. */
  44639. upperAlphaLimit: Nullable<number>;
  44640. /**
  44641. * Minimum allowed angle on the latitudinal axis.
  44642. * This can help limiting how the Camera is able to move in the scene.
  44643. */
  44644. lowerBetaLimit: number;
  44645. /**
  44646. * Maximum allowed angle on the latitudinal axis.
  44647. * This can help limiting how the Camera is able to move in the scene.
  44648. */
  44649. upperBetaLimit: number;
  44650. /**
  44651. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44652. * This can help limiting how the Camera is able to move in the scene.
  44653. */
  44654. lowerRadiusLimit: Nullable<number>;
  44655. /**
  44656. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44657. * This can help limiting how the Camera is able to move in the scene.
  44658. */
  44659. upperRadiusLimit: Nullable<number>;
  44660. /**
  44661. * Defines the current inertia value used during panning of the camera along the X axis.
  44662. */
  44663. inertialPanningX: number;
  44664. /**
  44665. * Defines the current inertia value used during panning of the camera along the Y axis.
  44666. */
  44667. inertialPanningY: number;
  44668. /**
  44669. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44670. * Basically if your fingers moves away from more than this distance you will be considered
  44671. * in pinch mode.
  44672. */
  44673. pinchToPanMaxDistance: number;
  44674. /**
  44675. * Defines the maximum distance the camera can pan.
  44676. * This could help keeping the cammera always in your scene.
  44677. */
  44678. panningDistanceLimit: Nullable<number>;
  44679. /**
  44680. * Defines the target of the camera before paning.
  44681. */
  44682. panningOriginTarget: Vector3;
  44683. /**
  44684. * Defines the value of the inertia used during panning.
  44685. * 0 would mean stop inertia and one would mean no decelleration at all.
  44686. */
  44687. panningInertia: number;
  44688. /**
  44689. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44690. */
  44691. get angularSensibilityX(): number;
  44692. set angularSensibilityX(value: number);
  44693. /**
  44694. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44695. */
  44696. get angularSensibilityY(): number;
  44697. set angularSensibilityY(value: number);
  44698. /**
  44699. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44700. */
  44701. get pinchPrecision(): number;
  44702. set pinchPrecision(value: number);
  44703. /**
  44704. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44705. * It will be used instead of pinchDeltaPrecision if different from 0.
  44706. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44707. */
  44708. get pinchDeltaPercentage(): number;
  44709. set pinchDeltaPercentage(value: number);
  44710. /**
  44711. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44712. * and pinch delta percentage.
  44713. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44714. * that any object in the plane at the camera's target point will scale
  44715. * perfectly with finger motion.
  44716. */
  44717. get useNaturalPinchZoom(): boolean;
  44718. set useNaturalPinchZoom(value: boolean);
  44719. /**
  44720. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44721. */
  44722. get panningSensibility(): number;
  44723. set panningSensibility(value: number);
  44724. /**
  44725. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44726. */
  44727. get keysUp(): number[];
  44728. set keysUp(value: number[]);
  44729. /**
  44730. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44731. */
  44732. get keysDown(): number[];
  44733. set keysDown(value: number[]);
  44734. /**
  44735. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44736. */
  44737. get keysLeft(): number[];
  44738. set keysLeft(value: number[]);
  44739. /**
  44740. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44741. */
  44742. get keysRight(): number[];
  44743. set keysRight(value: number[]);
  44744. /**
  44745. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44746. */
  44747. get wheelPrecision(): number;
  44748. set wheelPrecision(value: number);
  44749. /**
  44750. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44751. * It will be used instead of pinchDeltaPrecision if different from 0.
  44752. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44753. */
  44754. get wheelDeltaPercentage(): number;
  44755. set wheelDeltaPercentage(value: number);
  44756. /**
  44757. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44758. */
  44759. zoomOnFactor: number;
  44760. /**
  44761. * Defines a screen offset for the camera position.
  44762. */
  44763. targetScreenOffset: Vector2;
  44764. /**
  44765. * Allows the camera to be completely reversed.
  44766. * If false the camera can not arrive upside down.
  44767. */
  44768. allowUpsideDown: boolean;
  44769. /**
  44770. * Define if double tap/click is used to restore the previously saved state of the camera.
  44771. */
  44772. useInputToRestoreState: boolean;
  44773. /** @hidden */
  44774. _viewMatrix: Matrix;
  44775. /** @hidden */
  44776. _useCtrlForPanning: boolean;
  44777. /** @hidden */
  44778. _panningMouseButton: number;
  44779. /**
  44780. * Defines the input associated to the camera.
  44781. */
  44782. inputs: ArcRotateCameraInputsManager;
  44783. /** @hidden */
  44784. _reset: () => void;
  44785. /**
  44786. * Defines the allowed panning axis.
  44787. */
  44788. panningAxis: Vector3;
  44789. protected _localDirection: Vector3;
  44790. protected _transformedDirection: Vector3;
  44791. private _bouncingBehavior;
  44792. /**
  44793. * Gets the bouncing behavior of the camera if it has been enabled.
  44794. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44795. */
  44796. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44797. /**
  44798. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44799. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44800. */
  44801. get useBouncingBehavior(): boolean;
  44802. set useBouncingBehavior(value: boolean);
  44803. private _framingBehavior;
  44804. /**
  44805. * Gets the framing behavior of the camera if it has been enabled.
  44806. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44807. */
  44808. get framingBehavior(): Nullable<FramingBehavior>;
  44809. /**
  44810. * Defines if the framing behavior of the camera is enabled on the camera.
  44811. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44812. */
  44813. get useFramingBehavior(): boolean;
  44814. set useFramingBehavior(value: boolean);
  44815. private _autoRotationBehavior;
  44816. /**
  44817. * Gets the auto rotation behavior of the camera if it has been enabled.
  44818. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44819. */
  44820. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44821. /**
  44822. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44823. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44824. */
  44825. get useAutoRotationBehavior(): boolean;
  44826. set useAutoRotationBehavior(value: boolean);
  44827. /**
  44828. * Observable triggered when the mesh target has been changed on the camera.
  44829. */
  44830. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44831. /**
  44832. * Event raised when the camera is colliding with a mesh.
  44833. */
  44834. onCollide: (collidedMesh: AbstractMesh) => void;
  44835. /**
  44836. * Defines whether the camera should check collision with the objects oh the scene.
  44837. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44838. */
  44839. checkCollisions: boolean;
  44840. /**
  44841. * Defines the collision radius of the camera.
  44842. * This simulates a sphere around the camera.
  44843. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44844. */
  44845. collisionRadius: Vector3;
  44846. protected _collider: Collider;
  44847. protected _previousPosition: Vector3;
  44848. protected _collisionVelocity: Vector3;
  44849. protected _newPosition: Vector3;
  44850. protected _previousAlpha: number;
  44851. protected _previousBeta: number;
  44852. protected _previousRadius: number;
  44853. protected _collisionTriggered: boolean;
  44854. protected _targetBoundingCenter: Nullable<Vector3>;
  44855. private _computationVector;
  44856. /**
  44857. * Instantiates a new ArcRotateCamera in a given scene
  44858. * @param name Defines the name of the camera
  44859. * @param alpha Defines the camera rotation along the logitudinal axis
  44860. * @param beta Defines the camera rotation along the latitudinal axis
  44861. * @param radius Defines the camera distance from its target
  44862. * @param target Defines the camera target
  44863. * @param scene Defines the scene the camera belongs to
  44864. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44865. */
  44866. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44867. /** @hidden */
  44868. _initCache(): void;
  44869. /** @hidden */
  44870. _updateCache(ignoreParentClass?: boolean): void;
  44871. protected _getTargetPosition(): Vector3;
  44872. private _storedAlpha;
  44873. private _storedBeta;
  44874. private _storedRadius;
  44875. private _storedTarget;
  44876. private _storedTargetScreenOffset;
  44877. /**
  44878. * Stores the current state of the camera (alpha, beta, radius and target)
  44879. * @returns the camera itself
  44880. */
  44881. storeState(): Camera;
  44882. /**
  44883. * @hidden
  44884. * Restored camera state. You must call storeState() first
  44885. */
  44886. _restoreStateValues(): boolean;
  44887. /** @hidden */
  44888. _isSynchronizedViewMatrix(): boolean;
  44889. /**
  44890. * Attached controls to the current camera.
  44891. * @param element Defines the element the controls should be listened from
  44892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44893. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44894. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44895. */
  44896. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44897. /**
  44898. * Detach the current controls from the camera.
  44899. * The camera will stop reacting to inputs.
  44900. * @param element Defines the element to stop listening the inputs from
  44901. */
  44902. detachControl(element: HTMLElement): void;
  44903. /** @hidden */
  44904. _checkInputs(): void;
  44905. protected _checkLimits(): void;
  44906. /**
  44907. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44908. */
  44909. rebuildAnglesAndRadius(): void;
  44910. /**
  44911. * Use a position to define the current camera related information like alpha, beta and radius
  44912. * @param position Defines the position to set the camera at
  44913. */
  44914. setPosition(position: Vector3): void;
  44915. /**
  44916. * Defines the target the camera should look at.
  44917. * This will automatically adapt alpha beta and radius to fit within the new target.
  44918. * @param target Defines the new target as a Vector or a mesh
  44919. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44920. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44921. */
  44922. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44923. /** @hidden */
  44924. _getViewMatrix(): Matrix;
  44925. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44926. /**
  44927. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44928. * @param meshes Defines the mesh to zoom on
  44929. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  44930. */
  44931. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44932. /**
  44933. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44934. * The target will be changed but the radius
  44935. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44936. * @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)
  44937. */
  44938. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44939. min: Vector3;
  44940. max: Vector3;
  44941. distance: number;
  44942. }, doNotUpdateMaxZ?: boolean): void;
  44943. /**
  44944. * @override
  44945. * Override Camera.createRigCamera
  44946. */
  44947. createRigCamera(name: string, cameraIndex: number): Camera;
  44948. /**
  44949. * @hidden
  44950. * @override
  44951. * Override Camera._updateRigCameras
  44952. */
  44953. _updateRigCameras(): void;
  44954. /**
  44955. * Destroy the camera and release the current resources hold by it.
  44956. */
  44957. dispose(): void;
  44958. /**
  44959. * Gets the current object class name.
  44960. * @return the class name
  44961. */
  44962. getClassName(): string;
  44963. }
  44964. }
  44965. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44966. import { Behavior } from "babylonjs/Behaviors/behavior";
  44967. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44968. /**
  44969. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44970. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44971. */
  44972. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44973. /**
  44974. * Gets the name of the behavior.
  44975. */
  44976. get name(): string;
  44977. private _zoomStopsAnimation;
  44978. private _idleRotationSpeed;
  44979. private _idleRotationWaitTime;
  44980. private _idleRotationSpinupTime;
  44981. /**
  44982. * Sets the flag that indicates if user zooming should stop animation.
  44983. */
  44984. set zoomStopsAnimation(flag: boolean);
  44985. /**
  44986. * Gets the flag that indicates if user zooming should stop animation.
  44987. */
  44988. get zoomStopsAnimation(): boolean;
  44989. /**
  44990. * Sets the default speed at which the camera rotates around the model.
  44991. */
  44992. set idleRotationSpeed(speed: number);
  44993. /**
  44994. * Gets the default speed at which the camera rotates around the model.
  44995. */
  44996. get idleRotationSpeed(): number;
  44997. /**
  44998. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44999. */
  45000. set idleRotationWaitTime(time: number);
  45001. /**
  45002. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  45003. */
  45004. get idleRotationWaitTime(): number;
  45005. /**
  45006. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  45007. */
  45008. set idleRotationSpinupTime(time: number);
  45009. /**
  45010. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  45011. */
  45012. get idleRotationSpinupTime(): number;
  45013. /**
  45014. * Gets a value indicating if the camera is currently rotating because of this behavior
  45015. */
  45016. get rotationInProgress(): boolean;
  45017. private _onPrePointerObservableObserver;
  45018. private _onAfterCheckInputsObserver;
  45019. private _attachedCamera;
  45020. private _isPointerDown;
  45021. private _lastFrameTime;
  45022. private _lastInteractionTime;
  45023. private _cameraRotationSpeed;
  45024. /**
  45025. * Initializes the behavior.
  45026. */
  45027. init(): void;
  45028. /**
  45029. * Attaches the behavior to its arc rotate camera.
  45030. * @param camera Defines the camera to attach the behavior to
  45031. */
  45032. attach(camera: ArcRotateCamera): void;
  45033. /**
  45034. * Detaches the behavior from its current arc rotate camera.
  45035. */
  45036. detach(): void;
  45037. /**
  45038. * Returns true if user is scrolling.
  45039. * @return true if user is scrolling.
  45040. */
  45041. private _userIsZooming;
  45042. private _lastFrameRadius;
  45043. private _shouldAnimationStopForInteraction;
  45044. /**
  45045. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45046. */
  45047. private _applyUserInteraction;
  45048. private _userIsMoving;
  45049. }
  45050. }
  45051. declare module "babylonjs/Behaviors/Cameras/index" {
  45052. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  45053. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  45054. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  45055. }
  45056. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  45057. import { Mesh } from "babylonjs/Meshes/mesh";
  45058. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45059. import { Behavior } from "babylonjs/Behaviors/behavior";
  45060. /**
  45061. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  45062. */
  45063. export class AttachToBoxBehavior implements Behavior<Mesh> {
  45064. private ui;
  45065. /**
  45066. * The name of the behavior
  45067. */
  45068. name: string;
  45069. /**
  45070. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  45071. */
  45072. distanceAwayFromFace: number;
  45073. /**
  45074. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  45075. */
  45076. distanceAwayFromBottomOfFace: number;
  45077. private _faceVectors;
  45078. private _target;
  45079. private _scene;
  45080. private _onRenderObserver;
  45081. private _tmpMatrix;
  45082. private _tmpVector;
  45083. /**
  45084. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  45085. * @param ui The transform node that should be attched to the mesh
  45086. */
  45087. constructor(ui: TransformNode);
  45088. /**
  45089. * Initializes the behavior
  45090. */
  45091. init(): void;
  45092. private _closestFace;
  45093. private _zeroVector;
  45094. private _lookAtTmpMatrix;
  45095. private _lookAtToRef;
  45096. /**
  45097. * Attaches the AttachToBoxBehavior to the passed in mesh
  45098. * @param target The mesh that the specified node will be attached to
  45099. */
  45100. attach(target: Mesh): void;
  45101. /**
  45102. * Detaches the behavior from the mesh
  45103. */
  45104. detach(): void;
  45105. }
  45106. }
  45107. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  45108. import { Behavior } from "babylonjs/Behaviors/behavior";
  45109. import { Mesh } from "babylonjs/Meshes/mesh";
  45110. /**
  45111. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  45112. */
  45113. export class FadeInOutBehavior implements Behavior<Mesh> {
  45114. /**
  45115. * Time in milliseconds to delay before fading in (Default: 0)
  45116. */
  45117. delay: number;
  45118. /**
  45119. * Time in milliseconds for the mesh to fade in (Default: 300)
  45120. */
  45121. fadeInTime: number;
  45122. private _millisecondsPerFrame;
  45123. private _hovered;
  45124. private _hoverValue;
  45125. private _ownerNode;
  45126. /**
  45127. * Instatiates the FadeInOutBehavior
  45128. */
  45129. constructor();
  45130. /**
  45131. * The name of the behavior
  45132. */
  45133. get name(): string;
  45134. /**
  45135. * Initializes the behavior
  45136. */
  45137. init(): void;
  45138. /**
  45139. * Attaches the fade behavior on the passed in mesh
  45140. * @param ownerNode The mesh that will be faded in/out once attached
  45141. */
  45142. attach(ownerNode: Mesh): void;
  45143. /**
  45144. * Detaches the behavior from the mesh
  45145. */
  45146. detach(): void;
  45147. /**
  45148. * Triggers the mesh to begin fading in or out
  45149. * @param value if the object should fade in or out (true to fade in)
  45150. */
  45151. fadeIn(value: boolean): void;
  45152. private _update;
  45153. private _setAllVisibility;
  45154. }
  45155. }
  45156. declare module "babylonjs/Misc/pivotTools" {
  45157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45158. /**
  45159. * Class containing a set of static utilities functions for managing Pivots
  45160. * @hidden
  45161. */
  45162. export class PivotTools {
  45163. private static _PivotCached;
  45164. private static _OldPivotPoint;
  45165. private static _PivotTranslation;
  45166. private static _PivotTmpVector;
  45167. private static _PivotPostMultiplyPivotMatrix;
  45168. /** @hidden */
  45169. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  45170. /** @hidden */
  45171. static _RestorePivotPoint(mesh: AbstractMesh): void;
  45172. }
  45173. }
  45174. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  45175. import { Scene } from "babylonjs/scene";
  45176. import { Vector4 } from "babylonjs/Maths/math.vector";
  45177. import { Mesh } from "babylonjs/Meshes/mesh";
  45178. import { Nullable } from "babylonjs/types";
  45179. import { Plane } from "babylonjs/Maths/math.plane";
  45180. /**
  45181. * Class containing static functions to help procedurally build meshes
  45182. */
  45183. export class PlaneBuilder {
  45184. /**
  45185. * Creates a plane mesh
  45186. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  45187. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  45188. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  45189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45192. * @param name defines the name of the mesh
  45193. * @param options defines the options used to create the mesh
  45194. * @param scene defines the hosting scene
  45195. * @returns the plane mesh
  45196. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  45197. */
  45198. static CreatePlane(name: string, options: {
  45199. size?: number;
  45200. width?: number;
  45201. height?: number;
  45202. sideOrientation?: number;
  45203. frontUVs?: Vector4;
  45204. backUVs?: Vector4;
  45205. updatable?: boolean;
  45206. sourcePlane?: Plane;
  45207. }, scene?: Nullable<Scene>): Mesh;
  45208. }
  45209. }
  45210. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  45211. import { Behavior } from "babylonjs/Behaviors/behavior";
  45212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45213. import { Observable } from "babylonjs/Misc/observable";
  45214. import { Vector3 } from "babylonjs/Maths/math.vector";
  45215. import { Ray } from "babylonjs/Culling/ray";
  45216. import "babylonjs/Meshes/Builders/planeBuilder";
  45217. /**
  45218. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  45219. */
  45220. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  45221. private static _AnyMouseID;
  45222. /**
  45223. * Abstract mesh the behavior is set on
  45224. */
  45225. attachedNode: AbstractMesh;
  45226. private _dragPlane;
  45227. private _scene;
  45228. private _pointerObserver;
  45229. private _beforeRenderObserver;
  45230. private static _planeScene;
  45231. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  45232. /**
  45233. * 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)
  45234. */
  45235. maxDragAngle: number;
  45236. /**
  45237. * @hidden
  45238. */
  45239. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  45240. /**
  45241. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45242. */
  45243. currentDraggingPointerID: number;
  45244. /**
  45245. * The last position where the pointer hit the drag plane in world space
  45246. */
  45247. lastDragPosition: Vector3;
  45248. /**
  45249. * If the behavior is currently in a dragging state
  45250. */
  45251. dragging: boolean;
  45252. /**
  45253. * 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)
  45254. */
  45255. dragDeltaRatio: number;
  45256. /**
  45257. * If the drag plane orientation should be updated during the dragging (Default: true)
  45258. */
  45259. updateDragPlane: boolean;
  45260. private _debugMode;
  45261. private _moving;
  45262. /**
  45263. * Fires each time the attached mesh is dragged with the pointer
  45264. * * delta between last drag position and current drag position in world space
  45265. * * dragDistance along the drag axis
  45266. * * dragPlaneNormal normal of the current drag plane used during the drag
  45267. * * dragPlanePoint in world space where the drag intersects the drag plane
  45268. */
  45269. onDragObservable: Observable<{
  45270. delta: Vector3;
  45271. dragPlanePoint: Vector3;
  45272. dragPlaneNormal: Vector3;
  45273. dragDistance: number;
  45274. pointerId: number;
  45275. }>;
  45276. /**
  45277. * Fires each time a drag begins (eg. mouse down on mesh)
  45278. */
  45279. onDragStartObservable: Observable<{
  45280. dragPlanePoint: Vector3;
  45281. pointerId: number;
  45282. }>;
  45283. /**
  45284. * Fires each time a drag ends (eg. mouse release after drag)
  45285. */
  45286. onDragEndObservable: Observable<{
  45287. dragPlanePoint: Vector3;
  45288. pointerId: number;
  45289. }>;
  45290. /**
  45291. * If the attached mesh should be moved when dragged
  45292. */
  45293. moveAttached: boolean;
  45294. /**
  45295. * If the drag behavior will react to drag events (Default: true)
  45296. */
  45297. enabled: boolean;
  45298. /**
  45299. * If pointer events should start and release the drag (Default: true)
  45300. */
  45301. startAndReleaseDragOnPointerEvents: boolean;
  45302. /**
  45303. * If camera controls should be detached during the drag
  45304. */
  45305. detachCameraControls: boolean;
  45306. /**
  45307. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45308. */
  45309. useObjectOrientationForDragging: boolean;
  45310. private _options;
  45311. /**
  45312. * Gets the options used by the behavior
  45313. */
  45314. get options(): {
  45315. dragAxis?: Vector3;
  45316. dragPlaneNormal?: Vector3;
  45317. };
  45318. /**
  45319. * Sets the options used by the behavior
  45320. */
  45321. set options(options: {
  45322. dragAxis?: Vector3;
  45323. dragPlaneNormal?: Vector3;
  45324. });
  45325. /**
  45326. * Creates a pointer drag behavior that can be attached to a mesh
  45327. * @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)
  45328. */
  45329. constructor(options?: {
  45330. dragAxis?: Vector3;
  45331. dragPlaneNormal?: Vector3;
  45332. });
  45333. /**
  45334. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45335. */
  45336. validateDrag: (targetPosition: Vector3) => boolean;
  45337. /**
  45338. * The name of the behavior
  45339. */
  45340. get name(): string;
  45341. /**
  45342. * Initializes the behavior
  45343. */
  45344. init(): void;
  45345. private _tmpVector;
  45346. private _alternatePickedPoint;
  45347. private _worldDragAxis;
  45348. private _targetPosition;
  45349. private _attachedElement;
  45350. /**
  45351. * Attaches the drag behavior the passed in mesh
  45352. * @param ownerNode The mesh that will be dragged around once attached
  45353. * @param predicate Predicate to use for pick filtering
  45354. */
  45355. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45356. /**
  45357. * Force relase the drag action by code.
  45358. */
  45359. releaseDrag(): void;
  45360. private _startDragRay;
  45361. private _lastPointerRay;
  45362. /**
  45363. * Simulates the start of a pointer drag event on the behavior
  45364. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45365. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45366. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45367. */
  45368. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45369. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45370. private _dragDelta;
  45371. protected _moveDrag(ray: Ray): void;
  45372. private _pickWithRayOnDragPlane;
  45373. private _pointA;
  45374. private _pointC;
  45375. private _localAxis;
  45376. private _lookAt;
  45377. private _updateDragPlanePosition;
  45378. /**
  45379. * Detaches the behavior from the mesh
  45380. */
  45381. detach(): void;
  45382. }
  45383. }
  45384. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45385. import { Mesh } from "babylonjs/Meshes/mesh";
  45386. import { Behavior } from "babylonjs/Behaviors/behavior";
  45387. /**
  45388. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45389. */
  45390. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45391. private _dragBehaviorA;
  45392. private _dragBehaviorB;
  45393. private _startDistance;
  45394. private _initialScale;
  45395. private _targetScale;
  45396. private _ownerNode;
  45397. private _sceneRenderObserver;
  45398. /**
  45399. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45400. */
  45401. constructor();
  45402. /**
  45403. * The name of the behavior
  45404. */
  45405. get name(): string;
  45406. /**
  45407. * Initializes the behavior
  45408. */
  45409. init(): void;
  45410. private _getCurrentDistance;
  45411. /**
  45412. * Attaches the scale behavior the passed in mesh
  45413. * @param ownerNode The mesh that will be scaled around once attached
  45414. */
  45415. attach(ownerNode: Mesh): void;
  45416. /**
  45417. * Detaches the behavior from the mesh
  45418. */
  45419. detach(): void;
  45420. }
  45421. }
  45422. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45423. import { Behavior } from "babylonjs/Behaviors/behavior";
  45424. import { Mesh } from "babylonjs/Meshes/mesh";
  45425. import { Observable } from "babylonjs/Misc/observable";
  45426. /**
  45427. * 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
  45428. */
  45429. export class SixDofDragBehavior implements Behavior<Mesh> {
  45430. private static _virtualScene;
  45431. private _ownerNode;
  45432. private _sceneRenderObserver;
  45433. private _scene;
  45434. private _targetPosition;
  45435. private _virtualOriginMesh;
  45436. private _virtualDragMesh;
  45437. private _pointerObserver;
  45438. private _moving;
  45439. private _startingOrientation;
  45440. private _attachedElement;
  45441. /**
  45442. * 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)
  45443. */
  45444. private zDragFactor;
  45445. /**
  45446. * If the object should rotate to face the drag origin
  45447. */
  45448. rotateDraggedObject: boolean;
  45449. /**
  45450. * If the behavior is currently in a dragging state
  45451. */
  45452. dragging: boolean;
  45453. /**
  45454. * 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)
  45455. */
  45456. dragDeltaRatio: number;
  45457. /**
  45458. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45459. */
  45460. currentDraggingPointerID: number;
  45461. /**
  45462. * If camera controls should be detached during the drag
  45463. */
  45464. detachCameraControls: boolean;
  45465. /**
  45466. * Fires each time a drag starts
  45467. */
  45468. onDragStartObservable: Observable<{}>;
  45469. /**
  45470. * Fires each time a drag ends (eg. mouse release after drag)
  45471. */
  45472. onDragEndObservable: Observable<{}>;
  45473. /**
  45474. * 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
  45475. */
  45476. constructor();
  45477. /**
  45478. * The name of the behavior
  45479. */
  45480. get name(): string;
  45481. /**
  45482. * Initializes the behavior
  45483. */
  45484. init(): void;
  45485. /**
  45486. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45487. */
  45488. private get _pointerCamera();
  45489. /**
  45490. * Attaches the scale behavior the passed in mesh
  45491. * @param ownerNode The mesh that will be scaled around once attached
  45492. */
  45493. attach(ownerNode: Mesh): void;
  45494. /**
  45495. * Detaches the behavior from the mesh
  45496. */
  45497. detach(): void;
  45498. }
  45499. }
  45500. declare module "babylonjs/Behaviors/Meshes/index" {
  45501. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45502. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45503. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45504. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45505. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45506. }
  45507. declare module "babylonjs/Behaviors/index" {
  45508. export * from "babylonjs/Behaviors/behavior";
  45509. export * from "babylonjs/Behaviors/Cameras/index";
  45510. export * from "babylonjs/Behaviors/Meshes/index";
  45511. }
  45512. declare module "babylonjs/Bones/boneIKController" {
  45513. import { Bone } from "babylonjs/Bones/bone";
  45514. import { Vector3 } from "babylonjs/Maths/math.vector";
  45515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45516. import { Nullable } from "babylonjs/types";
  45517. /**
  45518. * Class used to apply inverse kinematics to bones
  45519. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45520. */
  45521. export class BoneIKController {
  45522. private static _tmpVecs;
  45523. private static _tmpQuat;
  45524. private static _tmpMats;
  45525. /**
  45526. * Gets or sets the target mesh
  45527. */
  45528. targetMesh: AbstractMesh;
  45529. /** Gets or sets the mesh used as pole */
  45530. poleTargetMesh: AbstractMesh;
  45531. /**
  45532. * Gets or sets the bone used as pole
  45533. */
  45534. poleTargetBone: Nullable<Bone>;
  45535. /**
  45536. * Gets or sets the target position
  45537. */
  45538. targetPosition: Vector3;
  45539. /**
  45540. * Gets or sets the pole target position
  45541. */
  45542. poleTargetPosition: Vector3;
  45543. /**
  45544. * Gets or sets the pole target local offset
  45545. */
  45546. poleTargetLocalOffset: Vector3;
  45547. /**
  45548. * Gets or sets the pole angle
  45549. */
  45550. poleAngle: number;
  45551. /**
  45552. * Gets or sets the mesh associated with the controller
  45553. */
  45554. mesh: AbstractMesh;
  45555. /**
  45556. * 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)
  45557. */
  45558. slerpAmount: number;
  45559. private _bone1Quat;
  45560. private _bone1Mat;
  45561. private _bone2Ang;
  45562. private _bone1;
  45563. private _bone2;
  45564. private _bone1Length;
  45565. private _bone2Length;
  45566. private _maxAngle;
  45567. private _maxReach;
  45568. private _rightHandedSystem;
  45569. private _bendAxis;
  45570. private _slerping;
  45571. private _adjustRoll;
  45572. /**
  45573. * Gets or sets maximum allowed angle
  45574. */
  45575. get maxAngle(): number;
  45576. set maxAngle(value: number);
  45577. /**
  45578. * Creates a new BoneIKController
  45579. * @param mesh defines the mesh to control
  45580. * @param bone defines the bone to control
  45581. * @param options defines options to set up the controller
  45582. */
  45583. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45584. targetMesh?: AbstractMesh;
  45585. poleTargetMesh?: AbstractMesh;
  45586. poleTargetBone?: Bone;
  45587. poleTargetLocalOffset?: Vector3;
  45588. poleAngle?: number;
  45589. bendAxis?: Vector3;
  45590. maxAngle?: number;
  45591. slerpAmount?: number;
  45592. });
  45593. private _setMaxAngle;
  45594. /**
  45595. * Force the controller to update the bones
  45596. */
  45597. update(): void;
  45598. }
  45599. }
  45600. declare module "babylonjs/Bones/boneLookController" {
  45601. import { Vector3 } from "babylonjs/Maths/math.vector";
  45602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45603. import { Bone } from "babylonjs/Bones/bone";
  45604. import { Space } from "babylonjs/Maths/math.axis";
  45605. /**
  45606. * Class used to make a bone look toward a point in space
  45607. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45608. */
  45609. export class BoneLookController {
  45610. private static _tmpVecs;
  45611. private static _tmpQuat;
  45612. private static _tmpMats;
  45613. /**
  45614. * The target Vector3 that the bone will look at
  45615. */
  45616. target: Vector3;
  45617. /**
  45618. * The mesh that the bone is attached to
  45619. */
  45620. mesh: AbstractMesh;
  45621. /**
  45622. * The bone that will be looking to the target
  45623. */
  45624. bone: Bone;
  45625. /**
  45626. * The up axis of the coordinate system that is used when the bone is rotated
  45627. */
  45628. upAxis: Vector3;
  45629. /**
  45630. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45631. */
  45632. upAxisSpace: Space;
  45633. /**
  45634. * Used to make an adjustment to the yaw of the bone
  45635. */
  45636. adjustYaw: number;
  45637. /**
  45638. * Used to make an adjustment to the pitch of the bone
  45639. */
  45640. adjustPitch: number;
  45641. /**
  45642. * Used to make an adjustment to the roll of the bone
  45643. */
  45644. adjustRoll: number;
  45645. /**
  45646. * 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)
  45647. */
  45648. slerpAmount: number;
  45649. private _minYaw;
  45650. private _maxYaw;
  45651. private _minPitch;
  45652. private _maxPitch;
  45653. private _minYawSin;
  45654. private _minYawCos;
  45655. private _maxYawSin;
  45656. private _maxYawCos;
  45657. private _midYawConstraint;
  45658. private _minPitchTan;
  45659. private _maxPitchTan;
  45660. private _boneQuat;
  45661. private _slerping;
  45662. private _transformYawPitch;
  45663. private _transformYawPitchInv;
  45664. private _firstFrameSkipped;
  45665. private _yawRange;
  45666. private _fowardAxis;
  45667. /**
  45668. * Gets or sets the minimum yaw angle that the bone can look to
  45669. */
  45670. get minYaw(): number;
  45671. set minYaw(value: number);
  45672. /**
  45673. * Gets or sets the maximum yaw angle that the bone can look to
  45674. */
  45675. get maxYaw(): number;
  45676. set maxYaw(value: number);
  45677. /**
  45678. * Gets or sets the minimum pitch angle that the bone can look to
  45679. */
  45680. get minPitch(): number;
  45681. set minPitch(value: number);
  45682. /**
  45683. * Gets or sets the maximum pitch angle that the bone can look to
  45684. */
  45685. get maxPitch(): number;
  45686. set maxPitch(value: number);
  45687. /**
  45688. * Create a BoneLookController
  45689. * @param mesh the mesh that the bone belongs to
  45690. * @param bone the bone that will be looking to the target
  45691. * @param target the target Vector3 to look at
  45692. * @param options optional settings:
  45693. * * maxYaw: the maximum angle the bone will yaw to
  45694. * * minYaw: the minimum angle the bone will yaw to
  45695. * * maxPitch: the maximum angle the bone will pitch to
  45696. * * minPitch: the minimum angle the bone will yaw to
  45697. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45698. * * upAxis: the up axis of the coordinate system
  45699. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45700. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45701. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45702. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45703. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45704. * * adjustRoll: used to make an adjustment to the roll of the bone
  45705. **/
  45706. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45707. maxYaw?: number;
  45708. minYaw?: number;
  45709. maxPitch?: number;
  45710. minPitch?: number;
  45711. slerpAmount?: number;
  45712. upAxis?: Vector3;
  45713. upAxisSpace?: Space;
  45714. yawAxis?: Vector3;
  45715. pitchAxis?: Vector3;
  45716. adjustYaw?: number;
  45717. adjustPitch?: number;
  45718. adjustRoll?: number;
  45719. });
  45720. /**
  45721. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45722. */
  45723. update(): void;
  45724. private _getAngleDiff;
  45725. private _getAngleBetween;
  45726. private _isAngleBetween;
  45727. }
  45728. }
  45729. declare module "babylonjs/Bones/index" {
  45730. export * from "babylonjs/Bones/bone";
  45731. export * from "babylonjs/Bones/boneIKController";
  45732. export * from "babylonjs/Bones/boneLookController";
  45733. export * from "babylonjs/Bones/skeleton";
  45734. }
  45735. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45736. import { Nullable } from "babylonjs/types";
  45737. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45738. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45739. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45740. /**
  45741. * Manage the gamepad inputs to control an arc rotate camera.
  45742. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45743. */
  45744. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45745. /**
  45746. * Defines the camera the input is attached to.
  45747. */
  45748. camera: ArcRotateCamera;
  45749. /**
  45750. * Defines the gamepad the input is gathering event from.
  45751. */
  45752. gamepad: Nullable<Gamepad>;
  45753. /**
  45754. * Defines the gamepad rotation sensiblity.
  45755. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45756. */
  45757. gamepadRotationSensibility: number;
  45758. /**
  45759. * Defines the gamepad move sensiblity.
  45760. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45761. */
  45762. gamepadMoveSensibility: number;
  45763. private _yAxisScale;
  45764. /**
  45765. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45766. */
  45767. get invertYAxis(): boolean;
  45768. set invertYAxis(value: boolean);
  45769. private _onGamepadConnectedObserver;
  45770. private _onGamepadDisconnectedObserver;
  45771. /**
  45772. * Attach the input controls to a specific dom element to get the input from.
  45773. * @param element Defines the element the controls should be listened from
  45774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45775. */
  45776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45777. /**
  45778. * Detach the current controls from the specified dom element.
  45779. * @param element Defines the element to stop listening the inputs from
  45780. */
  45781. detachControl(element: Nullable<HTMLElement>): void;
  45782. /**
  45783. * Update the current camera state depending on the inputs that have been used this frame.
  45784. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45785. */
  45786. checkInputs(): void;
  45787. /**
  45788. * Gets the class name of the current intput.
  45789. * @returns the class name
  45790. */
  45791. getClassName(): string;
  45792. /**
  45793. * Get the friendly name associated with the input class.
  45794. * @returns the input friendly name
  45795. */
  45796. getSimpleName(): string;
  45797. }
  45798. }
  45799. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45800. import { Nullable } from "babylonjs/types";
  45801. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45802. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45803. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45804. interface ArcRotateCameraInputsManager {
  45805. /**
  45806. * Add orientation input support to the input manager.
  45807. * @returns the current input manager
  45808. */
  45809. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45810. }
  45811. }
  45812. /**
  45813. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45814. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45815. */
  45816. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45817. /**
  45818. * Defines the camera the input is attached to.
  45819. */
  45820. camera: ArcRotateCamera;
  45821. /**
  45822. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45823. */
  45824. alphaCorrection: number;
  45825. /**
  45826. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45827. */
  45828. gammaCorrection: number;
  45829. private _alpha;
  45830. private _gamma;
  45831. private _dirty;
  45832. private _deviceOrientationHandler;
  45833. /**
  45834. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45835. */
  45836. constructor();
  45837. /**
  45838. * Attach the input controls to a specific dom element to get the input from.
  45839. * @param element Defines the element the controls should be listened from
  45840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45841. */
  45842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45843. /** @hidden */
  45844. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45845. /**
  45846. * Update the current camera state depending on the inputs that have been used this frame.
  45847. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45848. */
  45849. checkInputs(): void;
  45850. /**
  45851. * Detach the current controls from the specified dom element.
  45852. * @param element Defines the element to stop listening the inputs from
  45853. */
  45854. detachControl(element: Nullable<HTMLElement>): void;
  45855. /**
  45856. * Gets the class name of the current intput.
  45857. * @returns the class name
  45858. */
  45859. getClassName(): string;
  45860. /**
  45861. * Get the friendly name associated with the input class.
  45862. * @returns the input friendly name
  45863. */
  45864. getSimpleName(): string;
  45865. }
  45866. }
  45867. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45868. import { Nullable } from "babylonjs/types";
  45869. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45870. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45871. /**
  45872. * Listen to mouse events to control the camera.
  45873. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45874. */
  45875. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45876. /**
  45877. * Defines the camera the input is attached to.
  45878. */
  45879. camera: FlyCamera;
  45880. /**
  45881. * Defines if touch is enabled. (Default is true.)
  45882. */
  45883. touchEnabled: boolean;
  45884. /**
  45885. * Defines the buttons associated with the input to handle camera rotation.
  45886. */
  45887. buttons: number[];
  45888. /**
  45889. * Assign buttons for Yaw control.
  45890. */
  45891. buttonsYaw: number[];
  45892. /**
  45893. * Assign buttons for Pitch control.
  45894. */
  45895. buttonsPitch: number[];
  45896. /**
  45897. * Assign buttons for Roll control.
  45898. */
  45899. buttonsRoll: number[];
  45900. /**
  45901. * Detect if any button is being pressed while mouse is moved.
  45902. * -1 = Mouse locked.
  45903. * 0 = Left button.
  45904. * 1 = Middle Button.
  45905. * 2 = Right Button.
  45906. */
  45907. activeButton: number;
  45908. /**
  45909. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45910. * Higher values reduce its sensitivity.
  45911. */
  45912. angularSensibility: number;
  45913. private _observer;
  45914. private _rollObserver;
  45915. private previousPosition;
  45916. private noPreventDefault;
  45917. private element;
  45918. /**
  45919. * Listen to mouse events to control the camera.
  45920. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45921. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45922. */
  45923. constructor(touchEnabled?: boolean);
  45924. /**
  45925. * Attach the mouse control to the HTML DOM element.
  45926. * @param element Defines the element that listens to the input events.
  45927. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45928. */
  45929. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45930. /**
  45931. * Detach the current controls from the specified dom element.
  45932. * @param element Defines the element to stop listening the inputs from
  45933. */
  45934. detachControl(element: Nullable<HTMLElement>): void;
  45935. /**
  45936. * Gets the class name of the current input.
  45937. * @returns the class name.
  45938. */
  45939. getClassName(): string;
  45940. /**
  45941. * Get the friendly name associated with the input class.
  45942. * @returns the input's friendly name.
  45943. */
  45944. getSimpleName(): string;
  45945. private _pointerInput;
  45946. private _onMouseMove;
  45947. /**
  45948. * Rotate camera by mouse offset.
  45949. */
  45950. private rotateCamera;
  45951. }
  45952. }
  45953. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45954. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45955. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45956. /**
  45957. * Default Inputs manager for the FlyCamera.
  45958. * It groups all the default supported inputs for ease of use.
  45959. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45960. */
  45961. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45962. /**
  45963. * Instantiates a new FlyCameraInputsManager.
  45964. * @param camera Defines the camera the inputs belong to.
  45965. */
  45966. constructor(camera: FlyCamera);
  45967. /**
  45968. * Add keyboard input support to the input manager.
  45969. * @returns the new FlyCameraKeyboardMoveInput().
  45970. */
  45971. addKeyboard(): FlyCameraInputsManager;
  45972. /**
  45973. * Add mouse input support to the input manager.
  45974. * @param touchEnabled Enable touch screen support.
  45975. * @returns the new FlyCameraMouseInput().
  45976. */
  45977. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45978. }
  45979. }
  45980. declare module "babylonjs/Cameras/flyCamera" {
  45981. import { Scene } from "babylonjs/scene";
  45982. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45984. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45985. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45986. /**
  45987. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45988. * such as in a 3D Space Shooter or a Flight Simulator.
  45989. */
  45990. export class FlyCamera extends TargetCamera {
  45991. /**
  45992. * Define the collision ellipsoid of the camera.
  45993. * This is helpful for simulating a camera body, like a player's body.
  45994. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45995. */
  45996. ellipsoid: Vector3;
  45997. /**
  45998. * Define an offset for the position of the ellipsoid around the camera.
  45999. * This can be helpful if the camera is attached away from the player's body center,
  46000. * such as at its head.
  46001. */
  46002. ellipsoidOffset: Vector3;
  46003. /**
  46004. * Enable or disable collisions of the camera with the rest of the scene objects.
  46005. */
  46006. checkCollisions: boolean;
  46007. /**
  46008. * Enable or disable gravity on the camera.
  46009. */
  46010. applyGravity: boolean;
  46011. /**
  46012. * Define the current direction the camera is moving to.
  46013. */
  46014. cameraDirection: Vector3;
  46015. /**
  46016. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  46017. * This overrides and empties cameraRotation.
  46018. */
  46019. rotationQuaternion: Quaternion;
  46020. /**
  46021. * Track Roll to maintain the wanted Rolling when looking around.
  46022. */
  46023. _trackRoll: number;
  46024. /**
  46025. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  46026. */
  46027. rollCorrect: number;
  46028. /**
  46029. * Mimic a banked turn, Rolling the camera when Yawing.
  46030. * It's recommended to use rollCorrect = 10 for faster banking correction.
  46031. */
  46032. bankedTurn: boolean;
  46033. /**
  46034. * Limit in radians for how much Roll banking will add. (Default: 90°)
  46035. */
  46036. bankedTurnLimit: number;
  46037. /**
  46038. * Value of 0 disables the banked Roll.
  46039. * Value of 1 is equal to the Yaw angle in radians.
  46040. */
  46041. bankedTurnMultiplier: number;
  46042. /**
  46043. * The inputs manager loads all the input sources, such as keyboard and mouse.
  46044. */
  46045. inputs: FlyCameraInputsManager;
  46046. /**
  46047. * Gets the input sensibility for mouse input.
  46048. * Higher values reduce sensitivity.
  46049. */
  46050. get angularSensibility(): number;
  46051. /**
  46052. * Sets the input sensibility for a mouse input.
  46053. * Higher values reduce sensitivity.
  46054. */
  46055. set angularSensibility(value: number);
  46056. /**
  46057. * Get the keys for camera movement forward.
  46058. */
  46059. get keysForward(): number[];
  46060. /**
  46061. * Set the keys for camera movement forward.
  46062. */
  46063. set keysForward(value: number[]);
  46064. /**
  46065. * Get the keys for camera movement backward.
  46066. */
  46067. get keysBackward(): number[];
  46068. set keysBackward(value: number[]);
  46069. /**
  46070. * Get the keys for camera movement up.
  46071. */
  46072. get keysUp(): number[];
  46073. /**
  46074. * Set the keys for camera movement up.
  46075. */
  46076. set keysUp(value: number[]);
  46077. /**
  46078. * Get the keys for camera movement down.
  46079. */
  46080. get keysDown(): number[];
  46081. /**
  46082. * Set the keys for camera movement down.
  46083. */
  46084. set keysDown(value: number[]);
  46085. /**
  46086. * Get the keys for camera movement left.
  46087. */
  46088. get keysLeft(): number[];
  46089. /**
  46090. * Set the keys for camera movement left.
  46091. */
  46092. set keysLeft(value: number[]);
  46093. /**
  46094. * Set the keys for camera movement right.
  46095. */
  46096. get keysRight(): number[];
  46097. /**
  46098. * Set the keys for camera movement right.
  46099. */
  46100. set keysRight(value: number[]);
  46101. /**
  46102. * Event raised when the camera collides with a mesh in the scene.
  46103. */
  46104. onCollide: (collidedMesh: AbstractMesh) => void;
  46105. private _collider;
  46106. private _needMoveForGravity;
  46107. private _oldPosition;
  46108. private _diffPosition;
  46109. private _newPosition;
  46110. /** @hidden */
  46111. _localDirection: Vector3;
  46112. /** @hidden */
  46113. _transformedDirection: Vector3;
  46114. /**
  46115. * Instantiates a FlyCamera.
  46116. * This is a flying camera, designed for 3D movement and rotation in all directions,
  46117. * such as in a 3D Space Shooter or a Flight Simulator.
  46118. * @param name Define the name of the camera in the scene.
  46119. * @param position Define the starting position of the camera in the scene.
  46120. * @param scene Define the scene the camera belongs to.
  46121. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  46122. */
  46123. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46124. /**
  46125. * Attach a control to the HTML DOM element.
  46126. * @param element Defines the element that listens to the input events.
  46127. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  46128. */
  46129. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46130. /**
  46131. * Detach a control from the HTML DOM element.
  46132. * The camera will stop reacting to that input.
  46133. * @param element Defines the element that listens to the input events.
  46134. */
  46135. detachControl(element: HTMLElement): void;
  46136. private _collisionMask;
  46137. /**
  46138. * Get the mask that the camera ignores in collision events.
  46139. */
  46140. get collisionMask(): number;
  46141. /**
  46142. * Set the mask that the camera ignores in collision events.
  46143. */
  46144. set collisionMask(mask: number);
  46145. /** @hidden */
  46146. _collideWithWorld(displacement: Vector3): void;
  46147. /** @hidden */
  46148. private _onCollisionPositionChange;
  46149. /** @hidden */
  46150. _checkInputs(): void;
  46151. /** @hidden */
  46152. _decideIfNeedsToMove(): boolean;
  46153. /** @hidden */
  46154. _updatePosition(): void;
  46155. /**
  46156. * Restore the Roll to its target value at the rate specified.
  46157. * @param rate - Higher means slower restoring.
  46158. * @hidden
  46159. */
  46160. restoreRoll(rate: number): void;
  46161. /**
  46162. * Destroy the camera and release the current resources held by it.
  46163. */
  46164. dispose(): void;
  46165. /**
  46166. * Get the current object class name.
  46167. * @returns the class name.
  46168. */
  46169. getClassName(): string;
  46170. }
  46171. }
  46172. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  46173. import { Nullable } from "babylonjs/types";
  46174. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46175. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  46176. /**
  46177. * Listen to keyboard events to control the camera.
  46178. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46179. */
  46180. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  46181. /**
  46182. * Defines the camera the input is attached to.
  46183. */
  46184. camera: FlyCamera;
  46185. /**
  46186. * The list of keyboard keys used to control the forward move of the camera.
  46187. */
  46188. keysForward: number[];
  46189. /**
  46190. * The list of keyboard keys used to control the backward move of the camera.
  46191. */
  46192. keysBackward: number[];
  46193. /**
  46194. * The list of keyboard keys used to control the forward move of the camera.
  46195. */
  46196. keysUp: number[];
  46197. /**
  46198. * The list of keyboard keys used to control the backward move of the camera.
  46199. */
  46200. keysDown: number[];
  46201. /**
  46202. * The list of keyboard keys used to control the right strafe move of the camera.
  46203. */
  46204. keysRight: number[];
  46205. /**
  46206. * The list of keyboard keys used to control the left strafe move of the camera.
  46207. */
  46208. keysLeft: number[];
  46209. private _keys;
  46210. private _onCanvasBlurObserver;
  46211. private _onKeyboardObserver;
  46212. private _engine;
  46213. private _scene;
  46214. /**
  46215. * Attach the input controls to a specific dom element to get the input from.
  46216. * @param element Defines the element the controls should be listened from
  46217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46218. */
  46219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46220. /**
  46221. * Detach the current controls from the specified dom element.
  46222. * @param element Defines the element to stop listening the inputs from
  46223. */
  46224. detachControl(element: Nullable<HTMLElement>): void;
  46225. /**
  46226. * Gets the class name of the current intput.
  46227. * @returns the class name
  46228. */
  46229. getClassName(): string;
  46230. /** @hidden */
  46231. _onLostFocus(e: FocusEvent): void;
  46232. /**
  46233. * Get the friendly name associated with the input class.
  46234. * @returns the input friendly name
  46235. */
  46236. getSimpleName(): string;
  46237. /**
  46238. * Update the current camera state depending on the inputs that have been used this frame.
  46239. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46240. */
  46241. checkInputs(): void;
  46242. }
  46243. }
  46244. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46245. import { Nullable } from "babylonjs/types";
  46246. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46247. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46248. /**
  46249. * Manage the mouse wheel inputs to control a follow camera.
  46250. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46251. */
  46252. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46253. /**
  46254. * Defines the camera the input is attached to.
  46255. */
  46256. camera: FollowCamera;
  46257. /**
  46258. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46259. */
  46260. axisControlRadius: boolean;
  46261. /**
  46262. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46263. */
  46264. axisControlHeight: boolean;
  46265. /**
  46266. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46267. */
  46268. axisControlRotation: boolean;
  46269. /**
  46270. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46271. * relation to mouseWheel events.
  46272. */
  46273. wheelPrecision: number;
  46274. /**
  46275. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46276. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46277. */
  46278. wheelDeltaPercentage: number;
  46279. private _wheel;
  46280. private _observer;
  46281. /**
  46282. * Attach the input controls to a specific dom element to get the input from.
  46283. * @param element Defines the element the controls should be listened from
  46284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46285. */
  46286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46287. /**
  46288. * Detach the current controls from the specified dom element.
  46289. * @param element Defines the element to stop listening the inputs from
  46290. */
  46291. detachControl(element: Nullable<HTMLElement>): void;
  46292. /**
  46293. * Gets the class name of the current intput.
  46294. * @returns the class name
  46295. */
  46296. getClassName(): string;
  46297. /**
  46298. * Get the friendly name associated with the input class.
  46299. * @returns the input friendly name
  46300. */
  46301. getSimpleName(): string;
  46302. }
  46303. }
  46304. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46305. import { Nullable } from "babylonjs/types";
  46306. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46307. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46308. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46309. /**
  46310. * Manage the pointers inputs to control an follow camera.
  46311. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46312. */
  46313. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46314. /**
  46315. * Defines the camera the input is attached to.
  46316. */
  46317. camera: FollowCamera;
  46318. /**
  46319. * Gets the class name of the current input.
  46320. * @returns the class name
  46321. */
  46322. getClassName(): string;
  46323. /**
  46324. * Defines the pointer angular sensibility along the X axis or how fast is
  46325. * the camera rotating.
  46326. * A negative number will reverse the axis direction.
  46327. */
  46328. angularSensibilityX: number;
  46329. /**
  46330. * Defines the pointer angular sensibility along the Y axis or how fast is
  46331. * the camera rotating.
  46332. * A negative number will reverse the axis direction.
  46333. */
  46334. angularSensibilityY: number;
  46335. /**
  46336. * Defines the pointer pinch precision or how fast is the camera zooming.
  46337. * A negative number will reverse the axis direction.
  46338. */
  46339. pinchPrecision: number;
  46340. /**
  46341. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46342. * from 0.
  46343. * It defines the percentage of current camera.radius to use as delta when
  46344. * pinch zoom is used.
  46345. */
  46346. pinchDeltaPercentage: number;
  46347. /**
  46348. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46349. */
  46350. axisXControlRadius: boolean;
  46351. /**
  46352. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46353. */
  46354. axisXControlHeight: boolean;
  46355. /**
  46356. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46357. */
  46358. axisXControlRotation: boolean;
  46359. /**
  46360. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46361. */
  46362. axisYControlRadius: boolean;
  46363. /**
  46364. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46365. */
  46366. axisYControlHeight: boolean;
  46367. /**
  46368. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46369. */
  46370. axisYControlRotation: boolean;
  46371. /**
  46372. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46373. */
  46374. axisPinchControlRadius: boolean;
  46375. /**
  46376. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46377. */
  46378. axisPinchControlHeight: boolean;
  46379. /**
  46380. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46381. */
  46382. axisPinchControlRotation: boolean;
  46383. /**
  46384. * Log error messages if basic misconfiguration has occurred.
  46385. */
  46386. warningEnable: boolean;
  46387. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46388. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46389. private _warningCounter;
  46390. private _warning;
  46391. }
  46392. }
  46393. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46394. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46395. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46396. /**
  46397. * Default Inputs manager for the FollowCamera.
  46398. * It groups all the default supported inputs for ease of use.
  46399. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46400. */
  46401. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46402. /**
  46403. * Instantiates a new FollowCameraInputsManager.
  46404. * @param camera Defines the camera the inputs belong to
  46405. */
  46406. constructor(camera: FollowCamera);
  46407. /**
  46408. * Add keyboard input support to the input manager.
  46409. * @returns the current input manager
  46410. */
  46411. addKeyboard(): FollowCameraInputsManager;
  46412. /**
  46413. * Add mouse wheel input support to the input manager.
  46414. * @returns the current input manager
  46415. */
  46416. addMouseWheel(): FollowCameraInputsManager;
  46417. /**
  46418. * Add pointers input support to the input manager.
  46419. * @returns the current input manager
  46420. */
  46421. addPointers(): FollowCameraInputsManager;
  46422. /**
  46423. * Add orientation input support to the input manager.
  46424. * @returns the current input manager
  46425. */
  46426. addVRDeviceOrientation(): FollowCameraInputsManager;
  46427. }
  46428. }
  46429. declare module "babylonjs/Cameras/followCamera" {
  46430. import { Nullable } from "babylonjs/types";
  46431. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46432. import { Scene } from "babylonjs/scene";
  46433. import { Vector3 } from "babylonjs/Maths/math.vector";
  46434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46435. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46436. /**
  46437. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46438. * an arc rotate version arcFollowCamera are available.
  46439. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46440. */
  46441. export class FollowCamera extends TargetCamera {
  46442. /**
  46443. * Distance the follow camera should follow an object at
  46444. */
  46445. radius: number;
  46446. /**
  46447. * Minimum allowed distance of the camera to the axis of rotation
  46448. * (The camera can not get closer).
  46449. * This can help limiting how the Camera is able to move in the scene.
  46450. */
  46451. lowerRadiusLimit: Nullable<number>;
  46452. /**
  46453. * Maximum allowed distance of the camera to the axis of rotation
  46454. * (The camera can not get further).
  46455. * This can help limiting how the Camera is able to move in the scene.
  46456. */
  46457. upperRadiusLimit: Nullable<number>;
  46458. /**
  46459. * Define a rotation offset between the camera and the object it follows
  46460. */
  46461. rotationOffset: number;
  46462. /**
  46463. * Minimum allowed angle to camera position relative to target object.
  46464. * This can help limiting how the Camera is able to move in the scene.
  46465. */
  46466. lowerRotationOffsetLimit: Nullable<number>;
  46467. /**
  46468. * Maximum allowed angle to camera position relative to target object.
  46469. * This can help limiting how the Camera is able to move in the scene.
  46470. */
  46471. upperRotationOffsetLimit: Nullable<number>;
  46472. /**
  46473. * Define a height offset between the camera and the object it follows.
  46474. * It can help following an object from the top (like a car chaing a plane)
  46475. */
  46476. heightOffset: number;
  46477. /**
  46478. * Minimum allowed height of camera position relative to target object.
  46479. * This can help limiting how the Camera is able to move in the scene.
  46480. */
  46481. lowerHeightOffsetLimit: Nullable<number>;
  46482. /**
  46483. * Maximum allowed height of camera position relative to target object.
  46484. * This can help limiting how the Camera is able to move in the scene.
  46485. */
  46486. upperHeightOffsetLimit: Nullable<number>;
  46487. /**
  46488. * Define how fast the camera can accelerate to follow it s target.
  46489. */
  46490. cameraAcceleration: number;
  46491. /**
  46492. * Define the speed limit of the camera following an object.
  46493. */
  46494. maxCameraSpeed: number;
  46495. /**
  46496. * Define the target of the camera.
  46497. */
  46498. lockedTarget: Nullable<AbstractMesh>;
  46499. /**
  46500. * Defines the input associated with the camera.
  46501. */
  46502. inputs: FollowCameraInputsManager;
  46503. /**
  46504. * Instantiates the follow camera.
  46505. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46506. * @param name Define the name of the camera in the scene
  46507. * @param position Define the position of the camera
  46508. * @param scene Define the scene the camera belong to
  46509. * @param lockedTarget Define the target of the camera
  46510. */
  46511. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46512. private _follow;
  46513. /**
  46514. * Attached controls to the current camera.
  46515. * @param element Defines the element the controls should be listened from
  46516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46517. */
  46518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46519. /**
  46520. * Detach the current controls from the camera.
  46521. * The camera will stop reacting to inputs.
  46522. * @param element Defines the element to stop listening the inputs from
  46523. */
  46524. detachControl(element: HTMLElement): void;
  46525. /** @hidden */
  46526. _checkInputs(): void;
  46527. private _checkLimits;
  46528. /**
  46529. * Gets the camera class name.
  46530. * @returns the class name
  46531. */
  46532. getClassName(): string;
  46533. }
  46534. /**
  46535. * Arc Rotate version of the follow camera.
  46536. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46537. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46538. */
  46539. export class ArcFollowCamera extends TargetCamera {
  46540. /** The longitudinal angle of the camera */
  46541. alpha: number;
  46542. /** The latitudinal angle of the camera */
  46543. beta: number;
  46544. /** The radius of the camera from its target */
  46545. radius: number;
  46546. private _cartesianCoordinates;
  46547. /** Define the camera target (the mesh it should follow) */
  46548. private _meshTarget;
  46549. /**
  46550. * Instantiates a new ArcFollowCamera
  46551. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46552. * @param name Define the name of the camera
  46553. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46554. * @param beta Define the rotation angle of the camera around the elevation axis
  46555. * @param radius Define the radius of the camera from its target point
  46556. * @param target Define the target of the camera
  46557. * @param scene Define the scene the camera belongs to
  46558. */
  46559. constructor(name: string,
  46560. /** The longitudinal angle of the camera */
  46561. alpha: number,
  46562. /** The latitudinal angle of the camera */
  46563. beta: number,
  46564. /** The radius of the camera from its target */
  46565. radius: number,
  46566. /** Define the camera target (the mesh it should follow) */
  46567. target: Nullable<AbstractMesh>, scene: Scene);
  46568. private _follow;
  46569. /** @hidden */
  46570. _checkInputs(): void;
  46571. /**
  46572. * Returns the class name of the object.
  46573. * It is mostly used internally for serialization purposes.
  46574. */
  46575. getClassName(): string;
  46576. }
  46577. }
  46578. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46579. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46580. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46581. import { Nullable } from "babylonjs/types";
  46582. /**
  46583. * Manage the keyboard inputs to control the movement of a follow camera.
  46584. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46585. */
  46586. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46587. /**
  46588. * Defines the camera the input is attached to.
  46589. */
  46590. camera: FollowCamera;
  46591. /**
  46592. * Defines the list of key codes associated with the up action (increase heightOffset)
  46593. */
  46594. keysHeightOffsetIncr: number[];
  46595. /**
  46596. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46597. */
  46598. keysHeightOffsetDecr: number[];
  46599. /**
  46600. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46601. */
  46602. keysHeightOffsetModifierAlt: boolean;
  46603. /**
  46604. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46605. */
  46606. keysHeightOffsetModifierCtrl: boolean;
  46607. /**
  46608. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46609. */
  46610. keysHeightOffsetModifierShift: boolean;
  46611. /**
  46612. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46613. */
  46614. keysRotationOffsetIncr: number[];
  46615. /**
  46616. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46617. */
  46618. keysRotationOffsetDecr: number[];
  46619. /**
  46620. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46621. */
  46622. keysRotationOffsetModifierAlt: boolean;
  46623. /**
  46624. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46625. */
  46626. keysRotationOffsetModifierCtrl: boolean;
  46627. /**
  46628. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46629. */
  46630. keysRotationOffsetModifierShift: boolean;
  46631. /**
  46632. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46633. */
  46634. keysRadiusIncr: number[];
  46635. /**
  46636. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46637. */
  46638. keysRadiusDecr: number[];
  46639. /**
  46640. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46641. */
  46642. keysRadiusModifierAlt: boolean;
  46643. /**
  46644. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46645. */
  46646. keysRadiusModifierCtrl: boolean;
  46647. /**
  46648. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46649. */
  46650. keysRadiusModifierShift: boolean;
  46651. /**
  46652. * Defines the rate of change of heightOffset.
  46653. */
  46654. heightSensibility: number;
  46655. /**
  46656. * Defines the rate of change of rotationOffset.
  46657. */
  46658. rotationSensibility: number;
  46659. /**
  46660. * Defines the rate of change of radius.
  46661. */
  46662. radiusSensibility: number;
  46663. private _keys;
  46664. private _ctrlPressed;
  46665. private _altPressed;
  46666. private _shiftPressed;
  46667. private _onCanvasBlurObserver;
  46668. private _onKeyboardObserver;
  46669. private _engine;
  46670. private _scene;
  46671. /**
  46672. * Attach the input controls to a specific dom element to get the input from.
  46673. * @param element Defines the element the controls should be listened from
  46674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46675. */
  46676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46677. /**
  46678. * Detach the current controls from the specified dom element.
  46679. * @param element Defines the element to stop listening the inputs from
  46680. */
  46681. detachControl(element: Nullable<HTMLElement>): void;
  46682. /**
  46683. * Update the current camera state depending on the inputs that have been used this frame.
  46684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46685. */
  46686. checkInputs(): void;
  46687. /**
  46688. * Gets the class name of the current input.
  46689. * @returns the class name
  46690. */
  46691. getClassName(): string;
  46692. /**
  46693. * Get the friendly name associated with the input class.
  46694. * @returns the input friendly name
  46695. */
  46696. getSimpleName(): string;
  46697. /**
  46698. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46699. * allow modification of the heightOffset value.
  46700. */
  46701. private _modifierHeightOffset;
  46702. /**
  46703. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46704. * allow modification of the rotationOffset value.
  46705. */
  46706. private _modifierRotationOffset;
  46707. /**
  46708. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46709. * allow modification of the radius value.
  46710. */
  46711. private _modifierRadius;
  46712. }
  46713. }
  46714. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46715. import { Nullable } from "babylonjs/types";
  46716. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46717. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46718. import { Observable } from "babylonjs/Misc/observable";
  46719. module "babylonjs/Cameras/freeCameraInputsManager" {
  46720. interface FreeCameraInputsManager {
  46721. /**
  46722. * @hidden
  46723. */
  46724. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46725. /**
  46726. * Add orientation input support to the input manager.
  46727. * @returns the current input manager
  46728. */
  46729. addDeviceOrientation(): FreeCameraInputsManager;
  46730. }
  46731. }
  46732. /**
  46733. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46734. * Screen rotation is taken into account.
  46735. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46736. */
  46737. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46738. private _camera;
  46739. private _screenOrientationAngle;
  46740. private _constantTranform;
  46741. private _screenQuaternion;
  46742. private _alpha;
  46743. private _beta;
  46744. private _gamma;
  46745. /**
  46746. * Can be used to detect if a device orientation sensor is available on a device
  46747. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46748. * @returns a promise that will resolve on orientation change
  46749. */
  46750. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46751. /**
  46752. * @hidden
  46753. */
  46754. _onDeviceOrientationChangedObservable: Observable<void>;
  46755. /**
  46756. * Instantiates a new input
  46757. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46758. */
  46759. constructor();
  46760. /**
  46761. * Define the camera controlled by the input.
  46762. */
  46763. get camera(): FreeCamera;
  46764. set camera(camera: FreeCamera);
  46765. /**
  46766. * Attach the input controls to a specific dom element to get the input from.
  46767. * @param element Defines the element the controls should be listened from
  46768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46769. */
  46770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46771. private _orientationChanged;
  46772. private _deviceOrientation;
  46773. /**
  46774. * Detach the current controls from the specified dom element.
  46775. * @param element Defines the element to stop listening the inputs from
  46776. */
  46777. detachControl(element: Nullable<HTMLElement>): void;
  46778. /**
  46779. * Update the current camera state depending on the inputs that have been used this frame.
  46780. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46781. */
  46782. checkInputs(): void;
  46783. /**
  46784. * Gets the class name of the current intput.
  46785. * @returns the class name
  46786. */
  46787. getClassName(): string;
  46788. /**
  46789. * Get the friendly name associated with the input class.
  46790. * @returns the input friendly name
  46791. */
  46792. getSimpleName(): string;
  46793. }
  46794. }
  46795. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46796. import { Nullable } from "babylonjs/types";
  46797. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46798. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46799. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46800. /**
  46801. * Manage the gamepad inputs to control a free camera.
  46802. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46803. */
  46804. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46805. /**
  46806. * Define the camera the input is attached to.
  46807. */
  46808. camera: FreeCamera;
  46809. /**
  46810. * Define the Gamepad controlling the input
  46811. */
  46812. gamepad: Nullable<Gamepad>;
  46813. /**
  46814. * Defines the gamepad rotation sensiblity.
  46815. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46816. */
  46817. gamepadAngularSensibility: number;
  46818. /**
  46819. * Defines the gamepad move sensiblity.
  46820. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46821. */
  46822. gamepadMoveSensibility: number;
  46823. private _yAxisScale;
  46824. /**
  46825. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46826. */
  46827. get invertYAxis(): boolean;
  46828. set invertYAxis(value: boolean);
  46829. private _onGamepadConnectedObserver;
  46830. private _onGamepadDisconnectedObserver;
  46831. private _cameraTransform;
  46832. private _deltaTransform;
  46833. private _vector3;
  46834. private _vector2;
  46835. /**
  46836. * Attach the input controls to a specific dom element to get the input from.
  46837. * @param element Defines the element the controls should be listened from
  46838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46839. */
  46840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46841. /**
  46842. * Detach the current controls from the specified dom element.
  46843. * @param element Defines the element to stop listening the inputs from
  46844. */
  46845. detachControl(element: Nullable<HTMLElement>): void;
  46846. /**
  46847. * Update the current camera state depending on the inputs that have been used this frame.
  46848. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46849. */
  46850. checkInputs(): void;
  46851. /**
  46852. * Gets the class name of the current intput.
  46853. * @returns the class name
  46854. */
  46855. getClassName(): string;
  46856. /**
  46857. * Get the friendly name associated with the input class.
  46858. * @returns the input friendly name
  46859. */
  46860. getSimpleName(): string;
  46861. }
  46862. }
  46863. declare module "babylonjs/Misc/virtualJoystick" {
  46864. import { Nullable } from "babylonjs/types";
  46865. import { Vector3 } from "babylonjs/Maths/math.vector";
  46866. /**
  46867. * Defines the potential axis of a Joystick
  46868. */
  46869. export enum JoystickAxis {
  46870. /** X axis */
  46871. X = 0,
  46872. /** Y axis */
  46873. Y = 1,
  46874. /** Z axis */
  46875. Z = 2
  46876. }
  46877. /**
  46878. * Represents the different customization options available
  46879. * for VirtualJoystick
  46880. */
  46881. interface VirtualJoystickCustomizations {
  46882. /**
  46883. * Size of the joystick's puck
  46884. */
  46885. puckSize: number;
  46886. /**
  46887. * Size of the joystick's container
  46888. */
  46889. containerSize: number;
  46890. /**
  46891. * Color of the joystick && puck
  46892. */
  46893. color: string;
  46894. /**
  46895. * Image URL for the joystick's puck
  46896. */
  46897. puckImage?: string;
  46898. /**
  46899. * Image URL for the joystick's container
  46900. */
  46901. containerImage?: string;
  46902. /**
  46903. * Defines the unmoving position of the joystick container
  46904. */
  46905. position?: {
  46906. x: number;
  46907. y: number;
  46908. };
  46909. /**
  46910. * Defines whether or not the joystick container is always visible
  46911. */
  46912. alwaysVisible: boolean;
  46913. /**
  46914. * Defines whether or not to limit the movement of the puck to the joystick's container
  46915. */
  46916. limitToContainer: boolean;
  46917. }
  46918. /**
  46919. * Class used to define virtual joystick (used in touch mode)
  46920. */
  46921. export class VirtualJoystick {
  46922. /**
  46923. * Gets or sets a boolean indicating that left and right values must be inverted
  46924. */
  46925. reverseLeftRight: boolean;
  46926. /**
  46927. * Gets or sets a boolean indicating that up and down values must be inverted
  46928. */
  46929. reverseUpDown: boolean;
  46930. /**
  46931. * Gets the offset value for the position (ie. the change of the position value)
  46932. */
  46933. deltaPosition: Vector3;
  46934. /**
  46935. * Gets a boolean indicating if the virtual joystick was pressed
  46936. */
  46937. pressed: boolean;
  46938. /**
  46939. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46940. */
  46941. static Canvas: Nullable<HTMLCanvasElement>;
  46942. /**
  46943. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46944. */
  46945. limitToContainer: boolean;
  46946. private static _globalJoystickIndex;
  46947. private static _alwaysVisibleSticks;
  46948. private static vjCanvasContext;
  46949. private static vjCanvasWidth;
  46950. private static vjCanvasHeight;
  46951. private static halfWidth;
  46952. private static _GetDefaultOptions;
  46953. private _action;
  46954. private _axisTargetedByLeftAndRight;
  46955. private _axisTargetedByUpAndDown;
  46956. private _joystickSensibility;
  46957. private _inversedSensibility;
  46958. private _joystickPointerID;
  46959. private _joystickColor;
  46960. private _joystickPointerPos;
  46961. private _joystickPreviousPointerPos;
  46962. private _joystickPointerStartPos;
  46963. private _deltaJoystickVector;
  46964. private _leftJoystick;
  46965. private _touches;
  46966. private _joystickPosition;
  46967. private _alwaysVisible;
  46968. private _puckImage;
  46969. private _containerImage;
  46970. private _joystickPuckSize;
  46971. private _joystickContainerSize;
  46972. private _clearPuckSize;
  46973. private _clearContainerSize;
  46974. private _clearPuckSizeOffset;
  46975. private _clearContainerSizeOffset;
  46976. private _onPointerDownHandlerRef;
  46977. private _onPointerMoveHandlerRef;
  46978. private _onPointerUpHandlerRef;
  46979. private _onResize;
  46980. /**
  46981. * Creates a new virtual joystick
  46982. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46983. * @param customizations Defines the options we want to customize the VirtualJoystick
  46984. */
  46985. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46986. /**
  46987. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46988. * @param newJoystickSensibility defines the new sensibility
  46989. */
  46990. setJoystickSensibility(newJoystickSensibility: number): void;
  46991. private _onPointerDown;
  46992. private _onPointerMove;
  46993. private _onPointerUp;
  46994. /**
  46995. * Change the color of the virtual joystick
  46996. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46997. */
  46998. setJoystickColor(newColor: string): void;
  46999. /**
  47000. * Size of the joystick's container
  47001. */
  47002. set containerSize(newSize: number);
  47003. get containerSize(): number;
  47004. /**
  47005. * Size of the joystick's puck
  47006. */
  47007. set puckSize(newSize: number);
  47008. get puckSize(): number;
  47009. /**
  47010. * Clears the set position of the joystick
  47011. */
  47012. clearPosition(): void;
  47013. /**
  47014. * Defines whether or not the joystick container is always visible
  47015. */
  47016. set alwaysVisible(value: boolean);
  47017. get alwaysVisible(): boolean;
  47018. /**
  47019. * Sets the constant position of the Joystick container
  47020. * @param x X axis coordinate
  47021. * @param y Y axis coordinate
  47022. */
  47023. setPosition(x: number, y: number): void;
  47024. /**
  47025. * Defines a callback to call when the joystick is touched
  47026. * @param action defines the callback
  47027. */
  47028. setActionOnTouch(action: () => any): void;
  47029. /**
  47030. * Defines which axis you'd like to control for left & right
  47031. * @param axis defines the axis to use
  47032. */
  47033. setAxisForLeftRight(axis: JoystickAxis): void;
  47034. /**
  47035. * Defines which axis you'd like to control for up & down
  47036. * @param axis defines the axis to use
  47037. */
  47038. setAxisForUpDown(axis: JoystickAxis): void;
  47039. /**
  47040. * Clears the canvas from the previous puck / container draw
  47041. */
  47042. private _clearPreviousDraw;
  47043. /**
  47044. * Loads `urlPath` to be used for the container's image
  47045. * @param urlPath defines the urlPath of an image to use
  47046. */
  47047. setContainerImage(urlPath: string): void;
  47048. /**
  47049. * Loads `urlPath` to be used for the puck's image
  47050. * @param urlPath defines the urlPath of an image to use
  47051. */
  47052. setPuckImage(urlPath: string): void;
  47053. /**
  47054. * Draws the Virtual Joystick's container
  47055. */
  47056. private _drawContainer;
  47057. /**
  47058. * Draws the Virtual Joystick's puck
  47059. */
  47060. private _drawPuck;
  47061. private _drawVirtualJoystick;
  47062. /**
  47063. * Release internal HTML canvas
  47064. */
  47065. releaseCanvas(): void;
  47066. }
  47067. }
  47068. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  47069. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  47070. import { Nullable } from "babylonjs/types";
  47071. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47072. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47073. module "babylonjs/Cameras/freeCameraInputsManager" {
  47074. interface FreeCameraInputsManager {
  47075. /**
  47076. * Add virtual joystick input support to the input manager.
  47077. * @returns the current input manager
  47078. */
  47079. addVirtualJoystick(): FreeCameraInputsManager;
  47080. }
  47081. }
  47082. /**
  47083. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  47084. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47085. */
  47086. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  47087. /**
  47088. * Defines the camera the input is attached to.
  47089. */
  47090. camera: FreeCamera;
  47091. private _leftjoystick;
  47092. private _rightjoystick;
  47093. /**
  47094. * Gets the left stick of the virtual joystick.
  47095. * @returns The virtual Joystick
  47096. */
  47097. getLeftJoystick(): VirtualJoystick;
  47098. /**
  47099. * Gets the right stick of the virtual joystick.
  47100. * @returns The virtual Joystick
  47101. */
  47102. getRightJoystick(): VirtualJoystick;
  47103. /**
  47104. * Update the current camera state depending on the inputs that have been used this frame.
  47105. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47106. */
  47107. checkInputs(): void;
  47108. /**
  47109. * Attach the input controls to a specific dom element to get the input from.
  47110. * @param element Defines the element the controls should be listened from
  47111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47112. */
  47113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47114. /**
  47115. * Detach the current controls from the specified dom element.
  47116. * @param element Defines the element to stop listening the inputs from
  47117. */
  47118. detachControl(element: Nullable<HTMLElement>): void;
  47119. /**
  47120. * Gets the class name of the current intput.
  47121. * @returns the class name
  47122. */
  47123. getClassName(): string;
  47124. /**
  47125. * Get the friendly name associated with the input class.
  47126. * @returns the input friendly name
  47127. */
  47128. getSimpleName(): string;
  47129. }
  47130. }
  47131. declare module "babylonjs/Cameras/Inputs/index" {
  47132. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  47133. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  47134. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  47135. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  47136. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47137. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  47138. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  47139. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  47140. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  47141. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  47142. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47143. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  47144. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  47145. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  47146. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  47147. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47148. }
  47149. declare module "babylonjs/Cameras/touchCamera" {
  47150. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47151. import { Scene } from "babylonjs/scene";
  47152. import { Vector3 } from "babylonjs/Maths/math.vector";
  47153. /**
  47154. * This represents a FPS type of camera controlled by touch.
  47155. * This is like a universal camera minus the Gamepad controls.
  47156. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47157. */
  47158. export class TouchCamera extends FreeCamera {
  47159. /**
  47160. * Defines the touch sensibility for rotation.
  47161. * The higher the faster.
  47162. */
  47163. get touchAngularSensibility(): number;
  47164. set touchAngularSensibility(value: number);
  47165. /**
  47166. * Defines the touch sensibility for move.
  47167. * The higher the faster.
  47168. */
  47169. get touchMoveSensibility(): number;
  47170. set touchMoveSensibility(value: number);
  47171. /**
  47172. * Instantiates a new touch camera.
  47173. * This represents a FPS type of camera controlled by touch.
  47174. * This is like a universal camera minus the Gamepad controls.
  47175. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47176. * @param name Define the name of the camera in the scene
  47177. * @param position Define the start position of the camera in the scene
  47178. * @param scene Define the scene the camera belongs to
  47179. */
  47180. constructor(name: string, position: Vector3, scene: Scene);
  47181. /**
  47182. * Gets the current object class name.
  47183. * @return the class name
  47184. */
  47185. getClassName(): string;
  47186. /** @hidden */
  47187. _setupInputs(): void;
  47188. }
  47189. }
  47190. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  47191. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47192. import { Scene } from "babylonjs/scene";
  47193. import { Vector3 } from "babylonjs/Maths/math.vector";
  47194. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47195. import { Axis } from "babylonjs/Maths/math.axis";
  47196. /**
  47197. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  47198. * being tilted forward or back and left or right.
  47199. */
  47200. export class DeviceOrientationCamera extends FreeCamera {
  47201. private _initialQuaternion;
  47202. private _quaternionCache;
  47203. private _tmpDragQuaternion;
  47204. private _disablePointerInputWhenUsingDeviceOrientation;
  47205. /**
  47206. * Creates a new device orientation camera
  47207. * @param name The name of the camera
  47208. * @param position The start position camera
  47209. * @param scene The scene the camera belongs to
  47210. */
  47211. constructor(name: string, position: Vector3, scene: Scene);
  47212. /**
  47213. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  47214. */
  47215. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  47216. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  47217. private _dragFactor;
  47218. /**
  47219. * Enabled turning on the y axis when the orientation sensor is active
  47220. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  47221. */
  47222. enableHorizontalDragging(dragFactor?: number): void;
  47223. /**
  47224. * Gets the current instance class name ("DeviceOrientationCamera").
  47225. * This helps avoiding instanceof at run time.
  47226. * @returns the class name
  47227. */
  47228. getClassName(): string;
  47229. /**
  47230. * @hidden
  47231. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  47232. */
  47233. _checkInputs(): void;
  47234. /**
  47235. * Reset the camera to its default orientation on the specified axis only.
  47236. * @param axis The axis to reset
  47237. */
  47238. resetToCurrentRotation(axis?: Axis): void;
  47239. }
  47240. }
  47241. declare module "babylonjs/Gamepads/xboxGamepad" {
  47242. import { Observable } from "babylonjs/Misc/observable";
  47243. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47244. /**
  47245. * Defines supported buttons for XBox360 compatible gamepads
  47246. */
  47247. export enum Xbox360Button {
  47248. /** A */
  47249. A = 0,
  47250. /** B */
  47251. B = 1,
  47252. /** X */
  47253. X = 2,
  47254. /** Y */
  47255. Y = 3,
  47256. /** Left button */
  47257. LB = 4,
  47258. /** Right button */
  47259. RB = 5,
  47260. /** Back */
  47261. Back = 8,
  47262. /** Start */
  47263. Start = 9,
  47264. /** Left stick */
  47265. LeftStick = 10,
  47266. /** Right stick */
  47267. RightStick = 11
  47268. }
  47269. /** Defines values for XBox360 DPad */
  47270. export enum Xbox360Dpad {
  47271. /** Up */
  47272. Up = 12,
  47273. /** Down */
  47274. Down = 13,
  47275. /** Left */
  47276. Left = 14,
  47277. /** Right */
  47278. Right = 15
  47279. }
  47280. /**
  47281. * Defines a XBox360 gamepad
  47282. */
  47283. export class Xbox360Pad extends Gamepad {
  47284. private _leftTrigger;
  47285. private _rightTrigger;
  47286. private _onlefttriggerchanged;
  47287. private _onrighttriggerchanged;
  47288. private _onbuttondown;
  47289. private _onbuttonup;
  47290. private _ondpaddown;
  47291. private _ondpadup;
  47292. /** Observable raised when a button is pressed */
  47293. onButtonDownObservable: Observable<Xbox360Button>;
  47294. /** Observable raised when a button is released */
  47295. onButtonUpObservable: Observable<Xbox360Button>;
  47296. /** Observable raised when a pad is pressed */
  47297. onPadDownObservable: Observable<Xbox360Dpad>;
  47298. /** Observable raised when a pad is released */
  47299. onPadUpObservable: Observable<Xbox360Dpad>;
  47300. private _buttonA;
  47301. private _buttonB;
  47302. private _buttonX;
  47303. private _buttonY;
  47304. private _buttonBack;
  47305. private _buttonStart;
  47306. private _buttonLB;
  47307. private _buttonRB;
  47308. private _buttonLeftStick;
  47309. private _buttonRightStick;
  47310. private _dPadUp;
  47311. private _dPadDown;
  47312. private _dPadLeft;
  47313. private _dPadRight;
  47314. private _isXboxOnePad;
  47315. /**
  47316. * Creates a new XBox360 gamepad object
  47317. * @param id defines the id of this gamepad
  47318. * @param index defines its index
  47319. * @param gamepad defines the internal HTML gamepad object
  47320. * @param xboxOne defines if it is a XBox One gamepad
  47321. */
  47322. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47323. /**
  47324. * Defines the callback to call when left trigger is pressed
  47325. * @param callback defines the callback to use
  47326. */
  47327. onlefttriggerchanged(callback: (value: number) => void): void;
  47328. /**
  47329. * Defines the callback to call when right trigger is pressed
  47330. * @param callback defines the callback to use
  47331. */
  47332. onrighttriggerchanged(callback: (value: number) => void): void;
  47333. /**
  47334. * Gets the left trigger value
  47335. */
  47336. get leftTrigger(): number;
  47337. /**
  47338. * Sets the left trigger value
  47339. */
  47340. set leftTrigger(newValue: number);
  47341. /**
  47342. * Gets the right trigger value
  47343. */
  47344. get rightTrigger(): number;
  47345. /**
  47346. * Sets the right trigger value
  47347. */
  47348. set rightTrigger(newValue: number);
  47349. /**
  47350. * Defines the callback to call when a button is pressed
  47351. * @param callback defines the callback to use
  47352. */
  47353. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47354. /**
  47355. * Defines the callback to call when a button is released
  47356. * @param callback defines the callback to use
  47357. */
  47358. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47359. /**
  47360. * Defines the callback to call when a pad is pressed
  47361. * @param callback defines the callback to use
  47362. */
  47363. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47364. /**
  47365. * Defines the callback to call when a pad is released
  47366. * @param callback defines the callback to use
  47367. */
  47368. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47369. private _setButtonValue;
  47370. private _setDPadValue;
  47371. /**
  47372. * Gets the value of the `A` button
  47373. */
  47374. get buttonA(): number;
  47375. /**
  47376. * Sets the value of the `A` button
  47377. */
  47378. set buttonA(value: number);
  47379. /**
  47380. * Gets the value of the `B` button
  47381. */
  47382. get buttonB(): number;
  47383. /**
  47384. * Sets the value of the `B` button
  47385. */
  47386. set buttonB(value: number);
  47387. /**
  47388. * Gets the value of the `X` button
  47389. */
  47390. get buttonX(): number;
  47391. /**
  47392. * Sets the value of the `X` button
  47393. */
  47394. set buttonX(value: number);
  47395. /**
  47396. * Gets the value of the `Y` button
  47397. */
  47398. get buttonY(): number;
  47399. /**
  47400. * Sets the value of the `Y` button
  47401. */
  47402. set buttonY(value: number);
  47403. /**
  47404. * Gets the value of the `Start` button
  47405. */
  47406. get buttonStart(): number;
  47407. /**
  47408. * Sets the value of the `Start` button
  47409. */
  47410. set buttonStart(value: number);
  47411. /**
  47412. * Gets the value of the `Back` button
  47413. */
  47414. get buttonBack(): number;
  47415. /**
  47416. * Sets the value of the `Back` button
  47417. */
  47418. set buttonBack(value: number);
  47419. /**
  47420. * Gets the value of the `Left` button
  47421. */
  47422. get buttonLB(): number;
  47423. /**
  47424. * Sets the value of the `Left` button
  47425. */
  47426. set buttonLB(value: number);
  47427. /**
  47428. * Gets the value of the `Right` button
  47429. */
  47430. get buttonRB(): number;
  47431. /**
  47432. * Sets the value of the `Right` button
  47433. */
  47434. set buttonRB(value: number);
  47435. /**
  47436. * Gets the value of the Left joystick
  47437. */
  47438. get buttonLeftStick(): number;
  47439. /**
  47440. * Sets the value of the Left joystick
  47441. */
  47442. set buttonLeftStick(value: number);
  47443. /**
  47444. * Gets the value of the Right joystick
  47445. */
  47446. get buttonRightStick(): number;
  47447. /**
  47448. * Sets the value of the Right joystick
  47449. */
  47450. set buttonRightStick(value: number);
  47451. /**
  47452. * Gets the value of D-pad up
  47453. */
  47454. get dPadUp(): number;
  47455. /**
  47456. * Sets the value of D-pad up
  47457. */
  47458. set dPadUp(value: number);
  47459. /**
  47460. * Gets the value of D-pad down
  47461. */
  47462. get dPadDown(): number;
  47463. /**
  47464. * Sets the value of D-pad down
  47465. */
  47466. set dPadDown(value: number);
  47467. /**
  47468. * Gets the value of D-pad left
  47469. */
  47470. get dPadLeft(): number;
  47471. /**
  47472. * Sets the value of D-pad left
  47473. */
  47474. set dPadLeft(value: number);
  47475. /**
  47476. * Gets the value of D-pad right
  47477. */
  47478. get dPadRight(): number;
  47479. /**
  47480. * Sets the value of D-pad right
  47481. */
  47482. set dPadRight(value: number);
  47483. /**
  47484. * Force the gamepad to synchronize with device values
  47485. */
  47486. update(): void;
  47487. /**
  47488. * Disposes the gamepad
  47489. */
  47490. dispose(): void;
  47491. }
  47492. }
  47493. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47494. import { Observable } from "babylonjs/Misc/observable";
  47495. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47496. /**
  47497. * Defines supported buttons for DualShock compatible gamepads
  47498. */
  47499. export enum DualShockButton {
  47500. /** Cross */
  47501. Cross = 0,
  47502. /** Circle */
  47503. Circle = 1,
  47504. /** Square */
  47505. Square = 2,
  47506. /** Triangle */
  47507. Triangle = 3,
  47508. /** L1 */
  47509. L1 = 4,
  47510. /** R1 */
  47511. R1 = 5,
  47512. /** Share */
  47513. Share = 8,
  47514. /** Options */
  47515. Options = 9,
  47516. /** Left stick */
  47517. LeftStick = 10,
  47518. /** Right stick */
  47519. RightStick = 11
  47520. }
  47521. /** Defines values for DualShock DPad */
  47522. export enum DualShockDpad {
  47523. /** Up */
  47524. Up = 12,
  47525. /** Down */
  47526. Down = 13,
  47527. /** Left */
  47528. Left = 14,
  47529. /** Right */
  47530. Right = 15
  47531. }
  47532. /**
  47533. * Defines a DualShock gamepad
  47534. */
  47535. export class DualShockPad extends Gamepad {
  47536. private _leftTrigger;
  47537. private _rightTrigger;
  47538. private _onlefttriggerchanged;
  47539. private _onrighttriggerchanged;
  47540. private _onbuttondown;
  47541. private _onbuttonup;
  47542. private _ondpaddown;
  47543. private _ondpadup;
  47544. /** Observable raised when a button is pressed */
  47545. onButtonDownObservable: Observable<DualShockButton>;
  47546. /** Observable raised when a button is released */
  47547. onButtonUpObservable: Observable<DualShockButton>;
  47548. /** Observable raised when a pad is pressed */
  47549. onPadDownObservable: Observable<DualShockDpad>;
  47550. /** Observable raised when a pad is released */
  47551. onPadUpObservable: Observable<DualShockDpad>;
  47552. private _buttonCross;
  47553. private _buttonCircle;
  47554. private _buttonSquare;
  47555. private _buttonTriangle;
  47556. private _buttonShare;
  47557. private _buttonOptions;
  47558. private _buttonL1;
  47559. private _buttonR1;
  47560. private _buttonLeftStick;
  47561. private _buttonRightStick;
  47562. private _dPadUp;
  47563. private _dPadDown;
  47564. private _dPadLeft;
  47565. private _dPadRight;
  47566. /**
  47567. * Creates a new DualShock gamepad object
  47568. * @param id defines the id of this gamepad
  47569. * @param index defines its index
  47570. * @param gamepad defines the internal HTML gamepad object
  47571. */
  47572. constructor(id: string, index: number, gamepad: any);
  47573. /**
  47574. * Defines the callback to call when left trigger is pressed
  47575. * @param callback defines the callback to use
  47576. */
  47577. onlefttriggerchanged(callback: (value: number) => void): void;
  47578. /**
  47579. * Defines the callback to call when right trigger is pressed
  47580. * @param callback defines the callback to use
  47581. */
  47582. onrighttriggerchanged(callback: (value: number) => void): void;
  47583. /**
  47584. * Gets the left trigger value
  47585. */
  47586. get leftTrigger(): number;
  47587. /**
  47588. * Sets the left trigger value
  47589. */
  47590. set leftTrigger(newValue: number);
  47591. /**
  47592. * Gets the right trigger value
  47593. */
  47594. get rightTrigger(): number;
  47595. /**
  47596. * Sets the right trigger value
  47597. */
  47598. set rightTrigger(newValue: number);
  47599. /**
  47600. * Defines the callback to call when a button is pressed
  47601. * @param callback defines the callback to use
  47602. */
  47603. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47604. /**
  47605. * Defines the callback to call when a button is released
  47606. * @param callback defines the callback to use
  47607. */
  47608. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47609. /**
  47610. * Defines the callback to call when a pad is pressed
  47611. * @param callback defines the callback to use
  47612. */
  47613. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47614. /**
  47615. * Defines the callback to call when a pad is released
  47616. * @param callback defines the callback to use
  47617. */
  47618. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47619. private _setButtonValue;
  47620. private _setDPadValue;
  47621. /**
  47622. * Gets the value of the `Cross` button
  47623. */
  47624. get buttonCross(): number;
  47625. /**
  47626. * Sets the value of the `Cross` button
  47627. */
  47628. set buttonCross(value: number);
  47629. /**
  47630. * Gets the value of the `Circle` button
  47631. */
  47632. get buttonCircle(): number;
  47633. /**
  47634. * Sets the value of the `Circle` button
  47635. */
  47636. set buttonCircle(value: number);
  47637. /**
  47638. * Gets the value of the `Square` button
  47639. */
  47640. get buttonSquare(): number;
  47641. /**
  47642. * Sets the value of the `Square` button
  47643. */
  47644. set buttonSquare(value: number);
  47645. /**
  47646. * Gets the value of the `Triangle` button
  47647. */
  47648. get buttonTriangle(): number;
  47649. /**
  47650. * Sets the value of the `Triangle` button
  47651. */
  47652. set buttonTriangle(value: number);
  47653. /**
  47654. * Gets the value of the `Options` button
  47655. */
  47656. get buttonOptions(): number;
  47657. /**
  47658. * Sets the value of the `Options` button
  47659. */
  47660. set buttonOptions(value: number);
  47661. /**
  47662. * Gets the value of the `Share` button
  47663. */
  47664. get buttonShare(): number;
  47665. /**
  47666. * Sets the value of the `Share` button
  47667. */
  47668. set buttonShare(value: number);
  47669. /**
  47670. * Gets the value of the `L1` button
  47671. */
  47672. get buttonL1(): number;
  47673. /**
  47674. * Sets the value of the `L1` button
  47675. */
  47676. set buttonL1(value: number);
  47677. /**
  47678. * Gets the value of the `R1` button
  47679. */
  47680. get buttonR1(): number;
  47681. /**
  47682. * Sets the value of the `R1` button
  47683. */
  47684. set buttonR1(value: number);
  47685. /**
  47686. * Gets the value of the Left joystick
  47687. */
  47688. get buttonLeftStick(): number;
  47689. /**
  47690. * Sets the value of the Left joystick
  47691. */
  47692. set buttonLeftStick(value: number);
  47693. /**
  47694. * Gets the value of the Right joystick
  47695. */
  47696. get buttonRightStick(): number;
  47697. /**
  47698. * Sets the value of the Right joystick
  47699. */
  47700. set buttonRightStick(value: number);
  47701. /**
  47702. * Gets the value of D-pad up
  47703. */
  47704. get dPadUp(): number;
  47705. /**
  47706. * Sets the value of D-pad up
  47707. */
  47708. set dPadUp(value: number);
  47709. /**
  47710. * Gets the value of D-pad down
  47711. */
  47712. get dPadDown(): number;
  47713. /**
  47714. * Sets the value of D-pad down
  47715. */
  47716. set dPadDown(value: number);
  47717. /**
  47718. * Gets the value of D-pad left
  47719. */
  47720. get dPadLeft(): number;
  47721. /**
  47722. * Sets the value of D-pad left
  47723. */
  47724. set dPadLeft(value: number);
  47725. /**
  47726. * Gets the value of D-pad right
  47727. */
  47728. get dPadRight(): number;
  47729. /**
  47730. * Sets the value of D-pad right
  47731. */
  47732. set dPadRight(value: number);
  47733. /**
  47734. * Force the gamepad to synchronize with device values
  47735. */
  47736. update(): void;
  47737. /**
  47738. * Disposes the gamepad
  47739. */
  47740. dispose(): void;
  47741. }
  47742. }
  47743. declare module "babylonjs/Gamepads/gamepadManager" {
  47744. import { Observable } from "babylonjs/Misc/observable";
  47745. import { Nullable } from "babylonjs/types";
  47746. import { Scene } from "babylonjs/scene";
  47747. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47748. /**
  47749. * Manager for handling gamepads
  47750. */
  47751. export class GamepadManager {
  47752. private _scene?;
  47753. private _babylonGamepads;
  47754. private _oneGamepadConnected;
  47755. /** @hidden */
  47756. _isMonitoring: boolean;
  47757. private _gamepadEventSupported;
  47758. private _gamepadSupport?;
  47759. /**
  47760. * observable to be triggered when the gamepad controller has been connected
  47761. */
  47762. onGamepadConnectedObservable: Observable<Gamepad>;
  47763. /**
  47764. * observable to be triggered when the gamepad controller has been disconnected
  47765. */
  47766. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47767. private _onGamepadConnectedEvent;
  47768. private _onGamepadDisconnectedEvent;
  47769. /**
  47770. * Initializes the gamepad manager
  47771. * @param _scene BabylonJS scene
  47772. */
  47773. constructor(_scene?: Scene | undefined);
  47774. /**
  47775. * The gamepads in the game pad manager
  47776. */
  47777. get gamepads(): Gamepad[];
  47778. /**
  47779. * Get the gamepad controllers based on type
  47780. * @param type The type of gamepad controller
  47781. * @returns Nullable gamepad
  47782. */
  47783. getGamepadByType(type?: number): Nullable<Gamepad>;
  47784. /**
  47785. * Disposes the gamepad manager
  47786. */
  47787. dispose(): void;
  47788. private _addNewGamepad;
  47789. private _startMonitoringGamepads;
  47790. private _stopMonitoringGamepads;
  47791. /** @hidden */
  47792. _checkGamepadsStatus(): void;
  47793. private _updateGamepadObjects;
  47794. }
  47795. }
  47796. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47797. import { Nullable } from "babylonjs/types";
  47798. import { Scene } from "babylonjs/scene";
  47799. import { ISceneComponent } from "babylonjs/sceneComponent";
  47800. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47801. module "babylonjs/scene" {
  47802. interface Scene {
  47803. /** @hidden */
  47804. _gamepadManager: Nullable<GamepadManager>;
  47805. /**
  47806. * Gets the gamepad manager associated with the scene
  47807. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47808. */
  47809. gamepadManager: GamepadManager;
  47810. }
  47811. }
  47812. module "babylonjs/Cameras/freeCameraInputsManager" {
  47813. /**
  47814. * Interface representing a free camera inputs manager
  47815. */
  47816. interface FreeCameraInputsManager {
  47817. /**
  47818. * Adds gamepad input support to the FreeCameraInputsManager.
  47819. * @returns the FreeCameraInputsManager
  47820. */
  47821. addGamepad(): FreeCameraInputsManager;
  47822. }
  47823. }
  47824. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47825. /**
  47826. * Interface representing an arc rotate camera inputs manager
  47827. */
  47828. interface ArcRotateCameraInputsManager {
  47829. /**
  47830. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47831. * @returns the camera inputs manager
  47832. */
  47833. addGamepad(): ArcRotateCameraInputsManager;
  47834. }
  47835. }
  47836. /**
  47837. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47838. */
  47839. export class GamepadSystemSceneComponent implements ISceneComponent {
  47840. /**
  47841. * The component name helpfull to identify the component in the list of scene components.
  47842. */
  47843. readonly name: string;
  47844. /**
  47845. * The scene the component belongs to.
  47846. */
  47847. scene: Scene;
  47848. /**
  47849. * Creates a new instance of the component for the given scene
  47850. * @param scene Defines the scene to register the component in
  47851. */
  47852. constructor(scene: Scene);
  47853. /**
  47854. * Registers the component in a given scene
  47855. */
  47856. register(): void;
  47857. /**
  47858. * Rebuilds the elements related to this component in case of
  47859. * context lost for instance.
  47860. */
  47861. rebuild(): void;
  47862. /**
  47863. * Disposes the component and the associated ressources
  47864. */
  47865. dispose(): void;
  47866. private _beforeCameraUpdate;
  47867. }
  47868. }
  47869. declare module "babylonjs/Cameras/universalCamera" {
  47870. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47871. import { Scene } from "babylonjs/scene";
  47872. import { Vector3 } from "babylonjs/Maths/math.vector";
  47873. import "babylonjs/Gamepads/gamepadSceneComponent";
  47874. /**
  47875. * 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,
  47876. * which still works and will still be found in many Playgrounds.
  47877. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47878. */
  47879. export class UniversalCamera extends TouchCamera {
  47880. /**
  47881. * Defines the gamepad rotation sensiblity.
  47882. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47883. */
  47884. get gamepadAngularSensibility(): number;
  47885. set gamepadAngularSensibility(value: number);
  47886. /**
  47887. * Defines the gamepad move sensiblity.
  47888. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47889. */
  47890. get gamepadMoveSensibility(): number;
  47891. set gamepadMoveSensibility(value: number);
  47892. /**
  47893. * 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,
  47894. * which still works and will still be found in many Playgrounds.
  47895. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47896. * @param name Define the name of the camera in the scene
  47897. * @param position Define the start position of the camera in the scene
  47898. * @param scene Define the scene the camera belongs to
  47899. */
  47900. constructor(name: string, position: Vector3, scene: Scene);
  47901. /**
  47902. * Gets the current object class name.
  47903. * @return the class name
  47904. */
  47905. getClassName(): string;
  47906. }
  47907. }
  47908. declare module "babylonjs/Cameras/gamepadCamera" {
  47909. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47910. import { Scene } from "babylonjs/scene";
  47911. import { Vector3 } from "babylonjs/Maths/math.vector";
  47912. /**
  47913. * This represents a FPS type of camera. This is only here for back compat purpose.
  47914. * Please use the UniversalCamera instead as both are identical.
  47915. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47916. */
  47917. export class GamepadCamera extends UniversalCamera {
  47918. /**
  47919. * Instantiates a new Gamepad Camera
  47920. * This represents a FPS type of camera. This is only here for back compat purpose.
  47921. * Please use the UniversalCamera instead as both are identical.
  47922. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47923. * @param name Define the name of the camera in the scene
  47924. * @param position Define the start position of the camera in the scene
  47925. * @param scene Define the scene the camera belongs to
  47926. */
  47927. constructor(name: string, position: Vector3, scene: Scene);
  47928. /**
  47929. * Gets the current object class name.
  47930. * @return the class name
  47931. */
  47932. getClassName(): string;
  47933. }
  47934. }
  47935. declare module "babylonjs/Shaders/pass.fragment" {
  47936. /** @hidden */
  47937. export var passPixelShader: {
  47938. name: string;
  47939. shader: string;
  47940. };
  47941. }
  47942. declare module "babylonjs/Shaders/passCube.fragment" {
  47943. /** @hidden */
  47944. export var passCubePixelShader: {
  47945. name: string;
  47946. shader: string;
  47947. };
  47948. }
  47949. declare module "babylonjs/PostProcesses/passPostProcess" {
  47950. import { Nullable } from "babylonjs/types";
  47951. import { Camera } from "babylonjs/Cameras/camera";
  47952. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47953. import { Engine } from "babylonjs/Engines/engine";
  47954. import "babylonjs/Shaders/pass.fragment";
  47955. import "babylonjs/Shaders/passCube.fragment";
  47956. import { Scene } from "babylonjs/scene";
  47957. /**
  47958. * PassPostProcess which produces an output the same as it's input
  47959. */
  47960. export class PassPostProcess extends PostProcess {
  47961. /**
  47962. * Gets a string identifying the name of the class
  47963. * @returns "PassPostProcess" string
  47964. */
  47965. getClassName(): string;
  47966. /**
  47967. * Creates the PassPostProcess
  47968. * @param name The name of the effect.
  47969. * @param options The required width/height ratio to downsize to before computing the render pass.
  47970. * @param camera The camera to apply the render pass to.
  47971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47972. * @param engine The engine which the post process will be applied. (default: current engine)
  47973. * @param reusable If the post process can be reused on the same frame. (default: false)
  47974. * @param textureType The type of texture to be used when performing the post processing.
  47975. * @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)
  47976. */
  47977. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47978. /** @hidden */
  47979. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47980. }
  47981. /**
  47982. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47983. */
  47984. export class PassCubePostProcess extends PostProcess {
  47985. private _face;
  47986. /**
  47987. * Gets or sets the cube face to display.
  47988. * * 0 is +X
  47989. * * 1 is -X
  47990. * * 2 is +Y
  47991. * * 3 is -Y
  47992. * * 4 is +Z
  47993. * * 5 is -Z
  47994. */
  47995. get face(): number;
  47996. set face(value: number);
  47997. /**
  47998. * Gets a string identifying the name of the class
  47999. * @returns "PassCubePostProcess" string
  48000. */
  48001. getClassName(): string;
  48002. /**
  48003. * Creates the PassCubePostProcess
  48004. * @param name The name of the effect.
  48005. * @param options The required width/height ratio to downsize to before computing the render pass.
  48006. * @param camera The camera to apply the render pass to.
  48007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48008. * @param engine The engine which the post process will be applied. (default: current engine)
  48009. * @param reusable If the post process can be reused on the same frame. (default: false)
  48010. * @param textureType The type of texture to be used when performing the post processing.
  48011. * @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)
  48012. */
  48013. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48014. /** @hidden */
  48015. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  48016. }
  48017. }
  48018. declare module "babylonjs/Shaders/anaglyph.fragment" {
  48019. /** @hidden */
  48020. export var anaglyphPixelShader: {
  48021. name: string;
  48022. shader: string;
  48023. };
  48024. }
  48025. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  48026. import { Engine } from "babylonjs/Engines/engine";
  48027. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  48028. import { Camera } from "babylonjs/Cameras/camera";
  48029. import "babylonjs/Shaders/anaglyph.fragment";
  48030. /**
  48031. * Postprocess used to generate anaglyphic rendering
  48032. */
  48033. export class AnaglyphPostProcess extends PostProcess {
  48034. private _passedProcess;
  48035. /**
  48036. * Gets a string identifying the name of the class
  48037. * @returns "AnaglyphPostProcess" string
  48038. */
  48039. getClassName(): string;
  48040. /**
  48041. * Creates a new AnaglyphPostProcess
  48042. * @param name defines postprocess name
  48043. * @param options defines creation options or target ratio scale
  48044. * @param rigCameras defines cameras using this postprocess
  48045. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  48046. * @param engine defines hosting engine
  48047. * @param reusable defines if the postprocess will be reused multiple times per frame
  48048. */
  48049. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  48050. }
  48051. }
  48052. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  48053. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  48054. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48055. import { Scene } from "babylonjs/scene";
  48056. import { Vector3 } from "babylonjs/Maths/math.vector";
  48057. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48058. /**
  48059. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  48060. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48061. */
  48062. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  48063. /**
  48064. * Creates a new AnaglyphArcRotateCamera
  48065. * @param name defines camera name
  48066. * @param alpha defines alpha angle (in radians)
  48067. * @param beta defines beta angle (in radians)
  48068. * @param radius defines radius
  48069. * @param target defines camera target
  48070. * @param interaxialDistance defines distance between each color axis
  48071. * @param scene defines the hosting scene
  48072. */
  48073. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  48074. /**
  48075. * Gets camera class name
  48076. * @returns AnaglyphArcRotateCamera
  48077. */
  48078. getClassName(): string;
  48079. }
  48080. }
  48081. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  48082. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48083. import { Scene } from "babylonjs/scene";
  48084. import { Vector3 } from "babylonjs/Maths/math.vector";
  48085. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48086. /**
  48087. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  48088. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48089. */
  48090. export class AnaglyphFreeCamera extends FreeCamera {
  48091. /**
  48092. * Creates a new AnaglyphFreeCamera
  48093. * @param name defines camera name
  48094. * @param position defines initial position
  48095. * @param interaxialDistance defines distance between each color axis
  48096. * @param scene defines the hosting scene
  48097. */
  48098. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48099. /**
  48100. * Gets camera class name
  48101. * @returns AnaglyphFreeCamera
  48102. */
  48103. getClassName(): string;
  48104. }
  48105. }
  48106. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  48107. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48108. import { Scene } from "babylonjs/scene";
  48109. import { Vector3 } from "babylonjs/Maths/math.vector";
  48110. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48111. /**
  48112. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  48113. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48114. */
  48115. export class AnaglyphGamepadCamera extends GamepadCamera {
  48116. /**
  48117. * Creates a new AnaglyphGamepadCamera
  48118. * @param name defines camera name
  48119. * @param position defines initial position
  48120. * @param interaxialDistance defines distance between each color axis
  48121. * @param scene defines the hosting scene
  48122. */
  48123. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48124. /**
  48125. * Gets camera class name
  48126. * @returns AnaglyphGamepadCamera
  48127. */
  48128. getClassName(): string;
  48129. }
  48130. }
  48131. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  48132. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48133. import { Scene } from "babylonjs/scene";
  48134. import { Vector3 } from "babylonjs/Maths/math.vector";
  48135. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48136. /**
  48137. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  48138. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48139. */
  48140. export class AnaglyphUniversalCamera extends UniversalCamera {
  48141. /**
  48142. * Creates a new AnaglyphUniversalCamera
  48143. * @param name defines camera name
  48144. * @param position defines initial position
  48145. * @param interaxialDistance defines distance between each color axis
  48146. * @param scene defines the hosting scene
  48147. */
  48148. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48149. /**
  48150. * Gets camera class name
  48151. * @returns AnaglyphUniversalCamera
  48152. */
  48153. getClassName(): string;
  48154. }
  48155. }
  48156. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  48157. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  48158. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48159. import { Scene } from "babylonjs/scene";
  48160. import { Vector3 } from "babylonjs/Maths/math.vector";
  48161. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48162. /**
  48163. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  48164. * @see https://doc.babylonjs.com/features/cameras
  48165. */
  48166. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  48167. /**
  48168. * Creates a new StereoscopicArcRotateCamera
  48169. * @param name defines camera name
  48170. * @param alpha defines alpha angle (in radians)
  48171. * @param beta defines beta angle (in radians)
  48172. * @param radius defines radius
  48173. * @param target defines camera target
  48174. * @param interaxialDistance defines distance between each color axis
  48175. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48176. * @param scene defines the hosting scene
  48177. */
  48178. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48179. /**
  48180. * Gets camera class name
  48181. * @returns StereoscopicArcRotateCamera
  48182. */
  48183. getClassName(): string;
  48184. }
  48185. }
  48186. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  48187. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48188. import { Scene } from "babylonjs/scene";
  48189. import { Vector3 } from "babylonjs/Maths/math.vector";
  48190. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48191. /**
  48192. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  48193. * @see https://doc.babylonjs.com/features/cameras
  48194. */
  48195. export class StereoscopicFreeCamera extends FreeCamera {
  48196. /**
  48197. * Creates a new StereoscopicFreeCamera
  48198. * @param name defines camera name
  48199. * @param position defines initial position
  48200. * @param interaxialDistance defines distance between each color axis
  48201. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48202. * @param scene defines the hosting scene
  48203. */
  48204. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48205. /**
  48206. * Gets camera class name
  48207. * @returns StereoscopicFreeCamera
  48208. */
  48209. getClassName(): string;
  48210. }
  48211. }
  48212. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  48213. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48214. import { Scene } from "babylonjs/scene";
  48215. import { Vector3 } from "babylonjs/Maths/math.vector";
  48216. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48217. /**
  48218. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  48219. * @see https://doc.babylonjs.com/features/cameras
  48220. */
  48221. export class StereoscopicGamepadCamera extends GamepadCamera {
  48222. /**
  48223. * Creates a new StereoscopicGamepadCamera
  48224. * @param name defines camera name
  48225. * @param position defines initial position
  48226. * @param interaxialDistance defines distance between each color axis
  48227. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48228. * @param scene defines the hosting scene
  48229. */
  48230. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48231. /**
  48232. * Gets camera class name
  48233. * @returns StereoscopicGamepadCamera
  48234. */
  48235. getClassName(): string;
  48236. }
  48237. }
  48238. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  48239. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48240. import { Scene } from "babylonjs/scene";
  48241. import { Vector3 } from "babylonjs/Maths/math.vector";
  48242. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48243. /**
  48244. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48245. * @see https://doc.babylonjs.com/features/cameras
  48246. */
  48247. export class StereoscopicUniversalCamera extends UniversalCamera {
  48248. /**
  48249. * Creates a new StereoscopicUniversalCamera
  48250. * @param name defines camera name
  48251. * @param position defines initial position
  48252. * @param interaxialDistance defines distance between each color axis
  48253. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48254. * @param scene defines the hosting scene
  48255. */
  48256. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48257. /**
  48258. * Gets camera class name
  48259. * @returns StereoscopicUniversalCamera
  48260. */
  48261. getClassName(): string;
  48262. }
  48263. }
  48264. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48265. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48266. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48267. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48268. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48269. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48270. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48271. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48272. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48273. }
  48274. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48275. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48276. import { Scene } from "babylonjs/scene";
  48277. import { Vector3 } from "babylonjs/Maths/math.vector";
  48278. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48279. /**
  48280. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48281. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48282. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48283. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48284. */
  48285. export class VirtualJoysticksCamera extends FreeCamera {
  48286. /**
  48287. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48288. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48289. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48290. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48291. * @param name Define the name of the camera in the scene
  48292. * @param position Define the start position of the camera in the scene
  48293. * @param scene Define the scene the camera belongs to
  48294. */
  48295. constructor(name: string, position: Vector3, scene: Scene);
  48296. /**
  48297. * Gets the current object class name.
  48298. * @return the class name
  48299. */
  48300. getClassName(): string;
  48301. }
  48302. }
  48303. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48304. import { Matrix } from "babylonjs/Maths/math.vector";
  48305. /**
  48306. * This represents all the required metrics to create a VR camera.
  48307. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48308. */
  48309. export class VRCameraMetrics {
  48310. /**
  48311. * Define the horizontal resolution off the screen.
  48312. */
  48313. hResolution: number;
  48314. /**
  48315. * Define the vertical resolution off the screen.
  48316. */
  48317. vResolution: number;
  48318. /**
  48319. * Define the horizontal screen size.
  48320. */
  48321. hScreenSize: number;
  48322. /**
  48323. * Define the vertical screen size.
  48324. */
  48325. vScreenSize: number;
  48326. /**
  48327. * Define the vertical screen center position.
  48328. */
  48329. vScreenCenter: number;
  48330. /**
  48331. * Define the distance of the eyes to the screen.
  48332. */
  48333. eyeToScreenDistance: number;
  48334. /**
  48335. * Define the distance between both lenses
  48336. */
  48337. lensSeparationDistance: number;
  48338. /**
  48339. * Define the distance between both viewer's eyes.
  48340. */
  48341. interpupillaryDistance: number;
  48342. /**
  48343. * Define the distortion factor of the VR postprocess.
  48344. * Please, touch with care.
  48345. */
  48346. distortionK: number[];
  48347. /**
  48348. * Define the chromatic aberration correction factors for the VR post process.
  48349. */
  48350. chromaAbCorrection: number[];
  48351. /**
  48352. * Define the scale factor of the post process.
  48353. * The smaller the better but the slower.
  48354. */
  48355. postProcessScaleFactor: number;
  48356. /**
  48357. * Define an offset for the lens center.
  48358. */
  48359. lensCenterOffset: number;
  48360. /**
  48361. * Define if the current vr camera should compensate the distortion of the lense or not.
  48362. */
  48363. compensateDistortion: boolean;
  48364. /**
  48365. * Defines if multiview should be enabled when rendering (Default: false)
  48366. */
  48367. multiviewEnabled: boolean;
  48368. /**
  48369. * Gets the rendering aspect ratio based on the provided resolutions.
  48370. */
  48371. get aspectRatio(): number;
  48372. /**
  48373. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48374. */
  48375. get aspectRatioFov(): number;
  48376. /**
  48377. * @hidden
  48378. */
  48379. get leftHMatrix(): Matrix;
  48380. /**
  48381. * @hidden
  48382. */
  48383. get rightHMatrix(): Matrix;
  48384. /**
  48385. * @hidden
  48386. */
  48387. get leftPreViewMatrix(): Matrix;
  48388. /**
  48389. * @hidden
  48390. */
  48391. get rightPreViewMatrix(): Matrix;
  48392. /**
  48393. * Get the default VRMetrics based on the most generic setup.
  48394. * @returns the default vr metrics
  48395. */
  48396. static GetDefault(): VRCameraMetrics;
  48397. }
  48398. }
  48399. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48400. /** @hidden */
  48401. export var vrDistortionCorrectionPixelShader: {
  48402. name: string;
  48403. shader: string;
  48404. };
  48405. }
  48406. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48407. import { Camera } from "babylonjs/Cameras/camera";
  48408. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48409. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48410. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48411. /**
  48412. * VRDistortionCorrectionPostProcess used for mobile VR
  48413. */
  48414. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48415. private _isRightEye;
  48416. private _distortionFactors;
  48417. private _postProcessScaleFactor;
  48418. private _lensCenterOffset;
  48419. private _scaleIn;
  48420. private _scaleFactor;
  48421. private _lensCenter;
  48422. /**
  48423. * Gets a string identifying the name of the class
  48424. * @returns "VRDistortionCorrectionPostProcess" string
  48425. */
  48426. getClassName(): string;
  48427. /**
  48428. * Initializes the VRDistortionCorrectionPostProcess
  48429. * @param name The name of the effect.
  48430. * @param camera The camera to apply the render pass to.
  48431. * @param isRightEye If this is for the right eye distortion
  48432. * @param vrMetrics All the required metrics for the VR camera
  48433. */
  48434. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48435. }
  48436. }
  48437. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48438. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48439. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48440. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48441. import { Scene } from "babylonjs/scene";
  48442. import { Vector3 } from "babylonjs/Maths/math.vector";
  48443. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48444. import "babylonjs/Cameras/RigModes/vrRigMode";
  48445. /**
  48446. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48447. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48448. */
  48449. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48450. /**
  48451. * Creates a new VRDeviceOrientationArcRotateCamera
  48452. * @param name defines camera name
  48453. * @param alpha defines the camera rotation along the logitudinal axis
  48454. * @param beta defines the camera rotation along the latitudinal axis
  48455. * @param radius defines the camera distance from its target
  48456. * @param target defines the camera target
  48457. * @param scene defines the scene the camera belongs to
  48458. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48459. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48460. */
  48461. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48462. /**
  48463. * Gets camera class name
  48464. * @returns VRDeviceOrientationArcRotateCamera
  48465. */
  48466. getClassName(): string;
  48467. }
  48468. }
  48469. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48470. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48471. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48472. import { Scene } from "babylonjs/scene";
  48473. import { Vector3 } from "babylonjs/Maths/math.vector";
  48474. import "babylonjs/Cameras/RigModes/vrRigMode";
  48475. /**
  48476. * Camera used to simulate VR rendering (based on FreeCamera)
  48477. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48478. */
  48479. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48480. /**
  48481. * Creates a new VRDeviceOrientationFreeCamera
  48482. * @param name defines camera name
  48483. * @param position defines the start position of the camera
  48484. * @param scene defines the scene the camera belongs to
  48485. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48486. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48487. */
  48488. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48489. /**
  48490. * Gets camera class name
  48491. * @returns VRDeviceOrientationFreeCamera
  48492. */
  48493. getClassName(): string;
  48494. }
  48495. }
  48496. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48497. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48498. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48499. import { Scene } from "babylonjs/scene";
  48500. import { Vector3 } from "babylonjs/Maths/math.vector";
  48501. import "babylonjs/Gamepads/gamepadSceneComponent";
  48502. /**
  48503. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48504. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48505. */
  48506. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48507. /**
  48508. * Creates a new VRDeviceOrientationGamepadCamera
  48509. * @param name defines camera name
  48510. * @param position defines the start position of the camera
  48511. * @param scene defines the scene the camera belongs to
  48512. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48513. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48514. */
  48515. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48516. /**
  48517. * Gets camera class name
  48518. * @returns VRDeviceOrientationGamepadCamera
  48519. */
  48520. getClassName(): string;
  48521. }
  48522. }
  48523. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48524. import { Scene } from "babylonjs/scene";
  48525. import { Texture } from "babylonjs/Materials/Textures/texture";
  48526. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48527. /**
  48528. * A class extending Texture allowing drawing on a texture
  48529. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48530. */
  48531. export class DynamicTexture extends Texture {
  48532. private _generateMipMaps;
  48533. private _canvas;
  48534. private _context;
  48535. /**
  48536. * Creates a DynamicTexture
  48537. * @param name defines the name of the texture
  48538. * @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
  48539. * @param scene defines the scene where you want the texture
  48540. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48541. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48542. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48543. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  48544. */
  48545. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  48546. /**
  48547. * Get the current class name of the texture useful for serialization or dynamic coding.
  48548. * @returns "DynamicTexture"
  48549. */
  48550. getClassName(): string;
  48551. /**
  48552. * Gets the current state of canRescale
  48553. */
  48554. get canRescale(): boolean;
  48555. private _recreate;
  48556. /**
  48557. * Scales the texture
  48558. * @param ratio the scale factor to apply to both width and height
  48559. */
  48560. scale(ratio: number): void;
  48561. /**
  48562. * Resizes the texture
  48563. * @param width the new width
  48564. * @param height the new height
  48565. */
  48566. scaleTo(width: number, height: number): void;
  48567. /**
  48568. * Gets the context of the canvas used by the texture
  48569. * @returns the canvas context of the dynamic texture
  48570. */
  48571. getContext(): CanvasRenderingContext2D;
  48572. /**
  48573. * Clears the texture
  48574. */
  48575. clear(): void;
  48576. /**
  48577. * Updates the texture
  48578. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48579. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48580. */
  48581. update(invertY?: boolean, premulAlpha?: boolean): void;
  48582. /**
  48583. * Draws text onto the texture
  48584. * @param text defines the text to be drawn
  48585. * @param x defines the placement of the text from the left
  48586. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48587. * @param font defines the font to be used with font-style, font-size, font-name
  48588. * @param color defines the color used for the text
  48589. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48590. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48591. * @param update defines whether texture is immediately update (default is true)
  48592. */
  48593. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48594. /**
  48595. * Clones the texture
  48596. * @returns the clone of the texture.
  48597. */
  48598. clone(): DynamicTexture;
  48599. /**
  48600. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48601. * @returns a serialized dynamic texture object
  48602. */
  48603. serialize(): any;
  48604. private _IsCanvasElement;
  48605. /** @hidden */
  48606. _rebuild(): void;
  48607. }
  48608. }
  48609. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48610. import { Scene } from "babylonjs/scene";
  48611. import { Color3 } from "babylonjs/Maths/math.color";
  48612. import { Mesh } from "babylonjs/Meshes/mesh";
  48613. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48614. import { Nullable } from "babylonjs/types";
  48615. /**
  48616. * Class containing static functions to help procedurally build meshes
  48617. */
  48618. export class GroundBuilder {
  48619. /**
  48620. * Creates a ground mesh
  48621. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48622. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48624. * @param name defines the name of the mesh
  48625. * @param options defines the options used to create the mesh
  48626. * @param scene defines the hosting scene
  48627. * @returns the ground mesh
  48628. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48629. */
  48630. static CreateGround(name: string, options: {
  48631. width?: number;
  48632. height?: number;
  48633. subdivisions?: number;
  48634. subdivisionsX?: number;
  48635. subdivisionsY?: number;
  48636. updatable?: boolean;
  48637. }, scene: any): Mesh;
  48638. /**
  48639. * Creates a tiled ground mesh
  48640. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48641. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48642. * * 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
  48643. * * 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
  48644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48645. * @param name defines the name of the mesh
  48646. * @param options defines the options used to create the mesh
  48647. * @param scene defines the hosting scene
  48648. * @returns the tiled ground mesh
  48649. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48650. */
  48651. static CreateTiledGround(name: string, options: {
  48652. xmin: number;
  48653. zmin: number;
  48654. xmax: number;
  48655. zmax: number;
  48656. subdivisions?: {
  48657. w: number;
  48658. h: number;
  48659. };
  48660. precision?: {
  48661. w: number;
  48662. h: number;
  48663. };
  48664. updatable?: boolean;
  48665. }, scene?: Nullable<Scene>): Mesh;
  48666. /**
  48667. * Creates a ground mesh from a height map
  48668. * * The parameter `url` sets the URL of the height map image resource.
  48669. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48670. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48671. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48672. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48673. * * 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.
  48674. * * 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).
  48675. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48677. * @param name defines the name of the mesh
  48678. * @param url defines the url to the height map
  48679. * @param options defines the options used to create the mesh
  48680. * @param scene defines the hosting scene
  48681. * @returns the ground mesh
  48682. * @see https://doc.babylonjs.com/babylon101/height_map
  48683. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48684. */
  48685. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48686. width?: number;
  48687. height?: number;
  48688. subdivisions?: number;
  48689. minHeight?: number;
  48690. maxHeight?: number;
  48691. colorFilter?: Color3;
  48692. alphaFilter?: number;
  48693. updatable?: boolean;
  48694. onReady?: (mesh: GroundMesh) => void;
  48695. }, scene?: Nullable<Scene>): GroundMesh;
  48696. }
  48697. }
  48698. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48699. import { Vector4 } from "babylonjs/Maths/math.vector";
  48700. import { Mesh } from "babylonjs/Meshes/mesh";
  48701. /**
  48702. * Class containing static functions to help procedurally build meshes
  48703. */
  48704. export class TorusBuilder {
  48705. /**
  48706. * Creates a torus mesh
  48707. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48708. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48709. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48713. * @param name defines the name of the mesh
  48714. * @param options defines the options used to create the mesh
  48715. * @param scene defines the hosting scene
  48716. * @returns the torus mesh
  48717. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48718. */
  48719. static CreateTorus(name: string, options: {
  48720. diameter?: number;
  48721. thickness?: number;
  48722. tessellation?: number;
  48723. updatable?: boolean;
  48724. sideOrientation?: number;
  48725. frontUVs?: Vector4;
  48726. backUVs?: Vector4;
  48727. }, scene: any): Mesh;
  48728. }
  48729. }
  48730. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48731. import { Vector4 } from "babylonjs/Maths/math.vector";
  48732. import { Color4 } from "babylonjs/Maths/math.color";
  48733. import { Mesh } from "babylonjs/Meshes/mesh";
  48734. /**
  48735. * Class containing static functions to help procedurally build meshes
  48736. */
  48737. export class CylinderBuilder {
  48738. /**
  48739. * Creates a cylinder or a cone mesh
  48740. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48741. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48742. * * 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.
  48743. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48744. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48745. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48746. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48747. * * 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).
  48748. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48749. * * 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).
  48750. * * 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
  48751. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48752. * * 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
  48753. * * 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.
  48754. * * If `enclose` is false, a ring surface is one element.
  48755. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48756. * * 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
  48757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48760. * @param name defines the name of the mesh
  48761. * @param options defines the options used to create the mesh
  48762. * @param scene defines the hosting scene
  48763. * @returns the cylinder mesh
  48764. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48765. */
  48766. static CreateCylinder(name: string, options: {
  48767. height?: number;
  48768. diameterTop?: number;
  48769. diameterBottom?: number;
  48770. diameter?: number;
  48771. tessellation?: number;
  48772. subdivisions?: number;
  48773. arc?: number;
  48774. faceColors?: Color4[];
  48775. faceUV?: Vector4[];
  48776. updatable?: boolean;
  48777. hasRings?: boolean;
  48778. enclose?: boolean;
  48779. cap?: number;
  48780. sideOrientation?: number;
  48781. frontUVs?: Vector4;
  48782. backUVs?: Vector4;
  48783. }, scene: any): Mesh;
  48784. }
  48785. }
  48786. declare module "babylonjs/XR/webXRTypes" {
  48787. import { Nullable } from "babylonjs/types";
  48788. import { IDisposable } from "babylonjs/scene";
  48789. /**
  48790. * States of the webXR experience
  48791. */
  48792. export enum WebXRState {
  48793. /**
  48794. * Transitioning to being in XR mode
  48795. */
  48796. ENTERING_XR = 0,
  48797. /**
  48798. * Transitioning to non XR mode
  48799. */
  48800. EXITING_XR = 1,
  48801. /**
  48802. * In XR mode and presenting
  48803. */
  48804. IN_XR = 2,
  48805. /**
  48806. * Not entered XR mode
  48807. */
  48808. NOT_IN_XR = 3
  48809. }
  48810. /**
  48811. * Abstraction of the XR render target
  48812. */
  48813. export interface WebXRRenderTarget extends IDisposable {
  48814. /**
  48815. * xrpresent context of the canvas which can be used to display/mirror xr content
  48816. */
  48817. canvasContext: WebGLRenderingContext;
  48818. /**
  48819. * xr layer for the canvas
  48820. */
  48821. xrLayer: Nullable<XRWebGLLayer>;
  48822. /**
  48823. * Initializes the xr layer for the session
  48824. * @param xrSession xr session
  48825. * @returns a promise that will resolve once the XR Layer has been created
  48826. */
  48827. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48828. }
  48829. }
  48830. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48831. import { Nullable } from "babylonjs/types";
  48832. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48833. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48834. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48835. import { Observable } from "babylonjs/Misc/observable";
  48836. /**
  48837. * COnfiguration object for WebXR output canvas
  48838. */
  48839. export class WebXRManagedOutputCanvasOptions {
  48840. /**
  48841. * An optional canvas in case you wish to create it yourself and provide it here.
  48842. * If not provided, a new canvas will be created
  48843. */
  48844. canvasElement?: HTMLCanvasElement;
  48845. /**
  48846. * Options for this XR Layer output
  48847. */
  48848. canvasOptions?: XRWebGLLayerOptions;
  48849. /**
  48850. * CSS styling for a newly created canvas (if not provided)
  48851. */
  48852. newCanvasCssStyle?: string;
  48853. /**
  48854. * Get the default values of the configuration object
  48855. * @param engine defines the engine to use (can be null)
  48856. * @returns default values of this configuration object
  48857. */
  48858. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48859. }
  48860. /**
  48861. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48862. */
  48863. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48864. private _options;
  48865. private _canvas;
  48866. private _engine;
  48867. private _originalCanvasSize;
  48868. /**
  48869. * Rendering context of the canvas which can be used to display/mirror xr content
  48870. */
  48871. canvasContext: WebGLRenderingContext;
  48872. /**
  48873. * xr layer for the canvas
  48874. */
  48875. xrLayer: Nullable<XRWebGLLayer>;
  48876. /**
  48877. * Obseervers registered here will be triggered when the xr layer was initialized
  48878. */
  48879. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48880. /**
  48881. * Initializes the canvas to be added/removed upon entering/exiting xr
  48882. * @param _xrSessionManager The XR Session manager
  48883. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48884. */
  48885. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48886. /**
  48887. * Disposes of the object
  48888. */
  48889. dispose(): void;
  48890. /**
  48891. * Initializes the xr layer for the session
  48892. * @param xrSession xr session
  48893. * @returns a promise that will resolve once the XR Layer has been created
  48894. */
  48895. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48896. private _addCanvas;
  48897. private _removeCanvas;
  48898. private _setCanvasSize;
  48899. private _setManagedOutputCanvas;
  48900. }
  48901. }
  48902. declare module "babylonjs/XR/webXRSessionManager" {
  48903. import { Observable } from "babylonjs/Misc/observable";
  48904. import { Nullable } from "babylonjs/types";
  48905. import { IDisposable, Scene } from "babylonjs/scene";
  48906. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48907. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48908. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48909. /**
  48910. * Manages an XRSession to work with Babylon's engine
  48911. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48912. */
  48913. export class WebXRSessionManager implements IDisposable {
  48914. /** The scene which the session should be created for */
  48915. scene: Scene;
  48916. private _referenceSpace;
  48917. private _rttProvider;
  48918. private _sessionEnded;
  48919. private _xrNavigator;
  48920. private baseLayer;
  48921. /**
  48922. * The base reference space from which the session started. good if you want to reset your
  48923. * reference space
  48924. */
  48925. baseReferenceSpace: XRReferenceSpace;
  48926. /**
  48927. * Current XR frame
  48928. */
  48929. currentFrame: Nullable<XRFrame>;
  48930. /** WebXR timestamp updated every frame */
  48931. currentTimestamp: number;
  48932. /**
  48933. * Used just in case of a failure to initialize an immersive session.
  48934. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48935. */
  48936. defaultHeightCompensation: number;
  48937. /**
  48938. * Fires every time a new xrFrame arrives which can be used to update the camera
  48939. */
  48940. onXRFrameObservable: Observable<XRFrame>;
  48941. /**
  48942. * Fires when the reference space changed
  48943. */
  48944. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48945. /**
  48946. * Fires when the xr session is ended either by the device or manually done
  48947. */
  48948. onXRSessionEnded: Observable<any>;
  48949. /**
  48950. * Fires when the xr session is ended either by the device or manually done
  48951. */
  48952. onXRSessionInit: Observable<XRSession>;
  48953. /**
  48954. * Underlying xr session
  48955. */
  48956. session: XRSession;
  48957. /**
  48958. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48959. * or get the offset the player is currently at.
  48960. */
  48961. viewerReferenceSpace: XRReferenceSpace;
  48962. /**
  48963. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48964. * @param scene The scene which the session should be created for
  48965. */
  48966. constructor(
  48967. /** The scene which the session should be created for */
  48968. scene: Scene);
  48969. /**
  48970. * The current reference space used in this session. This reference space can constantly change!
  48971. * It is mainly used to offset the camera's position.
  48972. */
  48973. get referenceSpace(): XRReferenceSpace;
  48974. /**
  48975. * Set a new reference space and triggers the observable
  48976. */
  48977. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48978. /**
  48979. * Disposes of the session manager
  48980. */
  48981. dispose(): void;
  48982. /**
  48983. * Stops the xrSession and restores the render loop
  48984. * @returns Promise which resolves after it exits XR
  48985. */
  48986. exitXRAsync(): Promise<void>;
  48987. /**
  48988. * Gets the correct render target texture to be rendered this frame for this eye
  48989. * @param eye the eye for which to get the render target
  48990. * @returns the render target for the specified eye
  48991. */
  48992. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48993. /**
  48994. * Creates a WebXRRenderTarget object for the XR session
  48995. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48996. * @param options optional options to provide when creating a new render target
  48997. * @returns a WebXR render target to which the session can render
  48998. */
  48999. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  49000. /**
  49001. * Initializes the manager
  49002. * After initialization enterXR can be called to start an XR session
  49003. * @returns Promise which resolves after it is initialized
  49004. */
  49005. initializeAsync(): Promise<void>;
  49006. /**
  49007. * Initializes an xr session
  49008. * @param xrSessionMode mode to initialize
  49009. * @param xrSessionInit defines optional and required values to pass to the session builder
  49010. * @returns a promise which will resolve once the session has been initialized
  49011. */
  49012. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  49013. /**
  49014. * Checks if a session would be supported for the creation options specified
  49015. * @param sessionMode session mode to check if supported eg. immersive-vr
  49016. * @returns A Promise that resolves to true if supported and false if not
  49017. */
  49018. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  49019. /**
  49020. * Resets the reference space to the one started the session
  49021. */
  49022. resetReferenceSpace(): void;
  49023. /**
  49024. * Starts rendering to the xr layer
  49025. */
  49026. runXRRenderLoop(): void;
  49027. /**
  49028. * Sets the reference space on the xr session
  49029. * @param referenceSpaceType space to set
  49030. * @returns a promise that will resolve once the reference space has been set
  49031. */
  49032. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  49033. /**
  49034. * Updates the render state of the session
  49035. * @param state state to set
  49036. * @returns a promise that resolves once the render state has been updated
  49037. */
  49038. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  49039. /**
  49040. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  49041. * @param sessionMode defines the session to test
  49042. * @returns a promise with boolean as final value
  49043. */
  49044. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  49045. private _createRenderTargetTexture;
  49046. }
  49047. }
  49048. declare module "babylonjs/XR/webXRCamera" {
  49049. import { Vector3 } from "babylonjs/Maths/math.vector";
  49050. import { Scene } from "babylonjs/scene";
  49051. import { Camera } from "babylonjs/Cameras/camera";
  49052. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49053. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49054. import { Observable } from "babylonjs/Misc/observable";
  49055. /**
  49056. * WebXR Camera which holds the views for the xrSession
  49057. * @see https://doc.babylonjs.com/how_to/webxr_camera
  49058. */
  49059. export class WebXRCamera extends FreeCamera {
  49060. private _xrSessionManager;
  49061. private _firstFrame;
  49062. private _referenceQuaternion;
  49063. private _referencedPosition;
  49064. private _xrInvPositionCache;
  49065. private _xrInvQuaternionCache;
  49066. /**
  49067. * Observable raised before camera teleportation
  49068. */
  49069. onBeforeCameraTeleport: Observable<Vector3>;
  49070. /**
  49071. * Observable raised after camera teleportation
  49072. */
  49073. onAfterCameraTeleport: Observable<Vector3>;
  49074. /**
  49075. * Should position compensation execute on first frame.
  49076. * This is used when copying the position from a native (non XR) camera
  49077. */
  49078. compensateOnFirstFrame: boolean;
  49079. /**
  49080. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  49081. * @param name the name of the camera
  49082. * @param scene the scene to add the camera to
  49083. * @param _xrSessionManager a constructed xr session manager
  49084. */
  49085. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  49086. /**
  49087. * Return the user's height, unrelated to the current ground.
  49088. * This will be the y position of this camera, when ground level is 0.
  49089. */
  49090. get realWorldHeight(): number;
  49091. /** @hidden */
  49092. _updateForDualEyeDebugging(): void;
  49093. /**
  49094. * Sets this camera's transformation based on a non-vr camera
  49095. * @param otherCamera the non-vr camera to copy the transformation from
  49096. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  49097. */
  49098. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  49099. /**
  49100. * Gets the current instance class name ("WebXRCamera").
  49101. * @returns the class name
  49102. */
  49103. getClassName(): string;
  49104. private _rotate180;
  49105. private _updateFromXRSession;
  49106. private _updateNumberOfRigCameras;
  49107. private _updateReferenceSpace;
  49108. private _updateReferenceSpaceOffset;
  49109. }
  49110. }
  49111. declare module "babylonjs/XR/webXRFeaturesManager" {
  49112. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49113. import { IDisposable } from "babylonjs/scene";
  49114. /**
  49115. * Defining the interface required for a (webxr) feature
  49116. */
  49117. export interface IWebXRFeature extends IDisposable {
  49118. /**
  49119. * Is this feature attached
  49120. */
  49121. attached: boolean;
  49122. /**
  49123. * Should auto-attach be disabled?
  49124. */
  49125. disableAutoAttach: boolean;
  49126. /**
  49127. * Attach the feature to the session
  49128. * Will usually be called by the features manager
  49129. *
  49130. * @param force should attachment be forced (even when already attached)
  49131. * @returns true if successful.
  49132. */
  49133. attach(force?: boolean): boolean;
  49134. /**
  49135. * Detach the feature from the session
  49136. * Will usually be called by the features manager
  49137. *
  49138. * @returns true if successful.
  49139. */
  49140. detach(): boolean;
  49141. /**
  49142. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  49143. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  49144. *
  49145. * @returns whether or not the feature is compatible in this environment
  49146. */
  49147. isCompatible(): boolean;
  49148. /**
  49149. * Was this feature disposed;
  49150. */
  49151. isDisposed: boolean;
  49152. /**
  49153. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  49154. */
  49155. xrNativeFeatureName?: string;
  49156. /**
  49157. * A list of (Babylon WebXR) features this feature depends on
  49158. */
  49159. dependsOn?: string[];
  49160. }
  49161. /**
  49162. * A list of the currently available features without referencing them
  49163. */
  49164. export class WebXRFeatureName {
  49165. /**
  49166. * The name of the anchor system feature
  49167. */
  49168. static readonly ANCHOR_SYSTEM: string;
  49169. /**
  49170. * The name of the background remover feature
  49171. */
  49172. static readonly BACKGROUND_REMOVER: string;
  49173. /**
  49174. * The name of the hit test feature
  49175. */
  49176. static readonly HIT_TEST: string;
  49177. /**
  49178. * physics impostors for xr controllers feature
  49179. */
  49180. static readonly PHYSICS_CONTROLLERS: string;
  49181. /**
  49182. * The name of the plane detection feature
  49183. */
  49184. static readonly PLANE_DETECTION: string;
  49185. /**
  49186. * The name of the pointer selection feature
  49187. */
  49188. static readonly POINTER_SELECTION: string;
  49189. /**
  49190. * The name of the teleportation feature
  49191. */
  49192. static readonly TELEPORTATION: string;
  49193. /**
  49194. * The name of the feature points feature.
  49195. */
  49196. static readonly FEATURE_POINTS: string;
  49197. /**
  49198. * The name of the hand tracking feature.
  49199. */
  49200. static readonly HAND_TRACKING: string;
  49201. }
  49202. /**
  49203. * Defining the constructor of a feature. Used to register the modules.
  49204. */
  49205. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  49206. /**
  49207. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  49208. * It is mainly used in AR sessions.
  49209. *
  49210. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  49211. */
  49212. export class WebXRFeaturesManager implements IDisposable {
  49213. private _xrSessionManager;
  49214. private static readonly _AvailableFeatures;
  49215. private _features;
  49216. /**
  49217. * constructs a new features manages.
  49218. *
  49219. * @param _xrSessionManager an instance of WebXRSessionManager
  49220. */
  49221. constructor(_xrSessionManager: WebXRSessionManager);
  49222. /**
  49223. * Used to register a module. After calling this function a developer can use this feature in the scene.
  49224. * Mainly used internally.
  49225. *
  49226. * @param featureName the name of the feature to register
  49227. * @param constructorFunction the function used to construct the module
  49228. * @param version the (babylon) version of the module
  49229. * @param stable is that a stable version of this module
  49230. */
  49231. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  49232. /**
  49233. * Returns a constructor of a specific feature.
  49234. *
  49235. * @param featureName the name of the feature to construct
  49236. * @param version the version of the feature to load
  49237. * @param xrSessionManager the xrSessionManager. Used to construct the module
  49238. * @param options optional options provided to the module.
  49239. * @returns a function that, when called, will return a new instance of this feature
  49240. */
  49241. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  49242. /**
  49243. * Can be used to return the list of features currently registered
  49244. *
  49245. * @returns an Array of available features
  49246. */
  49247. static GetAvailableFeatures(): string[];
  49248. /**
  49249. * Gets the versions available for a specific feature
  49250. * @param featureName the name of the feature
  49251. * @returns an array with the available versions
  49252. */
  49253. static GetAvailableVersions(featureName: string): string[];
  49254. /**
  49255. * Return the latest unstable version of this feature
  49256. * @param featureName the name of the feature to search
  49257. * @returns the version number. if not found will return -1
  49258. */
  49259. static GetLatestVersionOfFeature(featureName: string): number;
  49260. /**
  49261. * Return the latest stable version of this feature
  49262. * @param featureName the name of the feature to search
  49263. * @returns the version number. if not found will return -1
  49264. */
  49265. static GetStableVersionOfFeature(featureName: string): number;
  49266. /**
  49267. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49268. * Can be used during a session to start a feature
  49269. * @param featureName the name of feature to attach
  49270. */
  49271. attachFeature(featureName: string): void;
  49272. /**
  49273. * Can be used inside a session or when the session ends to detach a specific feature
  49274. * @param featureName the name of the feature to detach
  49275. */
  49276. detachFeature(featureName: string): void;
  49277. /**
  49278. * Used to disable an already-enabled feature
  49279. * The feature will be disposed and will be recreated once enabled.
  49280. * @param featureName the feature to disable
  49281. * @returns true if disable was successful
  49282. */
  49283. disableFeature(featureName: string | {
  49284. Name: string;
  49285. }): boolean;
  49286. /**
  49287. * dispose this features manager
  49288. */
  49289. dispose(): void;
  49290. /**
  49291. * 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.
  49292. * 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.
  49293. *
  49294. * @param featureName the name of the feature to load or the class of the feature
  49295. * @param version optional version to load. if not provided the latest version will be enabled
  49296. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49297. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49298. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49299. * @returns a new constructed feature or throws an error if feature not found.
  49300. */
  49301. enableFeature(featureName: string | {
  49302. Name: string;
  49303. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49304. /**
  49305. * get the implementation of an enabled feature.
  49306. * @param featureName the name of the feature to load
  49307. * @returns the feature class, if found
  49308. */
  49309. getEnabledFeature(featureName: string): IWebXRFeature;
  49310. /**
  49311. * Get the list of enabled features
  49312. * @returns an array of enabled features
  49313. */
  49314. getEnabledFeatures(): string[];
  49315. /**
  49316. * This function will exten the session creation configuration object with enabled features.
  49317. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49318. * according to the defined "required" variable, provided during enableFeature call
  49319. * @param xrSessionInit the xr Session init object to extend
  49320. *
  49321. * @returns an extended XRSessionInit object
  49322. */
  49323. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49324. }
  49325. }
  49326. declare module "babylonjs/XR/webXRExperienceHelper" {
  49327. import { Observable } from "babylonjs/Misc/observable";
  49328. import { IDisposable, Scene } from "babylonjs/scene";
  49329. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49330. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49331. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49332. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49333. /**
  49334. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49335. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49336. */
  49337. export class WebXRExperienceHelper implements IDisposable {
  49338. private scene;
  49339. private _nonVRCamera;
  49340. private _originalSceneAutoClear;
  49341. private _supported;
  49342. /**
  49343. * Camera used to render xr content
  49344. */
  49345. camera: WebXRCamera;
  49346. /** A features manager for this xr session */
  49347. featuresManager: WebXRFeaturesManager;
  49348. /**
  49349. * Observers registered here will be triggered after the camera's initial transformation is set
  49350. * This can be used to set a different ground level or an extra rotation.
  49351. *
  49352. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49353. * to the position set after this observable is done executing.
  49354. */
  49355. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49356. /**
  49357. * Fires when the state of the experience helper has changed
  49358. */
  49359. onStateChangedObservable: Observable<WebXRState>;
  49360. /** Session manager used to keep track of xr session */
  49361. sessionManager: WebXRSessionManager;
  49362. /**
  49363. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49364. */
  49365. state: WebXRState;
  49366. /**
  49367. * Creates a WebXRExperienceHelper
  49368. * @param scene The scene the helper should be created in
  49369. */
  49370. private constructor();
  49371. /**
  49372. * Creates the experience helper
  49373. * @param scene the scene to attach the experience helper to
  49374. * @returns a promise for the experience helper
  49375. */
  49376. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49377. /**
  49378. * Disposes of the experience helper
  49379. */
  49380. dispose(): void;
  49381. /**
  49382. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49383. * @param sessionMode options for the XR session
  49384. * @param referenceSpaceType frame of reference of the XR session
  49385. * @param renderTarget the output canvas that will be used to enter XR mode
  49386. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49387. * @returns promise that resolves after xr mode has entered
  49388. */
  49389. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49390. /**
  49391. * Exits XR mode and returns the scene to its original state
  49392. * @returns promise that resolves after xr mode has exited
  49393. */
  49394. exitXRAsync(): Promise<void>;
  49395. private _nonXRToXRCamera;
  49396. private _setState;
  49397. }
  49398. }
  49399. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49400. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49401. import { Observable } from "babylonjs/Misc/observable";
  49402. import { IDisposable } from "babylonjs/scene";
  49403. /**
  49404. * X-Y values for axes in WebXR
  49405. */
  49406. export interface IWebXRMotionControllerAxesValue {
  49407. /**
  49408. * The value of the x axis
  49409. */
  49410. x: number;
  49411. /**
  49412. * The value of the y-axis
  49413. */
  49414. y: number;
  49415. }
  49416. /**
  49417. * changed / previous values for the values of this component
  49418. */
  49419. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49420. /**
  49421. * current (this frame) value
  49422. */
  49423. current: T;
  49424. /**
  49425. * previous (last change) value
  49426. */
  49427. previous: T;
  49428. }
  49429. /**
  49430. * Represents changes in the component between current frame and last values recorded
  49431. */
  49432. export interface IWebXRMotionControllerComponentChanges {
  49433. /**
  49434. * will be populated with previous and current values if axes changed
  49435. */
  49436. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49437. /**
  49438. * will be populated with previous and current values if pressed changed
  49439. */
  49440. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49441. /**
  49442. * will be populated with previous and current values if touched changed
  49443. */
  49444. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49445. /**
  49446. * will be populated with previous and current values if value changed
  49447. */
  49448. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49449. }
  49450. /**
  49451. * This class represents a single component (for example button or thumbstick) of a motion controller
  49452. */
  49453. export class WebXRControllerComponent implements IDisposable {
  49454. /**
  49455. * the id of this component
  49456. */
  49457. id: string;
  49458. /**
  49459. * the type of the component
  49460. */
  49461. type: MotionControllerComponentType;
  49462. private _buttonIndex;
  49463. private _axesIndices;
  49464. private _axes;
  49465. private _changes;
  49466. private _currentValue;
  49467. private _hasChanges;
  49468. private _pressed;
  49469. private _touched;
  49470. /**
  49471. * button component type
  49472. */
  49473. static BUTTON_TYPE: MotionControllerComponentType;
  49474. /**
  49475. * squeeze component type
  49476. */
  49477. static SQUEEZE_TYPE: MotionControllerComponentType;
  49478. /**
  49479. * Thumbstick component type
  49480. */
  49481. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49482. /**
  49483. * Touchpad component type
  49484. */
  49485. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49486. /**
  49487. * trigger component type
  49488. */
  49489. static TRIGGER_TYPE: MotionControllerComponentType;
  49490. /**
  49491. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49492. * the axes data changes
  49493. */
  49494. onAxisValueChangedObservable: Observable<{
  49495. x: number;
  49496. y: number;
  49497. }>;
  49498. /**
  49499. * Observers registered here will be triggered when the state of a button changes
  49500. * State change is either pressed / touched / value
  49501. */
  49502. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49503. /**
  49504. * Creates a new component for a motion controller.
  49505. * It is created by the motion controller itself
  49506. *
  49507. * @param id the id of this component
  49508. * @param type the type of the component
  49509. * @param _buttonIndex index in the buttons array of the gamepad
  49510. * @param _axesIndices indices of the values in the axes array of the gamepad
  49511. */
  49512. constructor(
  49513. /**
  49514. * the id of this component
  49515. */
  49516. id: string,
  49517. /**
  49518. * the type of the component
  49519. */
  49520. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49521. /**
  49522. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49523. */
  49524. get axes(): IWebXRMotionControllerAxesValue;
  49525. /**
  49526. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49527. */
  49528. get changes(): IWebXRMotionControllerComponentChanges;
  49529. /**
  49530. * Return whether or not the component changed the last frame
  49531. */
  49532. get hasChanges(): boolean;
  49533. /**
  49534. * is the button currently pressed
  49535. */
  49536. get pressed(): boolean;
  49537. /**
  49538. * is the button currently touched
  49539. */
  49540. get touched(): boolean;
  49541. /**
  49542. * Get the current value of this component
  49543. */
  49544. get value(): number;
  49545. /**
  49546. * Dispose this component
  49547. */
  49548. dispose(): void;
  49549. /**
  49550. * Are there axes correlating to this component
  49551. * @return true is axes data is available
  49552. */
  49553. isAxes(): boolean;
  49554. /**
  49555. * Is this component a button (hence - pressable)
  49556. * @returns true if can be pressed
  49557. */
  49558. isButton(): boolean;
  49559. /**
  49560. * update this component using the gamepad object it is in. Called on every frame
  49561. * @param nativeController the native gamepad controller object
  49562. */
  49563. update(nativeController: IMinimalMotionControllerObject): void;
  49564. }
  49565. }
  49566. declare module "babylonjs/Loading/sceneLoader" {
  49567. import { Observable } from "babylonjs/Misc/observable";
  49568. import { Nullable } from "babylonjs/types";
  49569. import { Scene } from "babylonjs/scene";
  49570. import { Engine } from "babylonjs/Engines/engine";
  49571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49572. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49573. import { AssetContainer } from "babylonjs/assetContainer";
  49574. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49575. import { Skeleton } from "babylonjs/Bones/skeleton";
  49576. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49577. import { WebRequest } from "babylonjs/Misc/webRequest";
  49578. /**
  49579. * Interface used to represent data loading progression
  49580. */
  49581. export interface ISceneLoaderProgressEvent {
  49582. /**
  49583. * Defines if data length to load can be evaluated
  49584. */
  49585. readonly lengthComputable: boolean;
  49586. /**
  49587. * Defines the loaded data length
  49588. */
  49589. readonly loaded: number;
  49590. /**
  49591. * Defines the data length to load
  49592. */
  49593. readonly total: number;
  49594. }
  49595. /**
  49596. * Interface used by SceneLoader plugins to define supported file extensions
  49597. */
  49598. export interface ISceneLoaderPluginExtensions {
  49599. /**
  49600. * Defines the list of supported extensions
  49601. */
  49602. [extension: string]: {
  49603. isBinary: boolean;
  49604. };
  49605. }
  49606. /**
  49607. * Interface used by SceneLoader plugin factory
  49608. */
  49609. export interface ISceneLoaderPluginFactory {
  49610. /**
  49611. * Defines the name of the factory
  49612. */
  49613. name: string;
  49614. /**
  49615. * Function called to create a new plugin
  49616. * @return the new plugin
  49617. */
  49618. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49619. /**
  49620. * The callback that returns true if the data can be directly loaded.
  49621. * @param data string containing the file data
  49622. * @returns if the data can be loaded directly
  49623. */
  49624. canDirectLoad?(data: string): boolean;
  49625. }
  49626. /**
  49627. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49628. */
  49629. export interface ISceneLoaderPluginBase {
  49630. /**
  49631. * The friendly name of this plugin.
  49632. */
  49633. name: string;
  49634. /**
  49635. * The file extensions supported by this plugin.
  49636. */
  49637. extensions: string | ISceneLoaderPluginExtensions;
  49638. /**
  49639. * The callback called when loading from a url.
  49640. * @param scene scene loading this url
  49641. * @param url url to load
  49642. * @param onSuccess callback called when the file successfully loads
  49643. * @param onProgress callback called while file is loading (if the server supports this mode)
  49644. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49645. * @param onError callback called when the file fails to load
  49646. * @returns a file request object
  49647. */
  49648. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49649. /**
  49650. * The callback called when loading from a file object.
  49651. * @param scene scene loading this file
  49652. * @param file defines the file to load
  49653. * @param onSuccess defines the callback to call when data is loaded
  49654. * @param onProgress defines the callback to call during loading process
  49655. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49656. * @param onError defines the callback to call when an error occurs
  49657. * @returns a file request object
  49658. */
  49659. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49660. /**
  49661. * The callback that returns true if the data can be directly loaded.
  49662. * @param data string containing the file data
  49663. * @returns if the data can be loaded directly
  49664. */
  49665. canDirectLoad?(data: string): boolean;
  49666. /**
  49667. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49668. * @param scene scene loading this data
  49669. * @param data string containing the data
  49670. * @returns data to pass to the plugin
  49671. */
  49672. directLoad?(scene: Scene, data: string): any;
  49673. /**
  49674. * The callback that allows custom handling of the root url based on the response url.
  49675. * @param rootUrl the original root url
  49676. * @param responseURL the response url if available
  49677. * @returns the new root url
  49678. */
  49679. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49680. }
  49681. /**
  49682. * Interface used to define a SceneLoader plugin
  49683. */
  49684. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49685. /**
  49686. * Import meshes into a scene.
  49687. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49688. * @param scene The scene to import into
  49689. * @param data The data to import
  49690. * @param rootUrl The root url for scene and resources
  49691. * @param meshes The meshes array to import into
  49692. * @param particleSystems The particle systems array to import into
  49693. * @param skeletons The skeletons array to import into
  49694. * @param onError The callback when import fails
  49695. * @returns True if successful or false otherwise
  49696. */
  49697. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49698. /**
  49699. * Load into a scene.
  49700. * @param scene The scene to load into
  49701. * @param data The data to import
  49702. * @param rootUrl The root url for scene and resources
  49703. * @param onError The callback when import fails
  49704. * @returns True if successful or false otherwise
  49705. */
  49706. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49707. /**
  49708. * Load into an asset container.
  49709. * @param scene The scene to load into
  49710. * @param data The data to import
  49711. * @param rootUrl The root url for scene and resources
  49712. * @param onError The callback when import fails
  49713. * @returns The loaded asset container
  49714. */
  49715. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49716. }
  49717. /**
  49718. * Interface used to define an async SceneLoader plugin
  49719. */
  49720. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49721. /**
  49722. * Import meshes into a scene.
  49723. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49724. * @param scene The scene to import into
  49725. * @param data The data to import
  49726. * @param rootUrl The root url for scene and resources
  49727. * @param onProgress The callback when the load progresses
  49728. * @param fileName Defines the name of the file to load
  49729. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49730. */
  49731. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49732. meshes: AbstractMesh[];
  49733. particleSystems: IParticleSystem[];
  49734. skeletons: Skeleton[];
  49735. animationGroups: AnimationGroup[];
  49736. }>;
  49737. /**
  49738. * Load into a scene.
  49739. * @param scene The scene to load into
  49740. * @param data The data to import
  49741. * @param rootUrl The root url for scene and resources
  49742. * @param onProgress The callback when the load progresses
  49743. * @param fileName Defines the name of the file to load
  49744. * @returns Nothing
  49745. */
  49746. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49747. /**
  49748. * Load into an asset container.
  49749. * @param scene The scene to load into
  49750. * @param data The data to import
  49751. * @param rootUrl The root url for scene and resources
  49752. * @param onProgress The callback when the load progresses
  49753. * @param fileName Defines the name of the file to load
  49754. * @returns The loaded asset container
  49755. */
  49756. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49757. }
  49758. /**
  49759. * Mode that determines how to handle old animation groups before loading new ones.
  49760. */
  49761. export enum SceneLoaderAnimationGroupLoadingMode {
  49762. /**
  49763. * Reset all old animations to initial state then dispose them.
  49764. */
  49765. Clean = 0,
  49766. /**
  49767. * Stop all old animations.
  49768. */
  49769. Stop = 1,
  49770. /**
  49771. * Restart old animations from first frame.
  49772. */
  49773. Sync = 2,
  49774. /**
  49775. * Old animations remains untouched.
  49776. */
  49777. NoSync = 3
  49778. }
  49779. /**
  49780. * Defines a plugin registered by the SceneLoader
  49781. */
  49782. interface IRegisteredPlugin {
  49783. /**
  49784. * Defines the plugin to use
  49785. */
  49786. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49787. /**
  49788. * Defines if the plugin supports binary data
  49789. */
  49790. isBinary: boolean;
  49791. }
  49792. /**
  49793. * Class used to load scene from various file formats using registered plugins
  49794. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49795. */
  49796. export class SceneLoader {
  49797. /**
  49798. * No logging while loading
  49799. */
  49800. static readonly NO_LOGGING: number;
  49801. /**
  49802. * Minimal logging while loading
  49803. */
  49804. static readonly MINIMAL_LOGGING: number;
  49805. /**
  49806. * Summary logging while loading
  49807. */
  49808. static readonly SUMMARY_LOGGING: number;
  49809. /**
  49810. * Detailled logging while loading
  49811. */
  49812. static readonly DETAILED_LOGGING: number;
  49813. /**
  49814. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49815. */
  49816. static get ForceFullSceneLoadingForIncremental(): boolean;
  49817. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49818. /**
  49819. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49820. */
  49821. static get ShowLoadingScreen(): boolean;
  49822. static set ShowLoadingScreen(value: boolean);
  49823. /**
  49824. * Defines the current logging level (while loading the scene)
  49825. * @ignorenaming
  49826. */
  49827. static get loggingLevel(): number;
  49828. static set loggingLevel(value: number);
  49829. /**
  49830. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49831. */
  49832. static get CleanBoneMatrixWeights(): boolean;
  49833. static set CleanBoneMatrixWeights(value: boolean);
  49834. /**
  49835. * Event raised when a plugin is used to load a scene
  49836. */
  49837. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49838. private static _registeredPlugins;
  49839. private static _showingLoadingScreen;
  49840. /**
  49841. * Gets the default plugin (used to load Babylon files)
  49842. * @returns the .babylon plugin
  49843. */
  49844. static GetDefaultPlugin(): IRegisteredPlugin;
  49845. private static _GetPluginForExtension;
  49846. private static _GetPluginForDirectLoad;
  49847. private static _GetPluginForFilename;
  49848. private static _GetDirectLoad;
  49849. private static _LoadData;
  49850. private static _GetFileInfo;
  49851. /**
  49852. * Gets a plugin that can load the given extension
  49853. * @param extension defines the extension to load
  49854. * @returns a plugin or null if none works
  49855. */
  49856. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49857. /**
  49858. * Gets a boolean indicating that the given extension can be loaded
  49859. * @param extension defines the extension to load
  49860. * @returns true if the extension is supported
  49861. */
  49862. static IsPluginForExtensionAvailable(extension: string): boolean;
  49863. /**
  49864. * Adds a new plugin to the list of registered plugins
  49865. * @param plugin defines the plugin to add
  49866. */
  49867. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49868. /**
  49869. * Import meshes into a scene
  49870. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49871. * @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)
  49872. * @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)
  49873. * @param scene the instance of BABYLON.Scene to append to
  49874. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  49875. * @param onProgress a callback with a progress event for each file being loaded
  49876. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49877. * @param pluginExtension the extension used to determine the plugin
  49878. * @returns The loaded plugin
  49879. */
  49880. 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>;
  49881. /**
  49882. * Import meshes into a scene
  49883. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49884. * @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)
  49885. * @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)
  49886. * @param scene the instance of BABYLON.Scene to append to
  49887. * @param onProgress a callback with a progress event for each file being loaded
  49888. * @param pluginExtension the extension used to determine the plugin
  49889. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49890. */
  49891. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49892. meshes: AbstractMesh[];
  49893. particleSystems: IParticleSystem[];
  49894. skeletons: Skeleton[];
  49895. animationGroups: AnimationGroup[];
  49896. }>;
  49897. /**
  49898. * Load a scene
  49899. * @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)
  49900. * @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)
  49901. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49902. * @param onSuccess a callback with the scene when import succeeds
  49903. * @param onProgress a callback with a progress event for each file being loaded
  49904. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49905. * @param pluginExtension the extension used to determine the plugin
  49906. * @returns The loaded plugin
  49907. */
  49908. 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>;
  49909. /**
  49910. * Load a scene
  49911. * @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)
  49912. * @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)
  49913. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49914. * @param onProgress a callback with a progress event for each file being loaded
  49915. * @param pluginExtension the extension used to determine the plugin
  49916. * @returns The loaded scene
  49917. */
  49918. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49919. /**
  49920. * Append a scene
  49921. * @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)
  49922. * @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)
  49923. * @param scene is the instance of BABYLON.Scene to append to
  49924. * @param onSuccess a callback with the scene when import succeeds
  49925. * @param onProgress a callback with a progress event for each file being loaded
  49926. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49927. * @param pluginExtension the extension used to determine the plugin
  49928. * @returns The loaded plugin
  49929. */
  49930. 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>;
  49931. /**
  49932. * Append a scene
  49933. * @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)
  49934. * @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)
  49935. * @param scene is the instance of BABYLON.Scene to append to
  49936. * @param onProgress a callback with a progress event for each file being loaded
  49937. * @param pluginExtension the extension used to determine the plugin
  49938. * @returns The given scene
  49939. */
  49940. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49941. /**
  49942. * Load a scene into an asset container
  49943. * @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)
  49944. * @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)
  49945. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49946. * @param onSuccess a callback with the scene when import succeeds
  49947. * @param onProgress a callback with a progress event for each file being loaded
  49948. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49949. * @param pluginExtension the extension used to determine the plugin
  49950. * @returns The loaded plugin
  49951. */
  49952. 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>;
  49953. /**
  49954. * Load a scene into an asset container
  49955. * @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)
  49956. * @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)
  49957. * @param scene is the instance of Scene to append to
  49958. * @param onProgress a callback with a progress event for each file being loaded
  49959. * @param pluginExtension the extension used to determine the plugin
  49960. * @returns The loaded asset container
  49961. */
  49962. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49963. /**
  49964. * Import animations from a file into a scene
  49965. * @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)
  49966. * @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)
  49967. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49968. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49969. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49970. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49971. * @param onSuccess a callback with the scene when import succeeds
  49972. * @param onProgress a callback with a progress event for each file being loaded
  49973. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49974. * @param pluginExtension the extension used to determine the plugin
  49975. */
  49976. 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;
  49977. /**
  49978. * Import animations from a file into a scene
  49979. * @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)
  49980. * @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)
  49981. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49982. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49983. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49984. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49985. * @param onSuccess a callback with the scene when import succeeds
  49986. * @param onProgress a callback with a progress event for each file being loaded
  49987. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49988. * @param pluginExtension the extension used to determine the plugin
  49989. * @returns the updated scene with imported animations
  49990. */
  49991. 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>;
  49992. }
  49993. }
  49994. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49995. import { IDisposable, Scene } from "babylonjs/scene";
  49996. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49997. import { Observable } from "babylonjs/Misc/observable";
  49998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49999. import { Nullable } from "babylonjs/types";
  50000. /**
  50001. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  50002. */
  50003. export type MotionControllerHandedness = "none" | "left" | "right";
  50004. /**
  50005. * The type of components available in motion controllers.
  50006. * This is not the name of the component.
  50007. */
  50008. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  50009. /**
  50010. * The state of a controller component
  50011. */
  50012. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  50013. /**
  50014. * The schema of motion controller layout.
  50015. * No object will be initialized using this interface
  50016. * This is used just to define the profile.
  50017. */
  50018. export interface IMotionControllerLayout {
  50019. /**
  50020. * Path to load the assets. Usually relative to the base path
  50021. */
  50022. assetPath: string;
  50023. /**
  50024. * Available components (unsorted)
  50025. */
  50026. components: {
  50027. /**
  50028. * A map of component Ids
  50029. */
  50030. [componentId: string]: {
  50031. /**
  50032. * The type of input the component outputs
  50033. */
  50034. type: MotionControllerComponentType;
  50035. /**
  50036. * The indices of this component in the gamepad object
  50037. */
  50038. gamepadIndices: {
  50039. /**
  50040. * Index of button
  50041. */
  50042. button?: number;
  50043. /**
  50044. * If available, index of x-axis
  50045. */
  50046. xAxis?: number;
  50047. /**
  50048. * If available, index of y-axis
  50049. */
  50050. yAxis?: number;
  50051. };
  50052. /**
  50053. * The mesh's root node name
  50054. */
  50055. rootNodeName: string;
  50056. /**
  50057. * Animation definitions for this model
  50058. */
  50059. visualResponses: {
  50060. [stateKey: string]: {
  50061. /**
  50062. * What property will be animated
  50063. */
  50064. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  50065. /**
  50066. * What states influence this visual response
  50067. */
  50068. states: MotionControllerComponentStateType[];
  50069. /**
  50070. * Type of animation - movement or visibility
  50071. */
  50072. valueNodeProperty: "transform" | "visibility";
  50073. /**
  50074. * Base node name to move. Its position will be calculated according to the min and max nodes
  50075. */
  50076. valueNodeName?: string;
  50077. /**
  50078. * Minimum movement node
  50079. */
  50080. minNodeName?: string;
  50081. /**
  50082. * Max movement node
  50083. */
  50084. maxNodeName?: string;
  50085. };
  50086. };
  50087. /**
  50088. * If touch enabled, what is the name of node to display user feedback
  50089. */
  50090. touchPointNodeName?: string;
  50091. };
  50092. };
  50093. /**
  50094. * Is it xr standard mapping or not
  50095. */
  50096. gamepadMapping: "" | "xr-standard";
  50097. /**
  50098. * Base root node of this entire model
  50099. */
  50100. rootNodeName: string;
  50101. /**
  50102. * Defines the main button component id
  50103. */
  50104. selectComponentId: string;
  50105. }
  50106. /**
  50107. * A definition for the layout map in the input profile
  50108. */
  50109. export interface IMotionControllerLayoutMap {
  50110. /**
  50111. * Layouts with handedness type as a key
  50112. */
  50113. [handedness: string]: IMotionControllerLayout;
  50114. }
  50115. /**
  50116. * The XR Input profile schema
  50117. * Profiles can be found here:
  50118. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  50119. */
  50120. export interface IMotionControllerProfile {
  50121. /**
  50122. * fallback profiles for this profileId
  50123. */
  50124. fallbackProfileIds: string[];
  50125. /**
  50126. * The layout map, with handedness as key
  50127. */
  50128. layouts: IMotionControllerLayoutMap;
  50129. /**
  50130. * The id of this profile
  50131. * correlates to the profile(s) in the xrInput.profiles array
  50132. */
  50133. profileId: string;
  50134. }
  50135. /**
  50136. * A helper-interface for the 3 meshes needed for controller button animation
  50137. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  50138. */
  50139. export interface IMotionControllerButtonMeshMap {
  50140. /**
  50141. * the mesh that defines the pressed value mesh position.
  50142. * This is used to find the max-position of this button
  50143. */
  50144. pressedMesh: AbstractMesh;
  50145. /**
  50146. * the mesh that defines the unpressed value mesh position.
  50147. * This is used to find the min (or initial) position of this button
  50148. */
  50149. unpressedMesh: AbstractMesh;
  50150. /**
  50151. * The mesh that will be changed when value changes
  50152. */
  50153. valueMesh: AbstractMesh;
  50154. }
  50155. /**
  50156. * A helper-interface for the 3 meshes needed for controller axis animation.
  50157. * This will be expanded when touchpad animations are fully supported
  50158. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  50159. */
  50160. export interface IMotionControllerMeshMap {
  50161. /**
  50162. * the mesh that defines the maximum value mesh position.
  50163. */
  50164. maxMesh?: AbstractMesh;
  50165. /**
  50166. * the mesh that defines the minimum value mesh position.
  50167. */
  50168. minMesh?: AbstractMesh;
  50169. /**
  50170. * The mesh that will be changed when axis value changes
  50171. */
  50172. valueMesh?: AbstractMesh;
  50173. }
  50174. /**
  50175. * The elements needed for change-detection of the gamepad objects in motion controllers
  50176. */
  50177. export interface IMinimalMotionControllerObject {
  50178. /**
  50179. * Available axes of this controller
  50180. */
  50181. axes: number[];
  50182. /**
  50183. * An array of available buttons
  50184. */
  50185. buttons: Array<{
  50186. /**
  50187. * Value of the button/trigger
  50188. */
  50189. value: number;
  50190. /**
  50191. * If the button/trigger is currently touched
  50192. */
  50193. touched: boolean;
  50194. /**
  50195. * If the button/trigger is currently pressed
  50196. */
  50197. pressed: boolean;
  50198. }>;
  50199. /**
  50200. * EXPERIMENTAL haptic support.
  50201. */
  50202. hapticActuators?: Array<{
  50203. pulse: (value: number, duration: number) => Promise<boolean>;
  50204. }>;
  50205. }
  50206. /**
  50207. * An Abstract Motion controller
  50208. * This class receives an xrInput and a profile layout and uses those to initialize the components
  50209. * Each component has an observable to check for changes in value and state
  50210. */
  50211. export abstract class WebXRAbstractMotionController implements IDisposable {
  50212. protected scene: Scene;
  50213. protected layout: IMotionControllerLayout;
  50214. /**
  50215. * The gamepad object correlating to this controller
  50216. */
  50217. gamepadObject: IMinimalMotionControllerObject;
  50218. /**
  50219. * handedness (left/right/none) of this controller
  50220. */
  50221. handedness: MotionControllerHandedness;
  50222. private _initComponent;
  50223. private _modelReady;
  50224. /**
  50225. * A map of components (WebXRControllerComponent) in this motion controller
  50226. * Components have a ComponentType and can also have both button and axis definitions
  50227. */
  50228. readonly components: {
  50229. [id: string]: WebXRControllerComponent;
  50230. };
  50231. /**
  50232. * Disable the model's animation. Can be set at any time.
  50233. */
  50234. disableAnimation: boolean;
  50235. /**
  50236. * Observers registered here will be triggered when the model of this controller is done loading
  50237. */
  50238. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  50239. /**
  50240. * The profile id of this motion controller
  50241. */
  50242. abstract profileId: string;
  50243. /**
  50244. * The root mesh of the model. It is null if the model was not yet initialized
  50245. */
  50246. rootMesh: Nullable<AbstractMesh>;
  50247. /**
  50248. * constructs a new abstract motion controller
  50249. * @param scene the scene to which the model of the controller will be added
  50250. * @param layout The profile layout to load
  50251. * @param gamepadObject The gamepad object correlating to this controller
  50252. * @param handedness handedness (left/right/none) of this controller
  50253. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50254. */
  50255. constructor(scene: Scene, layout: IMotionControllerLayout,
  50256. /**
  50257. * The gamepad object correlating to this controller
  50258. */
  50259. gamepadObject: IMinimalMotionControllerObject,
  50260. /**
  50261. * handedness (left/right/none) of this controller
  50262. */
  50263. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50264. /**
  50265. * Dispose this controller, the model mesh and all its components
  50266. */
  50267. dispose(): void;
  50268. /**
  50269. * Returns all components of specific type
  50270. * @param type the type to search for
  50271. * @return an array of components with this type
  50272. */
  50273. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50274. /**
  50275. * get a component based an its component id as defined in layout.components
  50276. * @param id the id of the component
  50277. * @returns the component correlates to the id or undefined if not found
  50278. */
  50279. getComponent(id: string): WebXRControllerComponent;
  50280. /**
  50281. * Get the list of components available in this motion controller
  50282. * @returns an array of strings correlating to available components
  50283. */
  50284. getComponentIds(): string[];
  50285. /**
  50286. * Get the first component of specific type
  50287. * @param type type of component to find
  50288. * @return a controller component or null if not found
  50289. */
  50290. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50291. /**
  50292. * Get the main (Select) component of this controller as defined in the layout
  50293. * @returns the main component of this controller
  50294. */
  50295. getMainComponent(): WebXRControllerComponent;
  50296. /**
  50297. * Loads the model correlating to this controller
  50298. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50299. * @returns A promise fulfilled with the result of the model loading
  50300. */
  50301. loadModel(): Promise<boolean>;
  50302. /**
  50303. * Update this model using the current XRFrame
  50304. * @param xrFrame the current xr frame to use and update the model
  50305. */
  50306. updateFromXRFrame(xrFrame: XRFrame): void;
  50307. /**
  50308. * Backwards compatibility due to a deeply-integrated typo
  50309. */
  50310. get handness(): XREye;
  50311. /**
  50312. * Pulse (vibrate) this controller
  50313. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50314. * Consecutive calls to this function will cancel the last pulse call
  50315. *
  50316. * @param value the strength of the pulse in 0.0...1.0 range
  50317. * @param duration Duration of the pulse in milliseconds
  50318. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50319. * @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
  50320. */
  50321. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50322. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50323. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50324. /**
  50325. * Moves the axis on the controller mesh based on its current state
  50326. * @param axis the index of the axis
  50327. * @param axisValue the value of the axis which determines the meshes new position
  50328. * @hidden
  50329. */
  50330. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50331. /**
  50332. * Update the model itself with the current frame data
  50333. * @param xrFrame the frame to use for updating the model mesh
  50334. */
  50335. protected updateModel(xrFrame: XRFrame): void;
  50336. /**
  50337. * Get the filename and path for this controller's model
  50338. * @returns a map of filename and path
  50339. */
  50340. protected abstract _getFilenameAndPath(): {
  50341. filename: string;
  50342. path: string;
  50343. };
  50344. /**
  50345. * This function is called before the mesh is loaded. It checks for loading constraints.
  50346. * For example, this function can check if the GLB loader is available
  50347. * If this function returns false, the generic controller will be loaded instead
  50348. * @returns Is the client ready to load the mesh
  50349. */
  50350. protected abstract _getModelLoadingConstraints(): boolean;
  50351. /**
  50352. * This function will be called after the model was successfully loaded and can be used
  50353. * for mesh transformations before it is available for the user
  50354. * @param meshes the loaded meshes
  50355. */
  50356. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50357. /**
  50358. * Set the root mesh for this controller. Important for the WebXR controller class
  50359. * @param meshes the loaded meshes
  50360. */
  50361. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50362. /**
  50363. * A function executed each frame that updates the mesh (if needed)
  50364. * @param xrFrame the current xrFrame
  50365. */
  50366. protected abstract _updateModel(xrFrame: XRFrame): void;
  50367. private _getGenericFilenameAndPath;
  50368. private _getGenericParentMesh;
  50369. }
  50370. }
  50371. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50372. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50374. import { Scene } from "babylonjs/scene";
  50375. /**
  50376. * A generic trigger-only motion controller for WebXR
  50377. */
  50378. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50379. /**
  50380. * Static version of the profile id of this controller
  50381. */
  50382. static ProfileId: string;
  50383. profileId: string;
  50384. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50385. protected _getFilenameAndPath(): {
  50386. filename: string;
  50387. path: string;
  50388. };
  50389. protected _getModelLoadingConstraints(): boolean;
  50390. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50391. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50392. protected _updateModel(): void;
  50393. }
  50394. }
  50395. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50396. import { Vector4 } from "babylonjs/Maths/math.vector";
  50397. import { Mesh } from "babylonjs/Meshes/mesh";
  50398. import { Scene } from "babylonjs/scene";
  50399. import { Nullable } from "babylonjs/types";
  50400. /**
  50401. * Class containing static functions to help procedurally build meshes
  50402. */
  50403. export class SphereBuilder {
  50404. /**
  50405. * Creates a sphere mesh
  50406. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50407. * * 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`)
  50408. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50409. * * 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
  50410. * * 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)
  50411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50414. * @param name defines the name of the mesh
  50415. * @param options defines the options used to create the mesh
  50416. * @param scene defines the hosting scene
  50417. * @returns the sphere mesh
  50418. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50419. */
  50420. static CreateSphere(name: string, options: {
  50421. segments?: number;
  50422. diameter?: number;
  50423. diameterX?: number;
  50424. diameterY?: number;
  50425. diameterZ?: number;
  50426. arc?: number;
  50427. slice?: number;
  50428. sideOrientation?: number;
  50429. frontUVs?: Vector4;
  50430. backUVs?: Vector4;
  50431. updatable?: boolean;
  50432. }, scene?: Nullable<Scene>): Mesh;
  50433. }
  50434. }
  50435. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50437. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50438. import { Scene } from "babylonjs/scene";
  50439. /**
  50440. * A profiled motion controller has its profile loaded from an online repository.
  50441. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50442. */
  50443. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50444. private _repositoryUrl;
  50445. private _buttonMeshMapping;
  50446. private _touchDots;
  50447. /**
  50448. * The profile ID of this controller. Will be populated when the controller initializes.
  50449. */
  50450. profileId: string;
  50451. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50452. dispose(): void;
  50453. protected _getFilenameAndPath(): {
  50454. filename: string;
  50455. path: string;
  50456. };
  50457. protected _getModelLoadingConstraints(): boolean;
  50458. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50459. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50460. protected _updateModel(_xrFrame: XRFrame): void;
  50461. }
  50462. }
  50463. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50464. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50465. import { Scene } from "babylonjs/scene";
  50466. /**
  50467. * A construction function type to create a new controller based on an xrInput object
  50468. */
  50469. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50470. /**
  50471. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50472. *
  50473. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50474. * it should be replaced with auto-loaded controllers.
  50475. *
  50476. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50477. */
  50478. export class WebXRMotionControllerManager {
  50479. private static _AvailableControllers;
  50480. private static _Fallbacks;
  50481. private static _ProfileLoadingPromises;
  50482. private static _ProfilesList;
  50483. /**
  50484. * The base URL of the online controller repository. Can be changed at any time.
  50485. */
  50486. static BaseRepositoryUrl: string;
  50487. /**
  50488. * Which repository gets priority - local or online
  50489. */
  50490. static PrioritizeOnlineRepository: boolean;
  50491. /**
  50492. * Use the online repository, or use only locally-defined controllers
  50493. */
  50494. static UseOnlineRepository: boolean;
  50495. /**
  50496. * Clear the cache used for profile loading and reload when requested again
  50497. */
  50498. static ClearProfilesCache(): void;
  50499. /**
  50500. * Register the default fallbacks.
  50501. * This function is called automatically when this file is imported.
  50502. */
  50503. static DefaultFallbacks(): void;
  50504. /**
  50505. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50506. * @param profileId the profile to which a fallback needs to be found
  50507. * @return an array with corresponding fallback profiles
  50508. */
  50509. static FindFallbackWithProfileId(profileId: string): string[];
  50510. /**
  50511. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50512. * The order of search:
  50513. *
  50514. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50515. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50516. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50517. * 4) return the generic trigger controller if none were found
  50518. *
  50519. * @param xrInput the xrInput to which a new controller is initialized
  50520. * @param scene the scene to which the model will be added
  50521. * @param forceProfile force a certain profile for this controller
  50522. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50523. */
  50524. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50525. /**
  50526. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50527. *
  50528. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50529. *
  50530. * @param type the profile type to register
  50531. * @param constructFunction the function to be called when loading this profile
  50532. */
  50533. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50534. /**
  50535. * Register a fallback to a specific profile.
  50536. * @param profileId the profileId that will receive the fallbacks
  50537. * @param fallbacks A list of fallback profiles
  50538. */
  50539. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50540. /**
  50541. * Will update the list of profiles available in the repository
  50542. * @return a promise that resolves to a map of profiles available online
  50543. */
  50544. static UpdateProfilesList(): Promise<{
  50545. [profile: string]: string;
  50546. }>;
  50547. private static _LoadProfileFromRepository;
  50548. private static _LoadProfilesFromAvailableControllers;
  50549. }
  50550. }
  50551. declare module "babylonjs/XR/webXRInputSource" {
  50552. import { Observable } from "babylonjs/Misc/observable";
  50553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50554. import { Ray } from "babylonjs/Culling/ray";
  50555. import { Scene } from "babylonjs/scene";
  50556. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50557. /**
  50558. * Configuration options for the WebXR controller creation
  50559. */
  50560. export interface IWebXRControllerOptions {
  50561. /**
  50562. * Should the controller mesh be animated when a user interacts with it
  50563. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50564. */
  50565. disableMotionControllerAnimation?: boolean;
  50566. /**
  50567. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50568. */
  50569. doNotLoadControllerMesh?: boolean;
  50570. /**
  50571. * Force a specific controller type for this controller.
  50572. * This can be used when creating your own profile or when testing different controllers
  50573. */
  50574. forceControllerProfile?: string;
  50575. /**
  50576. * Defines a rendering group ID for meshes that will be loaded.
  50577. * This is for the default controllers only.
  50578. */
  50579. renderingGroupId?: number;
  50580. }
  50581. /**
  50582. * Represents an XR controller
  50583. */
  50584. export class WebXRInputSource {
  50585. private _scene;
  50586. /** The underlying input source for the controller */
  50587. inputSource: XRInputSource;
  50588. private _options;
  50589. private _tmpVector;
  50590. private _uniqueId;
  50591. private _disposed;
  50592. /**
  50593. * 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
  50594. */
  50595. grip?: AbstractMesh;
  50596. /**
  50597. * If available, this is the gamepad object related to this controller.
  50598. * Using this object it is possible to get click events and trackpad changes of the
  50599. * webxr controller that is currently being used.
  50600. */
  50601. motionController?: WebXRAbstractMotionController;
  50602. /**
  50603. * Event that fires when the controller is removed/disposed.
  50604. * The object provided as event data is this controller, after associated assets were disposed.
  50605. * uniqueId is still available.
  50606. */
  50607. onDisposeObservable: Observable<WebXRInputSource>;
  50608. /**
  50609. * Will be triggered when the mesh associated with the motion controller is done loading.
  50610. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50611. * A shortened version of controller -> motion controller -> on mesh loaded.
  50612. */
  50613. onMeshLoadedObservable: Observable<AbstractMesh>;
  50614. /**
  50615. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50616. */
  50617. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50618. /**
  50619. * Pointer which can be used to select objects or attach a visible laser to
  50620. */
  50621. pointer: AbstractMesh;
  50622. /**
  50623. * Creates the input source object
  50624. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50625. * @param _scene the scene which the controller should be associated to
  50626. * @param inputSource the underlying input source for the controller
  50627. * @param _options options for this controller creation
  50628. */
  50629. constructor(_scene: Scene,
  50630. /** The underlying input source for the controller */
  50631. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50632. /**
  50633. * Get this controllers unique id
  50634. */
  50635. get uniqueId(): string;
  50636. /**
  50637. * Disposes of the object
  50638. */
  50639. dispose(): void;
  50640. /**
  50641. * Gets a world space ray coming from the pointer or grip
  50642. * @param result the resulting ray
  50643. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50644. */
  50645. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50646. /**
  50647. * Updates the controller pose based on the given XRFrame
  50648. * @param xrFrame xr frame to update the pose with
  50649. * @param referenceSpace reference space to use
  50650. */
  50651. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50652. }
  50653. }
  50654. declare module "babylonjs/XR/webXRInput" {
  50655. import { Observable } from "babylonjs/Misc/observable";
  50656. import { IDisposable } from "babylonjs/scene";
  50657. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50658. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50659. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50660. /**
  50661. * The schema for initialization options of the XR Input class
  50662. */
  50663. export interface IWebXRInputOptions {
  50664. /**
  50665. * If set to true no model will be automatically loaded
  50666. */
  50667. doNotLoadControllerMeshes?: boolean;
  50668. /**
  50669. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50670. * If not found, the xr input profile data will be used.
  50671. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50672. */
  50673. forceInputProfile?: string;
  50674. /**
  50675. * Do not send a request to the controller repository to load the profile.
  50676. *
  50677. * Instead, use the controllers available in babylon itself.
  50678. */
  50679. disableOnlineControllerRepository?: boolean;
  50680. /**
  50681. * A custom URL for the controllers repository
  50682. */
  50683. customControllersRepositoryURL?: string;
  50684. /**
  50685. * Should the controller model's components not move according to the user input
  50686. */
  50687. disableControllerAnimation?: boolean;
  50688. /**
  50689. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50690. */
  50691. controllerOptions?: IWebXRControllerOptions;
  50692. }
  50693. /**
  50694. * XR input used to track XR inputs such as controllers/rays
  50695. */
  50696. export class WebXRInput implements IDisposable {
  50697. /**
  50698. * the xr session manager for this session
  50699. */
  50700. xrSessionManager: WebXRSessionManager;
  50701. /**
  50702. * the WebXR camera for this session. Mainly used for teleportation
  50703. */
  50704. xrCamera: WebXRCamera;
  50705. private readonly options;
  50706. /**
  50707. * XR controllers being tracked
  50708. */
  50709. controllers: Array<WebXRInputSource>;
  50710. private _frameObserver;
  50711. private _sessionEndedObserver;
  50712. private _sessionInitObserver;
  50713. /**
  50714. * Event when a controller has been connected/added
  50715. */
  50716. onControllerAddedObservable: Observable<WebXRInputSource>;
  50717. /**
  50718. * Event when a controller has been removed/disconnected
  50719. */
  50720. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50721. /**
  50722. * Initializes the WebXRInput
  50723. * @param xrSessionManager the xr session manager for this session
  50724. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50725. * @param options = initialization options for this xr input
  50726. */
  50727. constructor(
  50728. /**
  50729. * the xr session manager for this session
  50730. */
  50731. xrSessionManager: WebXRSessionManager,
  50732. /**
  50733. * the WebXR camera for this session. Mainly used for teleportation
  50734. */
  50735. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50736. private _onInputSourcesChange;
  50737. private _addAndRemoveControllers;
  50738. /**
  50739. * Disposes of the object
  50740. */
  50741. dispose(): void;
  50742. }
  50743. }
  50744. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50745. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50746. import { Observable, EventState } from "babylonjs/Misc/observable";
  50747. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50748. /**
  50749. * This is the base class for all WebXR features.
  50750. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50751. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50752. */
  50753. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50754. protected _xrSessionManager: WebXRSessionManager;
  50755. private _attached;
  50756. private _removeOnDetach;
  50757. /**
  50758. * Is this feature disposed?
  50759. */
  50760. isDisposed: boolean;
  50761. /**
  50762. * Should auto-attach be disabled?
  50763. */
  50764. disableAutoAttach: boolean;
  50765. /**
  50766. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50767. */
  50768. xrNativeFeatureName: string;
  50769. /**
  50770. * Construct a new (abstract) WebXR feature
  50771. * @param _xrSessionManager the xr session manager for this feature
  50772. */
  50773. constructor(_xrSessionManager: WebXRSessionManager);
  50774. /**
  50775. * Is this feature attached
  50776. */
  50777. get attached(): boolean;
  50778. /**
  50779. * attach this feature
  50780. *
  50781. * @param force should attachment be forced (even when already attached)
  50782. * @returns true if successful, false is failed or already attached
  50783. */
  50784. attach(force?: boolean): boolean;
  50785. /**
  50786. * detach this feature.
  50787. *
  50788. * @returns true if successful, false if failed or already detached
  50789. */
  50790. detach(): boolean;
  50791. /**
  50792. * Dispose this feature and all of the resources attached
  50793. */
  50794. dispose(): void;
  50795. /**
  50796. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50797. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50798. *
  50799. * @returns whether or not the feature is compatible in this environment
  50800. */
  50801. isCompatible(): boolean;
  50802. /**
  50803. * This is used to register callbacks that will automatically be removed when detach is called.
  50804. * @param observable the observable to which the observer will be attached
  50805. * @param callback the callback to register
  50806. */
  50807. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50808. /**
  50809. * Code in this function will be executed on each xrFrame received from the browser.
  50810. * This function will not execute after the feature is detached.
  50811. * @param _xrFrame the current frame
  50812. */
  50813. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50814. }
  50815. }
  50816. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50817. import { IDisposable, Scene } from "babylonjs/scene";
  50818. import { Nullable } from "babylonjs/types";
  50819. import { Observable } from "babylonjs/Misc/observable";
  50820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50821. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50822. import { Camera } from "babylonjs/Cameras/camera";
  50823. /**
  50824. * Renders a layer on top of an existing scene
  50825. */
  50826. export class UtilityLayerRenderer implements IDisposable {
  50827. /** the original scene that will be rendered on top of */
  50828. originalScene: Scene;
  50829. private _pointerCaptures;
  50830. private _lastPointerEvents;
  50831. private static _DefaultUtilityLayer;
  50832. private static _DefaultKeepDepthUtilityLayer;
  50833. private _sharedGizmoLight;
  50834. private _renderCamera;
  50835. /**
  50836. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50837. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50838. * @returns the camera that is used when rendering the utility layer
  50839. */
  50840. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50841. /**
  50842. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50843. * @param cam the camera that should be used when rendering the utility layer
  50844. */
  50845. setRenderCamera(cam: Nullable<Camera>): void;
  50846. /**
  50847. * @hidden
  50848. * Light which used by gizmos to get light shading
  50849. */
  50850. _getSharedGizmoLight(): HemisphericLight;
  50851. /**
  50852. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50853. */
  50854. pickUtilitySceneFirst: boolean;
  50855. /**
  50856. * 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)
  50857. */
  50858. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50859. /**
  50860. * 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)
  50861. */
  50862. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50863. /**
  50864. * The scene that is rendered on top of the original scene
  50865. */
  50866. utilityLayerScene: Scene;
  50867. /**
  50868. * If the utility layer should automatically be rendered on top of existing scene
  50869. */
  50870. shouldRender: boolean;
  50871. /**
  50872. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50873. */
  50874. onlyCheckPointerDownEvents: boolean;
  50875. /**
  50876. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50877. */
  50878. processAllEvents: boolean;
  50879. /**
  50880. * Observable raised when the pointer move from the utility layer scene to the main scene
  50881. */
  50882. onPointerOutObservable: Observable<number>;
  50883. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50884. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50885. private _afterRenderObserver;
  50886. private _sceneDisposeObserver;
  50887. private _originalPointerObserver;
  50888. /**
  50889. * Instantiates a UtilityLayerRenderer
  50890. * @param originalScene the original scene that will be rendered on top of
  50891. * @param handleEvents boolean indicating if the utility layer should handle events
  50892. */
  50893. constructor(
  50894. /** the original scene that will be rendered on top of */
  50895. originalScene: Scene, handleEvents?: boolean);
  50896. private _notifyObservers;
  50897. /**
  50898. * Renders the utility layers scene on top of the original scene
  50899. */
  50900. render(): void;
  50901. /**
  50902. * Disposes of the renderer
  50903. */
  50904. dispose(): void;
  50905. private _updateCamera;
  50906. }
  50907. }
  50908. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50909. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50911. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50912. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50913. import { Scene } from "babylonjs/scene";
  50914. import { Nullable } from "babylonjs/types";
  50915. import { Color3 } from "babylonjs/Maths/math.color";
  50916. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50917. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50918. /**
  50919. * Options interface for the pointer selection module
  50920. */
  50921. export interface IWebXRControllerPointerSelectionOptions {
  50922. /**
  50923. * if provided, this scene will be used to render meshes.
  50924. */
  50925. customUtilityLayerScene?: Scene;
  50926. /**
  50927. * 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)
  50928. * If not disabled, the last picked point will be used to execute a pointer up event
  50929. * If disabled, pointer up event will be triggered right after the pointer down event.
  50930. * Used in screen and gaze target ray mode only
  50931. */
  50932. disablePointerUpOnTouchOut: boolean;
  50933. /**
  50934. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50935. */
  50936. forceGazeMode: boolean;
  50937. /**
  50938. * 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
  50939. * to start a new countdown to the pointer down event.
  50940. * Defaults to 1.
  50941. */
  50942. gazeModePointerMovedFactor?: number;
  50943. /**
  50944. * Different button type to use instead of the main component
  50945. */
  50946. overrideButtonId?: string;
  50947. /**
  50948. * use this rendering group id for the meshes (optional)
  50949. */
  50950. renderingGroupId?: number;
  50951. /**
  50952. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50953. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50954. * 3000 means 3 seconds between pointing at something and selecting it
  50955. */
  50956. timeToSelect?: number;
  50957. /**
  50958. * Should meshes created here be added to a utility layer or the main scene
  50959. */
  50960. useUtilityLayer?: boolean;
  50961. /**
  50962. * Optional WebXR camera to be used for gaze selection
  50963. */
  50964. gazeCamera?: WebXRCamera;
  50965. /**
  50966. * the xr input to use with this pointer selection
  50967. */
  50968. xrInput: WebXRInput;
  50969. }
  50970. /**
  50971. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50972. */
  50973. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50974. private readonly _options;
  50975. private static _idCounter;
  50976. private _attachController;
  50977. private _controllers;
  50978. private _scene;
  50979. private _tmpVectorForPickCompare;
  50980. /**
  50981. * The module's name
  50982. */
  50983. static readonly Name: string;
  50984. /**
  50985. * The (Babylon) version of this module.
  50986. * This is an integer representing the implementation version.
  50987. * This number does not correspond to the WebXR specs version
  50988. */
  50989. static readonly Version: number;
  50990. /**
  50991. * Disable lighting on the laser pointer (so it will always be visible)
  50992. */
  50993. disablePointerLighting: boolean;
  50994. /**
  50995. * Disable lighting on the selection mesh (so it will always be visible)
  50996. */
  50997. disableSelectionMeshLighting: boolean;
  50998. /**
  50999. * Should the laser pointer be displayed
  51000. */
  51001. displayLaserPointer: boolean;
  51002. /**
  51003. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  51004. */
  51005. displaySelectionMesh: boolean;
  51006. /**
  51007. * This color will be set to the laser pointer when selection is triggered
  51008. */
  51009. laserPointerPickedColor: Color3;
  51010. /**
  51011. * Default color of the laser pointer
  51012. */
  51013. laserPointerDefaultColor: Color3;
  51014. /**
  51015. * default color of the selection ring
  51016. */
  51017. selectionMeshDefaultColor: Color3;
  51018. /**
  51019. * This color will be applied to the selection ring when selection is triggered
  51020. */
  51021. selectionMeshPickedColor: Color3;
  51022. /**
  51023. * Optional filter to be used for ray selection. This predicate shares behavior with
  51024. * scene.pointerMovePredicate which takes priority if it is also assigned.
  51025. */
  51026. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51027. /**
  51028. * constructs a new background remover module
  51029. * @param _xrSessionManager the session manager for this module
  51030. * @param _options read-only options to be used in this module
  51031. */
  51032. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  51033. /**
  51034. * attach this feature
  51035. * Will usually be called by the features manager
  51036. *
  51037. * @returns true if successful.
  51038. */
  51039. attach(): boolean;
  51040. /**
  51041. * detach this feature.
  51042. * Will usually be called by the features manager
  51043. *
  51044. * @returns true if successful.
  51045. */
  51046. detach(): boolean;
  51047. /**
  51048. * Will get the mesh under a specific pointer.
  51049. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  51050. * @param controllerId the controllerId to check
  51051. * @returns The mesh under pointer or null if no mesh is under the pointer
  51052. */
  51053. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  51054. /**
  51055. * Get the xr controller that correlates to the pointer id in the pointer event
  51056. *
  51057. * @param id the pointer id to search for
  51058. * @returns the controller that correlates to this id or null if not found
  51059. */
  51060. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  51061. protected _onXRFrame(_xrFrame: XRFrame): void;
  51062. private _attachGazeMode;
  51063. private _attachScreenRayMode;
  51064. private _attachTrackedPointerRayMode;
  51065. private _convertNormalToDirectionOfRay;
  51066. private _detachController;
  51067. private _generateNewMeshPair;
  51068. private _pickingMoved;
  51069. private _updatePointerDistance;
  51070. /** @hidden */
  51071. get lasterPointerDefaultColor(): Color3;
  51072. }
  51073. }
  51074. declare module "babylonjs/XR/webXREnterExitUI" {
  51075. import { Nullable } from "babylonjs/types";
  51076. import { Observable } from "babylonjs/Misc/observable";
  51077. import { IDisposable, Scene } from "babylonjs/scene";
  51078. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51079. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51080. /**
  51081. * Button which can be used to enter a different mode of XR
  51082. */
  51083. export class WebXREnterExitUIButton {
  51084. /** button element */
  51085. element: HTMLElement;
  51086. /** XR initialization options for the button */
  51087. sessionMode: XRSessionMode;
  51088. /** Reference space type */
  51089. referenceSpaceType: XRReferenceSpaceType;
  51090. /**
  51091. * Creates a WebXREnterExitUIButton
  51092. * @param element button element
  51093. * @param sessionMode XR initialization session mode
  51094. * @param referenceSpaceType the type of reference space to be used
  51095. */
  51096. constructor(
  51097. /** button element */
  51098. element: HTMLElement,
  51099. /** XR initialization options for the button */
  51100. sessionMode: XRSessionMode,
  51101. /** Reference space type */
  51102. referenceSpaceType: XRReferenceSpaceType);
  51103. /**
  51104. * Extendable function which can be used to update the button's visuals when the state changes
  51105. * @param activeButton the current active button in the UI
  51106. */
  51107. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  51108. }
  51109. /**
  51110. * Options to create the webXR UI
  51111. */
  51112. export class WebXREnterExitUIOptions {
  51113. /**
  51114. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  51115. */
  51116. customButtons?: Array<WebXREnterExitUIButton>;
  51117. /**
  51118. * A reference space type to use when creating the default button.
  51119. * Default is local-floor
  51120. */
  51121. referenceSpaceType?: XRReferenceSpaceType;
  51122. /**
  51123. * Context to enter xr with
  51124. */
  51125. renderTarget?: Nullable<WebXRRenderTarget>;
  51126. /**
  51127. * A session mode to use when creating the default button.
  51128. * Default is immersive-vr
  51129. */
  51130. sessionMode?: XRSessionMode;
  51131. /**
  51132. * A list of optional features to init the session with
  51133. */
  51134. optionalFeatures?: string[];
  51135. /**
  51136. * A list of optional features to init the session with
  51137. */
  51138. requiredFeatures?: string[];
  51139. }
  51140. /**
  51141. * UI to allow the user to enter/exit XR mode
  51142. */
  51143. export class WebXREnterExitUI implements IDisposable {
  51144. private scene;
  51145. /** version of the options passed to this UI */
  51146. options: WebXREnterExitUIOptions;
  51147. private _activeButton;
  51148. private _buttons;
  51149. /**
  51150. * The HTML Div Element to which buttons are added.
  51151. */
  51152. readonly overlay: HTMLDivElement;
  51153. /**
  51154. * Fired every time the active button is changed.
  51155. *
  51156. * When xr is entered via a button that launches xr that button will be the callback parameter
  51157. *
  51158. * When exiting xr the callback parameter will be null)
  51159. */
  51160. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  51161. /**
  51162. *
  51163. * @param scene babylon scene object to use
  51164. * @param options (read-only) version of the options passed to this UI
  51165. */
  51166. private constructor();
  51167. /**
  51168. * Creates UI to allow the user to enter/exit XR mode
  51169. * @param scene the scene to add the ui to
  51170. * @param helper the xr experience helper to enter/exit xr with
  51171. * @param options options to configure the UI
  51172. * @returns the created ui
  51173. */
  51174. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  51175. /**
  51176. * Disposes of the XR UI component
  51177. */
  51178. dispose(): void;
  51179. private _updateButtons;
  51180. }
  51181. }
  51182. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  51183. import { Vector3 } from "babylonjs/Maths/math.vector";
  51184. import { Color4 } from "babylonjs/Maths/math.color";
  51185. import { Nullable } from "babylonjs/types";
  51186. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51187. import { Scene } from "babylonjs/scene";
  51188. /**
  51189. * Class containing static functions to help procedurally build meshes
  51190. */
  51191. export class LinesBuilder {
  51192. /**
  51193. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51194. * * 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
  51195. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51196. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51197. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51198. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51199. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51200. * * 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
  51201. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51204. * @param name defines the name of the new line system
  51205. * @param options defines the options used to create the line system
  51206. * @param scene defines the hosting scene
  51207. * @returns a new line system mesh
  51208. */
  51209. static CreateLineSystem(name: string, options: {
  51210. lines: Vector3[][];
  51211. updatable?: boolean;
  51212. instance?: Nullable<LinesMesh>;
  51213. colors?: Nullable<Color4[][]>;
  51214. useVertexAlpha?: boolean;
  51215. }, scene: Nullable<Scene>): LinesMesh;
  51216. /**
  51217. * Creates a line mesh
  51218. * 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
  51219. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51220. * * The parameter `points` is an array successive Vector3
  51221. * * 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
  51222. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51223. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51224. * * When updating an instance, remember that only point positions can change, not the number of points
  51225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51226. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51227. * @param name defines the name of the new line system
  51228. * @param options defines the options used to create the line system
  51229. * @param scene defines the hosting scene
  51230. * @returns a new line mesh
  51231. */
  51232. static CreateLines(name: string, options: {
  51233. points: Vector3[];
  51234. updatable?: boolean;
  51235. instance?: Nullable<LinesMesh>;
  51236. colors?: Color4[];
  51237. useVertexAlpha?: boolean;
  51238. }, scene?: Nullable<Scene>): LinesMesh;
  51239. /**
  51240. * Creates a dashed line mesh
  51241. * * 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
  51242. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51243. * * The parameter `points` is an array successive Vector3
  51244. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51245. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51246. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51247. * * 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
  51248. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51249. * * When updating an instance, remember that only point positions can change, not the number of points
  51250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51251. * @param name defines the name of the mesh
  51252. * @param options defines the options used to create the mesh
  51253. * @param scene defines the hosting scene
  51254. * @returns the dashed line mesh
  51255. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51256. */
  51257. static CreateDashedLines(name: string, options: {
  51258. points: Vector3[];
  51259. dashSize?: number;
  51260. gapSize?: number;
  51261. dashNb?: number;
  51262. updatable?: boolean;
  51263. instance?: LinesMesh;
  51264. useVertexAlpha?: boolean;
  51265. }, scene?: Nullable<Scene>): LinesMesh;
  51266. }
  51267. }
  51268. declare module "babylonjs/Misc/timer" {
  51269. import { Observable, Observer } from "babylonjs/Misc/observable";
  51270. import { Nullable } from "babylonjs/types";
  51271. import { IDisposable } from "babylonjs/scene";
  51272. /**
  51273. * Construction options for a timer
  51274. */
  51275. export interface ITimerOptions<T> {
  51276. /**
  51277. * Time-to-end
  51278. */
  51279. timeout: number;
  51280. /**
  51281. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51282. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51283. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51284. */
  51285. contextObservable: Observable<T>;
  51286. /**
  51287. * Optional parameters when adding an observer to the observable
  51288. */
  51289. observableParameters?: {
  51290. mask?: number;
  51291. insertFirst?: boolean;
  51292. scope?: any;
  51293. };
  51294. /**
  51295. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51296. */
  51297. breakCondition?: (data?: ITimerData<T>) => boolean;
  51298. /**
  51299. * Will be triggered when the time condition has met
  51300. */
  51301. onEnded?: (data: ITimerData<any>) => void;
  51302. /**
  51303. * Will be triggered when the break condition has met (prematurely ended)
  51304. */
  51305. onAborted?: (data: ITimerData<any>) => void;
  51306. /**
  51307. * Optional function to execute on each tick (or count)
  51308. */
  51309. onTick?: (data: ITimerData<any>) => void;
  51310. }
  51311. /**
  51312. * An interface defining the data sent by the timer
  51313. */
  51314. export interface ITimerData<T> {
  51315. /**
  51316. * When did it start
  51317. */
  51318. startTime: number;
  51319. /**
  51320. * Time now
  51321. */
  51322. currentTime: number;
  51323. /**
  51324. * Time passed since started
  51325. */
  51326. deltaTime: number;
  51327. /**
  51328. * How much is completed, in [0.0...1.0].
  51329. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51330. */
  51331. completeRate: number;
  51332. /**
  51333. * What the registered observable sent in the last count
  51334. */
  51335. payload: T;
  51336. }
  51337. /**
  51338. * The current state of the timer
  51339. */
  51340. export enum TimerState {
  51341. /**
  51342. * Timer initialized, not yet started
  51343. */
  51344. INIT = 0,
  51345. /**
  51346. * Timer started and counting
  51347. */
  51348. STARTED = 1,
  51349. /**
  51350. * Timer ended (whether aborted or time reached)
  51351. */
  51352. ENDED = 2
  51353. }
  51354. /**
  51355. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51356. *
  51357. * @param options options with which to initialize this timer
  51358. */
  51359. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51360. /**
  51361. * An advanced implementation of a timer class
  51362. */
  51363. export class AdvancedTimer<T = any> implements IDisposable {
  51364. /**
  51365. * Will notify each time the timer calculates the remaining time
  51366. */
  51367. onEachCountObservable: Observable<ITimerData<T>>;
  51368. /**
  51369. * Will trigger when the timer was aborted due to the break condition
  51370. */
  51371. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51372. /**
  51373. * Will trigger when the timer ended successfully
  51374. */
  51375. onTimerEndedObservable: Observable<ITimerData<T>>;
  51376. /**
  51377. * Will trigger when the timer state has changed
  51378. */
  51379. onStateChangedObservable: Observable<TimerState>;
  51380. private _observer;
  51381. private _contextObservable;
  51382. private _observableParameters;
  51383. private _startTime;
  51384. private _timer;
  51385. private _state;
  51386. private _breakCondition;
  51387. private _timeToEnd;
  51388. private _breakOnNextTick;
  51389. /**
  51390. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51391. * @param options construction options for this advanced timer
  51392. */
  51393. constructor(options: ITimerOptions<T>);
  51394. /**
  51395. * set a breaking condition for this timer. Default is to never break during count
  51396. * @param predicate the new break condition. Returns true to break, false otherwise
  51397. */
  51398. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51399. /**
  51400. * Reset ALL associated observables in this advanced timer
  51401. */
  51402. clearObservables(): void;
  51403. /**
  51404. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51405. *
  51406. * @param timeToEnd how much time to measure until timer ended
  51407. */
  51408. start(timeToEnd?: number): void;
  51409. /**
  51410. * Will force a stop on the next tick.
  51411. */
  51412. stop(): void;
  51413. /**
  51414. * Dispose this timer, clearing all resources
  51415. */
  51416. dispose(): void;
  51417. private _setState;
  51418. private _tick;
  51419. private _stop;
  51420. }
  51421. }
  51422. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51423. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51424. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51425. import { Nullable } from "babylonjs/types";
  51426. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51428. import { Vector3 } from "babylonjs/Maths/math.vector";
  51429. import { Material } from "babylonjs/Materials/material";
  51430. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51431. import { Scene } from "babylonjs/scene";
  51432. /**
  51433. * The options container for the teleportation module
  51434. */
  51435. export interface IWebXRTeleportationOptions {
  51436. /**
  51437. * if provided, this scene will be used to render meshes.
  51438. */
  51439. customUtilityLayerScene?: Scene;
  51440. /**
  51441. * Values to configure the default target mesh
  51442. */
  51443. defaultTargetMeshOptions?: {
  51444. /**
  51445. * Fill color of the teleportation area
  51446. */
  51447. teleportationFillColor?: string;
  51448. /**
  51449. * Border color for the teleportation area
  51450. */
  51451. teleportationBorderColor?: string;
  51452. /**
  51453. * Disable the mesh's animation sequence
  51454. */
  51455. disableAnimation?: boolean;
  51456. /**
  51457. * Disable lighting on the material or the ring and arrow
  51458. */
  51459. disableLighting?: boolean;
  51460. /**
  51461. * Override the default material of the torus and arrow
  51462. */
  51463. torusArrowMaterial?: Material;
  51464. };
  51465. /**
  51466. * A list of meshes to use as floor meshes.
  51467. * Meshes can be added and removed after initializing the feature using the
  51468. * addFloorMesh and removeFloorMesh functions
  51469. * If empty, rotation will still work
  51470. */
  51471. floorMeshes?: AbstractMesh[];
  51472. /**
  51473. * use this rendering group id for the meshes (optional)
  51474. */
  51475. renderingGroupId?: number;
  51476. /**
  51477. * Should teleportation move only to snap points
  51478. */
  51479. snapPointsOnly?: boolean;
  51480. /**
  51481. * An array of points to which the teleportation will snap to.
  51482. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51483. */
  51484. snapPositions?: Vector3[];
  51485. /**
  51486. * How close should the teleportation ray be in order to snap to position.
  51487. * Default to 0.8 units (meters)
  51488. */
  51489. snapToPositionRadius?: number;
  51490. /**
  51491. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51492. * If you want to support rotation, make sure your mesh has a direction indicator.
  51493. *
  51494. * When left untouched, the default mesh will be initialized.
  51495. */
  51496. teleportationTargetMesh?: AbstractMesh;
  51497. /**
  51498. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51499. */
  51500. timeToTeleport?: number;
  51501. /**
  51502. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51503. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51504. */
  51505. useMainComponentOnly?: boolean;
  51506. /**
  51507. * Should meshes created here be added to a utility layer or the main scene
  51508. */
  51509. useUtilityLayer?: boolean;
  51510. /**
  51511. * Babylon XR Input class for controller
  51512. */
  51513. xrInput: WebXRInput;
  51514. /**
  51515. * Meshes that the teleportation ray cannot go through
  51516. */
  51517. pickBlockerMeshes?: AbstractMesh[];
  51518. }
  51519. /**
  51520. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51521. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51522. * the input of the attached controllers.
  51523. */
  51524. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51525. private _options;
  51526. private _controllers;
  51527. private _currentTeleportationControllerId;
  51528. private _floorMeshes;
  51529. private _quadraticBezierCurve;
  51530. private _selectionFeature;
  51531. private _snapToPositions;
  51532. private _snappedToPoint;
  51533. private _teleportationRingMaterial?;
  51534. private _tmpRay;
  51535. private _tmpVector;
  51536. private _tmpQuaternion;
  51537. /**
  51538. * The module's name
  51539. */
  51540. static readonly Name: string;
  51541. /**
  51542. * The (Babylon) version of this module.
  51543. * This is an integer representing the implementation version.
  51544. * This number does not correspond to the webxr specs version
  51545. */
  51546. static readonly Version: number;
  51547. /**
  51548. * Is movement backwards enabled
  51549. */
  51550. backwardsMovementEnabled: boolean;
  51551. /**
  51552. * Distance to travel when moving backwards
  51553. */
  51554. backwardsTeleportationDistance: number;
  51555. /**
  51556. * The distance from the user to the inspection point in the direction of the controller
  51557. * A higher number will allow the user to move further
  51558. * defaults to 5 (meters, in xr units)
  51559. */
  51560. parabolicCheckRadius: number;
  51561. /**
  51562. * Should the module support parabolic ray on top of direct ray
  51563. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51564. * Very helpful when moving between floors / different heights
  51565. */
  51566. parabolicRayEnabled: boolean;
  51567. /**
  51568. * How much rotation should be applied when rotating right and left
  51569. */
  51570. rotationAngle: number;
  51571. /**
  51572. * Is rotation enabled when moving forward?
  51573. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51574. */
  51575. rotationEnabled: boolean;
  51576. /**
  51577. * constructs a new anchor system
  51578. * @param _xrSessionManager an instance of WebXRSessionManager
  51579. * @param _options configuration object for this feature
  51580. */
  51581. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51582. /**
  51583. * Get the snapPointsOnly flag
  51584. */
  51585. get snapPointsOnly(): boolean;
  51586. /**
  51587. * Sets the snapPointsOnly flag
  51588. * @param snapToPoints should teleportation be exclusively to snap points
  51589. */
  51590. set snapPointsOnly(snapToPoints: boolean);
  51591. /**
  51592. * Add a new mesh to the floor meshes array
  51593. * @param mesh the mesh to use as floor mesh
  51594. */
  51595. addFloorMesh(mesh: AbstractMesh): void;
  51596. /**
  51597. * Add a new snap-to point to fix teleportation to this position
  51598. * @param newSnapPoint The new Snap-To point
  51599. */
  51600. addSnapPoint(newSnapPoint: Vector3): void;
  51601. attach(): boolean;
  51602. detach(): boolean;
  51603. dispose(): void;
  51604. /**
  51605. * Remove a mesh from the floor meshes array
  51606. * @param mesh the mesh to remove
  51607. */
  51608. removeFloorMesh(mesh: AbstractMesh): void;
  51609. /**
  51610. * Remove a mesh from the floor meshes array using its name
  51611. * @param name the mesh name to remove
  51612. */
  51613. removeFloorMeshByName(name: string): void;
  51614. /**
  51615. * 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
  51616. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51617. * @returns was the point found and removed or not
  51618. */
  51619. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51620. /**
  51621. * This function sets a selection feature that will be disabled when
  51622. * the forward ray is shown and will be reattached when hidden.
  51623. * This is used to remove the selection rays when moving.
  51624. * @param selectionFeature the feature to disable when forward movement is enabled
  51625. */
  51626. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51627. protected _onXRFrame(_xrFrame: XRFrame): void;
  51628. private _attachController;
  51629. private _createDefaultTargetMesh;
  51630. private _detachController;
  51631. private _findClosestSnapPointWithRadius;
  51632. private _setTargetMeshPosition;
  51633. private _setTargetMeshVisibility;
  51634. private _showParabolicPath;
  51635. private _teleportForward;
  51636. }
  51637. }
  51638. declare module "babylonjs/XR/webXRDefaultExperience" {
  51639. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51640. import { Scene } from "babylonjs/scene";
  51641. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51642. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51643. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51644. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51646. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51647. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51648. /**
  51649. * Options for the default xr helper
  51650. */
  51651. export class WebXRDefaultExperienceOptions {
  51652. /**
  51653. * Enable or disable default UI to enter XR
  51654. */
  51655. disableDefaultUI?: boolean;
  51656. /**
  51657. * Should teleportation not initialize. defaults to false.
  51658. */
  51659. disableTeleportation?: boolean;
  51660. /**
  51661. * Floor meshes that will be used for teleport
  51662. */
  51663. floorMeshes?: Array<AbstractMesh>;
  51664. /**
  51665. * If set to true, the first frame will not be used to reset position
  51666. * The first frame is mainly used when copying transformation from the old camera
  51667. * Mainly used in AR
  51668. */
  51669. ignoreNativeCameraTransformation?: boolean;
  51670. /**
  51671. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51672. */
  51673. inputOptions?: IWebXRInputOptions;
  51674. /**
  51675. * optional configuration for the output canvas
  51676. */
  51677. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51678. /**
  51679. * optional UI options. This can be used among other to change session mode and reference space type
  51680. */
  51681. uiOptions?: WebXREnterExitUIOptions;
  51682. /**
  51683. * When loading teleportation and pointer select, use stable versions instead of latest.
  51684. */
  51685. useStablePlugins?: boolean;
  51686. /**
  51687. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51688. */
  51689. renderingGroupId?: number;
  51690. /**
  51691. * A list of optional features to init the session with
  51692. * If set to true, all features we support will be added
  51693. */
  51694. optionalFeatures?: boolean | string[];
  51695. }
  51696. /**
  51697. * Default experience which provides a similar setup to the previous webVRExperience
  51698. */
  51699. export class WebXRDefaultExperience {
  51700. /**
  51701. * Base experience
  51702. */
  51703. baseExperience: WebXRExperienceHelper;
  51704. /**
  51705. * Enables ui for entering/exiting xr
  51706. */
  51707. enterExitUI: WebXREnterExitUI;
  51708. /**
  51709. * Input experience extension
  51710. */
  51711. input: WebXRInput;
  51712. /**
  51713. * Enables laser pointer and selection
  51714. */
  51715. pointerSelection: WebXRControllerPointerSelection;
  51716. /**
  51717. * Default target xr should render to
  51718. */
  51719. renderTarget: WebXRRenderTarget;
  51720. /**
  51721. * Enables teleportation
  51722. */
  51723. teleportation: WebXRMotionControllerTeleportation;
  51724. private constructor();
  51725. /**
  51726. * Creates the default xr experience
  51727. * @param scene scene
  51728. * @param options options for basic configuration
  51729. * @returns resulting WebXRDefaultExperience
  51730. */
  51731. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51732. /**
  51733. * DIsposes of the experience helper
  51734. */
  51735. dispose(): void;
  51736. }
  51737. }
  51738. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51739. import { Observable } from "babylonjs/Misc/observable";
  51740. import { Nullable } from "babylonjs/types";
  51741. import { Camera } from "babylonjs/Cameras/camera";
  51742. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51743. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51744. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51745. import { Scene } from "babylonjs/scene";
  51746. import { Vector3 } from "babylonjs/Maths/math.vector";
  51747. import { Color3 } from "babylonjs/Maths/math.color";
  51748. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51750. import { Mesh } from "babylonjs/Meshes/mesh";
  51751. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51752. import { EasingFunction } from "babylonjs/Animations/easing";
  51753. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51754. import "babylonjs/Meshes/Builders/groundBuilder";
  51755. import "babylonjs/Meshes/Builders/torusBuilder";
  51756. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51757. import "babylonjs/Gamepads/gamepadSceneComponent";
  51758. import "babylonjs/Animations/animatable";
  51759. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51760. /**
  51761. * Options to modify the vr teleportation behavior.
  51762. */
  51763. export interface VRTeleportationOptions {
  51764. /**
  51765. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51766. */
  51767. floorMeshName?: string;
  51768. /**
  51769. * A list of meshes to be used as the teleportation floor. (default: empty)
  51770. */
  51771. floorMeshes?: Mesh[];
  51772. /**
  51773. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51774. */
  51775. teleportationMode?: number;
  51776. /**
  51777. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51778. */
  51779. teleportationTime?: number;
  51780. /**
  51781. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51782. */
  51783. teleportationSpeed?: number;
  51784. /**
  51785. * The easing function used in the animation or null for Linear. (default CircleEase)
  51786. */
  51787. easingFunction?: EasingFunction;
  51788. }
  51789. /**
  51790. * Options to modify the vr experience helper's behavior.
  51791. */
  51792. export interface VRExperienceHelperOptions extends WebVROptions {
  51793. /**
  51794. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51795. */
  51796. createDeviceOrientationCamera?: boolean;
  51797. /**
  51798. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51799. */
  51800. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51801. /**
  51802. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51803. */
  51804. laserToggle?: boolean;
  51805. /**
  51806. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51807. */
  51808. floorMeshes?: Mesh[];
  51809. /**
  51810. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51811. */
  51812. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51813. /**
  51814. * Defines if WebXR should be used instead of WebVR (if available)
  51815. */
  51816. useXR?: boolean;
  51817. }
  51818. /**
  51819. * Event containing information after VR has been entered
  51820. */
  51821. export class OnAfterEnteringVRObservableEvent {
  51822. /**
  51823. * If entering vr was successful
  51824. */
  51825. success: boolean;
  51826. }
  51827. /**
  51828. * Helps to quickly add VR support to an existing scene.
  51829. * See https://doc.babylonjs.com/how_to/webvr_helper
  51830. */
  51831. export class VRExperienceHelper {
  51832. /** Options to modify the vr experience helper's behavior. */
  51833. webVROptions: VRExperienceHelperOptions;
  51834. private _scene;
  51835. private _position;
  51836. private _btnVR;
  51837. private _btnVRDisplayed;
  51838. private _webVRsupported;
  51839. private _webVRready;
  51840. private _webVRrequesting;
  51841. private _webVRpresenting;
  51842. private _hasEnteredVR;
  51843. private _fullscreenVRpresenting;
  51844. private _inputElement;
  51845. private _webVRCamera;
  51846. private _vrDeviceOrientationCamera;
  51847. private _deviceOrientationCamera;
  51848. private _existingCamera;
  51849. private _onKeyDown;
  51850. private _onVrDisplayPresentChange;
  51851. private _onVRDisplayChanged;
  51852. private _onVRRequestPresentStart;
  51853. private _onVRRequestPresentComplete;
  51854. /**
  51855. * 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)
  51856. */
  51857. enableGazeEvenWhenNoPointerLock: boolean;
  51858. /**
  51859. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51860. */
  51861. exitVROnDoubleTap: boolean;
  51862. /**
  51863. * Observable raised right before entering VR.
  51864. */
  51865. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51866. /**
  51867. * Observable raised when entering VR has completed.
  51868. */
  51869. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51870. /**
  51871. * Observable raised when exiting VR.
  51872. */
  51873. onExitingVRObservable: Observable<VRExperienceHelper>;
  51874. /**
  51875. * Observable raised when controller mesh is loaded.
  51876. */
  51877. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51878. /** Return this.onEnteringVRObservable
  51879. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51880. */
  51881. get onEnteringVR(): Observable<VRExperienceHelper>;
  51882. /** Return this.onExitingVRObservable
  51883. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51884. */
  51885. get onExitingVR(): Observable<VRExperienceHelper>;
  51886. /** Return this.onControllerMeshLoadedObservable
  51887. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51888. */
  51889. get onControllerMeshLoaded(): Observable<WebVRController>;
  51890. private _rayLength;
  51891. private _useCustomVRButton;
  51892. private _teleportationRequested;
  51893. private _teleportActive;
  51894. private _floorMeshName;
  51895. private _floorMeshesCollection;
  51896. private _teleportationMode;
  51897. private _teleportationTime;
  51898. private _teleportationSpeed;
  51899. private _teleportationEasing;
  51900. private _rotationAllowed;
  51901. private _teleportBackwardsVector;
  51902. private _teleportationTarget;
  51903. private _isDefaultTeleportationTarget;
  51904. private _postProcessMove;
  51905. private _teleportationFillColor;
  51906. private _teleportationBorderColor;
  51907. private _rotationAngle;
  51908. private _haloCenter;
  51909. private _cameraGazer;
  51910. private _padSensibilityUp;
  51911. private _padSensibilityDown;
  51912. private _leftController;
  51913. private _rightController;
  51914. private _gazeColor;
  51915. private _laserColor;
  51916. private _pickedLaserColor;
  51917. private _pickedGazeColor;
  51918. /**
  51919. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51920. */
  51921. onNewMeshSelected: Observable<AbstractMesh>;
  51922. /**
  51923. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51924. * This observable will provide the mesh and the controller used to select the mesh
  51925. */
  51926. onMeshSelectedWithController: Observable<{
  51927. mesh: AbstractMesh;
  51928. controller: WebVRController;
  51929. }>;
  51930. /**
  51931. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51932. */
  51933. onNewMeshPicked: Observable<PickingInfo>;
  51934. private _circleEase;
  51935. /**
  51936. * Observable raised before camera teleportation
  51937. */
  51938. onBeforeCameraTeleport: Observable<Vector3>;
  51939. /**
  51940. * Observable raised after camera teleportation
  51941. */
  51942. onAfterCameraTeleport: Observable<Vector3>;
  51943. /**
  51944. * Observable raised when current selected mesh gets unselected
  51945. */
  51946. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51947. private _raySelectionPredicate;
  51948. /**
  51949. * To be optionaly changed by user to define custom ray selection
  51950. */
  51951. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51952. /**
  51953. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51954. */
  51955. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51956. /**
  51957. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51958. */
  51959. teleportationEnabled: boolean;
  51960. private _defaultHeight;
  51961. private _teleportationInitialized;
  51962. private _interactionsEnabled;
  51963. private _interactionsRequested;
  51964. private _displayGaze;
  51965. private _displayLaserPointer;
  51966. /**
  51967. * The mesh used to display where the user is going to teleport.
  51968. */
  51969. get teleportationTarget(): Mesh;
  51970. /**
  51971. * Sets the mesh to be used to display where the user is going to teleport.
  51972. */
  51973. set teleportationTarget(value: Mesh);
  51974. /**
  51975. * 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
  51976. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51977. * See https://doc.babylonjs.com/resources/baking_transformations
  51978. */
  51979. get gazeTrackerMesh(): Mesh;
  51980. set gazeTrackerMesh(value: Mesh);
  51981. /**
  51982. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51983. */
  51984. updateGazeTrackerScale: boolean;
  51985. /**
  51986. * If the gaze trackers color should be updated when selecting meshes
  51987. */
  51988. updateGazeTrackerColor: boolean;
  51989. /**
  51990. * If the controller laser color should be updated when selecting meshes
  51991. */
  51992. updateControllerLaserColor: boolean;
  51993. /**
  51994. * The gaze tracking mesh corresponding to the left controller
  51995. */
  51996. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51997. /**
  51998. * The gaze tracking mesh corresponding to the right controller
  51999. */
  52000. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  52001. /**
  52002. * If the ray of the gaze should be displayed.
  52003. */
  52004. get displayGaze(): boolean;
  52005. /**
  52006. * Sets if the ray of the gaze should be displayed.
  52007. */
  52008. set displayGaze(value: boolean);
  52009. /**
  52010. * If the ray of the LaserPointer should be displayed.
  52011. */
  52012. get displayLaserPointer(): boolean;
  52013. /**
  52014. * Sets if the ray of the LaserPointer should be displayed.
  52015. */
  52016. set displayLaserPointer(value: boolean);
  52017. /**
  52018. * The deviceOrientationCamera used as the camera when not in VR.
  52019. */
  52020. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  52021. /**
  52022. * Based on the current WebVR support, returns the current VR camera used.
  52023. */
  52024. get currentVRCamera(): Nullable<Camera>;
  52025. /**
  52026. * The webVRCamera which is used when in VR.
  52027. */
  52028. get webVRCamera(): WebVRFreeCamera;
  52029. /**
  52030. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  52031. */
  52032. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  52033. /**
  52034. * The html button that is used to trigger entering into VR.
  52035. */
  52036. get vrButton(): Nullable<HTMLButtonElement>;
  52037. private get _teleportationRequestInitiated();
  52038. /**
  52039. * Defines whether or not Pointer lock should be requested when switching to
  52040. * full screen.
  52041. */
  52042. requestPointerLockOnFullScreen: boolean;
  52043. /**
  52044. * If asking to force XR, this will be populated with the default xr experience
  52045. */
  52046. xr: WebXRDefaultExperience;
  52047. /**
  52048. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  52049. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  52050. */
  52051. xrTestDone: boolean;
  52052. /**
  52053. * Instantiates a VRExperienceHelper.
  52054. * Helps to quickly add VR support to an existing scene.
  52055. * @param scene The scene the VRExperienceHelper belongs to.
  52056. * @param webVROptions Options to modify the vr experience helper's behavior.
  52057. */
  52058. constructor(scene: Scene,
  52059. /** Options to modify the vr experience helper's behavior. */
  52060. webVROptions?: VRExperienceHelperOptions);
  52061. private completeVRInit;
  52062. private _onDefaultMeshLoaded;
  52063. private _onResize;
  52064. private _onFullscreenChange;
  52065. /**
  52066. * Gets a value indicating if we are currently in VR mode.
  52067. */
  52068. get isInVRMode(): boolean;
  52069. private onVrDisplayPresentChange;
  52070. private onVRDisplayChanged;
  52071. private moveButtonToBottomRight;
  52072. private displayVRButton;
  52073. private updateButtonVisibility;
  52074. private _cachedAngularSensibility;
  52075. /**
  52076. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  52077. * Otherwise, will use the fullscreen API.
  52078. */
  52079. enterVR(): void;
  52080. /**
  52081. * Attempt to exit VR, or fullscreen.
  52082. */
  52083. exitVR(): void;
  52084. /**
  52085. * The position of the vr experience helper.
  52086. */
  52087. get position(): Vector3;
  52088. /**
  52089. * Sets the position of the vr experience helper.
  52090. */
  52091. set position(value: Vector3);
  52092. /**
  52093. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  52094. */
  52095. enableInteractions(): void;
  52096. private get _noControllerIsActive();
  52097. private beforeRender;
  52098. private _isTeleportationFloor;
  52099. /**
  52100. * Adds a floor mesh to be used for teleportation.
  52101. * @param floorMesh the mesh to be used for teleportation.
  52102. */
  52103. addFloorMesh(floorMesh: Mesh): void;
  52104. /**
  52105. * Removes a floor mesh from being used for teleportation.
  52106. * @param floorMesh the mesh to be removed.
  52107. */
  52108. removeFloorMesh(floorMesh: Mesh): void;
  52109. /**
  52110. * Enables interactions and teleportation using the VR controllers and gaze.
  52111. * @param vrTeleportationOptions options to modify teleportation behavior.
  52112. */
  52113. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  52114. private _onNewGamepadConnected;
  52115. private _tryEnableInteractionOnController;
  52116. private _onNewGamepadDisconnected;
  52117. private _enableInteractionOnController;
  52118. private _checkTeleportWithRay;
  52119. private _checkRotate;
  52120. private _checkTeleportBackwards;
  52121. private _enableTeleportationOnController;
  52122. private _createTeleportationCircles;
  52123. private _displayTeleportationTarget;
  52124. private _hideTeleportationTarget;
  52125. private _rotateCamera;
  52126. private _moveTeleportationSelectorTo;
  52127. private _workingVector;
  52128. private _workingQuaternion;
  52129. private _workingMatrix;
  52130. /**
  52131. * Time Constant Teleportation Mode
  52132. */
  52133. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  52134. /**
  52135. * Speed Constant Teleportation Mode
  52136. */
  52137. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  52138. /**
  52139. * Teleports the users feet to the desired location
  52140. * @param location The location where the user's feet should be placed
  52141. */
  52142. teleportCamera(location: Vector3): void;
  52143. private _convertNormalToDirectionOfRay;
  52144. private _castRayAndSelectObject;
  52145. private _notifySelectedMeshUnselected;
  52146. /**
  52147. * Permanently set new colors for the laser pointer
  52148. * @param color the new laser color
  52149. * @param pickedColor the new laser color when picked mesh detected
  52150. */
  52151. setLaserColor(color: Color3, pickedColor?: Color3): void;
  52152. /**
  52153. * Set lighting enabled / disabled on the laser pointer of both controllers
  52154. * @param enabled should the lighting be enabled on the laser pointer
  52155. */
  52156. setLaserLightingState(enabled?: boolean): void;
  52157. /**
  52158. * Permanently set new colors for the gaze pointer
  52159. * @param color the new gaze color
  52160. * @param pickedColor the new gaze color when picked mesh detected
  52161. */
  52162. setGazeColor(color: Color3, pickedColor?: Color3): void;
  52163. /**
  52164. * Sets the color of the laser ray from the vr controllers.
  52165. * @param color new color for the ray.
  52166. */
  52167. changeLaserColor(color: Color3): void;
  52168. /**
  52169. * Sets the color of the ray from the vr headsets gaze.
  52170. * @param color new color for the ray.
  52171. */
  52172. changeGazeColor(color: Color3): void;
  52173. /**
  52174. * Exits VR and disposes of the vr experience helper
  52175. */
  52176. dispose(): void;
  52177. /**
  52178. * Gets the name of the VRExperienceHelper class
  52179. * @returns "VRExperienceHelper"
  52180. */
  52181. getClassName(): string;
  52182. }
  52183. }
  52184. declare module "babylonjs/Cameras/VR/index" {
  52185. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  52186. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  52187. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52188. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  52189. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  52190. export * from "babylonjs/Cameras/VR/webVRCamera";
  52191. }
  52192. declare module "babylonjs/Cameras/RigModes/index" {
  52193. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  52194. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  52195. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  52196. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  52197. }
  52198. declare module "babylonjs/Cameras/index" {
  52199. export * from "babylonjs/Cameras/Inputs/index";
  52200. export * from "babylonjs/Cameras/cameraInputsManager";
  52201. export * from "babylonjs/Cameras/camera";
  52202. export * from "babylonjs/Cameras/targetCamera";
  52203. export * from "babylonjs/Cameras/freeCamera";
  52204. export * from "babylonjs/Cameras/freeCameraInputsManager";
  52205. export * from "babylonjs/Cameras/touchCamera";
  52206. export * from "babylonjs/Cameras/arcRotateCamera";
  52207. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  52208. export * from "babylonjs/Cameras/deviceOrientationCamera";
  52209. export * from "babylonjs/Cameras/flyCamera";
  52210. export * from "babylonjs/Cameras/flyCameraInputsManager";
  52211. export * from "babylonjs/Cameras/followCamera";
  52212. export * from "babylonjs/Cameras/followCameraInputsManager";
  52213. export * from "babylonjs/Cameras/gamepadCamera";
  52214. export * from "babylonjs/Cameras/Stereoscopic/index";
  52215. export * from "babylonjs/Cameras/universalCamera";
  52216. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  52217. export * from "babylonjs/Cameras/VR/index";
  52218. export * from "babylonjs/Cameras/RigModes/index";
  52219. }
  52220. declare module "babylonjs/Collisions/index" {
  52221. export * from "babylonjs/Collisions/collider";
  52222. export * from "babylonjs/Collisions/collisionCoordinator";
  52223. export * from "babylonjs/Collisions/pickingInfo";
  52224. export * from "babylonjs/Collisions/intersectionInfo";
  52225. export * from "babylonjs/Collisions/meshCollisionData";
  52226. }
  52227. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  52228. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  52229. import { Vector3 } from "babylonjs/Maths/math.vector";
  52230. import { Ray } from "babylonjs/Culling/ray";
  52231. import { Plane } from "babylonjs/Maths/math.plane";
  52232. /**
  52233. * Contains an array of blocks representing the octree
  52234. */
  52235. export interface IOctreeContainer<T> {
  52236. /**
  52237. * Blocks within the octree
  52238. */
  52239. blocks: Array<OctreeBlock<T>>;
  52240. }
  52241. /**
  52242. * Class used to store a cell in an octree
  52243. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52244. */
  52245. export class OctreeBlock<T> {
  52246. /**
  52247. * Gets the content of the current block
  52248. */
  52249. entries: T[];
  52250. /**
  52251. * Gets the list of block children
  52252. */
  52253. blocks: Array<OctreeBlock<T>>;
  52254. private _depth;
  52255. private _maxDepth;
  52256. private _capacity;
  52257. private _minPoint;
  52258. private _maxPoint;
  52259. private _boundingVectors;
  52260. private _creationFunc;
  52261. /**
  52262. * Creates a new block
  52263. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52264. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52265. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52266. * @param depth defines the current depth of this block in the octree
  52267. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52268. * @param creationFunc defines a callback to call when an element is added to the block
  52269. */
  52270. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52271. /**
  52272. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52273. */
  52274. get capacity(): number;
  52275. /**
  52276. * Gets the minimum vector (in world space) of the block's bounding box
  52277. */
  52278. get minPoint(): Vector3;
  52279. /**
  52280. * Gets the maximum vector (in world space) of the block's bounding box
  52281. */
  52282. get maxPoint(): Vector3;
  52283. /**
  52284. * Add a new element to this block
  52285. * @param entry defines the element to add
  52286. */
  52287. addEntry(entry: T): void;
  52288. /**
  52289. * Remove an element from this block
  52290. * @param entry defines the element to remove
  52291. */
  52292. removeEntry(entry: T): void;
  52293. /**
  52294. * Add an array of elements to this block
  52295. * @param entries defines the array of elements to add
  52296. */
  52297. addEntries(entries: T[]): void;
  52298. /**
  52299. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52300. * @param frustumPlanes defines the frustum planes to test
  52301. * @param selection defines the array to store current content if selection is positive
  52302. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52303. */
  52304. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52305. /**
  52306. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52307. * @param sphereCenter defines the bounding sphere center
  52308. * @param sphereRadius defines the bounding sphere radius
  52309. * @param selection defines the array to store current content if selection is positive
  52310. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52311. */
  52312. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52313. /**
  52314. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52315. * @param ray defines the ray to test with
  52316. * @param selection defines the array to store current content if selection is positive
  52317. */
  52318. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52319. /**
  52320. * Subdivide the content into child blocks (this block will then be empty)
  52321. */
  52322. createInnerBlocks(): void;
  52323. /**
  52324. * @hidden
  52325. */
  52326. 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;
  52327. }
  52328. }
  52329. declare module "babylonjs/Culling/Octrees/octree" {
  52330. import { SmartArray } from "babylonjs/Misc/smartArray";
  52331. import { Vector3 } from "babylonjs/Maths/math.vector";
  52332. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52334. import { Ray } from "babylonjs/Culling/ray";
  52335. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52336. import { Plane } from "babylonjs/Maths/math.plane";
  52337. /**
  52338. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52339. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52340. */
  52341. export class Octree<T> {
  52342. /** 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.) */
  52343. maxDepth: number;
  52344. /**
  52345. * Blocks within the octree containing objects
  52346. */
  52347. blocks: Array<OctreeBlock<T>>;
  52348. /**
  52349. * Content stored in the octree
  52350. */
  52351. dynamicContent: T[];
  52352. private _maxBlockCapacity;
  52353. private _selectionContent;
  52354. private _creationFunc;
  52355. /**
  52356. * Creates a octree
  52357. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52358. * @param creationFunc function to be used to instatiate the octree
  52359. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52360. * @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.)
  52361. */
  52362. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52363. /** 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.) */
  52364. maxDepth?: number);
  52365. /**
  52366. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52367. * @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);
  52368. * @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);
  52369. * @param entries meshes to be added to the octree blocks
  52370. */
  52371. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52372. /**
  52373. * Adds a mesh to the octree
  52374. * @param entry Mesh to add to the octree
  52375. */
  52376. addMesh(entry: T): void;
  52377. /**
  52378. * Remove an element from the octree
  52379. * @param entry defines the element to remove
  52380. */
  52381. removeMesh(entry: T): void;
  52382. /**
  52383. * Selects an array of meshes within the frustum
  52384. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52385. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52386. * @returns array of meshes within the frustum
  52387. */
  52388. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52389. /**
  52390. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52391. * @param sphereCenter defines the bounding sphere center
  52392. * @param sphereRadius defines the bounding sphere radius
  52393. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52394. * @returns an array of objects that intersect the sphere
  52395. */
  52396. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52397. /**
  52398. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52399. * @param ray defines the ray to test with
  52400. * @returns array of intersected objects
  52401. */
  52402. intersectsRay(ray: Ray): SmartArray<T>;
  52403. /**
  52404. * Adds a mesh into the octree block if it intersects the block
  52405. */
  52406. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52407. /**
  52408. * Adds a submesh into the octree block if it intersects the block
  52409. */
  52410. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52411. }
  52412. }
  52413. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52414. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52415. import { Scene } from "babylonjs/scene";
  52416. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52418. import { Ray } from "babylonjs/Culling/ray";
  52419. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52420. import { Collider } from "babylonjs/Collisions/collider";
  52421. module "babylonjs/scene" {
  52422. interface Scene {
  52423. /**
  52424. * @hidden
  52425. * Backing Filed
  52426. */
  52427. _selectionOctree: Octree<AbstractMesh>;
  52428. /**
  52429. * Gets the octree used to boost mesh selection (picking)
  52430. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52431. */
  52432. selectionOctree: Octree<AbstractMesh>;
  52433. /**
  52434. * Creates or updates the octree used to boost selection (picking)
  52435. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52436. * @param maxCapacity defines the maximum capacity per leaf
  52437. * @param maxDepth defines the maximum depth of the octree
  52438. * @returns an octree of AbstractMesh
  52439. */
  52440. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52441. }
  52442. }
  52443. module "babylonjs/Meshes/abstractMesh" {
  52444. interface AbstractMesh {
  52445. /**
  52446. * @hidden
  52447. * Backing Field
  52448. */
  52449. _submeshesOctree: Octree<SubMesh>;
  52450. /**
  52451. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52452. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52453. * @param maxCapacity defines the maximum size of each block (64 by default)
  52454. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52455. * @returns the new octree
  52456. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52457. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52458. */
  52459. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52460. }
  52461. }
  52462. /**
  52463. * Defines the octree scene component responsible to manage any octrees
  52464. * in a given scene.
  52465. */
  52466. export class OctreeSceneComponent {
  52467. /**
  52468. * The component name help to identify the component in the list of scene components.
  52469. */
  52470. readonly name: string;
  52471. /**
  52472. * The scene the component belongs to.
  52473. */
  52474. scene: Scene;
  52475. /**
  52476. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52477. */
  52478. readonly checksIsEnabled: boolean;
  52479. /**
  52480. * Creates a new instance of the component for the given scene
  52481. * @param scene Defines the scene to register the component in
  52482. */
  52483. constructor(scene: Scene);
  52484. /**
  52485. * Registers the component in a given scene
  52486. */
  52487. register(): void;
  52488. /**
  52489. * Return the list of active meshes
  52490. * @returns the list of active meshes
  52491. */
  52492. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52493. /**
  52494. * Return the list of active sub meshes
  52495. * @param mesh The mesh to get the candidates sub meshes from
  52496. * @returns the list of active sub meshes
  52497. */
  52498. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52499. private _tempRay;
  52500. /**
  52501. * Return the list of sub meshes intersecting with a given local ray
  52502. * @param mesh defines the mesh to find the submesh for
  52503. * @param localRay defines the ray in local space
  52504. * @returns the list of intersecting sub meshes
  52505. */
  52506. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52507. /**
  52508. * Return the list of sub meshes colliding with a collider
  52509. * @param mesh defines the mesh to find the submesh for
  52510. * @param collider defines the collider to evaluate the collision against
  52511. * @returns the list of colliding sub meshes
  52512. */
  52513. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52514. /**
  52515. * Rebuilds the elements related to this component in case of
  52516. * context lost for instance.
  52517. */
  52518. rebuild(): void;
  52519. /**
  52520. * Disposes the component and the associated ressources.
  52521. */
  52522. dispose(): void;
  52523. }
  52524. }
  52525. declare module "babylonjs/Culling/Octrees/index" {
  52526. export * from "babylonjs/Culling/Octrees/octree";
  52527. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52528. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52529. }
  52530. declare module "babylonjs/Culling/index" {
  52531. export * from "babylonjs/Culling/boundingBox";
  52532. export * from "babylonjs/Culling/boundingInfo";
  52533. export * from "babylonjs/Culling/boundingSphere";
  52534. export * from "babylonjs/Culling/Octrees/index";
  52535. export * from "babylonjs/Culling/ray";
  52536. }
  52537. declare module "babylonjs/Gizmos/gizmo" {
  52538. import { Nullable } from "babylonjs/types";
  52539. import { IDisposable } from "babylonjs/scene";
  52540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52541. import { Mesh } from "babylonjs/Meshes/mesh";
  52542. import { Node } from "babylonjs/node";
  52543. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52544. /**
  52545. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52546. */
  52547. export class Gizmo implements IDisposable {
  52548. /** The utility layer the gizmo will be added to */
  52549. gizmoLayer: UtilityLayerRenderer;
  52550. /**
  52551. * The root mesh of the gizmo
  52552. */
  52553. _rootMesh: Mesh;
  52554. private _attachedMesh;
  52555. private _attachedNode;
  52556. /**
  52557. * Ratio for the scale of the gizmo (Default: 1)
  52558. */
  52559. protected _scaleRatio: number;
  52560. /**
  52561. * boolean updated by pointermove when a gizmo mesh is hovered
  52562. */
  52563. protected _isHovered: boolean;
  52564. /**
  52565. * Ratio for the scale of the gizmo (Default: 1)
  52566. */
  52567. set scaleRatio(value: number);
  52568. get scaleRatio(): number;
  52569. /**
  52570. * True when the mouse pointer is hovered a gizmo mesh
  52571. */
  52572. get isHovered(): boolean;
  52573. /**
  52574. * If a custom mesh has been set (Default: false)
  52575. */
  52576. protected _customMeshSet: boolean;
  52577. /**
  52578. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52579. * * When set, interactions will be enabled
  52580. */
  52581. get attachedMesh(): Nullable<AbstractMesh>;
  52582. set attachedMesh(value: Nullable<AbstractMesh>);
  52583. /**
  52584. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52585. * * When set, interactions will be enabled
  52586. */
  52587. get attachedNode(): Nullable<Node>;
  52588. set attachedNode(value: Nullable<Node>);
  52589. /**
  52590. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52591. * @param mesh The mesh to replace the default mesh of the gizmo
  52592. */
  52593. setCustomMesh(mesh: Mesh): void;
  52594. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52595. /**
  52596. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52597. */
  52598. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52599. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52600. /**
  52601. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52602. */
  52603. updateGizmoPositionToMatchAttachedMesh: boolean;
  52604. /**
  52605. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52606. */
  52607. updateScale: boolean;
  52608. protected _interactionsEnabled: boolean;
  52609. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52610. private _beforeRenderObserver;
  52611. private _tempQuaternion;
  52612. private _tempVector;
  52613. private _tempVector2;
  52614. private _tempMatrix1;
  52615. private _tempMatrix2;
  52616. private _rightHandtoLeftHandMatrix;
  52617. /**
  52618. * Creates a gizmo
  52619. * @param gizmoLayer The utility layer the gizmo will be added to
  52620. */
  52621. constructor(
  52622. /** The utility layer the gizmo will be added to */
  52623. gizmoLayer?: UtilityLayerRenderer);
  52624. /**
  52625. * Updates the gizmo to match the attached mesh's position/rotation
  52626. */
  52627. protected _update(): void;
  52628. /**
  52629. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52630. * @param value Node, TransformNode or mesh
  52631. */
  52632. protected _matrixChanged(): void;
  52633. /**
  52634. * Disposes of the gizmo
  52635. */
  52636. dispose(): void;
  52637. }
  52638. }
  52639. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52640. import { Observable } from "babylonjs/Misc/observable";
  52641. import { Nullable } from "babylonjs/types";
  52642. import { Vector3 } from "babylonjs/Maths/math.vector";
  52643. import { Color3 } from "babylonjs/Maths/math.color";
  52644. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52645. import { Node } from "babylonjs/node";
  52646. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52647. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52648. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52649. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52650. import { Scene } from "babylonjs/scene";
  52651. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52652. /**
  52653. * Single plane drag gizmo
  52654. */
  52655. export class PlaneDragGizmo extends Gizmo {
  52656. /**
  52657. * Drag behavior responsible for the gizmos dragging interactions
  52658. */
  52659. dragBehavior: PointerDragBehavior;
  52660. private _pointerObserver;
  52661. /**
  52662. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52663. */
  52664. snapDistance: number;
  52665. /**
  52666. * Event that fires each time the gizmo snaps to a new location.
  52667. * * snapDistance is the the change in distance
  52668. */
  52669. onSnapObservable: Observable<{
  52670. snapDistance: number;
  52671. }>;
  52672. private _plane;
  52673. private _coloredMaterial;
  52674. private _hoverMaterial;
  52675. private _isEnabled;
  52676. private _parent;
  52677. /** @hidden */
  52678. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52679. /** @hidden */
  52680. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52681. /**
  52682. * Creates a PlaneDragGizmo
  52683. * @param gizmoLayer The utility layer the gizmo will be added to
  52684. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52685. * @param color The color of the gizmo
  52686. */
  52687. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52688. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52689. /**
  52690. * If the gizmo is enabled
  52691. */
  52692. set isEnabled(value: boolean);
  52693. get isEnabled(): boolean;
  52694. /**
  52695. * Disposes of the gizmo
  52696. */
  52697. dispose(): void;
  52698. }
  52699. }
  52700. declare module "babylonjs/Gizmos/positionGizmo" {
  52701. import { Observable } from "babylonjs/Misc/observable";
  52702. import { Nullable } from "babylonjs/types";
  52703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52704. import { Node } from "babylonjs/node";
  52705. import { Mesh } from "babylonjs/Meshes/mesh";
  52706. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52707. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52708. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52709. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52710. /**
  52711. * Gizmo that enables dragging a mesh along 3 axis
  52712. */
  52713. export class PositionGizmo extends Gizmo {
  52714. /**
  52715. * Internal gizmo used for interactions on the x axis
  52716. */
  52717. xGizmo: AxisDragGizmo;
  52718. /**
  52719. * Internal gizmo used for interactions on the y axis
  52720. */
  52721. yGizmo: AxisDragGizmo;
  52722. /**
  52723. * Internal gizmo used for interactions on the z axis
  52724. */
  52725. zGizmo: AxisDragGizmo;
  52726. /**
  52727. * Internal gizmo used for interactions on the yz plane
  52728. */
  52729. xPlaneGizmo: PlaneDragGizmo;
  52730. /**
  52731. * Internal gizmo used for interactions on the xz plane
  52732. */
  52733. yPlaneGizmo: PlaneDragGizmo;
  52734. /**
  52735. * Internal gizmo used for interactions on the xy plane
  52736. */
  52737. zPlaneGizmo: PlaneDragGizmo;
  52738. /**
  52739. * private variables
  52740. */
  52741. private _meshAttached;
  52742. private _nodeAttached;
  52743. private _snapDistance;
  52744. /** Fires an event when any of it's sub gizmos are dragged */
  52745. onDragStartObservable: Observable<unknown>;
  52746. /** Fires an event when any of it's sub gizmos are released from dragging */
  52747. onDragEndObservable: Observable<unknown>;
  52748. /**
  52749. * If set to true, planar drag is enabled
  52750. */
  52751. private _planarGizmoEnabled;
  52752. get attachedMesh(): Nullable<AbstractMesh>;
  52753. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52754. get attachedNode(): Nullable<Node>;
  52755. set attachedNode(node: Nullable<Node>);
  52756. /**
  52757. * True when the mouse pointer is hovering a gizmo mesh
  52758. */
  52759. get isHovered(): boolean;
  52760. /**
  52761. * Creates a PositionGizmo
  52762. * @param gizmoLayer The utility layer the gizmo will be added to
  52763. @param thickness display gizmo axis thickness
  52764. */
  52765. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52766. /**
  52767. * If the planar drag gizmo is enabled
  52768. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52769. */
  52770. set planarGizmoEnabled(value: boolean);
  52771. get planarGizmoEnabled(): boolean;
  52772. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52773. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52774. /**
  52775. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52776. */
  52777. set snapDistance(value: number);
  52778. get snapDistance(): number;
  52779. /**
  52780. * Ratio for the scale of the gizmo (Default: 1)
  52781. */
  52782. set scaleRatio(value: number);
  52783. get scaleRatio(): number;
  52784. /**
  52785. * Disposes of the gizmo
  52786. */
  52787. dispose(): void;
  52788. /**
  52789. * CustomMeshes are not supported by this gizmo
  52790. * @param mesh The mesh to replace the default mesh of the gizmo
  52791. */
  52792. setCustomMesh(mesh: Mesh): void;
  52793. }
  52794. }
  52795. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52796. import { Observable } from "babylonjs/Misc/observable";
  52797. import { Nullable } from "babylonjs/types";
  52798. import { Vector3 } from "babylonjs/Maths/math.vector";
  52799. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52800. import { Node } from "babylonjs/node";
  52801. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52802. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52803. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52804. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52805. import { Scene } from "babylonjs/scene";
  52806. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52807. import { Color3 } from "babylonjs/Maths/math.color";
  52808. /**
  52809. * Single axis drag gizmo
  52810. */
  52811. export class AxisDragGizmo extends Gizmo {
  52812. /**
  52813. * Drag behavior responsible for the gizmos dragging interactions
  52814. */
  52815. dragBehavior: PointerDragBehavior;
  52816. private _pointerObserver;
  52817. /**
  52818. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52819. */
  52820. snapDistance: number;
  52821. /**
  52822. * Event that fires each time the gizmo snaps to a new location.
  52823. * * snapDistance is the the change in distance
  52824. */
  52825. onSnapObservable: Observable<{
  52826. snapDistance: number;
  52827. }>;
  52828. private _isEnabled;
  52829. private _parent;
  52830. private _arrow;
  52831. private _coloredMaterial;
  52832. private _hoverMaterial;
  52833. /** @hidden */
  52834. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52835. /** @hidden */
  52836. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52837. /**
  52838. * Creates an AxisDragGizmo
  52839. * @param gizmoLayer The utility layer the gizmo will be added to
  52840. * @param dragAxis The axis which the gizmo will be able to drag on
  52841. * @param color The color of the gizmo
  52842. * @param thickness display gizmo axis thickness
  52843. */
  52844. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52845. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52846. /**
  52847. * If the gizmo is enabled
  52848. */
  52849. set isEnabled(value: boolean);
  52850. get isEnabled(): boolean;
  52851. /**
  52852. * Disposes of the gizmo
  52853. */
  52854. dispose(): void;
  52855. }
  52856. }
  52857. declare module "babylonjs/Debug/axesViewer" {
  52858. import { Vector3 } from "babylonjs/Maths/math.vector";
  52859. import { Nullable } from "babylonjs/types";
  52860. import { Scene } from "babylonjs/scene";
  52861. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52862. /**
  52863. * The Axes viewer will show 3 axes in a specific point in space
  52864. */
  52865. export class AxesViewer {
  52866. private _xAxis;
  52867. private _yAxis;
  52868. private _zAxis;
  52869. private _scaleLinesFactor;
  52870. private _instanced;
  52871. /**
  52872. * Gets the hosting scene
  52873. */
  52874. scene: Nullable<Scene>;
  52875. /**
  52876. * Gets or sets a number used to scale line length
  52877. */
  52878. scaleLines: number;
  52879. /** Gets the node hierarchy used to render x-axis */
  52880. get xAxis(): TransformNode;
  52881. /** Gets the node hierarchy used to render y-axis */
  52882. get yAxis(): TransformNode;
  52883. /** Gets the node hierarchy used to render z-axis */
  52884. get zAxis(): TransformNode;
  52885. /**
  52886. * Creates a new AxesViewer
  52887. * @param scene defines the hosting scene
  52888. * @param scaleLines defines a number used to scale line length (1 by default)
  52889. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52890. * @param xAxis defines the node hierarchy used to render the x-axis
  52891. * @param yAxis defines the node hierarchy used to render the y-axis
  52892. * @param zAxis defines the node hierarchy used to render the z-axis
  52893. */
  52894. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52895. /**
  52896. * Force the viewer to update
  52897. * @param position defines the position of the viewer
  52898. * @param xaxis defines the x axis of the viewer
  52899. * @param yaxis defines the y axis of the viewer
  52900. * @param zaxis defines the z axis of the viewer
  52901. */
  52902. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52903. /**
  52904. * Creates an instance of this axes viewer.
  52905. * @returns a new axes viewer with instanced meshes
  52906. */
  52907. createInstance(): AxesViewer;
  52908. /** Releases resources */
  52909. dispose(): void;
  52910. private static _SetRenderingGroupId;
  52911. }
  52912. }
  52913. declare module "babylonjs/Debug/boneAxesViewer" {
  52914. import { Nullable } from "babylonjs/types";
  52915. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52916. import { Vector3 } from "babylonjs/Maths/math.vector";
  52917. import { Mesh } from "babylonjs/Meshes/mesh";
  52918. import { Bone } from "babylonjs/Bones/bone";
  52919. import { Scene } from "babylonjs/scene";
  52920. /**
  52921. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52922. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52923. */
  52924. export class BoneAxesViewer extends AxesViewer {
  52925. /**
  52926. * Gets or sets the target mesh where to display the axes viewer
  52927. */
  52928. mesh: Nullable<Mesh>;
  52929. /**
  52930. * Gets or sets the target bone where to display the axes viewer
  52931. */
  52932. bone: Nullable<Bone>;
  52933. /** Gets current position */
  52934. pos: Vector3;
  52935. /** Gets direction of X axis */
  52936. xaxis: Vector3;
  52937. /** Gets direction of Y axis */
  52938. yaxis: Vector3;
  52939. /** Gets direction of Z axis */
  52940. zaxis: Vector3;
  52941. /**
  52942. * Creates a new BoneAxesViewer
  52943. * @param scene defines the hosting scene
  52944. * @param bone defines the target bone
  52945. * @param mesh defines the target mesh
  52946. * @param scaleLines defines a scaling factor for line length (1 by default)
  52947. */
  52948. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52949. /**
  52950. * Force the viewer to update
  52951. */
  52952. update(): void;
  52953. /** Releases resources */
  52954. dispose(): void;
  52955. }
  52956. }
  52957. declare module "babylonjs/Debug/debugLayer" {
  52958. import { Scene } from "babylonjs/scene";
  52959. /**
  52960. * Interface used to define scene explorer extensibility option
  52961. */
  52962. export interface IExplorerExtensibilityOption {
  52963. /**
  52964. * Define the option label
  52965. */
  52966. label: string;
  52967. /**
  52968. * Defines the action to execute on click
  52969. */
  52970. action: (entity: any) => void;
  52971. }
  52972. /**
  52973. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52974. */
  52975. export interface IExplorerExtensibilityGroup {
  52976. /**
  52977. * Defines a predicate to test if a given type mut be extended
  52978. */
  52979. predicate: (entity: any) => boolean;
  52980. /**
  52981. * Gets the list of options added to a type
  52982. */
  52983. entries: IExplorerExtensibilityOption[];
  52984. }
  52985. /**
  52986. * Interface used to define the options to use to create the Inspector
  52987. */
  52988. export interface IInspectorOptions {
  52989. /**
  52990. * Display in overlay mode (default: false)
  52991. */
  52992. overlay?: boolean;
  52993. /**
  52994. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52995. */
  52996. globalRoot?: HTMLElement;
  52997. /**
  52998. * Display the Scene explorer
  52999. */
  53000. showExplorer?: boolean;
  53001. /**
  53002. * Display the property inspector
  53003. */
  53004. showInspector?: boolean;
  53005. /**
  53006. * Display in embed mode (both panes on the right)
  53007. */
  53008. embedMode?: boolean;
  53009. /**
  53010. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  53011. */
  53012. handleResize?: boolean;
  53013. /**
  53014. * Allow the panes to popup (default: true)
  53015. */
  53016. enablePopup?: boolean;
  53017. /**
  53018. * Allow the panes to be closed by users (default: true)
  53019. */
  53020. enableClose?: boolean;
  53021. /**
  53022. * Optional list of extensibility entries
  53023. */
  53024. explorerExtensibility?: IExplorerExtensibilityGroup[];
  53025. /**
  53026. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  53027. */
  53028. inspectorURL?: string;
  53029. /**
  53030. * Optional initial tab (default to DebugLayerTab.Properties)
  53031. */
  53032. initialTab?: DebugLayerTab;
  53033. }
  53034. module "babylonjs/scene" {
  53035. interface Scene {
  53036. /**
  53037. * @hidden
  53038. * Backing field
  53039. */
  53040. _debugLayer: DebugLayer;
  53041. /**
  53042. * Gets the debug layer (aka Inspector) associated with the scene
  53043. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53044. */
  53045. debugLayer: DebugLayer;
  53046. }
  53047. }
  53048. /**
  53049. * Enum of inspector action tab
  53050. */
  53051. export enum DebugLayerTab {
  53052. /**
  53053. * Properties tag (default)
  53054. */
  53055. Properties = 0,
  53056. /**
  53057. * Debug tab
  53058. */
  53059. Debug = 1,
  53060. /**
  53061. * Statistics tab
  53062. */
  53063. Statistics = 2,
  53064. /**
  53065. * Tools tab
  53066. */
  53067. Tools = 3,
  53068. /**
  53069. * Settings tab
  53070. */
  53071. Settings = 4
  53072. }
  53073. /**
  53074. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53075. * what is happening in your scene
  53076. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53077. */
  53078. export class DebugLayer {
  53079. /**
  53080. * Define the url to get the inspector script from.
  53081. * By default it uses the babylonjs CDN.
  53082. * @ignoreNaming
  53083. */
  53084. static InspectorURL: string;
  53085. private _scene;
  53086. private BJSINSPECTOR;
  53087. private _onPropertyChangedObservable?;
  53088. /**
  53089. * Observable triggered when a property is changed through the inspector.
  53090. */
  53091. get onPropertyChangedObservable(): any;
  53092. /**
  53093. * Instantiates a new debug layer.
  53094. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53095. * what is happening in your scene
  53096. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53097. * @param scene Defines the scene to inspect
  53098. */
  53099. constructor(scene: Scene);
  53100. /** Creates the inspector window. */
  53101. private _createInspector;
  53102. /**
  53103. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  53104. * @param entity defines the entity to select
  53105. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  53106. */
  53107. select(entity: any, lineContainerTitles?: string | string[]): void;
  53108. /** Get the inspector from bundle or global */
  53109. private _getGlobalInspector;
  53110. /**
  53111. * Get if the inspector is visible or not.
  53112. * @returns true if visible otherwise, false
  53113. */
  53114. isVisible(): boolean;
  53115. /**
  53116. * Hide the inspector and close its window.
  53117. */
  53118. hide(): void;
  53119. /**
  53120. * Update the scene in the inspector
  53121. */
  53122. setAsActiveScene(): void;
  53123. /**
  53124. * Launch the debugLayer.
  53125. * @param config Define the configuration of the inspector
  53126. * @return a promise fulfilled when the debug layer is visible
  53127. */
  53128. show(config?: IInspectorOptions): Promise<DebugLayer>;
  53129. }
  53130. }
  53131. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  53132. import { Nullable } from "babylonjs/types";
  53133. import { Scene } from "babylonjs/scene";
  53134. import { Vector4 } from "babylonjs/Maths/math.vector";
  53135. import { Color4 } from "babylonjs/Maths/math.color";
  53136. import { Mesh } from "babylonjs/Meshes/mesh";
  53137. /**
  53138. * Class containing static functions to help procedurally build meshes
  53139. */
  53140. export class BoxBuilder {
  53141. /**
  53142. * Creates a box mesh
  53143. * * The parameter `size` sets the size (float) of each box side (default 1)
  53144. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53145. * * 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)
  53146. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53147. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53148. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53150. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53151. * @param name defines the name of the mesh
  53152. * @param options defines the options used to create the mesh
  53153. * @param scene defines the hosting scene
  53154. * @returns the box mesh
  53155. */
  53156. static CreateBox(name: string, options: {
  53157. size?: number;
  53158. width?: number;
  53159. height?: number;
  53160. depth?: number;
  53161. faceUV?: Vector4[];
  53162. faceColors?: Color4[];
  53163. sideOrientation?: number;
  53164. frontUVs?: Vector4;
  53165. backUVs?: Vector4;
  53166. wrap?: boolean;
  53167. topBaseAt?: number;
  53168. bottomBaseAt?: number;
  53169. updatable?: boolean;
  53170. }, scene?: Nullable<Scene>): Mesh;
  53171. }
  53172. }
  53173. declare module "babylonjs/Debug/physicsViewer" {
  53174. import { Nullable } from "babylonjs/types";
  53175. import { Scene } from "babylonjs/scene";
  53176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53177. import { Mesh } from "babylonjs/Meshes/mesh";
  53178. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53179. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53180. /**
  53181. * Used to show the physics impostor around the specific mesh
  53182. */
  53183. export class PhysicsViewer {
  53184. /** @hidden */
  53185. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53186. /** @hidden */
  53187. protected _meshes: Array<Nullable<AbstractMesh>>;
  53188. /** @hidden */
  53189. protected _scene: Nullable<Scene>;
  53190. /** @hidden */
  53191. protected _numMeshes: number;
  53192. /** @hidden */
  53193. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53194. private _renderFunction;
  53195. private _utilityLayer;
  53196. private _debugBoxMesh;
  53197. private _debugSphereMesh;
  53198. private _debugCylinderMesh;
  53199. private _debugMaterial;
  53200. private _debugMeshMeshes;
  53201. /**
  53202. * Creates a new PhysicsViewer
  53203. * @param scene defines the hosting scene
  53204. */
  53205. constructor(scene: Scene);
  53206. /** @hidden */
  53207. protected _updateDebugMeshes(): void;
  53208. /**
  53209. * Renders a specified physic impostor
  53210. * @param impostor defines the impostor to render
  53211. * @param targetMesh defines the mesh represented by the impostor
  53212. * @returns the new debug mesh used to render the impostor
  53213. */
  53214. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53215. /**
  53216. * Hides a specified physic impostor
  53217. * @param impostor defines the impostor to hide
  53218. */
  53219. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53220. private _getDebugMaterial;
  53221. private _getDebugBoxMesh;
  53222. private _getDebugSphereMesh;
  53223. private _getDebugCylinderMesh;
  53224. private _getDebugMeshMesh;
  53225. private _getDebugMesh;
  53226. /** Releases all resources */
  53227. dispose(): void;
  53228. }
  53229. }
  53230. declare module "babylonjs/Debug/rayHelper" {
  53231. import { Nullable } from "babylonjs/types";
  53232. import { Ray } from "babylonjs/Culling/ray";
  53233. import { Vector3 } from "babylonjs/Maths/math.vector";
  53234. import { Color3 } from "babylonjs/Maths/math.color";
  53235. import { Scene } from "babylonjs/scene";
  53236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53237. import "babylonjs/Meshes/Builders/linesBuilder";
  53238. /**
  53239. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53240. * in order to better appreciate the issue one might have.
  53241. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53242. */
  53243. export class RayHelper {
  53244. /**
  53245. * Defines the ray we are currently tryin to visualize.
  53246. */
  53247. ray: Nullable<Ray>;
  53248. private _renderPoints;
  53249. private _renderLine;
  53250. private _renderFunction;
  53251. private _scene;
  53252. private _onAfterRenderObserver;
  53253. private _onAfterStepObserver;
  53254. private _attachedToMesh;
  53255. private _meshSpaceDirection;
  53256. private _meshSpaceOrigin;
  53257. /**
  53258. * Helper function to create a colored helper in a scene in one line.
  53259. * @param ray Defines the ray we are currently tryin to visualize
  53260. * @param scene Defines the scene the ray is used in
  53261. * @param color Defines the color we want to see the ray in
  53262. * @returns The newly created ray helper.
  53263. */
  53264. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53265. /**
  53266. * Instantiate a new ray helper.
  53267. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53268. * in order to better appreciate the issue one might have.
  53269. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53270. * @param ray Defines the ray we are currently tryin to visualize
  53271. */
  53272. constructor(ray: Ray);
  53273. /**
  53274. * Shows the ray we are willing to debug.
  53275. * @param scene Defines the scene the ray needs to be rendered in
  53276. * @param color Defines the color the ray needs to be rendered in
  53277. */
  53278. show(scene: Scene, color?: Color3): void;
  53279. /**
  53280. * Hides the ray we are debugging.
  53281. */
  53282. hide(): void;
  53283. private _render;
  53284. /**
  53285. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53286. * @param mesh Defines the mesh we want the helper attached to
  53287. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53288. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53289. * @param length Defines the length of the ray
  53290. */
  53291. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53292. /**
  53293. * Detach the ray helper from the mesh it has previously been attached to.
  53294. */
  53295. detachFromMesh(): void;
  53296. private _updateToMesh;
  53297. /**
  53298. * Dispose the helper and release its associated resources.
  53299. */
  53300. dispose(): void;
  53301. }
  53302. }
  53303. declare module "babylonjs/Debug/ISkeletonViewer" {
  53304. import { Skeleton } from "babylonjs/Bones/skeleton";
  53305. import { Color3 } from "babylonjs/Maths/math.color";
  53306. /**
  53307. * Defines the options associated with the creation of a SkeletonViewer.
  53308. */
  53309. export interface ISkeletonViewerOptions {
  53310. /** Should the system pause animations before building the Viewer? */
  53311. pauseAnimations: boolean;
  53312. /** Should the system return the skeleton to rest before building? */
  53313. returnToRest: boolean;
  53314. /** public Display Mode of the Viewer */
  53315. displayMode: number;
  53316. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53317. displayOptions: ISkeletonViewerDisplayOptions;
  53318. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53319. computeBonesUsingShaders: boolean;
  53320. /** Flag ignore non weighted bones */
  53321. useAllBones: boolean;
  53322. }
  53323. /**
  53324. * Defines how to display the various bone meshes for the viewer.
  53325. */
  53326. export interface ISkeletonViewerDisplayOptions {
  53327. /** How far down to start tapering the bone spurs */
  53328. midStep?: number;
  53329. /** How big is the midStep? */
  53330. midStepFactor?: number;
  53331. /** Base for the Sphere Size */
  53332. sphereBaseSize?: number;
  53333. /** The ratio of the sphere to the longest bone in units */
  53334. sphereScaleUnit?: number;
  53335. /** Ratio for the Sphere Size */
  53336. sphereFactor?: number;
  53337. /** Whether a spur should attach its far end to the child bone position */
  53338. spurFollowsChild?: boolean;
  53339. /** Whether to show local axes or not */
  53340. showLocalAxes?: boolean;
  53341. /** Length of each local axis */
  53342. localAxesSize?: number;
  53343. }
  53344. /**
  53345. * Defines the constructor options for the BoneWeight Shader.
  53346. */
  53347. export interface IBoneWeightShaderOptions {
  53348. /** Skeleton to Map */
  53349. skeleton: Skeleton;
  53350. /** Colors for Uninfluenced bones */
  53351. colorBase?: Color3;
  53352. /** Colors for 0.0-0.25 Weight bones */
  53353. colorZero?: Color3;
  53354. /** Color for 0.25-0.5 Weight Influence */
  53355. colorQuarter?: Color3;
  53356. /** Color for 0.5-0.75 Weight Influence */
  53357. colorHalf?: Color3;
  53358. /** Color for 0.75-1 Weight Influence */
  53359. colorFull?: Color3;
  53360. /** Color for Zero Weight Influence */
  53361. targetBoneIndex?: number;
  53362. }
  53363. /**
  53364. * Simple structure of the gradient steps for the Color Map.
  53365. */
  53366. export interface ISkeletonMapShaderColorMapKnot {
  53367. /** Color of the Knot */
  53368. color: Color3;
  53369. /** Location of the Knot */
  53370. location: number;
  53371. }
  53372. /**
  53373. * Defines the constructor options for the SkeletonMap Shader.
  53374. */
  53375. export interface ISkeletonMapShaderOptions {
  53376. /** Skeleton to Map */
  53377. skeleton: Skeleton;
  53378. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53379. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53380. }
  53381. }
  53382. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53383. import { Nullable } from "babylonjs/types";
  53384. import { Scene } from "babylonjs/scene";
  53385. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53386. import { Color4 } from "babylonjs/Maths/math.color";
  53387. import { Mesh } from "babylonjs/Meshes/mesh";
  53388. /**
  53389. * Class containing static functions to help procedurally build meshes
  53390. */
  53391. export class RibbonBuilder {
  53392. /**
  53393. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53394. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53395. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53396. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53397. * * 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
  53398. * * 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
  53399. * * 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
  53400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53402. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53403. * * 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
  53404. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53405. * * 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
  53406. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53408. * @param name defines the name of the mesh
  53409. * @param options defines the options used to create the mesh
  53410. * @param scene defines the hosting scene
  53411. * @returns the ribbon mesh
  53412. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53413. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53414. */
  53415. static CreateRibbon(name: string, options: {
  53416. pathArray: Vector3[][];
  53417. closeArray?: boolean;
  53418. closePath?: boolean;
  53419. offset?: number;
  53420. updatable?: boolean;
  53421. sideOrientation?: number;
  53422. frontUVs?: Vector4;
  53423. backUVs?: Vector4;
  53424. instance?: Mesh;
  53425. invertUV?: boolean;
  53426. uvs?: Vector2[];
  53427. colors?: Color4[];
  53428. }, scene?: Nullable<Scene>): Mesh;
  53429. }
  53430. }
  53431. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53432. import { Nullable } from "babylonjs/types";
  53433. import { Scene } from "babylonjs/scene";
  53434. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53435. import { Mesh } from "babylonjs/Meshes/mesh";
  53436. /**
  53437. * Class containing static functions to help procedurally build meshes
  53438. */
  53439. export class ShapeBuilder {
  53440. /**
  53441. * 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.
  53442. * * 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.
  53443. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53444. * * 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.
  53445. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53446. * * 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
  53447. * * 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
  53448. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53453. * @param name defines the name of the mesh
  53454. * @param options defines the options used to create the mesh
  53455. * @param scene defines the hosting scene
  53456. * @returns the extruded shape mesh
  53457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53459. */
  53460. static ExtrudeShape(name: string, options: {
  53461. shape: Vector3[];
  53462. path: Vector3[];
  53463. scale?: number;
  53464. rotation?: number;
  53465. cap?: number;
  53466. updatable?: boolean;
  53467. sideOrientation?: number;
  53468. frontUVs?: Vector4;
  53469. backUVs?: Vector4;
  53470. instance?: Mesh;
  53471. invertUV?: boolean;
  53472. }, scene?: Nullable<Scene>): Mesh;
  53473. /**
  53474. * Creates an custom extruded shape mesh.
  53475. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53476. * * 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.
  53477. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53478. * * 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
  53479. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53480. * * 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
  53481. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53482. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53483. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53484. * * 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
  53485. * * 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
  53486. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53489. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53491. * @param name defines the name of the mesh
  53492. * @param options defines the options used to create the mesh
  53493. * @param scene defines the hosting scene
  53494. * @returns the custom extruded shape mesh
  53495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53497. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53498. */
  53499. static ExtrudeShapeCustom(name: string, options: {
  53500. shape: Vector3[];
  53501. path: Vector3[];
  53502. scaleFunction?: any;
  53503. rotationFunction?: any;
  53504. ribbonCloseArray?: boolean;
  53505. ribbonClosePath?: boolean;
  53506. cap?: number;
  53507. updatable?: boolean;
  53508. sideOrientation?: number;
  53509. frontUVs?: Vector4;
  53510. backUVs?: Vector4;
  53511. instance?: Mesh;
  53512. invertUV?: boolean;
  53513. }, scene?: Nullable<Scene>): Mesh;
  53514. private static _ExtrudeShapeGeneric;
  53515. }
  53516. }
  53517. declare module "babylonjs/Debug/skeletonViewer" {
  53518. import { Color3 } from "babylonjs/Maths/math.color";
  53519. import { Scene } from "babylonjs/scene";
  53520. import { Nullable } from "babylonjs/types";
  53521. import { Skeleton } from "babylonjs/Bones/skeleton";
  53522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53523. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53524. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53525. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53526. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53527. /**
  53528. * Class used to render a debug view of a given skeleton
  53529. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53530. */
  53531. export class SkeletonViewer {
  53532. /** defines the skeleton to render */
  53533. skeleton: Skeleton;
  53534. /** defines the mesh attached to the skeleton */
  53535. mesh: AbstractMesh;
  53536. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53537. autoUpdateBonesMatrices: boolean;
  53538. /** defines the rendering group id to use with the viewer */
  53539. renderingGroupId: number;
  53540. /** is the options for the viewer */
  53541. options: Partial<ISkeletonViewerOptions>;
  53542. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53543. static readonly DISPLAY_LINES: number;
  53544. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53545. static readonly DISPLAY_SPHERES: number;
  53546. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53547. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53548. /** public static method to create a BoneWeight Shader
  53549. * @param options The constructor options
  53550. * @param scene The scene that the shader is scoped to
  53551. * @returns The created ShaderMaterial
  53552. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53553. */
  53554. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53555. /** public static method to create a BoneWeight Shader
  53556. * @param options The constructor options
  53557. * @param scene The scene that the shader is scoped to
  53558. * @returns The created ShaderMaterial
  53559. */
  53560. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53561. /** private static method to create a BoneWeight Shader
  53562. * @param size The size of the buffer to create (usually the bone count)
  53563. * @param colorMap The gradient data to generate
  53564. * @param scene The scene that the shader is scoped to
  53565. * @returns an Array of floats from the color gradient values
  53566. */
  53567. private static _CreateBoneMapColorBuffer;
  53568. /** If SkeletonViewer scene scope. */
  53569. private _scene;
  53570. /** Gets or sets the color used to render the skeleton */
  53571. color: Color3;
  53572. /** Array of the points of the skeleton fo the line view. */
  53573. private _debugLines;
  53574. /** The SkeletonViewers Mesh. */
  53575. private _debugMesh;
  53576. /** The local axes Meshes. */
  53577. private _localAxes;
  53578. /** If SkeletonViewer is enabled. */
  53579. private _isEnabled;
  53580. /** If SkeletonViewer is ready. */
  53581. private _ready;
  53582. /** SkeletonViewer render observable. */
  53583. private _obs;
  53584. /** The Utility Layer to render the gizmos in. */
  53585. private _utilityLayer;
  53586. private _boneIndices;
  53587. /** Gets the Scene. */
  53588. get scene(): Scene;
  53589. /** Gets the utilityLayer. */
  53590. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53591. /** Checks Ready Status. */
  53592. get isReady(): Boolean;
  53593. /** Sets Ready Status. */
  53594. set ready(value: boolean);
  53595. /** Gets the debugMesh */
  53596. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53597. /** Sets the debugMesh */
  53598. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53599. /** Gets the displayMode */
  53600. get displayMode(): number;
  53601. /** Sets the displayMode */
  53602. set displayMode(value: number);
  53603. /**
  53604. * Creates a new SkeletonViewer
  53605. * @param skeleton defines the skeleton to render
  53606. * @param mesh defines the mesh attached to the skeleton
  53607. * @param scene defines the hosting scene
  53608. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53609. * @param renderingGroupId defines the rendering group id to use with the viewer
  53610. * @param options All of the extra constructor options for the SkeletonViewer
  53611. */
  53612. constructor(
  53613. /** defines the skeleton to render */
  53614. skeleton: Skeleton,
  53615. /** defines the mesh attached to the skeleton */
  53616. mesh: AbstractMesh,
  53617. /** The Scene scope*/
  53618. scene: Scene,
  53619. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53620. autoUpdateBonesMatrices?: boolean,
  53621. /** defines the rendering group id to use with the viewer */
  53622. renderingGroupId?: number,
  53623. /** is the options for the viewer */
  53624. options?: Partial<ISkeletonViewerOptions>);
  53625. /** The Dynamic bindings for the update functions */
  53626. private _bindObs;
  53627. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53628. update(): void;
  53629. /** Gets or sets a boolean indicating if the viewer is enabled */
  53630. set isEnabled(value: boolean);
  53631. get isEnabled(): boolean;
  53632. private _getBonePosition;
  53633. private _getLinesForBonesWithLength;
  53634. private _getLinesForBonesNoLength;
  53635. /** function to revert the mesh and scene back to the initial state. */
  53636. private _revert;
  53637. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  53638. private _getAbsoluteBindPoseToRef;
  53639. /** function to build and bind sphere joint points and spur bone representations. */
  53640. private _buildSpheresAndSpurs;
  53641. private _buildLocalAxes;
  53642. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53643. private _displayLinesUpdate;
  53644. /** Changes the displayMode of the skeleton viewer
  53645. * @param mode The displayMode numerical value
  53646. */
  53647. changeDisplayMode(mode: number): void;
  53648. /** Sets a display option of the skeleton viewer
  53649. *
  53650. * | Option | Type | Default | Description |
  53651. * | ---------------- | ------- | ------- | ----------- |
  53652. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53653. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53654. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53655. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53656. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  53657. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  53658. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  53659. *
  53660. * @param option String of the option name
  53661. * @param value The numerical option value
  53662. */
  53663. changeDisplayOptions(option: string, value: number): void;
  53664. /** Release associated resources */
  53665. dispose(): void;
  53666. }
  53667. }
  53668. declare module "babylonjs/Debug/index" {
  53669. export * from "babylonjs/Debug/axesViewer";
  53670. export * from "babylonjs/Debug/boneAxesViewer";
  53671. export * from "babylonjs/Debug/debugLayer";
  53672. export * from "babylonjs/Debug/physicsViewer";
  53673. export * from "babylonjs/Debug/rayHelper";
  53674. export * from "babylonjs/Debug/skeletonViewer";
  53675. export * from "babylonjs/Debug/ISkeletonViewer";
  53676. }
  53677. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53678. /**
  53679. * Enum for Device Types
  53680. */
  53681. export enum DeviceType {
  53682. /** Generic */
  53683. Generic = 0,
  53684. /** Keyboard */
  53685. Keyboard = 1,
  53686. /** Mouse */
  53687. Mouse = 2,
  53688. /** Touch Pointers */
  53689. Touch = 3,
  53690. /** PS4 Dual Shock */
  53691. DualShock = 4,
  53692. /** Xbox */
  53693. Xbox = 5,
  53694. /** Switch Controller */
  53695. Switch = 6
  53696. }
  53697. /**
  53698. * Enum for All Pointers (Touch/Mouse)
  53699. */
  53700. export enum PointerInput {
  53701. /** Horizontal Axis */
  53702. Horizontal = 0,
  53703. /** Vertical Axis */
  53704. Vertical = 1,
  53705. /** Left Click or Touch */
  53706. LeftClick = 2,
  53707. /** Middle Click */
  53708. MiddleClick = 3,
  53709. /** Right Click */
  53710. RightClick = 4,
  53711. /** Browser Back */
  53712. BrowserBack = 5,
  53713. /** Browser Forward */
  53714. BrowserForward = 6
  53715. }
  53716. /**
  53717. * Enum for Dual Shock Gamepad
  53718. */
  53719. export enum DualShockInput {
  53720. /** Cross */
  53721. Cross = 0,
  53722. /** Circle */
  53723. Circle = 1,
  53724. /** Square */
  53725. Square = 2,
  53726. /** Triangle */
  53727. Triangle = 3,
  53728. /** L1 */
  53729. L1 = 4,
  53730. /** R1 */
  53731. R1 = 5,
  53732. /** L2 */
  53733. L2 = 6,
  53734. /** R2 */
  53735. R2 = 7,
  53736. /** Share */
  53737. Share = 8,
  53738. /** Options */
  53739. Options = 9,
  53740. /** L3 */
  53741. L3 = 10,
  53742. /** R3 */
  53743. R3 = 11,
  53744. /** DPadUp */
  53745. DPadUp = 12,
  53746. /** DPadDown */
  53747. DPadDown = 13,
  53748. /** DPadLeft */
  53749. DPadLeft = 14,
  53750. /** DRight */
  53751. DPadRight = 15,
  53752. /** Home */
  53753. Home = 16,
  53754. /** TouchPad */
  53755. TouchPad = 17,
  53756. /** LStickXAxis */
  53757. LStickXAxis = 18,
  53758. /** LStickYAxis */
  53759. LStickYAxis = 19,
  53760. /** RStickXAxis */
  53761. RStickXAxis = 20,
  53762. /** RStickYAxis */
  53763. RStickYAxis = 21
  53764. }
  53765. /**
  53766. * Enum for Xbox Gamepad
  53767. */
  53768. export enum XboxInput {
  53769. /** A */
  53770. A = 0,
  53771. /** B */
  53772. B = 1,
  53773. /** X */
  53774. X = 2,
  53775. /** Y */
  53776. Y = 3,
  53777. /** LB */
  53778. LB = 4,
  53779. /** RB */
  53780. RB = 5,
  53781. /** LT */
  53782. LT = 6,
  53783. /** RT */
  53784. RT = 7,
  53785. /** Back */
  53786. Back = 8,
  53787. /** Start */
  53788. Start = 9,
  53789. /** LS */
  53790. LS = 10,
  53791. /** RS */
  53792. RS = 11,
  53793. /** DPadUp */
  53794. DPadUp = 12,
  53795. /** DPadDown */
  53796. DPadDown = 13,
  53797. /** DPadLeft */
  53798. DPadLeft = 14,
  53799. /** DRight */
  53800. DPadRight = 15,
  53801. /** Home */
  53802. Home = 16,
  53803. /** LStickXAxis */
  53804. LStickXAxis = 17,
  53805. /** LStickYAxis */
  53806. LStickYAxis = 18,
  53807. /** RStickXAxis */
  53808. RStickXAxis = 19,
  53809. /** RStickYAxis */
  53810. RStickYAxis = 20
  53811. }
  53812. /**
  53813. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53814. */
  53815. export enum SwitchInput {
  53816. /** B */
  53817. B = 0,
  53818. /** A */
  53819. A = 1,
  53820. /** Y */
  53821. Y = 2,
  53822. /** X */
  53823. X = 3,
  53824. /** L */
  53825. L = 4,
  53826. /** R */
  53827. R = 5,
  53828. /** ZL */
  53829. ZL = 6,
  53830. /** ZR */
  53831. ZR = 7,
  53832. /** Minus */
  53833. Minus = 8,
  53834. /** Plus */
  53835. Plus = 9,
  53836. /** LS */
  53837. LS = 10,
  53838. /** RS */
  53839. RS = 11,
  53840. /** DPadUp */
  53841. DPadUp = 12,
  53842. /** DPadDown */
  53843. DPadDown = 13,
  53844. /** DPadLeft */
  53845. DPadLeft = 14,
  53846. /** DRight */
  53847. DPadRight = 15,
  53848. /** Home */
  53849. Home = 16,
  53850. /** Capture */
  53851. Capture = 17,
  53852. /** LStickXAxis */
  53853. LStickXAxis = 18,
  53854. /** LStickYAxis */
  53855. LStickYAxis = 19,
  53856. /** RStickXAxis */
  53857. RStickXAxis = 20,
  53858. /** RStickYAxis */
  53859. RStickYAxis = 21
  53860. }
  53861. }
  53862. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53863. import { Engine } from "babylonjs/Engines/engine";
  53864. import { IDisposable } from "babylonjs/scene";
  53865. import { Nullable } from "babylonjs/types";
  53866. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53867. /**
  53868. * This class will take all inputs from Keyboard, Pointer, and
  53869. * any Gamepads and provide a polling system that all devices
  53870. * will use. This class assumes that there will only be one
  53871. * pointer device and one keyboard.
  53872. */
  53873. export class DeviceInputSystem implements IDisposable {
  53874. /**
  53875. * Callback to be triggered when a device is connected
  53876. */
  53877. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53878. /**
  53879. * Callback to be triggered when a device is disconnected
  53880. */
  53881. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53882. /**
  53883. * Callback to be triggered when event driven input is updated
  53884. */
  53885. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53886. private _inputs;
  53887. private _gamepads;
  53888. private _keyboardActive;
  53889. private _pointerActive;
  53890. private _elementToAttachTo;
  53891. private _keyboardDownEvent;
  53892. private _keyboardUpEvent;
  53893. private _pointerMoveEvent;
  53894. private _pointerDownEvent;
  53895. private _pointerUpEvent;
  53896. private _gamepadConnectedEvent;
  53897. private _gamepadDisconnectedEvent;
  53898. private static _MAX_KEYCODES;
  53899. private static _MAX_POINTER_INPUTS;
  53900. private constructor();
  53901. /**
  53902. * Creates a new DeviceInputSystem instance
  53903. * @param engine Engine to pull input element from
  53904. * @returns The new instance
  53905. */
  53906. static Create(engine: Engine): DeviceInputSystem;
  53907. /**
  53908. * Checks for current device input value, given an id and input index
  53909. * @param deviceName Id of connected device
  53910. * @param inputIndex Index of device input
  53911. * @returns Current value of input
  53912. */
  53913. /**
  53914. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53915. * @param deviceType Enum specifiying device type
  53916. * @param deviceSlot "Slot" or index that device is referenced in
  53917. * @param inputIndex Id of input to be checked
  53918. * @returns Current value of input
  53919. */
  53920. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53921. /**
  53922. * Dispose of all the eventlisteners
  53923. */
  53924. dispose(): void;
  53925. /**
  53926. * Add device and inputs to device array
  53927. * @param deviceType Enum specifiying device type
  53928. * @param deviceSlot "Slot" or index that device is referenced in
  53929. * @param numberOfInputs Number of input entries to create for given device
  53930. */
  53931. private _registerDevice;
  53932. /**
  53933. * Given a specific device name, remove that device from the device map
  53934. * @param deviceType Enum specifiying device type
  53935. * @param deviceSlot "Slot" or index that device is referenced in
  53936. */
  53937. private _unregisterDevice;
  53938. /**
  53939. * Handle all actions that come from keyboard interaction
  53940. */
  53941. private _handleKeyActions;
  53942. /**
  53943. * Handle all actions that come from pointer interaction
  53944. */
  53945. private _handlePointerActions;
  53946. /**
  53947. * Handle all actions that come from gamepad interaction
  53948. */
  53949. private _handleGamepadActions;
  53950. /**
  53951. * Update all non-event based devices with each frame
  53952. * @param deviceType Enum specifiying device type
  53953. * @param deviceSlot "Slot" or index that device is referenced in
  53954. * @param inputIndex Id of input to be checked
  53955. */
  53956. private _updateDevice;
  53957. /**
  53958. * Gets DeviceType from the device name
  53959. * @param deviceName Name of Device from DeviceInputSystem
  53960. * @returns DeviceType enum value
  53961. */
  53962. private _getGamepadDeviceType;
  53963. }
  53964. }
  53965. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53966. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53967. /**
  53968. * Type to handle enforcement of inputs
  53969. */
  53970. 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;
  53971. }
  53972. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53973. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53974. import { Engine } from "babylonjs/Engines/engine";
  53975. import { IDisposable } from "babylonjs/scene";
  53976. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53977. import { Nullable } from "babylonjs/types";
  53978. import { Observable } from "babylonjs/Misc/observable";
  53979. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53980. /**
  53981. * Class that handles all input for a specific device
  53982. */
  53983. export class DeviceSource<T extends DeviceType> {
  53984. /** Type of device */
  53985. readonly deviceType: DeviceType;
  53986. /** "Slot" or index that device is referenced in */
  53987. readonly deviceSlot: number;
  53988. /**
  53989. * Observable to handle device input changes per device
  53990. */
  53991. readonly onInputChangedObservable: Observable<{
  53992. inputIndex: DeviceInput<T>;
  53993. previousState: Nullable<number>;
  53994. currentState: Nullable<number>;
  53995. }>;
  53996. private readonly _deviceInputSystem;
  53997. /**
  53998. * Default Constructor
  53999. * @param deviceInputSystem Reference to DeviceInputSystem
  54000. * @param deviceType Type of device
  54001. * @param deviceSlot "Slot" or index that device is referenced in
  54002. */
  54003. constructor(deviceInputSystem: DeviceInputSystem,
  54004. /** Type of device */
  54005. deviceType: DeviceType,
  54006. /** "Slot" or index that device is referenced in */
  54007. deviceSlot?: number);
  54008. /**
  54009. * Get input for specific input
  54010. * @param inputIndex index of specific input on device
  54011. * @returns Input value from DeviceInputSystem
  54012. */
  54013. getInput(inputIndex: DeviceInput<T>): number;
  54014. }
  54015. /**
  54016. * Class to keep track of devices
  54017. */
  54018. export class DeviceSourceManager implements IDisposable {
  54019. /**
  54020. * Observable to be triggered when before a device is connected
  54021. */
  54022. readonly onBeforeDeviceConnectedObservable: Observable<{
  54023. deviceType: DeviceType;
  54024. deviceSlot: number;
  54025. }>;
  54026. /**
  54027. * Observable to be triggered when before a device is disconnected
  54028. */
  54029. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  54030. deviceType: DeviceType;
  54031. deviceSlot: number;
  54032. }>;
  54033. /**
  54034. * Observable to be triggered when after a device is connected
  54035. */
  54036. readonly onAfterDeviceConnectedObservable: Observable<{
  54037. deviceType: DeviceType;
  54038. deviceSlot: number;
  54039. }>;
  54040. /**
  54041. * Observable to be triggered when after a device is disconnected
  54042. */
  54043. readonly onAfterDeviceDisconnectedObservable: Observable<{
  54044. deviceType: DeviceType;
  54045. deviceSlot: number;
  54046. }>;
  54047. private readonly _devices;
  54048. private readonly _firstDevice;
  54049. private readonly _deviceInputSystem;
  54050. /**
  54051. * Default Constructor
  54052. * @param engine engine to pull input element from
  54053. */
  54054. constructor(engine: Engine);
  54055. /**
  54056. * Gets a DeviceSource, given a type and slot
  54057. * @param deviceType Enum specifying device type
  54058. * @param deviceSlot "Slot" or index that device is referenced in
  54059. * @returns DeviceSource object
  54060. */
  54061. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  54062. /**
  54063. * Gets an array of DeviceSource objects for a given device type
  54064. * @param deviceType Enum specifying device type
  54065. * @returns Array of DeviceSource objects
  54066. */
  54067. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  54068. /**
  54069. * Dispose of DeviceInputSystem and other parts
  54070. */
  54071. dispose(): void;
  54072. /**
  54073. * Function to add device name to device list
  54074. * @param deviceType Enum specifying device type
  54075. * @param deviceSlot "Slot" or index that device is referenced in
  54076. */
  54077. private _addDevice;
  54078. /**
  54079. * Function to remove device name to device list
  54080. * @param deviceType Enum specifying device type
  54081. * @param deviceSlot "Slot" or index that device is referenced in
  54082. */
  54083. private _removeDevice;
  54084. /**
  54085. * Updates array storing first connected device of each type
  54086. * @param type Type of Device
  54087. */
  54088. private _updateFirstDevices;
  54089. }
  54090. }
  54091. declare module "babylonjs/DeviceInput/index" {
  54092. export * from "babylonjs/DeviceInput/deviceInputSystem";
  54093. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  54094. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  54095. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  54096. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  54097. }
  54098. declare module "babylonjs/Engines/nullEngine" {
  54099. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  54100. import { Engine } from "babylonjs/Engines/engine";
  54101. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54102. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54103. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54104. import { Effect } from "babylonjs/Materials/effect";
  54105. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54106. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54107. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  54108. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54109. /**
  54110. * Options to create the null engine
  54111. */
  54112. export class NullEngineOptions {
  54113. /**
  54114. * Render width (Default: 512)
  54115. */
  54116. renderWidth: number;
  54117. /**
  54118. * Render height (Default: 256)
  54119. */
  54120. renderHeight: number;
  54121. /**
  54122. * Texture size (Default: 512)
  54123. */
  54124. textureSize: number;
  54125. /**
  54126. * If delta time between frames should be constant
  54127. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54128. */
  54129. deterministicLockstep: boolean;
  54130. /**
  54131. * Maximum about of steps between frames (Default: 4)
  54132. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54133. */
  54134. lockstepMaxSteps: number;
  54135. /**
  54136. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54137. */
  54138. useHighPrecisionMatrix?: boolean;
  54139. }
  54140. /**
  54141. * The null engine class provides support for headless version of babylon.js.
  54142. * This can be used in server side scenario or for testing purposes
  54143. */
  54144. export class NullEngine extends Engine {
  54145. private _options;
  54146. /**
  54147. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54148. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54149. * @returns true if engine is in deterministic lock step mode
  54150. */
  54151. isDeterministicLockStep(): boolean;
  54152. /**
  54153. * Gets the max steps when engine is running in deterministic lock step
  54154. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54155. * @returns the max steps
  54156. */
  54157. getLockstepMaxSteps(): number;
  54158. /**
  54159. * Gets the current hardware scaling level.
  54160. * By default the hardware scaling level is computed from the window device ratio.
  54161. * 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.
  54162. * @returns a number indicating the current hardware scaling level
  54163. */
  54164. getHardwareScalingLevel(): number;
  54165. constructor(options?: NullEngineOptions);
  54166. /**
  54167. * Creates a vertex buffer
  54168. * @param vertices the data for the vertex buffer
  54169. * @returns the new WebGL static buffer
  54170. */
  54171. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54172. /**
  54173. * Creates a new index buffer
  54174. * @param indices defines the content of the index buffer
  54175. * @param updatable defines if the index buffer must be updatable
  54176. * @returns a new webGL buffer
  54177. */
  54178. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54179. /**
  54180. * Clear the current render buffer or the current render target (if any is set up)
  54181. * @param color defines the color to use
  54182. * @param backBuffer defines if the back buffer must be cleared
  54183. * @param depth defines if the depth buffer must be cleared
  54184. * @param stencil defines if the stencil buffer must be cleared
  54185. */
  54186. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54187. /**
  54188. * Gets the current render width
  54189. * @param useScreen defines if screen size must be used (or the current render target if any)
  54190. * @returns a number defining the current render width
  54191. */
  54192. getRenderWidth(useScreen?: boolean): number;
  54193. /**
  54194. * Gets the current render height
  54195. * @param useScreen defines if screen size must be used (or the current render target if any)
  54196. * @returns a number defining the current render height
  54197. */
  54198. getRenderHeight(useScreen?: boolean): number;
  54199. /**
  54200. * Set the WebGL's viewport
  54201. * @param viewport defines the viewport element to be used
  54202. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54203. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54204. */
  54205. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54206. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54207. /**
  54208. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54209. * @param pipelineContext defines the pipeline context to use
  54210. * @param uniformsNames defines the list of uniform names
  54211. * @returns an array of webGL uniform locations
  54212. */
  54213. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54214. /**
  54215. * Gets the lsit of active attributes for a given webGL program
  54216. * @param pipelineContext defines the pipeline context to use
  54217. * @param attributesNames defines the list of attribute names to get
  54218. * @returns an array of indices indicating the offset of each attribute
  54219. */
  54220. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54221. /**
  54222. * Binds an effect to the webGL context
  54223. * @param effect defines the effect to bind
  54224. */
  54225. bindSamplers(effect: Effect): void;
  54226. /**
  54227. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54228. * @param effect defines the effect to activate
  54229. */
  54230. enableEffect(effect: Effect): void;
  54231. /**
  54232. * Set various states to the webGL context
  54233. * @param culling defines backface culling state
  54234. * @param zOffset defines the value to apply to zOffset (0 by default)
  54235. * @param force defines if states must be applied even if cache is up to date
  54236. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54237. */
  54238. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54239. /**
  54240. * Set the value of an uniform to an array of int32
  54241. * @param uniform defines the webGL uniform location where to store the value
  54242. * @param array defines the array of int32 to store
  54243. * @returns true if value was set
  54244. */
  54245. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54246. /**
  54247. * Set the value of an uniform to an array of int32 (stored as vec2)
  54248. * @param uniform defines the webGL uniform location where to store the value
  54249. * @param array defines the array of int32 to store
  54250. * @returns true if value was set
  54251. */
  54252. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54253. /**
  54254. * Set the value of an uniform to an array of int32 (stored as vec3)
  54255. * @param uniform defines the webGL uniform location where to store the value
  54256. * @param array defines the array of int32 to store
  54257. * @returns true if value was set
  54258. */
  54259. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54260. /**
  54261. * Set the value of an uniform to an array of int32 (stored as vec4)
  54262. * @param uniform defines the webGL uniform location where to store the value
  54263. * @param array defines the array of int32 to store
  54264. * @returns true if value was set
  54265. */
  54266. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54267. /**
  54268. * Set the value of an uniform to an array of float32
  54269. * @param uniform defines the webGL uniform location where to store the value
  54270. * @param array defines the array of float32 to store
  54271. * @returns true if value was set
  54272. */
  54273. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54274. /**
  54275. * Set the value of an uniform to an array of float32 (stored as vec2)
  54276. * @param uniform defines the webGL uniform location where to store the value
  54277. * @param array defines the array of float32 to store
  54278. * @returns true if value was set
  54279. */
  54280. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54281. /**
  54282. * Set the value of an uniform to an array of float32 (stored as vec3)
  54283. * @param uniform defines the webGL uniform location where to store the value
  54284. * @param array defines the array of float32 to store
  54285. * @returns true if value was set
  54286. */
  54287. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54288. /**
  54289. * Set the value of an uniform to an array of float32 (stored as vec4)
  54290. * @param uniform defines the webGL uniform location where to store the value
  54291. * @param array defines the array of float32 to store
  54292. * @returns true if value was set
  54293. */
  54294. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54295. /**
  54296. * Set the value of an uniform to an array of number
  54297. * @param uniform defines the webGL uniform location where to store the value
  54298. * @param array defines the array of number to store
  54299. * @returns true if value was set
  54300. */
  54301. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  54302. /**
  54303. * Set the value of an uniform to an array of number (stored as vec2)
  54304. * @param uniform defines the webGL uniform location where to store the value
  54305. * @param array defines the array of number to store
  54306. * @returns true if value was set
  54307. */
  54308. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  54309. /**
  54310. * Set the value of an uniform to an array of number (stored as vec3)
  54311. * @param uniform defines the webGL uniform location where to store the value
  54312. * @param array defines the array of number to store
  54313. * @returns true if value was set
  54314. */
  54315. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  54316. /**
  54317. * Set the value of an uniform to an array of number (stored as vec4)
  54318. * @param uniform defines the webGL uniform location where to store the value
  54319. * @param array defines the array of number to store
  54320. * @returns true if value was set
  54321. */
  54322. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  54323. /**
  54324. * Set the value of an uniform to an array of float32 (stored as matrices)
  54325. * @param uniform defines the webGL uniform location where to store the value
  54326. * @param matrices defines the array of float32 to store
  54327. * @returns true if value was set
  54328. */
  54329. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  54330. /**
  54331. * Set the value of an uniform to a matrix (3x3)
  54332. * @param uniform defines the webGL uniform location where to store the value
  54333. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54334. * @returns true if value was set
  54335. */
  54336. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54337. /**
  54338. * Set the value of an uniform to a matrix (2x2)
  54339. * @param uniform defines the webGL uniform location where to store the value
  54340. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54341. * @returns true if value was set
  54342. */
  54343. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54344. /**
  54345. * Set the value of an uniform to a number (float)
  54346. * @param uniform defines the webGL uniform location where to store the value
  54347. * @param value defines the float number to store
  54348. * @returns true if value was set
  54349. */
  54350. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  54351. /**
  54352. * Set the value of an uniform to a vec2
  54353. * @param uniform defines the webGL uniform location where to store the value
  54354. * @param x defines the 1st component of the value
  54355. * @param y defines the 2nd component of the value
  54356. * @returns true if value was set
  54357. */
  54358. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  54359. /**
  54360. * Set the value of an uniform to a vec3
  54361. * @param uniform defines the webGL uniform location where to store the value
  54362. * @param x defines the 1st component of the value
  54363. * @param y defines the 2nd component of the value
  54364. * @param z defines the 3rd component of the value
  54365. * @returns true if value was set
  54366. */
  54367. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  54368. /**
  54369. * Set the value of an uniform to a boolean
  54370. * @param uniform defines the webGL uniform location where to store the value
  54371. * @param bool defines the boolean to store
  54372. * @returns true if value was set
  54373. */
  54374. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  54375. /**
  54376. * Set the value of an uniform to a vec4
  54377. * @param uniform defines the webGL uniform location where to store the value
  54378. * @param x defines the 1st component of the value
  54379. * @param y defines the 2nd component of the value
  54380. * @param z defines the 3rd component of the value
  54381. * @param w defines the 4th component of the value
  54382. * @returns true if value was set
  54383. */
  54384. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  54385. /**
  54386. * Sets the current alpha mode
  54387. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54388. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54389. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54390. */
  54391. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54392. /**
  54393. * Bind webGl buffers directly to the webGL context
  54394. * @param vertexBuffers defines the vertex buffer to bind
  54395. * @param indexBuffer defines the index buffer to bind
  54396. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54397. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54398. * @param effect defines the effect associated with the vertex buffer
  54399. */
  54400. bindBuffers(vertexBuffers: {
  54401. [key: string]: VertexBuffer;
  54402. }, indexBuffer: DataBuffer, effect: Effect): void;
  54403. /**
  54404. * Force the entire cache to be cleared
  54405. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54406. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54407. */
  54408. wipeCaches(bruteForce?: boolean): void;
  54409. /**
  54410. * Send a draw order
  54411. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54412. * @param indexStart defines the starting index
  54413. * @param indexCount defines the number of index to draw
  54414. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54415. */
  54416. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54417. /**
  54418. * Draw a list of indexed primitives
  54419. * @param fillMode defines the primitive to use
  54420. * @param indexStart defines the starting index
  54421. * @param indexCount defines the number of index to draw
  54422. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54423. */
  54424. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54425. /**
  54426. * Draw a list of unindexed primitives
  54427. * @param fillMode defines the primitive to use
  54428. * @param verticesStart defines the index of first vertex to draw
  54429. * @param verticesCount defines the count of vertices to draw
  54430. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54431. */
  54432. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54433. /** @hidden */
  54434. _createTexture(): WebGLTexture;
  54435. /** @hidden */
  54436. _releaseTexture(texture: InternalTexture): void;
  54437. /**
  54438. * Usually called from Texture.ts.
  54439. * Passed information to create a WebGLTexture
  54440. * @param urlArg defines a value which contains one of the following:
  54441. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54442. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54443. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54444. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54445. * @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)
  54446. * @param scene needed for loading to the correct scene
  54447. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54448. * @param onLoad optional callback to be called upon successful completion
  54449. * @param onError optional callback to be called upon failure
  54450. * @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
  54451. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54452. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54453. * @param forcedExtension defines the extension to use to pick the right loader
  54454. * @param mimeType defines an optional mime type
  54455. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54456. */
  54457. 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;
  54458. /**
  54459. * Creates a new render target texture
  54460. * @param size defines the size of the texture
  54461. * @param options defines the options used to create the texture
  54462. * @returns a new render target texture stored in an InternalTexture
  54463. */
  54464. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54465. /**
  54466. * Update the sampling mode of a given texture
  54467. * @param samplingMode defines the required sampling mode
  54468. * @param texture defines the texture to update
  54469. */
  54470. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54471. /**
  54472. * Binds the frame buffer to the specified texture.
  54473. * @param texture The texture to render to or null for the default canvas
  54474. * @param faceIndex The face of the texture to render to in case of cube texture
  54475. * @param requiredWidth The width of the target to render to
  54476. * @param requiredHeight The height of the target to render to
  54477. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54478. * @param lodLevel defines le lod level to bind to the frame buffer
  54479. */
  54480. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54481. /**
  54482. * Unbind the current render target texture from the webGL context
  54483. * @param texture defines the render target texture to unbind
  54484. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54485. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54486. */
  54487. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54488. /**
  54489. * Creates a dynamic vertex buffer
  54490. * @param vertices the data for the dynamic vertex buffer
  54491. * @returns the new WebGL dynamic buffer
  54492. */
  54493. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54494. /**
  54495. * Update the content of a dynamic texture
  54496. * @param texture defines the texture to update
  54497. * @param canvas defines the canvas containing the source
  54498. * @param invertY defines if data must be stored with Y axis inverted
  54499. * @param premulAlpha defines if alpha is stored as premultiplied
  54500. * @param format defines the format of the data
  54501. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54502. */
  54503. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54504. /**
  54505. * Gets a boolean indicating if all created effects are ready
  54506. * @returns true if all effects are ready
  54507. */
  54508. areAllEffectsReady(): boolean;
  54509. /**
  54510. * @hidden
  54511. * Get the current error code of the webGL context
  54512. * @returns the error code
  54513. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54514. */
  54515. getError(): number;
  54516. /** @hidden */
  54517. _getUnpackAlignement(): number;
  54518. /** @hidden */
  54519. _unpackFlipY(value: boolean): void;
  54520. /**
  54521. * Update a dynamic index buffer
  54522. * @param indexBuffer defines the target index buffer
  54523. * @param indices defines the data to update
  54524. * @param offset defines the offset in the target index buffer where update should start
  54525. */
  54526. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54527. /**
  54528. * Updates a dynamic vertex buffer.
  54529. * @param vertexBuffer the vertex buffer to update
  54530. * @param vertices the data used to update the vertex buffer
  54531. * @param byteOffset the byte offset of the data (optional)
  54532. * @param byteLength the byte length of the data (optional)
  54533. */
  54534. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54535. /** @hidden */
  54536. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54537. /** @hidden */
  54538. _bindTexture(channel: number, texture: InternalTexture): void;
  54539. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54540. /**
  54541. * 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
  54542. */
  54543. releaseEffects(): void;
  54544. displayLoadingUI(): void;
  54545. hideLoadingUI(): void;
  54546. /** @hidden */
  54547. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54548. /** @hidden */
  54549. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54550. /** @hidden */
  54551. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54552. /** @hidden */
  54553. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54554. }
  54555. }
  54556. declare module "babylonjs/Instrumentation/timeToken" {
  54557. import { Nullable } from "babylonjs/types";
  54558. /**
  54559. * @hidden
  54560. **/
  54561. export class _TimeToken {
  54562. _startTimeQuery: Nullable<WebGLQuery>;
  54563. _endTimeQuery: Nullable<WebGLQuery>;
  54564. _timeElapsedQuery: Nullable<WebGLQuery>;
  54565. _timeElapsedQueryEnded: boolean;
  54566. }
  54567. }
  54568. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54569. import { Nullable, int } from "babylonjs/types";
  54570. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54571. /** @hidden */
  54572. export class _OcclusionDataStorage {
  54573. /** @hidden */
  54574. occlusionInternalRetryCounter: number;
  54575. /** @hidden */
  54576. isOcclusionQueryInProgress: boolean;
  54577. /** @hidden */
  54578. isOccluded: boolean;
  54579. /** @hidden */
  54580. occlusionRetryCount: number;
  54581. /** @hidden */
  54582. occlusionType: number;
  54583. /** @hidden */
  54584. occlusionQueryAlgorithmType: number;
  54585. }
  54586. module "babylonjs/Engines/engine" {
  54587. interface Engine {
  54588. /**
  54589. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54590. * @return the new query
  54591. */
  54592. createQuery(): WebGLQuery;
  54593. /**
  54594. * Delete and release a webGL query
  54595. * @param query defines the query to delete
  54596. * @return the current engine
  54597. */
  54598. deleteQuery(query: WebGLQuery): Engine;
  54599. /**
  54600. * Check if a given query has resolved and got its value
  54601. * @param query defines the query to check
  54602. * @returns true if the query got its value
  54603. */
  54604. isQueryResultAvailable(query: WebGLQuery): boolean;
  54605. /**
  54606. * Gets the value of a given query
  54607. * @param query defines the query to check
  54608. * @returns the value of the query
  54609. */
  54610. getQueryResult(query: WebGLQuery): number;
  54611. /**
  54612. * Initiates an occlusion query
  54613. * @param algorithmType defines the algorithm to use
  54614. * @param query defines the query to use
  54615. * @returns the current engine
  54616. * @see https://doc.babylonjs.com/features/occlusionquery
  54617. */
  54618. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54619. /**
  54620. * Ends an occlusion query
  54621. * @see https://doc.babylonjs.com/features/occlusionquery
  54622. * @param algorithmType defines the algorithm to use
  54623. * @returns the current engine
  54624. */
  54625. endOcclusionQuery(algorithmType: number): Engine;
  54626. /**
  54627. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54628. * Please note that only one query can be issued at a time
  54629. * @returns a time token used to track the time span
  54630. */
  54631. startTimeQuery(): Nullable<_TimeToken>;
  54632. /**
  54633. * Ends a time query
  54634. * @param token defines the token used to measure the time span
  54635. * @returns the time spent (in ns)
  54636. */
  54637. endTimeQuery(token: _TimeToken): int;
  54638. /** @hidden */
  54639. _currentNonTimestampToken: Nullable<_TimeToken>;
  54640. /** @hidden */
  54641. _createTimeQuery(): WebGLQuery;
  54642. /** @hidden */
  54643. _deleteTimeQuery(query: WebGLQuery): void;
  54644. /** @hidden */
  54645. _getGlAlgorithmType(algorithmType: number): number;
  54646. /** @hidden */
  54647. _getTimeQueryResult(query: WebGLQuery): any;
  54648. /** @hidden */
  54649. _getTimeQueryAvailability(query: WebGLQuery): any;
  54650. }
  54651. }
  54652. module "babylonjs/Meshes/abstractMesh" {
  54653. interface AbstractMesh {
  54654. /**
  54655. * Backing filed
  54656. * @hidden
  54657. */
  54658. __occlusionDataStorage: _OcclusionDataStorage;
  54659. /**
  54660. * Access property
  54661. * @hidden
  54662. */
  54663. _occlusionDataStorage: _OcclusionDataStorage;
  54664. /**
  54665. * 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.
  54666. * The default value is -1 which means don't break the query and wait till the result
  54667. * @see https://doc.babylonjs.com/features/occlusionquery
  54668. */
  54669. occlusionRetryCount: number;
  54670. /**
  54671. * 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:
  54672. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54673. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54674. * * 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.
  54675. * @see https://doc.babylonjs.com/features/occlusionquery
  54676. */
  54677. occlusionType: number;
  54678. /**
  54679. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54680. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54681. * * 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.
  54682. * @see https://doc.babylonjs.com/features/occlusionquery
  54683. */
  54684. occlusionQueryAlgorithmType: number;
  54685. /**
  54686. * 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
  54687. * @see https://doc.babylonjs.com/features/occlusionquery
  54688. */
  54689. isOccluded: boolean;
  54690. /**
  54691. * Flag to check the progress status of the query
  54692. * @see https://doc.babylonjs.com/features/occlusionquery
  54693. */
  54694. isOcclusionQueryInProgress: boolean;
  54695. }
  54696. }
  54697. }
  54698. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54699. import { Nullable } from "babylonjs/types";
  54700. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54701. /** @hidden */
  54702. export var _forceTransformFeedbackToBundle: boolean;
  54703. module "babylonjs/Engines/engine" {
  54704. interface Engine {
  54705. /**
  54706. * Creates a webGL transform feedback object
  54707. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54708. * @returns the webGL transform feedback object
  54709. */
  54710. createTransformFeedback(): WebGLTransformFeedback;
  54711. /**
  54712. * Delete a webGL transform feedback object
  54713. * @param value defines the webGL transform feedback object to delete
  54714. */
  54715. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54716. /**
  54717. * Bind a webGL transform feedback object to the webgl context
  54718. * @param value defines the webGL transform feedback object to bind
  54719. */
  54720. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54721. /**
  54722. * Begins a transform feedback operation
  54723. * @param usePoints defines if points or triangles must be used
  54724. */
  54725. beginTransformFeedback(usePoints: boolean): void;
  54726. /**
  54727. * Ends a transform feedback operation
  54728. */
  54729. endTransformFeedback(): void;
  54730. /**
  54731. * Specify the varyings to use with transform feedback
  54732. * @param program defines the associated webGL program
  54733. * @param value defines the list of strings representing the varying names
  54734. */
  54735. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54736. /**
  54737. * Bind a webGL buffer for a transform feedback operation
  54738. * @param value defines the webGL buffer to bind
  54739. */
  54740. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54741. }
  54742. }
  54743. }
  54744. declare module "babylonjs/Engines/Extensions/engine.views" {
  54745. import { Camera } from "babylonjs/Cameras/camera";
  54746. import { Nullable } from "babylonjs/types";
  54747. /**
  54748. * Class used to define an additional view for the engine
  54749. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54750. */
  54751. export class EngineView {
  54752. /** Defines the canvas where to render the view */
  54753. target: HTMLCanvasElement;
  54754. /** Defines an optional camera used to render the view (will use active camera else) */
  54755. camera?: Camera;
  54756. }
  54757. module "babylonjs/Engines/engine" {
  54758. interface Engine {
  54759. /**
  54760. * Gets or sets the HTML element to use for attaching events
  54761. */
  54762. inputElement: Nullable<HTMLElement>;
  54763. /**
  54764. * Gets the current engine view
  54765. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54766. */
  54767. activeView: Nullable<EngineView>;
  54768. /** Gets or sets the list of views */
  54769. views: EngineView[];
  54770. /**
  54771. * Register a new child canvas
  54772. * @param canvas defines the canvas to register
  54773. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54774. * @returns the associated view
  54775. */
  54776. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54777. /**
  54778. * Remove a registered child canvas
  54779. * @param canvas defines the canvas to remove
  54780. * @returns the current engine
  54781. */
  54782. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54783. }
  54784. }
  54785. }
  54786. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54787. import { Nullable } from "babylonjs/types";
  54788. module "babylonjs/Engines/engine" {
  54789. interface Engine {
  54790. /** @hidden */
  54791. _excludedCompressedTextures: string[];
  54792. /** @hidden */
  54793. _textureFormatInUse: string;
  54794. /**
  54795. * Gets the list of texture formats supported
  54796. */
  54797. readonly texturesSupported: Array<string>;
  54798. /**
  54799. * Gets the texture format in use
  54800. */
  54801. readonly textureFormatInUse: Nullable<string>;
  54802. /**
  54803. * Set the compressed texture extensions or file names to skip.
  54804. *
  54805. * @param skippedFiles defines the list of those texture files you want to skip
  54806. * Example: [".dds", ".env", "myfile.png"]
  54807. */
  54808. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54809. /**
  54810. * Set the compressed texture format to use, based on the formats you have, and the formats
  54811. * supported by the hardware / browser.
  54812. *
  54813. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54814. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54815. * to API arguments needed to compressed textures. This puts the burden on the container
  54816. * generator to house the arcane code for determining these for current & future formats.
  54817. *
  54818. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54819. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54820. *
  54821. * Note: The result of this call is not taken into account when a texture is base64.
  54822. *
  54823. * @param formatsAvailable defines the list of those format families you have created
  54824. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54825. *
  54826. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54827. * @returns The extension selected.
  54828. */
  54829. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54830. }
  54831. }
  54832. }
  54833. declare module "babylonjs/Engines/Extensions/index" {
  54834. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54835. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54836. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54837. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54838. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54839. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54840. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54841. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54842. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54843. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54844. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54845. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54846. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54847. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54848. export * from "babylonjs/Engines/Extensions/engine.views";
  54849. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54850. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54851. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54852. }
  54853. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54854. import { Nullable } from "babylonjs/types";
  54855. /**
  54856. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54857. */
  54858. export interface CubeMapInfo {
  54859. /**
  54860. * The pixel array for the front face.
  54861. * This is stored in format, left to right, up to down format.
  54862. */
  54863. front: Nullable<ArrayBufferView>;
  54864. /**
  54865. * The pixel array for the back face.
  54866. * This is stored in format, left to right, up to down format.
  54867. */
  54868. back: Nullable<ArrayBufferView>;
  54869. /**
  54870. * The pixel array for the left face.
  54871. * This is stored in format, left to right, up to down format.
  54872. */
  54873. left: Nullable<ArrayBufferView>;
  54874. /**
  54875. * The pixel array for the right face.
  54876. * This is stored in format, left to right, up to down format.
  54877. */
  54878. right: Nullable<ArrayBufferView>;
  54879. /**
  54880. * The pixel array for the up face.
  54881. * This is stored in format, left to right, up to down format.
  54882. */
  54883. up: Nullable<ArrayBufferView>;
  54884. /**
  54885. * The pixel array for the down face.
  54886. * This is stored in format, left to right, up to down format.
  54887. */
  54888. down: Nullable<ArrayBufferView>;
  54889. /**
  54890. * The size of the cubemap stored.
  54891. *
  54892. * Each faces will be size * size pixels.
  54893. */
  54894. size: number;
  54895. /**
  54896. * The format of the texture.
  54897. *
  54898. * RGBA, RGB.
  54899. */
  54900. format: number;
  54901. /**
  54902. * The type of the texture data.
  54903. *
  54904. * UNSIGNED_INT, FLOAT.
  54905. */
  54906. type: number;
  54907. /**
  54908. * Specifies whether the texture is in gamma space.
  54909. */
  54910. gammaSpace: boolean;
  54911. }
  54912. /**
  54913. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54914. */
  54915. export class PanoramaToCubeMapTools {
  54916. private static FACE_LEFT;
  54917. private static FACE_RIGHT;
  54918. private static FACE_FRONT;
  54919. private static FACE_BACK;
  54920. private static FACE_DOWN;
  54921. private static FACE_UP;
  54922. /**
  54923. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54924. *
  54925. * @param float32Array The source data.
  54926. * @param inputWidth The width of the input panorama.
  54927. * @param inputHeight The height of the input panorama.
  54928. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54929. * @return The cubemap data
  54930. */
  54931. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54932. private static CreateCubemapTexture;
  54933. private static CalcProjectionSpherical;
  54934. }
  54935. }
  54936. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54937. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54938. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54939. import { Nullable } from "babylonjs/types";
  54940. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54941. /**
  54942. * Helper class dealing with the extraction of spherical polynomial dataArray
  54943. * from a cube map.
  54944. */
  54945. export class CubeMapToSphericalPolynomialTools {
  54946. private static FileFaces;
  54947. /**
  54948. * Converts a texture to the according Spherical Polynomial data.
  54949. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54950. *
  54951. * @param texture The texture to extract the information from.
  54952. * @return The Spherical Polynomial data.
  54953. */
  54954. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54955. /**
  54956. * Converts a cubemap to the according Spherical Polynomial data.
  54957. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54958. *
  54959. * @param cubeInfo The Cube map to extract the information from.
  54960. * @return The Spherical Polynomial data.
  54961. */
  54962. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54963. }
  54964. }
  54965. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54966. import { Nullable } from "babylonjs/types";
  54967. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54968. module "babylonjs/Materials/Textures/baseTexture" {
  54969. interface BaseTexture {
  54970. /**
  54971. * Get the polynomial representation of the texture data.
  54972. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54973. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54974. */
  54975. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54976. }
  54977. }
  54978. }
  54979. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54980. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54981. /** @hidden */
  54982. export var rgbdEncodePixelShader: {
  54983. name: string;
  54984. shader: string;
  54985. };
  54986. }
  54987. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54988. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54989. /** @hidden */
  54990. export var rgbdDecodePixelShader: {
  54991. name: string;
  54992. shader: string;
  54993. };
  54994. }
  54995. declare module "babylonjs/Misc/environmentTextureTools" {
  54996. import { Nullable } from "babylonjs/types";
  54997. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54998. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55000. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  55001. import "babylonjs/Engines/Extensions/engine.readTexture";
  55002. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  55003. import "babylonjs/Shaders/rgbdEncode.fragment";
  55004. import "babylonjs/Shaders/rgbdDecode.fragment";
  55005. /**
  55006. * Raw texture data and descriptor sufficient for WebGL texture upload
  55007. */
  55008. export interface EnvironmentTextureInfo {
  55009. /**
  55010. * Version of the environment map
  55011. */
  55012. version: number;
  55013. /**
  55014. * Width of image
  55015. */
  55016. width: number;
  55017. /**
  55018. * Irradiance information stored in the file.
  55019. */
  55020. irradiance: any;
  55021. /**
  55022. * Specular information stored in the file.
  55023. */
  55024. specular: any;
  55025. }
  55026. /**
  55027. * Defines One Image in the file. It requires only the position in the file
  55028. * as well as the length.
  55029. */
  55030. interface BufferImageData {
  55031. /**
  55032. * Length of the image data.
  55033. */
  55034. length: number;
  55035. /**
  55036. * Position of the data from the null terminator delimiting the end of the JSON.
  55037. */
  55038. position: number;
  55039. }
  55040. /**
  55041. * Defines the specular data enclosed in the file.
  55042. * This corresponds to the version 1 of the data.
  55043. */
  55044. export interface EnvironmentTextureSpecularInfoV1 {
  55045. /**
  55046. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55047. */
  55048. specularDataPosition?: number;
  55049. /**
  55050. * This contains all the images data needed to reconstruct the cubemap.
  55051. */
  55052. mipmaps: Array<BufferImageData>;
  55053. /**
  55054. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55055. */
  55056. lodGenerationScale: number;
  55057. }
  55058. /**
  55059. * Sets of helpers addressing the serialization and deserialization of environment texture
  55060. * stored in a BabylonJS env file.
  55061. * Those files are usually stored as .env files.
  55062. */
  55063. export class EnvironmentTextureTools {
  55064. /**
  55065. * Magic number identifying the env file.
  55066. */
  55067. private static _MagicBytes;
  55068. /**
  55069. * Gets the environment info from an env file.
  55070. * @param data The array buffer containing the .env bytes.
  55071. * @returns the environment file info (the json header) if successfully parsed.
  55072. */
  55073. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  55074. /**
  55075. * Creates an environment texture from a loaded cube texture.
  55076. * @param texture defines the cube texture to convert in env file
  55077. * @return a promise containing the environment data if succesfull.
  55078. */
  55079. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  55080. /**
  55081. * Creates a JSON representation of the spherical data.
  55082. * @param texture defines the texture containing the polynomials
  55083. * @return the JSON representation of the spherical info
  55084. */
  55085. private static _CreateEnvTextureIrradiance;
  55086. /**
  55087. * Creates the ArrayBufferViews used for initializing environment texture image data.
  55088. * @param data the image data
  55089. * @param info parameters that determine what views will be created for accessing the underlying buffer
  55090. * @return the views described by info providing access to the underlying buffer
  55091. */
  55092. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  55093. /**
  55094. * Uploads the texture info contained in the env file to the GPU.
  55095. * @param texture defines the internal texture to upload to
  55096. * @param data defines the data to load
  55097. * @param info defines the texture info retrieved through the GetEnvInfo method
  55098. * @returns a promise
  55099. */
  55100. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  55101. private static _OnImageReadyAsync;
  55102. /**
  55103. * Uploads the levels of image data to the GPU.
  55104. * @param texture defines the internal texture to upload to
  55105. * @param imageData defines the array buffer views of image data [mipmap][face]
  55106. * @returns a promise
  55107. */
  55108. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  55109. /**
  55110. * Uploads spherical polynomials information to the texture.
  55111. * @param texture defines the texture we are trying to upload the information to
  55112. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  55113. */
  55114. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  55115. /** @hidden */
  55116. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55117. }
  55118. }
  55119. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  55120. /**
  55121. * Class used to inline functions in shader code
  55122. */
  55123. export class ShaderCodeInliner {
  55124. private static readonly _RegexpFindFunctionNameAndType;
  55125. private _sourceCode;
  55126. private _functionDescr;
  55127. private _numMaxIterations;
  55128. /** Gets or sets the token used to mark the functions to inline */
  55129. inlineToken: string;
  55130. /** Gets or sets the debug mode */
  55131. debug: boolean;
  55132. /** Gets the code after the inlining process */
  55133. get code(): string;
  55134. /**
  55135. * Initializes the inliner
  55136. * @param sourceCode shader code source to inline
  55137. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55138. */
  55139. constructor(sourceCode: string, numMaxIterations?: number);
  55140. /**
  55141. * Start the processing of the shader code
  55142. */
  55143. processCode(): void;
  55144. private _collectFunctions;
  55145. private _processInlining;
  55146. private _extractBetweenMarkers;
  55147. private _skipWhitespaces;
  55148. private _removeComments;
  55149. private _replaceFunctionCallsByCode;
  55150. private _findBackward;
  55151. private _escapeRegExp;
  55152. private _replaceNames;
  55153. }
  55154. }
  55155. declare module "babylonjs/Engines/nativeEngine" {
  55156. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  55157. import { Engine } from "babylonjs/Engines/engine";
  55158. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  55159. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55160. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55161. import { Effect } from "babylonjs/Materials/effect";
  55162. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  55163. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  55164. import { IColor4Like } from "babylonjs/Maths/math.like";
  55165. import { Scene } from "babylonjs/scene";
  55166. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  55167. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  55168. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  55169. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  55170. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  55171. /**
  55172. * Container for accessors for natively-stored mesh data buffers.
  55173. */
  55174. class NativeDataBuffer extends DataBuffer {
  55175. /**
  55176. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55177. */
  55178. nativeIndexBuffer?: any;
  55179. /**
  55180. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55181. */
  55182. nativeVertexBuffer?: any;
  55183. }
  55184. /** @hidden */
  55185. class NativeTexture extends InternalTexture {
  55186. getInternalTexture(): InternalTexture;
  55187. getViewCount(): number;
  55188. }
  55189. /** @hidden */
  55190. export class NativeEngine extends Engine {
  55191. private readonly _native;
  55192. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55193. private readonly INVALID_HANDLE;
  55194. private _boundBuffersVertexArray;
  55195. private _currentDepthTest;
  55196. getHardwareScalingLevel(): number;
  55197. constructor();
  55198. dispose(): void;
  55199. /**
  55200. * Can be used to override the current requestAnimationFrame requester.
  55201. * @hidden
  55202. */
  55203. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55204. /**
  55205. * Override default engine behavior.
  55206. * @param color
  55207. * @param backBuffer
  55208. * @param depth
  55209. * @param stencil
  55210. */
  55211. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55212. /**
  55213. * Gets host document
  55214. * @returns the host document object
  55215. */
  55216. getHostDocument(): Nullable<Document>;
  55217. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55218. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55219. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55220. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55221. [key: string]: VertexBuffer;
  55222. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55223. bindBuffers(vertexBuffers: {
  55224. [key: string]: VertexBuffer;
  55225. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55226. recordVertexArrayObject(vertexBuffers: {
  55227. [key: string]: VertexBuffer;
  55228. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55229. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55230. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55231. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55232. /**
  55233. * Draw a list of indexed primitives
  55234. * @param fillMode defines the primitive to use
  55235. * @param indexStart defines the starting index
  55236. * @param indexCount defines the number of index to draw
  55237. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55238. */
  55239. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55240. /**
  55241. * Draw a list of unindexed primitives
  55242. * @param fillMode defines the primitive to use
  55243. * @param verticesStart defines the index of first vertex to draw
  55244. * @param verticesCount defines the count of vertices to draw
  55245. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55246. */
  55247. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55248. createPipelineContext(): IPipelineContext;
  55249. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55250. /** @hidden */
  55251. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55252. /** @hidden */
  55253. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55254. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55255. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55256. protected _setProgram(program: WebGLProgram): void;
  55257. _releaseEffect(effect: Effect): void;
  55258. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55259. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55260. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55261. bindSamplers(effect: Effect): void;
  55262. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55263. getRenderWidth(useScreen?: boolean): number;
  55264. getRenderHeight(useScreen?: boolean): number;
  55265. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55266. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55267. /**
  55268. * Set the z offset to apply to current rendering
  55269. * @param value defines the offset to apply
  55270. */
  55271. setZOffset(value: number): void;
  55272. /**
  55273. * Gets the current value of the zOffset
  55274. * @returns the current zOffset state
  55275. */
  55276. getZOffset(): number;
  55277. /**
  55278. * Enable or disable depth buffering
  55279. * @param enable defines the state to set
  55280. */
  55281. setDepthBuffer(enable: boolean): void;
  55282. /**
  55283. * Gets a boolean indicating if depth writing is enabled
  55284. * @returns the current depth writing state
  55285. */
  55286. getDepthWrite(): boolean;
  55287. setDepthFunctionToGreater(): void;
  55288. setDepthFunctionToGreaterOrEqual(): void;
  55289. setDepthFunctionToLess(): void;
  55290. setDepthFunctionToLessOrEqual(): void;
  55291. /**
  55292. * Enable or disable depth writing
  55293. * @param enable defines the state to set
  55294. */
  55295. setDepthWrite(enable: boolean): void;
  55296. /**
  55297. * Enable or disable color writing
  55298. * @param enable defines the state to set
  55299. */
  55300. setColorWrite(enable: boolean): void;
  55301. /**
  55302. * Gets a boolean indicating if color writing is enabled
  55303. * @returns the current color writing state
  55304. */
  55305. getColorWrite(): boolean;
  55306. /**
  55307. * Sets alpha constants used by some alpha blending modes
  55308. * @param r defines the red component
  55309. * @param g defines the green component
  55310. * @param b defines the blue component
  55311. * @param a defines the alpha component
  55312. */
  55313. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55314. /**
  55315. * Sets the current alpha mode
  55316. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55317. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55318. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55319. */
  55320. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55321. /**
  55322. * Gets the current alpha mode
  55323. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55324. * @returns the current alpha mode
  55325. */
  55326. getAlphaMode(): number;
  55327. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55328. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55329. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55330. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55331. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55332. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55333. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55334. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55335. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55336. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55337. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55338. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55339. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55340. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55341. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55342. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55343. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55344. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55345. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55346. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55347. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55348. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55349. wipeCaches(bruteForce?: boolean): void;
  55350. _createTexture(): WebGLTexture;
  55351. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55352. /**
  55353. * Update the content of a dynamic texture
  55354. * @param texture defines the texture to update
  55355. * @param canvas defines the canvas containing the source
  55356. * @param invertY defines if data must be stored with Y axis inverted
  55357. * @param premulAlpha defines if alpha is stored as premultiplied
  55358. * @param format defines the format of the data
  55359. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55360. */
  55361. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55362. /**
  55363. * Usually called from Texture.ts.
  55364. * Passed information to create a WebGLTexture
  55365. * @param url defines a value which contains one of the following:
  55366. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55367. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55368. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55369. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55370. * @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)
  55371. * @param scene needed for loading to the correct scene
  55372. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55373. * @param onLoad optional callback to be called upon successful completion
  55374. * @param onError optional callback to be called upon failure
  55375. * @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
  55376. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55377. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55378. * @param forcedExtension defines the extension to use to pick the right loader
  55379. * @param mimeType defines an optional mime type
  55380. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55381. */
  55382. 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;
  55383. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  55384. _releaseFramebufferObjects(texture: InternalTexture): void;
  55385. /**
  55386. * Creates a cube texture
  55387. * @param rootUrl defines the url where the files to load is located
  55388. * @param scene defines the current scene
  55389. * @param files defines the list of files to load (1 per face)
  55390. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55391. * @param onLoad defines an optional callback raised when the texture is loaded
  55392. * @param onError defines an optional callback raised if there is an issue to load the texture
  55393. * @param format defines the format of the data
  55394. * @param forcedExtension defines the extension to use to pick the right loader
  55395. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55396. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55397. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55398. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55399. * @returns the cube texture as an InternalTexture
  55400. */
  55401. 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;
  55402. createRenderTargetTexture(size: number | {
  55403. width: number;
  55404. height: number;
  55405. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55406. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55407. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55408. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55409. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55410. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55411. /**
  55412. * Updates a dynamic vertex buffer.
  55413. * @param vertexBuffer the vertex buffer to update
  55414. * @param data the data used to update the vertex buffer
  55415. * @param byteOffset the byte offset of the data (optional)
  55416. * @param byteLength the byte length of the data (optional)
  55417. */
  55418. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55419. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55420. private _updateAnisotropicLevel;
  55421. private _getAddressMode;
  55422. /** @hidden */
  55423. _bindTexture(channel: number, texture: InternalTexture): void;
  55424. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55425. releaseEffects(): void;
  55426. /** @hidden */
  55427. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55428. /** @hidden */
  55429. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55430. /** @hidden */
  55431. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55432. /** @hidden */
  55433. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55434. private _getNativeSamplingMode;
  55435. private _getNativeTextureFormat;
  55436. private _getNativeAlphaMode;
  55437. private _getNativeAttribType;
  55438. }
  55439. }
  55440. declare module "babylonjs/Engines/index" {
  55441. export * from "babylonjs/Engines/constants";
  55442. export * from "babylonjs/Engines/engineCapabilities";
  55443. export * from "babylonjs/Engines/instancingAttributeInfo";
  55444. export * from "babylonjs/Engines/thinEngine";
  55445. export * from "babylonjs/Engines/engine";
  55446. export * from "babylonjs/Engines/engineStore";
  55447. export * from "babylonjs/Engines/nullEngine";
  55448. export * from "babylonjs/Engines/Extensions/index";
  55449. export * from "babylonjs/Engines/IPipelineContext";
  55450. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55451. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55452. export * from "babylonjs/Engines/nativeEngine";
  55453. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55454. export * from "babylonjs/Engines/performanceConfigurator";
  55455. }
  55456. declare module "babylonjs/Events/clipboardEvents" {
  55457. /**
  55458. * Gather the list of clipboard event types as constants.
  55459. */
  55460. export class ClipboardEventTypes {
  55461. /**
  55462. * The clipboard event is fired when a copy command is active (pressed).
  55463. */
  55464. static readonly COPY: number;
  55465. /**
  55466. * The clipboard event is fired when a cut command is active (pressed).
  55467. */
  55468. static readonly CUT: number;
  55469. /**
  55470. * The clipboard event is fired when a paste command is active (pressed).
  55471. */
  55472. static readonly PASTE: number;
  55473. }
  55474. /**
  55475. * This class is used to store clipboard related info for the onClipboardObservable event.
  55476. */
  55477. export class ClipboardInfo {
  55478. /**
  55479. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55480. */
  55481. type: number;
  55482. /**
  55483. * Defines the related dom event
  55484. */
  55485. event: ClipboardEvent;
  55486. /**
  55487. *Creates an instance of ClipboardInfo.
  55488. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55489. * @param event Defines the related dom event
  55490. */
  55491. constructor(
  55492. /**
  55493. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55494. */
  55495. type: number,
  55496. /**
  55497. * Defines the related dom event
  55498. */
  55499. event: ClipboardEvent);
  55500. /**
  55501. * Get the clipboard event's type from the keycode.
  55502. * @param keyCode Defines the keyCode for the current keyboard event.
  55503. * @return {number}
  55504. */
  55505. static GetTypeFromCharacter(keyCode: number): number;
  55506. }
  55507. }
  55508. declare module "babylonjs/Events/index" {
  55509. export * from "babylonjs/Events/keyboardEvents";
  55510. export * from "babylonjs/Events/pointerEvents";
  55511. export * from "babylonjs/Events/clipboardEvents";
  55512. }
  55513. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55514. import { Scene } from "babylonjs/scene";
  55515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55516. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55517. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55518. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55519. /**
  55520. * Google Daydream controller
  55521. */
  55522. export class DaydreamController extends WebVRController {
  55523. /**
  55524. * Base Url for the controller model.
  55525. */
  55526. static MODEL_BASE_URL: string;
  55527. /**
  55528. * File name for the controller model.
  55529. */
  55530. static MODEL_FILENAME: string;
  55531. /**
  55532. * Gamepad Id prefix used to identify Daydream Controller.
  55533. */
  55534. static readonly GAMEPAD_ID_PREFIX: string;
  55535. /**
  55536. * Creates a new DaydreamController from a gamepad
  55537. * @param vrGamepad the gamepad that the controller should be created from
  55538. */
  55539. constructor(vrGamepad: any);
  55540. /**
  55541. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55542. * @param scene scene in which to add meshes
  55543. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55544. */
  55545. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55546. /**
  55547. * Called once for each button that changed state since the last frame
  55548. * @param buttonIdx Which button index changed
  55549. * @param state New state of the button
  55550. * @param changes Which properties on the state changed since last frame
  55551. */
  55552. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55553. }
  55554. }
  55555. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55556. import { Scene } from "babylonjs/scene";
  55557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55558. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55559. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55560. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55561. /**
  55562. * Gear VR Controller
  55563. */
  55564. export class GearVRController extends WebVRController {
  55565. /**
  55566. * Base Url for the controller model.
  55567. */
  55568. static MODEL_BASE_URL: string;
  55569. /**
  55570. * File name for the controller model.
  55571. */
  55572. static MODEL_FILENAME: string;
  55573. /**
  55574. * Gamepad Id prefix used to identify this controller.
  55575. */
  55576. static readonly GAMEPAD_ID_PREFIX: string;
  55577. private readonly _buttonIndexToObservableNameMap;
  55578. /**
  55579. * Creates a new GearVRController from a gamepad
  55580. * @param vrGamepad the gamepad that the controller should be created from
  55581. */
  55582. constructor(vrGamepad: any);
  55583. /**
  55584. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55585. * @param scene scene in which to add meshes
  55586. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55587. */
  55588. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55589. /**
  55590. * Called once for each button that changed state since the last frame
  55591. * @param buttonIdx Which button index changed
  55592. * @param state New state of the button
  55593. * @param changes Which properties on the state changed since last frame
  55594. */
  55595. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55596. }
  55597. }
  55598. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55599. import { Scene } from "babylonjs/scene";
  55600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55601. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55602. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55603. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55604. /**
  55605. * Generic Controller
  55606. */
  55607. export class GenericController extends WebVRController {
  55608. /**
  55609. * Base Url for the controller model.
  55610. */
  55611. static readonly MODEL_BASE_URL: string;
  55612. /**
  55613. * File name for the controller model.
  55614. */
  55615. static readonly MODEL_FILENAME: string;
  55616. /**
  55617. * Creates a new GenericController from a gamepad
  55618. * @param vrGamepad the gamepad that the controller should be created from
  55619. */
  55620. constructor(vrGamepad: any);
  55621. /**
  55622. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55623. * @param scene scene in which to add meshes
  55624. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55625. */
  55626. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55627. /**
  55628. * Called once for each button that changed state since the last frame
  55629. * @param buttonIdx Which button index changed
  55630. * @param state New state of the button
  55631. * @param changes Which properties on the state changed since last frame
  55632. */
  55633. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55634. }
  55635. }
  55636. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55637. import { Observable } from "babylonjs/Misc/observable";
  55638. import { Scene } from "babylonjs/scene";
  55639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55640. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55641. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55642. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55643. /**
  55644. * Oculus Touch Controller
  55645. */
  55646. export class OculusTouchController extends WebVRController {
  55647. /**
  55648. * Base Url for the controller model.
  55649. */
  55650. static MODEL_BASE_URL: string;
  55651. /**
  55652. * File name for the left controller model.
  55653. */
  55654. static MODEL_LEFT_FILENAME: string;
  55655. /**
  55656. * File name for the right controller model.
  55657. */
  55658. static MODEL_RIGHT_FILENAME: string;
  55659. /**
  55660. * Base Url for the Quest controller model.
  55661. */
  55662. static QUEST_MODEL_BASE_URL: string;
  55663. /**
  55664. * @hidden
  55665. * If the controllers are running on a device that needs the updated Quest controller models
  55666. */
  55667. static _IsQuest: boolean;
  55668. /**
  55669. * Fired when the secondary trigger on this controller is modified
  55670. */
  55671. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55672. /**
  55673. * Fired when the thumb rest on this controller is modified
  55674. */
  55675. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55676. /**
  55677. * Creates a new OculusTouchController from a gamepad
  55678. * @param vrGamepad the gamepad that the controller should be created from
  55679. */
  55680. constructor(vrGamepad: any);
  55681. /**
  55682. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55683. * @param scene scene in which to add meshes
  55684. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55685. */
  55686. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55687. /**
  55688. * Fired when the A button on this controller is modified
  55689. */
  55690. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55691. /**
  55692. * Fired when the B button on this controller is modified
  55693. */
  55694. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55695. /**
  55696. * Fired when the X button on this controller is modified
  55697. */
  55698. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55699. /**
  55700. * Fired when the Y button on this controller is modified
  55701. */
  55702. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55703. /**
  55704. * Called once for each button that changed state since the last frame
  55705. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55706. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55707. * 2) secondary trigger (same)
  55708. * 3) A (right) X (left), touch, pressed = value
  55709. * 4) B / Y
  55710. * 5) thumb rest
  55711. * @param buttonIdx Which button index changed
  55712. * @param state New state of the button
  55713. * @param changes Which properties on the state changed since last frame
  55714. */
  55715. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55716. }
  55717. }
  55718. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55719. import { Scene } from "babylonjs/scene";
  55720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55721. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55722. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55723. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55724. import { Observable } from "babylonjs/Misc/observable";
  55725. /**
  55726. * Vive Controller
  55727. */
  55728. export class ViveController extends WebVRController {
  55729. /**
  55730. * Base Url for the controller model.
  55731. */
  55732. static MODEL_BASE_URL: string;
  55733. /**
  55734. * File name for the controller model.
  55735. */
  55736. static MODEL_FILENAME: string;
  55737. /**
  55738. * Creates a new ViveController from a gamepad
  55739. * @param vrGamepad the gamepad that the controller should be created from
  55740. */
  55741. constructor(vrGamepad: any);
  55742. /**
  55743. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55744. * @param scene scene in which to add meshes
  55745. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55746. */
  55747. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55748. /**
  55749. * Fired when the left button on this controller is modified
  55750. */
  55751. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55752. /**
  55753. * Fired when the right button on this controller is modified
  55754. */
  55755. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55756. /**
  55757. * Fired when the menu button on this controller is modified
  55758. */
  55759. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55760. /**
  55761. * Called once for each button that changed state since the last frame
  55762. * Vive mapping:
  55763. * 0: touchpad
  55764. * 1: trigger
  55765. * 2: left AND right buttons
  55766. * 3: menu button
  55767. * @param buttonIdx Which button index changed
  55768. * @param state New state of the button
  55769. * @param changes Which properties on the state changed since last frame
  55770. */
  55771. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55772. }
  55773. }
  55774. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55775. import { Observable } from "babylonjs/Misc/observable";
  55776. import { Scene } from "babylonjs/scene";
  55777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55778. import { Ray } from "babylonjs/Culling/ray";
  55779. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55780. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55781. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55782. /**
  55783. * Defines the WindowsMotionController object that the state of the windows motion controller
  55784. */
  55785. export class WindowsMotionController extends WebVRController {
  55786. /**
  55787. * The base url used to load the left and right controller models
  55788. */
  55789. static MODEL_BASE_URL: string;
  55790. /**
  55791. * The name of the left controller model file
  55792. */
  55793. static MODEL_LEFT_FILENAME: string;
  55794. /**
  55795. * The name of the right controller model file
  55796. */
  55797. static MODEL_RIGHT_FILENAME: string;
  55798. /**
  55799. * The controller name prefix for this controller type
  55800. */
  55801. static readonly GAMEPAD_ID_PREFIX: string;
  55802. /**
  55803. * The controller id pattern for this controller type
  55804. */
  55805. private static readonly GAMEPAD_ID_PATTERN;
  55806. private _loadedMeshInfo;
  55807. protected readonly _mapping: {
  55808. buttons: string[];
  55809. buttonMeshNames: {
  55810. trigger: string;
  55811. menu: string;
  55812. grip: string;
  55813. thumbstick: string;
  55814. trackpad: string;
  55815. };
  55816. buttonObservableNames: {
  55817. trigger: string;
  55818. menu: string;
  55819. grip: string;
  55820. thumbstick: string;
  55821. trackpad: string;
  55822. };
  55823. axisMeshNames: string[];
  55824. pointingPoseMeshName: string;
  55825. };
  55826. /**
  55827. * Fired when the trackpad on this controller is clicked
  55828. */
  55829. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55830. /**
  55831. * Fired when the trackpad on this controller is modified
  55832. */
  55833. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55834. /**
  55835. * The current x and y values of this controller's trackpad
  55836. */
  55837. trackpad: StickValues;
  55838. /**
  55839. * Creates a new WindowsMotionController from a gamepad
  55840. * @param vrGamepad the gamepad that the controller should be created from
  55841. */
  55842. constructor(vrGamepad: any);
  55843. /**
  55844. * Fired when the trigger on this controller is modified
  55845. */
  55846. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55847. /**
  55848. * Fired when the menu button on this controller is modified
  55849. */
  55850. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55851. /**
  55852. * Fired when the grip button on this controller is modified
  55853. */
  55854. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55855. /**
  55856. * Fired when the thumbstick button on this controller is modified
  55857. */
  55858. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55859. /**
  55860. * Fired when the touchpad button on this controller is modified
  55861. */
  55862. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55863. /**
  55864. * Fired when the touchpad values on this controller are modified
  55865. */
  55866. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55867. protected _updateTrackpad(): void;
  55868. /**
  55869. * Called once per frame by the engine.
  55870. */
  55871. update(): void;
  55872. /**
  55873. * Called once for each button that changed state since the last frame
  55874. * @param buttonIdx Which button index changed
  55875. * @param state New state of the button
  55876. * @param changes Which properties on the state changed since last frame
  55877. */
  55878. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55879. /**
  55880. * Moves the buttons on the controller mesh based on their current state
  55881. * @param buttonName the name of the button to move
  55882. * @param buttonValue the value of the button which determines the buttons new position
  55883. */
  55884. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55885. /**
  55886. * Moves the axis on the controller mesh based on its current state
  55887. * @param axis the index of the axis
  55888. * @param axisValue the value of the axis which determines the meshes new position
  55889. * @hidden
  55890. */
  55891. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55892. /**
  55893. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55894. * @param scene scene in which to add meshes
  55895. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55896. */
  55897. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55898. /**
  55899. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55900. * can be transformed by button presses and axes values, based on this._mapping.
  55901. *
  55902. * @param scene scene in which the meshes exist
  55903. * @param meshes list of meshes that make up the controller model to process
  55904. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55905. */
  55906. private processModel;
  55907. private createMeshInfo;
  55908. /**
  55909. * Gets the ray of the controller in the direction the controller is pointing
  55910. * @param length the length the resulting ray should be
  55911. * @returns a ray in the direction the controller is pointing
  55912. */
  55913. getForwardRay(length?: number): Ray;
  55914. /**
  55915. * Disposes of the controller
  55916. */
  55917. dispose(): void;
  55918. }
  55919. /**
  55920. * This class represents a new windows motion controller in XR.
  55921. */
  55922. export class XRWindowsMotionController extends WindowsMotionController {
  55923. /**
  55924. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55925. */
  55926. protected readonly _mapping: {
  55927. buttons: string[];
  55928. buttonMeshNames: {
  55929. trigger: string;
  55930. menu: string;
  55931. grip: string;
  55932. thumbstick: string;
  55933. trackpad: string;
  55934. };
  55935. buttonObservableNames: {
  55936. trigger: string;
  55937. menu: string;
  55938. grip: string;
  55939. thumbstick: string;
  55940. trackpad: string;
  55941. };
  55942. axisMeshNames: string[];
  55943. pointingPoseMeshName: string;
  55944. };
  55945. /**
  55946. * Construct a new XR-Based windows motion controller
  55947. *
  55948. * @param gamepadInfo the gamepad object from the browser
  55949. */
  55950. constructor(gamepadInfo: any);
  55951. /**
  55952. * holds the thumbstick values (X,Y)
  55953. */
  55954. thumbstickValues: StickValues;
  55955. /**
  55956. * Fired when the thumbstick on this controller is clicked
  55957. */
  55958. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55959. /**
  55960. * Fired when the thumbstick on this controller is modified
  55961. */
  55962. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55963. /**
  55964. * Fired when the touchpad button on this controller is modified
  55965. */
  55966. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55967. /**
  55968. * Fired when the touchpad values on this controller are modified
  55969. */
  55970. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55971. /**
  55972. * Fired when the thumbstick button on this controller is modified
  55973. * here to prevent breaking changes
  55974. */
  55975. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55976. /**
  55977. * updating the thumbstick(!) and not the trackpad.
  55978. * This is named this way due to the difference between WebVR and XR and to avoid
  55979. * changing the parent class.
  55980. */
  55981. protected _updateTrackpad(): void;
  55982. /**
  55983. * Disposes the class with joy
  55984. */
  55985. dispose(): void;
  55986. }
  55987. }
  55988. declare module "babylonjs/Gamepads/Controllers/index" {
  55989. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55990. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55991. export * from "babylonjs/Gamepads/Controllers/genericController";
  55992. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55993. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55994. export * from "babylonjs/Gamepads/Controllers/viveController";
  55995. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55996. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55997. }
  55998. declare module "babylonjs/Gamepads/index" {
  55999. export * from "babylonjs/Gamepads/Controllers/index";
  56000. export * from "babylonjs/Gamepads/gamepad";
  56001. export * from "babylonjs/Gamepads/gamepadManager";
  56002. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  56003. export * from "babylonjs/Gamepads/xboxGamepad";
  56004. export * from "babylonjs/Gamepads/dualShockGamepad";
  56005. }
  56006. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  56007. import { Scene } from "babylonjs/scene";
  56008. import { Vector4 } from "babylonjs/Maths/math.vector";
  56009. import { Color4 } from "babylonjs/Maths/math.color";
  56010. import { Mesh } from "babylonjs/Meshes/mesh";
  56011. import { Nullable } from "babylonjs/types";
  56012. /**
  56013. * Class containing static functions to help procedurally build meshes
  56014. */
  56015. export class PolyhedronBuilder {
  56016. /**
  56017. * Creates a polyhedron mesh
  56018. * * 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
  56019. * * The parameter `size` (positive float, default 1) sets the polygon size
  56020. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56021. * * 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`
  56022. * * 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
  56023. * * 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)`)
  56024. * * 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
  56025. * * 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
  56026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56027. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56029. * @param name defines the name of the mesh
  56030. * @param options defines the options used to create the mesh
  56031. * @param scene defines the hosting scene
  56032. * @returns the polyhedron mesh
  56033. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56034. */
  56035. static CreatePolyhedron(name: string, options: {
  56036. type?: number;
  56037. size?: number;
  56038. sizeX?: number;
  56039. sizeY?: number;
  56040. sizeZ?: number;
  56041. custom?: any;
  56042. faceUV?: Vector4[];
  56043. faceColors?: Color4[];
  56044. flat?: boolean;
  56045. updatable?: boolean;
  56046. sideOrientation?: number;
  56047. frontUVs?: Vector4;
  56048. backUVs?: Vector4;
  56049. }, scene?: Nullable<Scene>): Mesh;
  56050. }
  56051. }
  56052. declare module "babylonjs/Gizmos/scaleGizmo" {
  56053. import { Observable } from "babylonjs/Misc/observable";
  56054. import { Nullable } from "babylonjs/types";
  56055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56056. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56057. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  56058. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56059. import { Node } from "babylonjs/node";
  56060. /**
  56061. * Gizmo that enables scaling a mesh along 3 axis
  56062. */
  56063. export class ScaleGizmo extends Gizmo {
  56064. /**
  56065. * Internal gizmo used for interactions on the x axis
  56066. */
  56067. xGizmo: AxisScaleGizmo;
  56068. /**
  56069. * Internal gizmo used for interactions on the y axis
  56070. */
  56071. yGizmo: AxisScaleGizmo;
  56072. /**
  56073. * Internal gizmo used for interactions on the z axis
  56074. */
  56075. zGizmo: AxisScaleGizmo;
  56076. /**
  56077. * Internal gizmo used to scale all axis equally
  56078. */
  56079. uniformScaleGizmo: AxisScaleGizmo;
  56080. private _meshAttached;
  56081. private _nodeAttached;
  56082. private _snapDistance;
  56083. private _uniformScalingMesh;
  56084. private _octahedron;
  56085. private _sensitivity;
  56086. /** Fires an event when any of it's sub gizmos are dragged */
  56087. onDragStartObservable: Observable<unknown>;
  56088. /** Fires an event when any of it's sub gizmos are released from dragging */
  56089. onDragEndObservable: Observable<unknown>;
  56090. get attachedMesh(): Nullable<AbstractMesh>;
  56091. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56092. get attachedNode(): Nullable<Node>;
  56093. set attachedNode(node: Nullable<Node>);
  56094. /**
  56095. * True when the mouse pointer is hovering a gizmo mesh
  56096. */
  56097. get isHovered(): boolean;
  56098. /**
  56099. * Creates a ScaleGizmo
  56100. * @param gizmoLayer The utility layer the gizmo will be added to
  56101. * @param thickness display gizmo axis thickness
  56102. */
  56103. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56104. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56105. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56106. /**
  56107. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56108. */
  56109. set snapDistance(value: number);
  56110. get snapDistance(): number;
  56111. /**
  56112. * Ratio for the scale of the gizmo (Default: 1)
  56113. */
  56114. set scaleRatio(value: number);
  56115. get scaleRatio(): number;
  56116. /**
  56117. * Sensitivity factor for dragging (Default: 1)
  56118. */
  56119. set sensitivity(value: number);
  56120. get sensitivity(): number;
  56121. /**
  56122. * Disposes of the gizmo
  56123. */
  56124. dispose(): void;
  56125. }
  56126. }
  56127. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  56128. import { Observable } from "babylonjs/Misc/observable";
  56129. import { Nullable } from "babylonjs/types";
  56130. import { Vector3 } from "babylonjs/Maths/math.vector";
  56131. import { Node } from "babylonjs/node";
  56132. import { Mesh } from "babylonjs/Meshes/mesh";
  56133. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56134. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56135. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56136. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56137. import { Color3 } from "babylonjs/Maths/math.color";
  56138. /**
  56139. * Single axis scale gizmo
  56140. */
  56141. export class AxisScaleGizmo extends Gizmo {
  56142. /**
  56143. * Drag behavior responsible for the gizmos dragging interactions
  56144. */
  56145. dragBehavior: PointerDragBehavior;
  56146. private _pointerObserver;
  56147. /**
  56148. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56149. */
  56150. snapDistance: number;
  56151. /**
  56152. * Event that fires each time the gizmo snaps to a new location.
  56153. * * snapDistance is the the change in distance
  56154. */
  56155. onSnapObservable: Observable<{
  56156. snapDistance: number;
  56157. }>;
  56158. /**
  56159. * If the scaling operation should be done on all axis (default: false)
  56160. */
  56161. uniformScaling: boolean;
  56162. /**
  56163. * Custom sensitivity value for the drag strength
  56164. */
  56165. sensitivity: number;
  56166. private _isEnabled;
  56167. private _parent;
  56168. private _arrow;
  56169. private _coloredMaterial;
  56170. private _hoverMaterial;
  56171. /**
  56172. * Creates an AxisScaleGizmo
  56173. * @param gizmoLayer The utility layer the gizmo will be added to
  56174. * @param dragAxis The axis which the gizmo will be able to scale on
  56175. * @param color The color of the gizmo
  56176. * @param thickness display gizmo axis thickness
  56177. */
  56178. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56179. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56180. /**
  56181. * If the gizmo is enabled
  56182. */
  56183. set isEnabled(value: boolean);
  56184. get isEnabled(): boolean;
  56185. /**
  56186. * Disposes of the gizmo
  56187. */
  56188. dispose(): void;
  56189. /**
  56190. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56191. * @param mesh The mesh to replace the default mesh of the gizmo
  56192. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56193. */
  56194. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56195. }
  56196. }
  56197. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56198. import { Observable } from "babylonjs/Misc/observable";
  56199. import { Nullable } from "babylonjs/types";
  56200. import { Vector3 } from "babylonjs/Maths/math.vector";
  56201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56202. import { Mesh } from "babylonjs/Meshes/mesh";
  56203. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56204. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56205. import { Color3 } from "babylonjs/Maths/math.color";
  56206. import "babylonjs/Meshes/Builders/boxBuilder";
  56207. /**
  56208. * Bounding box gizmo
  56209. */
  56210. export class BoundingBoxGizmo extends Gizmo {
  56211. private _lineBoundingBox;
  56212. private _rotateSpheresParent;
  56213. private _scaleBoxesParent;
  56214. private _boundingDimensions;
  56215. private _renderObserver;
  56216. private _pointerObserver;
  56217. private _scaleDragSpeed;
  56218. private _tmpQuaternion;
  56219. private _tmpVector;
  56220. private _tmpRotationMatrix;
  56221. /**
  56222. * 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)
  56223. */
  56224. ignoreChildren: boolean;
  56225. /**
  56226. * 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)
  56227. */
  56228. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56229. /**
  56230. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56231. */
  56232. rotationSphereSize: number;
  56233. /**
  56234. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56235. */
  56236. scaleBoxSize: number;
  56237. /**
  56238. * 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)
  56239. */
  56240. fixedDragMeshScreenSize: boolean;
  56241. /**
  56242. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56243. */
  56244. fixedDragMeshScreenSizeDistanceFactor: number;
  56245. /**
  56246. * Fired when a rotation sphere or scale box is dragged
  56247. */
  56248. onDragStartObservable: Observable<{}>;
  56249. /**
  56250. * Fired when a scale box is dragged
  56251. */
  56252. onScaleBoxDragObservable: Observable<{}>;
  56253. /**
  56254. * Fired when a scale box drag is ended
  56255. */
  56256. onScaleBoxDragEndObservable: Observable<{}>;
  56257. /**
  56258. * Fired when a rotation sphere is dragged
  56259. */
  56260. onRotationSphereDragObservable: Observable<{}>;
  56261. /**
  56262. * Fired when a rotation sphere drag is ended
  56263. */
  56264. onRotationSphereDragEndObservable: Observable<{}>;
  56265. /**
  56266. * 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)
  56267. */
  56268. scalePivot: Nullable<Vector3>;
  56269. /**
  56270. * Mesh used as a pivot to rotate the attached node
  56271. */
  56272. private _anchorMesh;
  56273. private _existingMeshScale;
  56274. private _dragMesh;
  56275. private pointerDragBehavior;
  56276. private coloredMaterial;
  56277. private hoverColoredMaterial;
  56278. /**
  56279. * Sets the color of the bounding box gizmo
  56280. * @param color the color to set
  56281. */
  56282. setColor(color: Color3): void;
  56283. /**
  56284. * Creates an BoundingBoxGizmo
  56285. * @param gizmoLayer The utility layer the gizmo will be added to
  56286. * @param color The color of the gizmo
  56287. */
  56288. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56289. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56290. private _selectNode;
  56291. /**
  56292. * Updates the bounding box information for the Gizmo
  56293. */
  56294. updateBoundingBox(): void;
  56295. private _updateRotationSpheres;
  56296. private _updateScaleBoxes;
  56297. /**
  56298. * Enables rotation on the specified axis and disables rotation on the others
  56299. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56300. */
  56301. setEnabledRotationAxis(axis: string): void;
  56302. /**
  56303. * Enables/disables scaling
  56304. * @param enable if scaling should be enabled
  56305. * @param homogeneousScaling defines if scaling should only be homogeneous
  56306. */
  56307. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56308. private _updateDummy;
  56309. /**
  56310. * Enables a pointer drag behavior on the bounding box of the gizmo
  56311. */
  56312. enableDragBehavior(): void;
  56313. /**
  56314. * Disposes of the gizmo
  56315. */
  56316. dispose(): void;
  56317. /**
  56318. * 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)
  56319. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56320. * @returns the bounding box mesh with the passed in mesh as a child
  56321. */
  56322. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56323. /**
  56324. * CustomMeshes are not supported by this gizmo
  56325. * @param mesh The mesh to replace the default mesh of the gizmo
  56326. */
  56327. setCustomMesh(mesh: Mesh): void;
  56328. }
  56329. }
  56330. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56331. import { Observable } from "babylonjs/Misc/observable";
  56332. import { Nullable } from "babylonjs/types";
  56333. import { Vector3 } from "babylonjs/Maths/math.vector";
  56334. import { Color3 } from "babylonjs/Maths/math.color";
  56335. import { Node } from "babylonjs/node";
  56336. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56337. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56338. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56339. import "babylonjs/Meshes/Builders/linesBuilder";
  56340. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56341. /**
  56342. * Single plane rotation gizmo
  56343. */
  56344. export class PlaneRotationGizmo extends Gizmo {
  56345. /**
  56346. * Drag behavior responsible for the gizmos dragging interactions
  56347. */
  56348. dragBehavior: PointerDragBehavior;
  56349. private _pointerObserver;
  56350. /**
  56351. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56352. */
  56353. snapDistance: number;
  56354. /**
  56355. * Event that fires each time the gizmo snaps to a new location.
  56356. * * snapDistance is the the change in distance
  56357. */
  56358. onSnapObservable: Observable<{
  56359. snapDistance: number;
  56360. }>;
  56361. private _isEnabled;
  56362. private _parent;
  56363. /**
  56364. * Creates a PlaneRotationGizmo
  56365. * @param gizmoLayer The utility layer the gizmo will be added to
  56366. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56367. * @param color The color of the gizmo
  56368. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56369. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56370. * @param thickness display gizmo axis thickness
  56371. */
  56372. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56373. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56374. /**
  56375. * If the gizmo is enabled
  56376. */
  56377. set isEnabled(value: boolean);
  56378. get isEnabled(): boolean;
  56379. /**
  56380. * Disposes of the gizmo
  56381. */
  56382. dispose(): void;
  56383. }
  56384. }
  56385. declare module "babylonjs/Gizmos/rotationGizmo" {
  56386. import { Observable } from "babylonjs/Misc/observable";
  56387. import { Nullable } from "babylonjs/types";
  56388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56389. import { Mesh } from "babylonjs/Meshes/mesh";
  56390. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56391. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56392. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56393. import { Node } from "babylonjs/node";
  56394. /**
  56395. * Gizmo that enables rotating a mesh along 3 axis
  56396. */
  56397. export class RotationGizmo extends Gizmo {
  56398. /**
  56399. * Internal gizmo used for interactions on the x axis
  56400. */
  56401. xGizmo: PlaneRotationGizmo;
  56402. /**
  56403. * Internal gizmo used for interactions on the y axis
  56404. */
  56405. yGizmo: PlaneRotationGizmo;
  56406. /**
  56407. * Internal gizmo used for interactions on the z axis
  56408. */
  56409. zGizmo: PlaneRotationGizmo;
  56410. /** Fires an event when any of it's sub gizmos are dragged */
  56411. onDragStartObservable: Observable<unknown>;
  56412. /** Fires an event when any of it's sub gizmos are released from dragging */
  56413. onDragEndObservable: Observable<unknown>;
  56414. private _meshAttached;
  56415. private _nodeAttached;
  56416. get attachedMesh(): Nullable<AbstractMesh>;
  56417. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56418. get attachedNode(): Nullable<Node>;
  56419. set attachedNode(node: Nullable<Node>);
  56420. /**
  56421. * True when the mouse pointer is hovering a gizmo mesh
  56422. */
  56423. get isHovered(): boolean;
  56424. /**
  56425. * Creates a RotationGizmo
  56426. * @param gizmoLayer The utility layer the gizmo will be added to
  56427. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56428. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56429. * @param thickness display gizmo axis thickness
  56430. */
  56431. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56432. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56433. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56434. /**
  56435. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56436. */
  56437. set snapDistance(value: number);
  56438. get snapDistance(): number;
  56439. /**
  56440. * Ratio for the scale of the gizmo (Default: 1)
  56441. */
  56442. set scaleRatio(value: number);
  56443. get scaleRatio(): number;
  56444. /**
  56445. * Disposes of the gizmo
  56446. */
  56447. dispose(): void;
  56448. /**
  56449. * CustomMeshes are not supported by this gizmo
  56450. * @param mesh The mesh to replace the default mesh of the gizmo
  56451. */
  56452. setCustomMesh(mesh: Mesh): void;
  56453. }
  56454. }
  56455. declare module "babylonjs/Gizmos/gizmoManager" {
  56456. import { Observable } from "babylonjs/Misc/observable";
  56457. import { Nullable } from "babylonjs/types";
  56458. import { Scene, IDisposable } from "babylonjs/scene";
  56459. import { Node } from "babylonjs/node";
  56460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56461. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56462. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56463. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56464. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56465. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56466. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56467. /**
  56468. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56469. */
  56470. export class GizmoManager implements IDisposable {
  56471. private scene;
  56472. /**
  56473. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56474. */
  56475. gizmos: {
  56476. positionGizmo: Nullable<PositionGizmo>;
  56477. rotationGizmo: Nullable<RotationGizmo>;
  56478. scaleGizmo: Nullable<ScaleGizmo>;
  56479. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56480. };
  56481. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56482. clearGizmoOnEmptyPointerEvent: boolean;
  56483. /** Fires an event when the manager is attached to a mesh */
  56484. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56485. /** Fires an event when the manager is attached to a node */
  56486. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56487. private _gizmosEnabled;
  56488. private _pointerObserver;
  56489. private _attachedMesh;
  56490. private _attachedNode;
  56491. private _boundingBoxColor;
  56492. private _defaultUtilityLayer;
  56493. private _defaultKeepDepthUtilityLayer;
  56494. private _thickness;
  56495. /**
  56496. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56497. */
  56498. boundingBoxDragBehavior: SixDofDragBehavior;
  56499. /**
  56500. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56501. */
  56502. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56503. /**
  56504. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56505. */
  56506. attachableNodes: Nullable<Array<Node>>;
  56507. /**
  56508. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56509. */
  56510. usePointerToAttachGizmos: boolean;
  56511. /**
  56512. * Utility layer that the bounding box gizmo belongs to
  56513. */
  56514. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56515. /**
  56516. * Utility layer that all gizmos besides bounding box belong to
  56517. */
  56518. get utilityLayer(): UtilityLayerRenderer;
  56519. /**
  56520. * True when the mouse pointer is hovering a gizmo mesh
  56521. */
  56522. get isHovered(): boolean;
  56523. /**
  56524. * Instatiates a gizmo manager
  56525. * @param scene the scene to overlay the gizmos on top of
  56526. * @param thickness display gizmo axis thickness
  56527. */
  56528. constructor(scene: Scene, thickness?: number);
  56529. /**
  56530. * Attaches a set of gizmos to the specified mesh
  56531. * @param mesh The mesh the gizmo's should be attached to
  56532. */
  56533. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56534. /**
  56535. * Attaches a set of gizmos to the specified node
  56536. * @param node The node the gizmo's should be attached to
  56537. */
  56538. attachToNode(node: Nullable<Node>): void;
  56539. /**
  56540. * If the position gizmo is enabled
  56541. */
  56542. set positionGizmoEnabled(value: boolean);
  56543. get positionGizmoEnabled(): boolean;
  56544. /**
  56545. * If the rotation gizmo is enabled
  56546. */
  56547. set rotationGizmoEnabled(value: boolean);
  56548. get rotationGizmoEnabled(): boolean;
  56549. /**
  56550. * If the scale gizmo is enabled
  56551. */
  56552. set scaleGizmoEnabled(value: boolean);
  56553. get scaleGizmoEnabled(): boolean;
  56554. /**
  56555. * If the boundingBox gizmo is enabled
  56556. */
  56557. set boundingBoxGizmoEnabled(value: boolean);
  56558. get boundingBoxGizmoEnabled(): boolean;
  56559. /**
  56560. * Disposes of the gizmo manager
  56561. */
  56562. dispose(): void;
  56563. }
  56564. }
  56565. declare module "babylonjs/Lights/directionalLight" {
  56566. import { Camera } from "babylonjs/Cameras/camera";
  56567. import { Scene } from "babylonjs/scene";
  56568. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56570. import { Light } from "babylonjs/Lights/light";
  56571. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56572. import { Effect } from "babylonjs/Materials/effect";
  56573. /**
  56574. * A directional light is defined by a direction (what a surprise!).
  56575. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56576. * 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.
  56577. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56578. */
  56579. export class DirectionalLight extends ShadowLight {
  56580. private _shadowFrustumSize;
  56581. /**
  56582. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56583. */
  56584. get shadowFrustumSize(): number;
  56585. /**
  56586. * Specifies a fix frustum size for the shadow generation.
  56587. */
  56588. set shadowFrustumSize(value: number);
  56589. private _shadowOrthoScale;
  56590. /**
  56591. * Gets the shadow projection scale against the optimal computed one.
  56592. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56593. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56594. */
  56595. get shadowOrthoScale(): number;
  56596. /**
  56597. * Sets the shadow projection scale against the optimal computed one.
  56598. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56599. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56600. */
  56601. set shadowOrthoScale(value: number);
  56602. /**
  56603. * Automatically compute the projection matrix to best fit (including all the casters)
  56604. * on each frame.
  56605. */
  56606. autoUpdateExtends: boolean;
  56607. /**
  56608. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56609. * on each frame. autoUpdateExtends must be set to true for this to work
  56610. */
  56611. autoCalcShadowZBounds: boolean;
  56612. private _orthoLeft;
  56613. private _orthoRight;
  56614. private _orthoTop;
  56615. private _orthoBottom;
  56616. /**
  56617. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56618. * The directional light is emitted from everywhere in the given direction.
  56619. * It can cast shadows.
  56620. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56621. * @param name The friendly name of the light
  56622. * @param direction The direction of the light
  56623. * @param scene The scene the light belongs to
  56624. */
  56625. constructor(name: string, direction: Vector3, scene: Scene);
  56626. /**
  56627. * Returns the string "DirectionalLight".
  56628. * @return The class name
  56629. */
  56630. getClassName(): string;
  56631. /**
  56632. * Returns the integer 1.
  56633. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56634. */
  56635. getTypeID(): number;
  56636. /**
  56637. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56638. * Returns the DirectionalLight Shadow projection matrix.
  56639. */
  56640. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56641. /**
  56642. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56643. * Returns the DirectionalLight Shadow projection matrix.
  56644. */
  56645. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56646. /**
  56647. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56648. * Returns the DirectionalLight Shadow projection matrix.
  56649. */
  56650. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56651. protected _buildUniformLayout(): void;
  56652. /**
  56653. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56654. * @param effect The effect to update
  56655. * @param lightIndex The index of the light in the effect to update
  56656. * @returns The directional light
  56657. */
  56658. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56659. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56660. /**
  56661. * Gets the minZ used for shadow according to both the scene and the light.
  56662. *
  56663. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56664. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56665. * @param activeCamera The camera we are returning the min for
  56666. * @returns the depth min z
  56667. */
  56668. getDepthMinZ(activeCamera: Camera): number;
  56669. /**
  56670. * Gets the maxZ used for shadow according to both the scene and the light.
  56671. *
  56672. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56673. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56674. * @param activeCamera The camera we are returning the max for
  56675. * @returns the depth max z
  56676. */
  56677. getDepthMaxZ(activeCamera: Camera): number;
  56678. /**
  56679. * Prepares the list of defines specific to the light type.
  56680. * @param defines the list of defines
  56681. * @param lightIndex defines the index of the light for the effect
  56682. */
  56683. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56684. }
  56685. }
  56686. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56687. import { Mesh } from "babylonjs/Meshes/mesh";
  56688. /**
  56689. * Class containing static functions to help procedurally build meshes
  56690. */
  56691. export class HemisphereBuilder {
  56692. /**
  56693. * Creates a hemisphere mesh
  56694. * @param name defines the name of the mesh
  56695. * @param options defines the options used to create the mesh
  56696. * @param scene defines the hosting scene
  56697. * @returns the hemisphere mesh
  56698. */
  56699. static CreateHemisphere(name: string, options: {
  56700. segments?: number;
  56701. diameter?: number;
  56702. sideOrientation?: number;
  56703. }, scene: any): Mesh;
  56704. }
  56705. }
  56706. declare module "babylonjs/Lights/spotLight" {
  56707. import { Nullable } from "babylonjs/types";
  56708. import { Scene } from "babylonjs/scene";
  56709. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56711. import { Effect } from "babylonjs/Materials/effect";
  56712. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56713. import { Light } from "babylonjs/Lights/light";
  56714. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56715. /**
  56716. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56717. * These values define a cone of light starting from the position, emitting toward the direction.
  56718. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56719. * and the exponent defines the speed of the decay of the light with distance (reach).
  56720. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56721. */
  56722. export class SpotLight extends ShadowLight {
  56723. private _angle;
  56724. private _innerAngle;
  56725. private _cosHalfAngle;
  56726. private _lightAngleScale;
  56727. private _lightAngleOffset;
  56728. /**
  56729. * Gets the cone angle of the spot light in Radians.
  56730. */
  56731. get angle(): number;
  56732. /**
  56733. * Sets the cone angle of the spot light in Radians.
  56734. */
  56735. set angle(value: number);
  56736. /**
  56737. * Only used in gltf falloff mode, this defines the angle where
  56738. * the directional falloff will start before cutting at angle which could be seen
  56739. * as outer angle.
  56740. */
  56741. get innerAngle(): number;
  56742. /**
  56743. * Only used in gltf falloff mode, this defines the angle where
  56744. * the directional falloff will start before cutting at angle which could be seen
  56745. * as outer angle.
  56746. */
  56747. set innerAngle(value: number);
  56748. private _shadowAngleScale;
  56749. /**
  56750. * Allows scaling the angle of the light for shadow generation only.
  56751. */
  56752. get shadowAngleScale(): number;
  56753. /**
  56754. * Allows scaling the angle of the light for shadow generation only.
  56755. */
  56756. set shadowAngleScale(value: number);
  56757. /**
  56758. * The light decay speed with the distance from the emission spot.
  56759. */
  56760. exponent: number;
  56761. private _projectionTextureMatrix;
  56762. /**
  56763. * Allows reading the projecton texture
  56764. */
  56765. get projectionTextureMatrix(): Matrix;
  56766. protected _projectionTextureLightNear: number;
  56767. /**
  56768. * Gets the near clip of the Spotlight for texture projection.
  56769. */
  56770. get projectionTextureLightNear(): number;
  56771. /**
  56772. * Sets the near clip of the Spotlight for texture projection.
  56773. */
  56774. set projectionTextureLightNear(value: number);
  56775. protected _projectionTextureLightFar: number;
  56776. /**
  56777. * Gets the far clip of the Spotlight for texture projection.
  56778. */
  56779. get projectionTextureLightFar(): number;
  56780. /**
  56781. * Sets the far clip of the Spotlight for texture projection.
  56782. */
  56783. set projectionTextureLightFar(value: number);
  56784. protected _projectionTextureUpDirection: Vector3;
  56785. /**
  56786. * Gets the Up vector of the Spotlight for texture projection.
  56787. */
  56788. get projectionTextureUpDirection(): Vector3;
  56789. /**
  56790. * Sets the Up vector of the Spotlight for texture projection.
  56791. */
  56792. set projectionTextureUpDirection(value: Vector3);
  56793. private _projectionTexture;
  56794. /**
  56795. * Gets the projection texture of the light.
  56796. */
  56797. get projectionTexture(): Nullable<BaseTexture>;
  56798. /**
  56799. * Sets the projection texture of the light.
  56800. */
  56801. set projectionTexture(value: Nullable<BaseTexture>);
  56802. private _projectionTextureViewLightDirty;
  56803. private _projectionTextureProjectionLightDirty;
  56804. private _projectionTextureDirty;
  56805. private _projectionTextureViewTargetVector;
  56806. private _projectionTextureViewLightMatrix;
  56807. private _projectionTextureProjectionLightMatrix;
  56808. private _projectionTextureScalingMatrix;
  56809. /**
  56810. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56811. * It can cast shadows.
  56812. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56813. * @param name The light friendly name
  56814. * @param position The position of the spot light in the scene
  56815. * @param direction The direction of the light in the scene
  56816. * @param angle The cone angle of the light in Radians
  56817. * @param exponent The light decay speed with the distance from the emission spot
  56818. * @param scene The scene the lights belongs to
  56819. */
  56820. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56821. /**
  56822. * Returns the string "SpotLight".
  56823. * @returns the class name
  56824. */
  56825. getClassName(): string;
  56826. /**
  56827. * Returns the integer 2.
  56828. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56829. */
  56830. getTypeID(): number;
  56831. /**
  56832. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56833. */
  56834. protected _setDirection(value: Vector3): void;
  56835. /**
  56836. * Overrides the position setter to recompute the projection texture view light Matrix.
  56837. */
  56838. protected _setPosition(value: Vector3): void;
  56839. /**
  56840. * 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.
  56841. * Returns the SpotLight.
  56842. */
  56843. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56844. protected _computeProjectionTextureViewLightMatrix(): void;
  56845. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56846. /**
  56847. * Main function for light texture projection matrix computing.
  56848. */
  56849. protected _computeProjectionTextureMatrix(): void;
  56850. protected _buildUniformLayout(): void;
  56851. private _computeAngleValues;
  56852. /**
  56853. * Sets the passed Effect "effect" with the Light textures.
  56854. * @param effect The effect to update
  56855. * @param lightIndex The index of the light in the effect to update
  56856. * @returns The light
  56857. */
  56858. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56859. /**
  56860. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56861. * @param effect The effect to update
  56862. * @param lightIndex The index of the light in the effect to update
  56863. * @returns The spot light
  56864. */
  56865. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56866. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56867. /**
  56868. * Disposes the light and the associated resources.
  56869. */
  56870. dispose(): void;
  56871. /**
  56872. * Prepares the list of defines specific to the light type.
  56873. * @param defines the list of defines
  56874. * @param lightIndex defines the index of the light for the effect
  56875. */
  56876. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56877. }
  56878. }
  56879. declare module "babylonjs/Gizmos/lightGizmo" {
  56880. import { Nullable } from "babylonjs/types";
  56881. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56882. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56883. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56884. import { Light } from "babylonjs/Lights/light";
  56885. import { Observable } from "babylonjs/Misc/observable";
  56886. /**
  56887. * Gizmo that enables viewing a light
  56888. */
  56889. export class LightGizmo extends Gizmo {
  56890. private _lightMesh;
  56891. private _material;
  56892. private _cachedPosition;
  56893. private _cachedForward;
  56894. private _attachedMeshParent;
  56895. private _pointerObserver;
  56896. /**
  56897. * Event that fires each time the gizmo is clicked
  56898. */
  56899. onClickedObservable: Observable<Light>;
  56900. /**
  56901. * Creates a LightGizmo
  56902. * @param gizmoLayer The utility layer the gizmo will be added to
  56903. */
  56904. constructor(gizmoLayer?: UtilityLayerRenderer);
  56905. private _light;
  56906. /**
  56907. * The light that the gizmo is attached to
  56908. */
  56909. set light(light: Nullable<Light>);
  56910. get light(): Nullable<Light>;
  56911. /**
  56912. * Gets the material used to render the light gizmo
  56913. */
  56914. get material(): StandardMaterial;
  56915. /**
  56916. * @hidden
  56917. * Updates the gizmo to match the attached mesh's position/rotation
  56918. */
  56919. protected _update(): void;
  56920. private static _Scale;
  56921. /**
  56922. * Creates the lines for a light mesh
  56923. */
  56924. private static _CreateLightLines;
  56925. /**
  56926. * Disposes of the light gizmo
  56927. */
  56928. dispose(): void;
  56929. private static _CreateHemisphericLightMesh;
  56930. private static _CreatePointLightMesh;
  56931. private static _CreateSpotLightMesh;
  56932. private static _CreateDirectionalLightMesh;
  56933. }
  56934. }
  56935. declare module "babylonjs/Gizmos/cameraGizmo" {
  56936. import { Nullable } from "babylonjs/types";
  56937. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56938. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56939. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56940. import { Camera } from "babylonjs/Cameras/camera";
  56941. import { Observable } from "babylonjs/Misc/observable";
  56942. /**
  56943. * Gizmo that enables viewing a camera
  56944. */
  56945. export class CameraGizmo extends Gizmo {
  56946. private _cameraMesh;
  56947. private _cameraLinesMesh;
  56948. private _material;
  56949. private _pointerObserver;
  56950. /**
  56951. * Event that fires each time the gizmo is clicked
  56952. */
  56953. onClickedObservable: Observable<Camera>;
  56954. /**
  56955. * Creates a CameraGizmo
  56956. * @param gizmoLayer The utility layer the gizmo will be added to
  56957. */
  56958. constructor(gizmoLayer?: UtilityLayerRenderer);
  56959. private _camera;
  56960. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56961. get displayFrustum(): boolean;
  56962. set displayFrustum(value: boolean);
  56963. /**
  56964. * The camera that the gizmo is attached to
  56965. */
  56966. set camera(camera: Nullable<Camera>);
  56967. get camera(): Nullable<Camera>;
  56968. /**
  56969. * Gets the material used to render the camera gizmo
  56970. */
  56971. get material(): StandardMaterial;
  56972. /**
  56973. * @hidden
  56974. * Updates the gizmo to match the attached mesh's position/rotation
  56975. */
  56976. protected _update(): void;
  56977. private static _Scale;
  56978. private _invProjection;
  56979. /**
  56980. * Disposes of the camera gizmo
  56981. */
  56982. dispose(): void;
  56983. private static _CreateCameraMesh;
  56984. private static _CreateCameraFrustum;
  56985. }
  56986. }
  56987. declare module "babylonjs/Gizmos/index" {
  56988. export * from "babylonjs/Gizmos/axisDragGizmo";
  56989. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56990. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56991. export * from "babylonjs/Gizmos/gizmo";
  56992. export * from "babylonjs/Gizmos/gizmoManager";
  56993. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56994. export * from "babylonjs/Gizmos/positionGizmo";
  56995. export * from "babylonjs/Gizmos/rotationGizmo";
  56996. export * from "babylonjs/Gizmos/scaleGizmo";
  56997. export * from "babylonjs/Gizmos/lightGizmo";
  56998. export * from "babylonjs/Gizmos/cameraGizmo";
  56999. export * from "babylonjs/Gizmos/planeDragGizmo";
  57000. }
  57001. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  57002. /** @hidden */
  57003. export var backgroundFragmentDeclaration: {
  57004. name: string;
  57005. shader: string;
  57006. };
  57007. }
  57008. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  57009. /** @hidden */
  57010. export var backgroundUboDeclaration: {
  57011. name: string;
  57012. shader: string;
  57013. };
  57014. }
  57015. declare module "babylonjs/Shaders/background.fragment" {
  57016. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  57017. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  57018. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57019. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57020. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57021. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57022. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57023. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57024. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57025. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57026. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57027. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57028. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57029. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57030. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57031. /** @hidden */
  57032. export var backgroundPixelShader: {
  57033. name: string;
  57034. shader: string;
  57035. };
  57036. }
  57037. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  57038. /** @hidden */
  57039. export var backgroundVertexDeclaration: {
  57040. name: string;
  57041. shader: string;
  57042. };
  57043. }
  57044. declare module "babylonjs/Shaders/background.vertex" {
  57045. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  57046. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  57047. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57048. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57049. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57050. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57051. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57052. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57053. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57054. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57055. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57056. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57057. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57058. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57059. /** @hidden */
  57060. export var backgroundVertexShader: {
  57061. name: string;
  57062. shader: string;
  57063. };
  57064. }
  57065. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  57066. import { Nullable, int, float } from "babylonjs/types";
  57067. import { Scene } from "babylonjs/scene";
  57068. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57069. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57071. import { Mesh } from "babylonjs/Meshes/mesh";
  57072. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57073. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  57074. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  57075. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57076. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  57077. import { Color3 } from "babylonjs/Maths/math.color";
  57078. import "babylonjs/Shaders/background.fragment";
  57079. import "babylonjs/Shaders/background.vertex";
  57080. /**
  57081. * Background material used to create an efficient environement around your scene.
  57082. */
  57083. export class BackgroundMaterial extends PushMaterial {
  57084. /**
  57085. * Standard reflectance value at parallel view angle.
  57086. */
  57087. static StandardReflectance0: number;
  57088. /**
  57089. * Standard reflectance value at grazing angle.
  57090. */
  57091. static StandardReflectance90: number;
  57092. protected _primaryColor: Color3;
  57093. /**
  57094. * Key light Color (multiply against the environement texture)
  57095. */
  57096. primaryColor: Color3;
  57097. protected __perceptualColor: Nullable<Color3>;
  57098. /**
  57099. * Experimental Internal Use Only.
  57100. *
  57101. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57102. * This acts as a helper to set the primary color to a more "human friendly" value.
  57103. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57104. * output color as close as possible from the chosen value.
  57105. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57106. * part of lighting setup.)
  57107. */
  57108. get _perceptualColor(): Nullable<Color3>;
  57109. set _perceptualColor(value: Nullable<Color3>);
  57110. protected _primaryColorShadowLevel: float;
  57111. /**
  57112. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57113. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57114. */
  57115. get primaryColorShadowLevel(): float;
  57116. set primaryColorShadowLevel(value: float);
  57117. protected _primaryColorHighlightLevel: float;
  57118. /**
  57119. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57120. * The primary color is used at the level chosen to define what the white area would look.
  57121. */
  57122. get primaryColorHighlightLevel(): float;
  57123. set primaryColorHighlightLevel(value: float);
  57124. protected _reflectionTexture: Nullable<BaseTexture>;
  57125. /**
  57126. * Reflection Texture used in the material.
  57127. * Should be author in a specific way for the best result (refer to the documentation).
  57128. */
  57129. reflectionTexture: Nullable<BaseTexture>;
  57130. protected _reflectionBlur: float;
  57131. /**
  57132. * Reflection Texture level of blur.
  57133. *
  57134. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57135. * texture twice.
  57136. */
  57137. reflectionBlur: float;
  57138. protected _diffuseTexture: Nullable<BaseTexture>;
  57139. /**
  57140. * Diffuse Texture used in the material.
  57141. * Should be author in a specific way for the best result (refer to the documentation).
  57142. */
  57143. diffuseTexture: Nullable<BaseTexture>;
  57144. protected _shadowLights: Nullable<IShadowLight[]>;
  57145. /**
  57146. * Specify the list of lights casting shadow on the material.
  57147. * All scene shadow lights will be included if null.
  57148. */
  57149. shadowLights: Nullable<IShadowLight[]>;
  57150. protected _shadowLevel: float;
  57151. /**
  57152. * Helps adjusting the shadow to a softer level if required.
  57153. * 0 means black shadows and 1 means no shadows.
  57154. */
  57155. shadowLevel: float;
  57156. protected _sceneCenter: Vector3;
  57157. /**
  57158. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57159. * It is usually zero but might be interesting to modify according to your setup.
  57160. */
  57161. sceneCenter: Vector3;
  57162. protected _opacityFresnel: boolean;
  57163. /**
  57164. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57165. * This helps ensuring a nice transition when the camera goes under the ground.
  57166. */
  57167. opacityFresnel: boolean;
  57168. protected _reflectionFresnel: boolean;
  57169. /**
  57170. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57171. * This helps adding a mirror texture on the ground.
  57172. */
  57173. reflectionFresnel: boolean;
  57174. protected _reflectionFalloffDistance: number;
  57175. /**
  57176. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57177. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57178. */
  57179. reflectionFalloffDistance: number;
  57180. protected _reflectionAmount: number;
  57181. /**
  57182. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57183. */
  57184. reflectionAmount: number;
  57185. protected _reflectionReflectance0: number;
  57186. /**
  57187. * This specifies the weight of the reflection at grazing angle.
  57188. */
  57189. reflectionReflectance0: number;
  57190. protected _reflectionReflectance90: number;
  57191. /**
  57192. * This specifies the weight of the reflection at a perpendicular point of view.
  57193. */
  57194. reflectionReflectance90: number;
  57195. /**
  57196. * Sets the reflection reflectance fresnel values according to the default standard
  57197. * empirically know to work well :-)
  57198. */
  57199. set reflectionStandardFresnelWeight(value: number);
  57200. protected _useRGBColor: boolean;
  57201. /**
  57202. * Helps to directly use the maps channels instead of their level.
  57203. */
  57204. useRGBColor: boolean;
  57205. protected _enableNoise: boolean;
  57206. /**
  57207. * This helps reducing the banding effect that could occur on the background.
  57208. */
  57209. enableNoise: boolean;
  57210. /**
  57211. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57212. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57213. * Recommended to be keep at 1.0 except for special cases.
  57214. */
  57215. get fovMultiplier(): number;
  57216. set fovMultiplier(value: number);
  57217. private _fovMultiplier;
  57218. /**
  57219. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57220. */
  57221. useEquirectangularFOV: boolean;
  57222. private _maxSimultaneousLights;
  57223. /**
  57224. * Number of Simultaneous lights allowed on the material.
  57225. */
  57226. maxSimultaneousLights: int;
  57227. private _shadowOnly;
  57228. /**
  57229. * Make the material only render shadows
  57230. */
  57231. shadowOnly: boolean;
  57232. /**
  57233. * Default configuration related to image processing available in the Background Material.
  57234. */
  57235. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57236. /**
  57237. * Keep track of the image processing observer to allow dispose and replace.
  57238. */
  57239. private _imageProcessingObserver;
  57240. /**
  57241. * Attaches a new image processing configuration to the PBR Material.
  57242. * @param configuration (if null the scene configuration will be use)
  57243. */
  57244. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57245. /**
  57246. * Gets the image processing configuration used either in this material.
  57247. */
  57248. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57249. /**
  57250. * Sets the Default image processing configuration used either in the this material.
  57251. *
  57252. * If sets to null, the scene one is in use.
  57253. */
  57254. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57255. /**
  57256. * Gets wether the color curves effect is enabled.
  57257. */
  57258. get cameraColorCurvesEnabled(): boolean;
  57259. /**
  57260. * Sets wether the color curves effect is enabled.
  57261. */
  57262. set cameraColorCurvesEnabled(value: boolean);
  57263. /**
  57264. * Gets wether the color grading effect is enabled.
  57265. */
  57266. get cameraColorGradingEnabled(): boolean;
  57267. /**
  57268. * Gets wether the color grading effect is enabled.
  57269. */
  57270. set cameraColorGradingEnabled(value: boolean);
  57271. /**
  57272. * Gets wether tonemapping is enabled or not.
  57273. */
  57274. get cameraToneMappingEnabled(): boolean;
  57275. /**
  57276. * Sets wether tonemapping is enabled or not
  57277. */
  57278. set cameraToneMappingEnabled(value: boolean);
  57279. /**
  57280. * The camera exposure used on this material.
  57281. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57282. * This corresponds to a photographic exposure.
  57283. */
  57284. get cameraExposure(): float;
  57285. /**
  57286. * The camera exposure used on this material.
  57287. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57288. * This corresponds to a photographic exposure.
  57289. */
  57290. set cameraExposure(value: float);
  57291. /**
  57292. * Gets The camera contrast used on this material.
  57293. */
  57294. get cameraContrast(): float;
  57295. /**
  57296. * Sets The camera contrast used on this material.
  57297. */
  57298. set cameraContrast(value: float);
  57299. /**
  57300. * Gets the Color Grading 2D Lookup Texture.
  57301. */
  57302. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57303. /**
  57304. * Sets the Color Grading 2D Lookup Texture.
  57305. */
  57306. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57307. /**
  57308. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57309. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57310. * 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;
  57311. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57312. */
  57313. get cameraColorCurves(): Nullable<ColorCurves>;
  57314. /**
  57315. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57316. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57317. * 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;
  57318. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57319. */
  57320. set cameraColorCurves(value: Nullable<ColorCurves>);
  57321. /**
  57322. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57323. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57324. */
  57325. switchToBGR: boolean;
  57326. private _renderTargets;
  57327. private _reflectionControls;
  57328. private _white;
  57329. private _primaryShadowColor;
  57330. private _primaryHighlightColor;
  57331. /**
  57332. * Instantiates a Background Material in the given scene
  57333. * @param name The friendly name of the material
  57334. * @param scene The scene to add the material to
  57335. */
  57336. constructor(name: string, scene: Scene);
  57337. /**
  57338. * Gets a boolean indicating that current material needs to register RTT
  57339. */
  57340. get hasRenderTargetTextures(): boolean;
  57341. /**
  57342. * The entire material has been created in order to prevent overdraw.
  57343. * @returns false
  57344. */
  57345. needAlphaTesting(): boolean;
  57346. /**
  57347. * The entire material has been created in order to prevent overdraw.
  57348. * @returns true if blending is enable
  57349. */
  57350. needAlphaBlending(): boolean;
  57351. /**
  57352. * Checks wether the material is ready to be rendered for a given mesh.
  57353. * @param mesh The mesh to render
  57354. * @param subMesh The submesh to check against
  57355. * @param useInstances Specify wether or not the material is used with instances
  57356. * @returns true if all the dependencies are ready (Textures, Effects...)
  57357. */
  57358. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57359. /**
  57360. * Compute the primary color according to the chosen perceptual color.
  57361. */
  57362. private _computePrimaryColorFromPerceptualColor;
  57363. /**
  57364. * Compute the highlights and shadow colors according to their chosen levels.
  57365. */
  57366. private _computePrimaryColors;
  57367. /**
  57368. * Build the uniform buffer used in the material.
  57369. */
  57370. buildUniformLayout(): void;
  57371. /**
  57372. * Unbind the material.
  57373. */
  57374. unbind(): void;
  57375. /**
  57376. * Bind only the world matrix to the material.
  57377. * @param world The world matrix to bind.
  57378. */
  57379. bindOnlyWorldMatrix(world: Matrix): void;
  57380. /**
  57381. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57382. * @param world The world matrix to bind.
  57383. * @param subMesh The submesh to bind for.
  57384. */
  57385. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57386. /**
  57387. * Checks to see if a texture is used in the material.
  57388. * @param texture - Base texture to use.
  57389. * @returns - Boolean specifying if a texture is used in the material.
  57390. */
  57391. hasTexture(texture: BaseTexture): boolean;
  57392. /**
  57393. * Dispose the material.
  57394. * @param forceDisposeEffect Force disposal of the associated effect.
  57395. * @param forceDisposeTextures Force disposal of the associated textures.
  57396. */
  57397. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57398. /**
  57399. * Clones the material.
  57400. * @param name The cloned name.
  57401. * @returns The cloned material.
  57402. */
  57403. clone(name: string): BackgroundMaterial;
  57404. /**
  57405. * Serializes the current material to its JSON representation.
  57406. * @returns The JSON representation.
  57407. */
  57408. serialize(): any;
  57409. /**
  57410. * Gets the class name of the material
  57411. * @returns "BackgroundMaterial"
  57412. */
  57413. getClassName(): string;
  57414. /**
  57415. * Parse a JSON input to create back a background material.
  57416. * @param source The JSON data to parse
  57417. * @param scene The scene to create the parsed material in
  57418. * @param rootUrl The root url of the assets the material depends upon
  57419. * @returns the instantiated BackgroundMaterial.
  57420. */
  57421. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57422. }
  57423. }
  57424. declare module "babylonjs/Helpers/environmentHelper" {
  57425. import { Observable } from "babylonjs/Misc/observable";
  57426. import { Nullable } from "babylonjs/types";
  57427. import { Scene } from "babylonjs/scene";
  57428. import { Vector3 } from "babylonjs/Maths/math.vector";
  57429. import { Color3 } from "babylonjs/Maths/math.color";
  57430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57431. import { Mesh } from "babylonjs/Meshes/mesh";
  57432. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57433. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57434. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57435. import "babylonjs/Meshes/Builders/planeBuilder";
  57436. import "babylonjs/Meshes/Builders/boxBuilder";
  57437. /**
  57438. * Represents the different options available during the creation of
  57439. * a Environment helper.
  57440. *
  57441. * This can control the default ground, skybox and image processing setup of your scene.
  57442. */
  57443. export interface IEnvironmentHelperOptions {
  57444. /**
  57445. * Specifies whether or not to create a ground.
  57446. * True by default.
  57447. */
  57448. createGround: boolean;
  57449. /**
  57450. * Specifies the ground size.
  57451. * 15 by default.
  57452. */
  57453. groundSize: number;
  57454. /**
  57455. * The texture used on the ground for the main color.
  57456. * Comes from the BabylonJS CDN by default.
  57457. *
  57458. * Remarks: Can be either a texture or a url.
  57459. */
  57460. groundTexture: string | BaseTexture;
  57461. /**
  57462. * The color mixed in the ground texture by default.
  57463. * BabylonJS clearColor by default.
  57464. */
  57465. groundColor: Color3;
  57466. /**
  57467. * Specifies the ground opacity.
  57468. * 1 by default.
  57469. */
  57470. groundOpacity: number;
  57471. /**
  57472. * Enables the ground to receive shadows.
  57473. * True by default.
  57474. */
  57475. enableGroundShadow: boolean;
  57476. /**
  57477. * Helps preventing the shadow to be fully black on the ground.
  57478. * 0.5 by default.
  57479. */
  57480. groundShadowLevel: number;
  57481. /**
  57482. * Creates a mirror texture attach to the ground.
  57483. * false by default.
  57484. */
  57485. enableGroundMirror: boolean;
  57486. /**
  57487. * Specifies the ground mirror size ratio.
  57488. * 0.3 by default as the default kernel is 64.
  57489. */
  57490. groundMirrorSizeRatio: number;
  57491. /**
  57492. * Specifies the ground mirror blur kernel size.
  57493. * 64 by default.
  57494. */
  57495. groundMirrorBlurKernel: number;
  57496. /**
  57497. * Specifies the ground mirror visibility amount.
  57498. * 1 by default
  57499. */
  57500. groundMirrorAmount: number;
  57501. /**
  57502. * Specifies the ground mirror reflectance weight.
  57503. * This uses the standard weight of the background material to setup the fresnel effect
  57504. * of the mirror.
  57505. * 1 by default.
  57506. */
  57507. groundMirrorFresnelWeight: number;
  57508. /**
  57509. * Specifies the ground mirror Falloff distance.
  57510. * This can helps reducing the size of the reflection.
  57511. * 0 by Default.
  57512. */
  57513. groundMirrorFallOffDistance: number;
  57514. /**
  57515. * Specifies the ground mirror texture type.
  57516. * Unsigned Int by Default.
  57517. */
  57518. groundMirrorTextureType: number;
  57519. /**
  57520. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57521. * the shown objects.
  57522. */
  57523. groundYBias: number;
  57524. /**
  57525. * Specifies whether or not to create a skybox.
  57526. * True by default.
  57527. */
  57528. createSkybox: boolean;
  57529. /**
  57530. * Specifies the skybox size.
  57531. * 20 by default.
  57532. */
  57533. skyboxSize: number;
  57534. /**
  57535. * The texture used on the skybox for the main color.
  57536. * Comes from the BabylonJS CDN by default.
  57537. *
  57538. * Remarks: Can be either a texture or a url.
  57539. */
  57540. skyboxTexture: string | BaseTexture;
  57541. /**
  57542. * The color mixed in the skybox texture by default.
  57543. * BabylonJS clearColor by default.
  57544. */
  57545. skyboxColor: Color3;
  57546. /**
  57547. * The background rotation around the Y axis of the scene.
  57548. * This helps aligning the key lights of your scene with the background.
  57549. * 0 by default.
  57550. */
  57551. backgroundYRotation: number;
  57552. /**
  57553. * Compute automatically the size of the elements to best fit with the scene.
  57554. */
  57555. sizeAuto: boolean;
  57556. /**
  57557. * Default position of the rootMesh if autoSize is not true.
  57558. */
  57559. rootPosition: Vector3;
  57560. /**
  57561. * Sets up the image processing in the scene.
  57562. * true by default.
  57563. */
  57564. setupImageProcessing: boolean;
  57565. /**
  57566. * The texture used as your environment texture in the scene.
  57567. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57568. *
  57569. * Remarks: Can be either a texture or a url.
  57570. */
  57571. environmentTexture: string | BaseTexture;
  57572. /**
  57573. * The value of the exposure to apply to the scene.
  57574. * 0.6 by default if setupImageProcessing is true.
  57575. */
  57576. cameraExposure: number;
  57577. /**
  57578. * The value of the contrast to apply to the scene.
  57579. * 1.6 by default if setupImageProcessing is true.
  57580. */
  57581. cameraContrast: number;
  57582. /**
  57583. * Specifies whether or not tonemapping should be enabled in the scene.
  57584. * true by default if setupImageProcessing is true.
  57585. */
  57586. toneMappingEnabled: boolean;
  57587. }
  57588. /**
  57589. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57590. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57591. * It also helps with the default setup of your imageProcessing configuration.
  57592. */
  57593. export class EnvironmentHelper {
  57594. /**
  57595. * Default ground texture URL.
  57596. */
  57597. private static _groundTextureCDNUrl;
  57598. /**
  57599. * Default skybox texture URL.
  57600. */
  57601. private static _skyboxTextureCDNUrl;
  57602. /**
  57603. * Default environment texture URL.
  57604. */
  57605. private static _environmentTextureCDNUrl;
  57606. /**
  57607. * Creates the default options for the helper.
  57608. */
  57609. private static _getDefaultOptions;
  57610. private _rootMesh;
  57611. /**
  57612. * Gets the root mesh created by the helper.
  57613. */
  57614. get rootMesh(): Mesh;
  57615. private _skybox;
  57616. /**
  57617. * Gets the skybox created by the helper.
  57618. */
  57619. get skybox(): Nullable<Mesh>;
  57620. private _skyboxTexture;
  57621. /**
  57622. * Gets the skybox texture created by the helper.
  57623. */
  57624. get skyboxTexture(): Nullable<BaseTexture>;
  57625. private _skyboxMaterial;
  57626. /**
  57627. * Gets the skybox material created by the helper.
  57628. */
  57629. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57630. private _ground;
  57631. /**
  57632. * Gets the ground mesh created by the helper.
  57633. */
  57634. get ground(): Nullable<Mesh>;
  57635. private _groundTexture;
  57636. /**
  57637. * Gets the ground texture created by the helper.
  57638. */
  57639. get groundTexture(): Nullable<BaseTexture>;
  57640. private _groundMirror;
  57641. /**
  57642. * Gets the ground mirror created by the helper.
  57643. */
  57644. get groundMirror(): Nullable<MirrorTexture>;
  57645. /**
  57646. * Gets the ground mirror render list to helps pushing the meshes
  57647. * you wish in the ground reflection.
  57648. */
  57649. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57650. private _groundMaterial;
  57651. /**
  57652. * Gets the ground material created by the helper.
  57653. */
  57654. get groundMaterial(): Nullable<BackgroundMaterial>;
  57655. /**
  57656. * Stores the creation options.
  57657. */
  57658. private readonly _scene;
  57659. private _options;
  57660. /**
  57661. * This observable will be notified with any error during the creation of the environment,
  57662. * mainly texture creation errors.
  57663. */
  57664. onErrorObservable: Observable<{
  57665. message?: string;
  57666. exception?: any;
  57667. }>;
  57668. /**
  57669. * constructor
  57670. * @param options Defines the options we want to customize the helper
  57671. * @param scene The scene to add the material to
  57672. */
  57673. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57674. /**
  57675. * Updates the background according to the new options
  57676. * @param options
  57677. */
  57678. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57679. /**
  57680. * Sets the primary color of all the available elements.
  57681. * @param color the main color to affect to the ground and the background
  57682. */
  57683. setMainColor(color: Color3): void;
  57684. /**
  57685. * Setup the image processing according to the specified options.
  57686. */
  57687. private _setupImageProcessing;
  57688. /**
  57689. * Setup the environment texture according to the specified options.
  57690. */
  57691. private _setupEnvironmentTexture;
  57692. /**
  57693. * Setup the background according to the specified options.
  57694. */
  57695. private _setupBackground;
  57696. /**
  57697. * Get the scene sizes according to the setup.
  57698. */
  57699. private _getSceneSize;
  57700. /**
  57701. * Setup the ground according to the specified options.
  57702. */
  57703. private _setupGround;
  57704. /**
  57705. * Setup the ground material according to the specified options.
  57706. */
  57707. private _setupGroundMaterial;
  57708. /**
  57709. * Setup the ground diffuse texture according to the specified options.
  57710. */
  57711. private _setupGroundDiffuseTexture;
  57712. /**
  57713. * Setup the ground mirror texture according to the specified options.
  57714. */
  57715. private _setupGroundMirrorTexture;
  57716. /**
  57717. * Setup the ground to receive the mirror texture.
  57718. */
  57719. private _setupMirrorInGroundMaterial;
  57720. /**
  57721. * Setup the skybox according to the specified options.
  57722. */
  57723. private _setupSkybox;
  57724. /**
  57725. * Setup the skybox material according to the specified options.
  57726. */
  57727. private _setupSkyboxMaterial;
  57728. /**
  57729. * Setup the skybox reflection texture according to the specified options.
  57730. */
  57731. private _setupSkyboxReflectionTexture;
  57732. private _errorHandler;
  57733. /**
  57734. * Dispose all the elements created by the Helper.
  57735. */
  57736. dispose(): void;
  57737. }
  57738. }
  57739. declare module "babylonjs/Helpers/textureDome" {
  57740. import { Scene } from "babylonjs/scene";
  57741. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57742. import { Mesh } from "babylonjs/Meshes/mesh";
  57743. import { Texture } from "babylonjs/Materials/Textures/texture";
  57744. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57745. import "babylonjs/Meshes/Builders/sphereBuilder";
  57746. import { Nullable } from "babylonjs/types";
  57747. import { Observable } from "babylonjs/Misc/observable";
  57748. /**
  57749. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57750. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57751. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57752. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57753. */
  57754. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57755. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57756. /**
  57757. * Define the source as a Monoscopic panoramic 360/180.
  57758. */
  57759. static readonly MODE_MONOSCOPIC: number;
  57760. /**
  57761. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57762. */
  57763. static readonly MODE_TOPBOTTOM: number;
  57764. /**
  57765. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57766. */
  57767. static readonly MODE_SIDEBYSIDE: number;
  57768. private _halfDome;
  57769. protected _useDirectMapping: boolean;
  57770. /**
  57771. * The texture being displayed on the sphere
  57772. */
  57773. protected _texture: T;
  57774. /**
  57775. * Gets the texture being displayed on the sphere
  57776. */
  57777. get texture(): T;
  57778. /**
  57779. * Sets the texture being displayed on the sphere
  57780. */
  57781. set texture(newTexture: T);
  57782. /**
  57783. * The skybox material
  57784. */
  57785. protected _material: BackgroundMaterial;
  57786. /**
  57787. * The surface used for the dome
  57788. */
  57789. protected _mesh: Mesh;
  57790. /**
  57791. * Gets the mesh used for the dome.
  57792. */
  57793. get mesh(): Mesh;
  57794. /**
  57795. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57796. */
  57797. private _halfDomeMask;
  57798. /**
  57799. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57800. * Also see the options.resolution property.
  57801. */
  57802. get fovMultiplier(): number;
  57803. set fovMultiplier(value: number);
  57804. protected _textureMode: number;
  57805. /**
  57806. * Gets or set the current texture mode for the texture. It can be:
  57807. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57808. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57809. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57810. */
  57811. get textureMode(): number;
  57812. /**
  57813. * Sets the current texture mode for the texture. It can be:
  57814. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57815. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57816. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57817. */
  57818. set textureMode(value: number);
  57819. /**
  57820. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57821. */
  57822. get halfDome(): boolean;
  57823. /**
  57824. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57825. */
  57826. set halfDome(enabled: boolean);
  57827. /**
  57828. * Oberserver used in Stereoscopic VR Mode.
  57829. */
  57830. private _onBeforeCameraRenderObserver;
  57831. /**
  57832. * Observable raised when an error occured while loading the 360 image
  57833. */
  57834. onLoadErrorObservable: Observable<string>;
  57835. /**
  57836. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57837. * @param name Element's name, child elements will append suffixes for their own names.
  57838. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57839. * @param options An object containing optional or exposed sub element properties
  57840. */
  57841. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57842. resolution?: number;
  57843. clickToPlay?: boolean;
  57844. autoPlay?: boolean;
  57845. loop?: boolean;
  57846. size?: number;
  57847. poster?: string;
  57848. faceForward?: boolean;
  57849. useDirectMapping?: boolean;
  57850. halfDomeMode?: boolean;
  57851. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57852. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57853. protected _changeTextureMode(value: number): void;
  57854. /**
  57855. * Releases resources associated with this node.
  57856. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57857. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57858. */
  57859. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57860. }
  57861. }
  57862. declare module "babylonjs/Helpers/photoDome" {
  57863. import { Scene } from "babylonjs/scene";
  57864. import { Texture } from "babylonjs/Materials/Textures/texture";
  57865. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57866. /**
  57867. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57868. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57869. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57870. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57871. */
  57872. export class PhotoDome extends TextureDome<Texture> {
  57873. /**
  57874. * Define the image as a Monoscopic panoramic 360 image.
  57875. */
  57876. static readonly MODE_MONOSCOPIC: number;
  57877. /**
  57878. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57879. */
  57880. static readonly MODE_TOPBOTTOM: number;
  57881. /**
  57882. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57883. */
  57884. static readonly MODE_SIDEBYSIDE: number;
  57885. /**
  57886. * Gets or sets the texture being displayed on the sphere
  57887. */
  57888. get photoTexture(): Texture;
  57889. /**
  57890. * sets the texture being displayed on the sphere
  57891. */
  57892. set photoTexture(value: Texture);
  57893. /**
  57894. * Gets the current video mode for the video. It can be:
  57895. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57896. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57897. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57898. */
  57899. get imageMode(): number;
  57900. /**
  57901. * Sets the current video mode for the video. It can be:
  57902. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57903. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57904. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57905. */
  57906. set imageMode(value: number);
  57907. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57908. }
  57909. }
  57910. declare module "babylonjs/Misc/rgbdTextureTools" {
  57911. import "babylonjs/Shaders/rgbdDecode.fragment";
  57912. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57913. import { Texture } from "babylonjs/Materials/Textures/texture";
  57914. /**
  57915. * Class used to host RGBD texture specific utilities
  57916. */
  57917. export class RGBDTextureTools {
  57918. /**
  57919. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57920. * @param texture the texture to expand.
  57921. */
  57922. static ExpandRGBDTexture(texture: Texture): void;
  57923. }
  57924. }
  57925. declare module "babylonjs/Misc/brdfTextureTools" {
  57926. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57927. import { Scene } from "babylonjs/scene";
  57928. /**
  57929. * Class used to host texture specific utilities
  57930. */
  57931. export class BRDFTextureTools {
  57932. /**
  57933. * Prevents texture cache collision
  57934. */
  57935. private static _instanceNumber;
  57936. /**
  57937. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57938. * @param scene defines the hosting scene
  57939. * @returns the environment BRDF texture
  57940. */
  57941. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57942. private static _environmentBRDFBase64Texture;
  57943. }
  57944. }
  57945. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57946. import { Nullable } from "babylonjs/types";
  57947. import { Color3 } from "babylonjs/Maths/math.color";
  57948. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57949. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57950. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57951. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57952. import { Engine } from "babylonjs/Engines/engine";
  57953. import { Scene } from "babylonjs/scene";
  57954. /**
  57955. * @hidden
  57956. */
  57957. export interface IMaterialClearCoatDefines {
  57958. CLEARCOAT: boolean;
  57959. CLEARCOAT_DEFAULTIOR: boolean;
  57960. CLEARCOAT_TEXTURE: boolean;
  57961. CLEARCOAT_TEXTUREDIRECTUV: number;
  57962. CLEARCOAT_BUMP: boolean;
  57963. CLEARCOAT_BUMPDIRECTUV: number;
  57964. CLEARCOAT_REMAP_F0: boolean;
  57965. CLEARCOAT_TINT: boolean;
  57966. CLEARCOAT_TINT_TEXTURE: boolean;
  57967. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57968. /** @hidden */
  57969. _areTexturesDirty: boolean;
  57970. }
  57971. /**
  57972. * Define the code related to the clear coat parameters of the pbr material.
  57973. */
  57974. export class PBRClearCoatConfiguration {
  57975. /**
  57976. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57977. * The default fits with a polyurethane material.
  57978. */
  57979. private static readonly _DefaultIndexOfRefraction;
  57980. private _isEnabled;
  57981. /**
  57982. * Defines if the clear coat is enabled in the material.
  57983. */
  57984. isEnabled: boolean;
  57985. /**
  57986. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57987. */
  57988. intensity: number;
  57989. /**
  57990. * Defines the clear coat layer roughness.
  57991. */
  57992. roughness: number;
  57993. private _indexOfRefraction;
  57994. /**
  57995. * Defines the index of refraction of the clear coat.
  57996. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57997. * The default fits with a polyurethane material.
  57998. * Changing the default value is more performance intensive.
  57999. */
  58000. indexOfRefraction: number;
  58001. private _texture;
  58002. /**
  58003. * Stores the clear coat values in a texture.
  58004. */
  58005. texture: Nullable<BaseTexture>;
  58006. private _remapF0OnInterfaceChange;
  58007. /**
  58008. * Defines if the F0 value should be remapped to account for the interface change in the material.
  58009. */
  58010. remapF0OnInterfaceChange: boolean;
  58011. private _bumpTexture;
  58012. /**
  58013. * Define the clear coat specific bump texture.
  58014. */
  58015. bumpTexture: Nullable<BaseTexture>;
  58016. private _isTintEnabled;
  58017. /**
  58018. * Defines if the clear coat tint is enabled in the material.
  58019. */
  58020. isTintEnabled: boolean;
  58021. /**
  58022. * Defines the clear coat tint of the material.
  58023. * This is only use if tint is enabled
  58024. */
  58025. tintColor: Color3;
  58026. /**
  58027. * Defines the distance at which the tint color should be found in the
  58028. * clear coat media.
  58029. * This is only use if tint is enabled
  58030. */
  58031. tintColorAtDistance: number;
  58032. /**
  58033. * Defines the clear coat layer thickness.
  58034. * This is only use if tint is enabled
  58035. */
  58036. tintThickness: number;
  58037. private _tintTexture;
  58038. /**
  58039. * Stores the clear tint values in a texture.
  58040. * rgb is tint
  58041. * a is a thickness factor
  58042. */
  58043. tintTexture: Nullable<BaseTexture>;
  58044. /** @hidden */
  58045. private _internalMarkAllSubMeshesAsTexturesDirty;
  58046. /** @hidden */
  58047. _markAllSubMeshesAsTexturesDirty(): void;
  58048. /**
  58049. * Instantiate a new istance of clear coat configuration.
  58050. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58051. */
  58052. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58053. /**
  58054. * Gets wehter the submesh is ready to be used or not.
  58055. * @param defines the list of "defines" to update.
  58056. * @param scene defines the scene the material belongs to.
  58057. * @param engine defines the engine the material belongs to.
  58058. * @param disableBumpMap defines wether the material disables bump or not.
  58059. * @returns - boolean indicating that the submesh is ready or not.
  58060. */
  58061. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  58062. /**
  58063. * Checks to see if a texture is used in the material.
  58064. * @param defines the list of "defines" to update.
  58065. * @param scene defines the scene to the material belongs to.
  58066. */
  58067. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  58068. /**
  58069. * Binds the material data.
  58070. * @param uniformBuffer defines the Uniform buffer to fill in.
  58071. * @param scene defines the scene the material belongs to.
  58072. * @param engine defines the engine the material belongs to.
  58073. * @param disableBumpMap defines wether the material disables bump or not.
  58074. * @param isFrozen defines wether the material is frozen or not.
  58075. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58076. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58077. */
  58078. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  58079. /**
  58080. * Checks to see if a texture is used in the material.
  58081. * @param texture - Base texture to use.
  58082. * @returns - Boolean specifying if a texture is used in the material.
  58083. */
  58084. hasTexture(texture: BaseTexture): boolean;
  58085. /**
  58086. * Returns an array of the actively used textures.
  58087. * @param activeTextures Array of BaseTextures
  58088. */
  58089. getActiveTextures(activeTextures: BaseTexture[]): void;
  58090. /**
  58091. * Returns the animatable textures.
  58092. * @param animatables Array of animatable textures.
  58093. */
  58094. getAnimatables(animatables: IAnimatable[]): void;
  58095. /**
  58096. * Disposes the resources of the material.
  58097. * @param forceDisposeTextures - Forces the disposal of all textures.
  58098. */
  58099. dispose(forceDisposeTextures?: boolean): void;
  58100. /**
  58101. * Get the current class name of the texture useful for serialization or dynamic coding.
  58102. * @returns "PBRClearCoatConfiguration"
  58103. */
  58104. getClassName(): string;
  58105. /**
  58106. * Add fallbacks to the effect fallbacks list.
  58107. * @param defines defines the Base texture to use.
  58108. * @param fallbacks defines the current fallback list.
  58109. * @param currentRank defines the current fallback rank.
  58110. * @returns the new fallback rank.
  58111. */
  58112. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58113. /**
  58114. * Add the required uniforms to the current list.
  58115. * @param uniforms defines the current uniform list.
  58116. */
  58117. static AddUniforms(uniforms: string[]): void;
  58118. /**
  58119. * Add the required samplers to the current list.
  58120. * @param samplers defines the current sampler list.
  58121. */
  58122. static AddSamplers(samplers: string[]): void;
  58123. /**
  58124. * Add the required uniforms to the current buffer.
  58125. * @param uniformBuffer defines the current uniform buffer.
  58126. */
  58127. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58128. /**
  58129. * Makes a duplicate of the current configuration into another one.
  58130. * @param clearCoatConfiguration define the config where to copy the info
  58131. */
  58132. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  58133. /**
  58134. * Serializes this clear coat configuration.
  58135. * @returns - An object with the serialized config.
  58136. */
  58137. serialize(): any;
  58138. /**
  58139. * Parses a anisotropy Configuration from a serialized object.
  58140. * @param source - Serialized object.
  58141. * @param scene Defines the scene we are parsing for
  58142. * @param rootUrl Defines the rootUrl to load from
  58143. */
  58144. parse(source: any, scene: Scene, rootUrl: string): void;
  58145. }
  58146. }
  58147. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  58148. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58150. import { Vector2 } from "babylonjs/Maths/math.vector";
  58151. import { Scene } from "babylonjs/scene";
  58152. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58153. import { Nullable } from "babylonjs/types";
  58154. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58155. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58156. /**
  58157. * @hidden
  58158. */
  58159. export interface IMaterialAnisotropicDefines {
  58160. ANISOTROPIC: boolean;
  58161. ANISOTROPIC_TEXTURE: boolean;
  58162. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58163. MAINUV1: boolean;
  58164. _areTexturesDirty: boolean;
  58165. _needUVs: boolean;
  58166. }
  58167. /**
  58168. * Define the code related to the anisotropic parameters of the pbr material.
  58169. */
  58170. export class PBRAnisotropicConfiguration {
  58171. private _isEnabled;
  58172. /**
  58173. * Defines if the anisotropy is enabled in the material.
  58174. */
  58175. isEnabled: boolean;
  58176. /**
  58177. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  58178. */
  58179. intensity: number;
  58180. /**
  58181. * Defines if the effect is along the tangents, bitangents or in between.
  58182. * By default, the effect is "strectching" the highlights along the tangents.
  58183. */
  58184. direction: Vector2;
  58185. private _texture;
  58186. /**
  58187. * Stores the anisotropy values in a texture.
  58188. * rg is direction (like normal from -1 to 1)
  58189. * b is a intensity
  58190. */
  58191. texture: Nullable<BaseTexture>;
  58192. /** @hidden */
  58193. private _internalMarkAllSubMeshesAsTexturesDirty;
  58194. /** @hidden */
  58195. _markAllSubMeshesAsTexturesDirty(): void;
  58196. /**
  58197. * Instantiate a new istance of anisotropy configuration.
  58198. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58199. */
  58200. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58201. /**
  58202. * Specifies that the submesh is ready to be used.
  58203. * @param defines the list of "defines" to update.
  58204. * @param scene defines the scene the material belongs to.
  58205. * @returns - boolean indicating that the submesh is ready or not.
  58206. */
  58207. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  58208. /**
  58209. * Checks to see if a texture is used in the material.
  58210. * @param defines the list of "defines" to update.
  58211. * @param mesh the mesh we are preparing the defines for.
  58212. * @param scene defines the scene the material belongs to.
  58213. */
  58214. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  58215. /**
  58216. * Binds the material data.
  58217. * @param uniformBuffer defines the Uniform buffer to fill in.
  58218. * @param scene defines the scene the material belongs to.
  58219. * @param isFrozen defines wether the material is frozen or not.
  58220. */
  58221. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58222. /**
  58223. * Checks to see if a texture is used in the material.
  58224. * @param texture - Base texture to use.
  58225. * @returns - Boolean specifying if a texture is used in the material.
  58226. */
  58227. hasTexture(texture: BaseTexture): boolean;
  58228. /**
  58229. * Returns an array of the actively used textures.
  58230. * @param activeTextures Array of BaseTextures
  58231. */
  58232. getActiveTextures(activeTextures: BaseTexture[]): void;
  58233. /**
  58234. * Returns the animatable textures.
  58235. * @param animatables Array of animatable textures.
  58236. */
  58237. getAnimatables(animatables: IAnimatable[]): void;
  58238. /**
  58239. * Disposes the resources of the material.
  58240. * @param forceDisposeTextures - Forces the disposal of all textures.
  58241. */
  58242. dispose(forceDisposeTextures?: boolean): void;
  58243. /**
  58244. * Get the current class name of the texture useful for serialization or dynamic coding.
  58245. * @returns "PBRAnisotropicConfiguration"
  58246. */
  58247. getClassName(): string;
  58248. /**
  58249. * Add fallbacks to the effect fallbacks list.
  58250. * @param defines defines the Base texture to use.
  58251. * @param fallbacks defines the current fallback list.
  58252. * @param currentRank defines the current fallback rank.
  58253. * @returns the new fallback rank.
  58254. */
  58255. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58256. /**
  58257. * Add the required uniforms to the current list.
  58258. * @param uniforms defines the current uniform list.
  58259. */
  58260. static AddUniforms(uniforms: string[]): void;
  58261. /**
  58262. * Add the required uniforms to the current buffer.
  58263. * @param uniformBuffer defines the current uniform buffer.
  58264. */
  58265. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58266. /**
  58267. * Add the required samplers to the current list.
  58268. * @param samplers defines the current sampler list.
  58269. */
  58270. static AddSamplers(samplers: string[]): void;
  58271. /**
  58272. * Makes a duplicate of the current configuration into another one.
  58273. * @param anisotropicConfiguration define the config where to copy the info
  58274. */
  58275. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  58276. /**
  58277. * Serializes this anisotropy configuration.
  58278. * @returns - An object with the serialized config.
  58279. */
  58280. serialize(): any;
  58281. /**
  58282. * Parses a anisotropy Configuration from a serialized object.
  58283. * @param source - Serialized object.
  58284. * @param scene Defines the scene we are parsing for
  58285. * @param rootUrl Defines the rootUrl to load from
  58286. */
  58287. parse(source: any, scene: Scene, rootUrl: string): void;
  58288. }
  58289. }
  58290. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  58291. import { Scene } from "babylonjs/scene";
  58292. /**
  58293. * @hidden
  58294. */
  58295. export interface IMaterialBRDFDefines {
  58296. BRDF_V_HEIGHT_CORRELATED: boolean;
  58297. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58298. SPHERICAL_HARMONICS: boolean;
  58299. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58300. /** @hidden */
  58301. _areMiscDirty: boolean;
  58302. }
  58303. /**
  58304. * Define the code related to the BRDF parameters of the pbr material.
  58305. */
  58306. export class PBRBRDFConfiguration {
  58307. /**
  58308. * Default value used for the energy conservation.
  58309. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58310. */
  58311. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  58312. /**
  58313. * Default value used for the Smith Visibility Height Correlated mode.
  58314. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58315. */
  58316. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  58317. /**
  58318. * Default value used for the IBL diffuse part.
  58319. * This can help switching back to the polynomials mode globally which is a tiny bit
  58320. * less GPU intensive at the drawback of a lower quality.
  58321. */
  58322. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  58323. /**
  58324. * Default value used for activating energy conservation for the specular workflow.
  58325. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58326. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58327. */
  58328. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  58329. private _useEnergyConservation;
  58330. /**
  58331. * Defines if the material uses energy conservation.
  58332. */
  58333. useEnergyConservation: boolean;
  58334. private _useSmithVisibilityHeightCorrelated;
  58335. /**
  58336. * LEGACY Mode set to false
  58337. * Defines if the material uses height smith correlated visibility term.
  58338. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  58339. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  58340. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  58341. * Not relying on height correlated will also disable energy conservation.
  58342. */
  58343. useSmithVisibilityHeightCorrelated: boolean;
  58344. private _useSphericalHarmonics;
  58345. /**
  58346. * LEGACY Mode set to false
  58347. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  58348. * diffuse part of the IBL.
  58349. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  58350. * to the ground truth.
  58351. */
  58352. useSphericalHarmonics: boolean;
  58353. private _useSpecularGlossinessInputEnergyConservation;
  58354. /**
  58355. * Defines if the material uses energy conservation, when the specular workflow is active.
  58356. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58357. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58358. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  58359. */
  58360. useSpecularGlossinessInputEnergyConservation: boolean;
  58361. /** @hidden */
  58362. private _internalMarkAllSubMeshesAsMiscDirty;
  58363. /** @hidden */
  58364. _markAllSubMeshesAsMiscDirty(): void;
  58365. /**
  58366. * Instantiate a new istance of clear coat configuration.
  58367. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  58368. */
  58369. constructor(markAllSubMeshesAsMiscDirty: () => void);
  58370. /**
  58371. * Checks to see if a texture is used in the material.
  58372. * @param defines the list of "defines" to update.
  58373. */
  58374. prepareDefines(defines: IMaterialBRDFDefines): void;
  58375. /**
  58376. * Get the current class name of the texture useful for serialization or dynamic coding.
  58377. * @returns "PBRClearCoatConfiguration"
  58378. */
  58379. getClassName(): string;
  58380. /**
  58381. * Makes a duplicate of the current configuration into another one.
  58382. * @param brdfConfiguration define the config where to copy the info
  58383. */
  58384. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  58385. /**
  58386. * Serializes this BRDF configuration.
  58387. * @returns - An object with the serialized config.
  58388. */
  58389. serialize(): any;
  58390. /**
  58391. * Parses a anisotropy Configuration from a serialized object.
  58392. * @param source - Serialized object.
  58393. * @param scene Defines the scene we are parsing for
  58394. * @param rootUrl Defines the rootUrl to load from
  58395. */
  58396. parse(source: any, scene: Scene, rootUrl: string): void;
  58397. }
  58398. }
  58399. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  58400. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58401. import { Color3 } from "babylonjs/Maths/math.color";
  58402. import { Scene } from "babylonjs/scene";
  58403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58404. import { Nullable } from "babylonjs/types";
  58405. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58406. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58407. /**
  58408. * @hidden
  58409. */
  58410. export interface IMaterialSheenDefines {
  58411. SHEEN: boolean;
  58412. SHEEN_TEXTURE: boolean;
  58413. SHEEN_TEXTUREDIRECTUV: number;
  58414. SHEEN_LINKWITHALBEDO: boolean;
  58415. SHEEN_ROUGHNESS: boolean;
  58416. SHEEN_ALBEDOSCALING: boolean;
  58417. /** @hidden */
  58418. _areTexturesDirty: boolean;
  58419. }
  58420. /**
  58421. * Define the code related to the Sheen parameters of the pbr material.
  58422. */
  58423. export class PBRSheenConfiguration {
  58424. private _isEnabled;
  58425. /**
  58426. * Defines if the material uses sheen.
  58427. */
  58428. isEnabled: boolean;
  58429. private _linkSheenWithAlbedo;
  58430. /**
  58431. * Defines if the sheen is linked to the sheen color.
  58432. */
  58433. linkSheenWithAlbedo: boolean;
  58434. /**
  58435. * Defines the sheen intensity.
  58436. */
  58437. intensity: number;
  58438. /**
  58439. * Defines the sheen color.
  58440. */
  58441. color: Color3;
  58442. private _texture;
  58443. /**
  58444. * Stores the sheen tint values in a texture.
  58445. * rgb is tint
  58446. * a is a intensity or roughness if roughness has been defined
  58447. */
  58448. texture: Nullable<BaseTexture>;
  58449. private _roughness;
  58450. /**
  58451. * Defines the sheen roughness.
  58452. * It is not taken into account if linkSheenWithAlbedo is true.
  58453. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58454. */
  58455. roughness: Nullable<number>;
  58456. private _albedoScaling;
  58457. /**
  58458. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58459. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58460. * making it easier to setup and tweak the effect
  58461. */
  58462. albedoScaling: boolean;
  58463. /** @hidden */
  58464. private _internalMarkAllSubMeshesAsTexturesDirty;
  58465. /** @hidden */
  58466. _markAllSubMeshesAsTexturesDirty(): void;
  58467. /**
  58468. * Instantiate a new istance of clear coat configuration.
  58469. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58470. */
  58471. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58472. /**
  58473. * Specifies that the submesh is ready to be used.
  58474. * @param defines the list of "defines" to update.
  58475. * @param scene defines the scene the material belongs to.
  58476. * @returns - boolean indicating that the submesh is ready or not.
  58477. */
  58478. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58479. /**
  58480. * Checks to see if a texture is used in the material.
  58481. * @param defines the list of "defines" to update.
  58482. * @param scene defines the scene the material belongs to.
  58483. */
  58484. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58485. /**
  58486. * Binds the material data.
  58487. * @param uniformBuffer defines the Uniform buffer to fill in.
  58488. * @param scene defines the scene the material belongs to.
  58489. * @param isFrozen defines wether the material is frozen or not.
  58490. */
  58491. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58492. /**
  58493. * Checks to see if a texture is used in the material.
  58494. * @param texture - Base texture to use.
  58495. * @returns - Boolean specifying if a texture is used in the material.
  58496. */
  58497. hasTexture(texture: BaseTexture): boolean;
  58498. /**
  58499. * Returns an array of the actively used textures.
  58500. * @param activeTextures Array of BaseTextures
  58501. */
  58502. getActiveTextures(activeTextures: BaseTexture[]): void;
  58503. /**
  58504. * Returns the animatable textures.
  58505. * @param animatables Array of animatable textures.
  58506. */
  58507. getAnimatables(animatables: IAnimatable[]): void;
  58508. /**
  58509. * Disposes the resources of the material.
  58510. * @param forceDisposeTextures - Forces the disposal of all textures.
  58511. */
  58512. dispose(forceDisposeTextures?: boolean): void;
  58513. /**
  58514. * Get the current class name of the texture useful for serialization or dynamic coding.
  58515. * @returns "PBRSheenConfiguration"
  58516. */
  58517. getClassName(): string;
  58518. /**
  58519. * Add fallbacks to the effect fallbacks list.
  58520. * @param defines defines the Base texture to use.
  58521. * @param fallbacks defines the current fallback list.
  58522. * @param currentRank defines the current fallback rank.
  58523. * @returns the new fallback rank.
  58524. */
  58525. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58526. /**
  58527. * Add the required uniforms to the current list.
  58528. * @param uniforms defines the current uniform list.
  58529. */
  58530. static AddUniforms(uniforms: string[]): void;
  58531. /**
  58532. * Add the required uniforms to the current buffer.
  58533. * @param uniformBuffer defines the current uniform buffer.
  58534. */
  58535. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58536. /**
  58537. * Add the required samplers to the current list.
  58538. * @param samplers defines the current sampler list.
  58539. */
  58540. static AddSamplers(samplers: string[]): void;
  58541. /**
  58542. * Makes a duplicate of the current configuration into another one.
  58543. * @param sheenConfiguration define the config where to copy the info
  58544. */
  58545. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58546. /**
  58547. * Serializes this BRDF configuration.
  58548. * @returns - An object with the serialized config.
  58549. */
  58550. serialize(): any;
  58551. /**
  58552. * Parses a anisotropy Configuration from a serialized object.
  58553. * @param source - Serialized object.
  58554. * @param scene Defines the scene we are parsing for
  58555. * @param rootUrl Defines the rootUrl to load from
  58556. */
  58557. parse(source: any, scene: Scene, rootUrl: string): void;
  58558. }
  58559. }
  58560. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58561. import { Nullable } from "babylonjs/types";
  58562. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58563. import { Color3 } from "babylonjs/Maths/math.color";
  58564. import { SmartArray } from "babylonjs/Misc/smartArray";
  58565. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58566. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58567. import { Effect } from "babylonjs/Materials/effect";
  58568. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58569. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58570. import { Engine } from "babylonjs/Engines/engine";
  58571. import { Scene } from "babylonjs/scene";
  58572. /**
  58573. * @hidden
  58574. */
  58575. export interface IMaterialSubSurfaceDefines {
  58576. SUBSURFACE: boolean;
  58577. SS_REFRACTION: boolean;
  58578. SS_TRANSLUCENCY: boolean;
  58579. SS_SCATTERING: boolean;
  58580. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58581. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58582. SS_REFRACTIONMAP_3D: boolean;
  58583. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58584. SS_LODINREFRACTIONALPHA: boolean;
  58585. SS_GAMMAREFRACTION: boolean;
  58586. SS_RGBDREFRACTION: boolean;
  58587. SS_LINEARSPECULARREFRACTION: boolean;
  58588. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58589. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58590. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58591. /** @hidden */
  58592. _areTexturesDirty: boolean;
  58593. }
  58594. /**
  58595. * Define the code related to the sub surface parameters of the pbr material.
  58596. */
  58597. export class PBRSubSurfaceConfiguration {
  58598. private _isRefractionEnabled;
  58599. /**
  58600. * Defines if the refraction is enabled in the material.
  58601. */
  58602. isRefractionEnabled: boolean;
  58603. private _isTranslucencyEnabled;
  58604. /**
  58605. * Defines if the translucency is enabled in the material.
  58606. */
  58607. isTranslucencyEnabled: boolean;
  58608. private _isScatteringEnabled;
  58609. /**
  58610. * Defines if the sub surface scattering is enabled in the material.
  58611. */
  58612. isScatteringEnabled: boolean;
  58613. private _scatteringDiffusionProfileIndex;
  58614. /**
  58615. * Diffusion profile for subsurface scattering.
  58616. * Useful for better scattering in the skins or foliages.
  58617. */
  58618. get scatteringDiffusionProfile(): Nullable<Color3>;
  58619. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58620. /**
  58621. * Defines the refraction intensity of the material.
  58622. * The refraction when enabled replaces the Diffuse part of the material.
  58623. * The intensity helps transitionning between diffuse and refraction.
  58624. */
  58625. refractionIntensity: number;
  58626. /**
  58627. * Defines the translucency intensity of the material.
  58628. * When translucency has been enabled, this defines how much of the "translucency"
  58629. * is addded to the diffuse part of the material.
  58630. */
  58631. translucencyIntensity: number;
  58632. /**
  58633. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58634. */
  58635. useAlbedoToTintRefraction: boolean;
  58636. private _thicknessTexture;
  58637. /**
  58638. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58639. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58640. * 0 would mean minimumThickness
  58641. * 1 would mean maximumThickness
  58642. * The other channels might be use as a mask to vary the different effects intensity.
  58643. */
  58644. thicknessTexture: Nullable<BaseTexture>;
  58645. private _refractionTexture;
  58646. /**
  58647. * Defines the texture to use for refraction.
  58648. */
  58649. refractionTexture: Nullable<BaseTexture>;
  58650. private _indexOfRefraction;
  58651. /**
  58652. * Index of refraction of the material base layer.
  58653. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58654. *
  58655. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58656. *
  58657. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58658. */
  58659. indexOfRefraction: number;
  58660. private _volumeIndexOfRefraction;
  58661. /**
  58662. * Index of refraction of the material's volume.
  58663. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58664. *
  58665. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58666. * the volume will use the same IOR as the surface.
  58667. */
  58668. get volumeIndexOfRefraction(): number;
  58669. set volumeIndexOfRefraction(value: number);
  58670. private _invertRefractionY;
  58671. /**
  58672. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58673. */
  58674. invertRefractionY: boolean;
  58675. private _linkRefractionWithTransparency;
  58676. /**
  58677. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58678. * Materials half opaque for instance using refraction could benefit from this control.
  58679. */
  58680. linkRefractionWithTransparency: boolean;
  58681. /**
  58682. * Defines the minimum thickness stored in the thickness map.
  58683. * If no thickness map is defined, this value will be used to simulate thickness.
  58684. */
  58685. minimumThickness: number;
  58686. /**
  58687. * Defines the maximum thickness stored in the thickness map.
  58688. */
  58689. maximumThickness: number;
  58690. /**
  58691. * Defines the volume tint of the material.
  58692. * This is used for both translucency and scattering.
  58693. */
  58694. tintColor: Color3;
  58695. /**
  58696. * Defines the distance at which the tint color should be found in the media.
  58697. * This is used for refraction only.
  58698. */
  58699. tintColorAtDistance: number;
  58700. /**
  58701. * Defines how far each channel transmit through the media.
  58702. * It is defined as a color to simplify it selection.
  58703. */
  58704. diffusionDistance: Color3;
  58705. private _useMaskFromThicknessTexture;
  58706. /**
  58707. * Stores the intensity of the different subsurface effects in the thickness texture.
  58708. * * the green channel is the translucency intensity.
  58709. * * the blue channel is the scattering intensity.
  58710. * * the alpha channel is the refraction intensity.
  58711. */
  58712. useMaskFromThicknessTexture: boolean;
  58713. private _scene;
  58714. /** @hidden */
  58715. private _internalMarkAllSubMeshesAsTexturesDirty;
  58716. private _internalMarkScenePrePassDirty;
  58717. /** @hidden */
  58718. _markAllSubMeshesAsTexturesDirty(): void;
  58719. /** @hidden */
  58720. _markScenePrePassDirty(): void;
  58721. /**
  58722. * Instantiate a new istance of sub surface configuration.
  58723. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58724. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58725. * @param scene The scene
  58726. */
  58727. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58728. /**
  58729. * Gets wehter the submesh is ready to be used or not.
  58730. * @param defines the list of "defines" to update.
  58731. * @param scene defines the scene the material belongs to.
  58732. * @returns - boolean indicating that the submesh is ready or not.
  58733. */
  58734. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58735. /**
  58736. * Checks to see if a texture is used in the material.
  58737. * @param defines the list of "defines" to update.
  58738. * @param scene defines the scene to the material belongs to.
  58739. */
  58740. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58741. /**
  58742. * Binds the material data.
  58743. * @param uniformBuffer defines the Uniform buffer to fill in.
  58744. * @param scene defines the scene the material belongs to.
  58745. * @param engine defines the engine the material belongs to.
  58746. * @param isFrozen defines whether the material is frozen or not.
  58747. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58748. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58749. */
  58750. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58751. /**
  58752. * Unbinds the material from the mesh.
  58753. * @param activeEffect defines the effect that should be unbound from.
  58754. * @returns true if unbound, otherwise false
  58755. */
  58756. unbind(activeEffect: Effect): boolean;
  58757. /**
  58758. * Returns the texture used for refraction or null if none is used.
  58759. * @param scene defines the scene the material belongs to.
  58760. * @returns - Refraction texture if present. If no refraction texture and refraction
  58761. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58762. */
  58763. private _getRefractionTexture;
  58764. /**
  58765. * Returns true if alpha blending should be disabled.
  58766. */
  58767. get disableAlphaBlending(): boolean;
  58768. /**
  58769. * Fills the list of render target textures.
  58770. * @param renderTargets the list of render targets to update
  58771. */
  58772. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58773. /**
  58774. * Checks to see if a texture is used in the material.
  58775. * @param texture - Base texture to use.
  58776. * @returns - Boolean specifying if a texture is used in the material.
  58777. */
  58778. hasTexture(texture: BaseTexture): boolean;
  58779. /**
  58780. * Gets a boolean indicating that current material needs to register RTT
  58781. * @returns true if this uses a render target otherwise false.
  58782. */
  58783. hasRenderTargetTextures(): boolean;
  58784. /**
  58785. * Returns an array of the actively used textures.
  58786. * @param activeTextures Array of BaseTextures
  58787. */
  58788. getActiveTextures(activeTextures: BaseTexture[]): void;
  58789. /**
  58790. * Returns the animatable textures.
  58791. * @param animatables Array of animatable textures.
  58792. */
  58793. getAnimatables(animatables: IAnimatable[]): void;
  58794. /**
  58795. * Disposes the resources of the material.
  58796. * @param forceDisposeTextures - Forces the disposal of all textures.
  58797. */
  58798. dispose(forceDisposeTextures?: boolean): void;
  58799. /**
  58800. * Get the current class name of the texture useful for serialization or dynamic coding.
  58801. * @returns "PBRSubSurfaceConfiguration"
  58802. */
  58803. getClassName(): string;
  58804. /**
  58805. * Add fallbacks to the effect fallbacks list.
  58806. * @param defines defines the Base texture to use.
  58807. * @param fallbacks defines the current fallback list.
  58808. * @param currentRank defines the current fallback rank.
  58809. * @returns the new fallback rank.
  58810. */
  58811. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58812. /**
  58813. * Add the required uniforms to the current list.
  58814. * @param uniforms defines the current uniform list.
  58815. */
  58816. static AddUniforms(uniforms: string[]): void;
  58817. /**
  58818. * Add the required samplers to the current list.
  58819. * @param samplers defines the current sampler list.
  58820. */
  58821. static AddSamplers(samplers: string[]): void;
  58822. /**
  58823. * Add the required uniforms to the current buffer.
  58824. * @param uniformBuffer defines the current uniform buffer.
  58825. */
  58826. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58827. /**
  58828. * Makes a duplicate of the current configuration into another one.
  58829. * @param configuration define the config where to copy the info
  58830. */
  58831. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58832. /**
  58833. * Serializes this Sub Surface configuration.
  58834. * @returns - An object with the serialized config.
  58835. */
  58836. serialize(): any;
  58837. /**
  58838. * Parses a anisotropy Configuration from a serialized object.
  58839. * @param source - Serialized object.
  58840. * @param scene Defines the scene we are parsing for
  58841. * @param rootUrl Defines the rootUrl to load from
  58842. */
  58843. parse(source: any, scene: Scene, rootUrl: string): void;
  58844. }
  58845. }
  58846. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58847. /** @hidden */
  58848. export var pbrFragmentDeclaration: {
  58849. name: string;
  58850. shader: string;
  58851. };
  58852. }
  58853. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58854. /** @hidden */
  58855. export var pbrUboDeclaration: {
  58856. name: string;
  58857. shader: string;
  58858. };
  58859. }
  58860. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58861. /** @hidden */
  58862. export var pbrFragmentExtraDeclaration: {
  58863. name: string;
  58864. shader: string;
  58865. };
  58866. }
  58867. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58868. /** @hidden */
  58869. export var pbrFragmentSamplersDeclaration: {
  58870. name: string;
  58871. shader: string;
  58872. };
  58873. }
  58874. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  58875. /** @hidden */
  58876. export var subSurfaceScatteringFunctions: {
  58877. name: string;
  58878. shader: string;
  58879. };
  58880. }
  58881. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58882. /** @hidden */
  58883. export var importanceSampling: {
  58884. name: string;
  58885. shader: string;
  58886. };
  58887. }
  58888. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58889. /** @hidden */
  58890. export var pbrHelperFunctions: {
  58891. name: string;
  58892. shader: string;
  58893. };
  58894. }
  58895. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58896. /** @hidden */
  58897. export var harmonicsFunctions: {
  58898. name: string;
  58899. shader: string;
  58900. };
  58901. }
  58902. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58903. /** @hidden */
  58904. export var pbrDirectLightingSetupFunctions: {
  58905. name: string;
  58906. shader: string;
  58907. };
  58908. }
  58909. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58910. /** @hidden */
  58911. export var pbrDirectLightingFalloffFunctions: {
  58912. name: string;
  58913. shader: string;
  58914. };
  58915. }
  58916. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58917. /** @hidden */
  58918. export var pbrBRDFFunctions: {
  58919. name: string;
  58920. shader: string;
  58921. };
  58922. }
  58923. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58924. /** @hidden */
  58925. export var hdrFilteringFunctions: {
  58926. name: string;
  58927. shader: string;
  58928. };
  58929. }
  58930. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58931. /** @hidden */
  58932. export var pbrDirectLightingFunctions: {
  58933. name: string;
  58934. shader: string;
  58935. };
  58936. }
  58937. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58938. /** @hidden */
  58939. export var pbrIBLFunctions: {
  58940. name: string;
  58941. shader: string;
  58942. };
  58943. }
  58944. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58945. /** @hidden */
  58946. export var pbrBlockAlbedoOpacity: {
  58947. name: string;
  58948. shader: string;
  58949. };
  58950. }
  58951. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58952. /** @hidden */
  58953. export var pbrBlockReflectivity: {
  58954. name: string;
  58955. shader: string;
  58956. };
  58957. }
  58958. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58959. /** @hidden */
  58960. export var pbrBlockAmbientOcclusion: {
  58961. name: string;
  58962. shader: string;
  58963. };
  58964. }
  58965. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58966. /** @hidden */
  58967. export var pbrBlockAlphaFresnel: {
  58968. name: string;
  58969. shader: string;
  58970. };
  58971. }
  58972. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58973. /** @hidden */
  58974. export var pbrBlockAnisotropic: {
  58975. name: string;
  58976. shader: string;
  58977. };
  58978. }
  58979. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58980. /** @hidden */
  58981. export var pbrBlockReflection: {
  58982. name: string;
  58983. shader: string;
  58984. };
  58985. }
  58986. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58987. /** @hidden */
  58988. export var pbrBlockSheen: {
  58989. name: string;
  58990. shader: string;
  58991. };
  58992. }
  58993. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58994. /** @hidden */
  58995. export var pbrBlockClearcoat: {
  58996. name: string;
  58997. shader: string;
  58998. };
  58999. }
  59000. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  59001. /** @hidden */
  59002. export var pbrBlockSubSurface: {
  59003. name: string;
  59004. shader: string;
  59005. };
  59006. }
  59007. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  59008. /** @hidden */
  59009. export var pbrBlockNormalGeometric: {
  59010. name: string;
  59011. shader: string;
  59012. };
  59013. }
  59014. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  59015. /** @hidden */
  59016. export var pbrBlockNormalFinal: {
  59017. name: string;
  59018. shader: string;
  59019. };
  59020. }
  59021. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  59022. /** @hidden */
  59023. export var pbrBlockLightmapInit: {
  59024. name: string;
  59025. shader: string;
  59026. };
  59027. }
  59028. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  59029. /** @hidden */
  59030. export var pbrBlockGeometryInfo: {
  59031. name: string;
  59032. shader: string;
  59033. };
  59034. }
  59035. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  59036. /** @hidden */
  59037. export var pbrBlockReflectance0: {
  59038. name: string;
  59039. shader: string;
  59040. };
  59041. }
  59042. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  59043. /** @hidden */
  59044. export var pbrBlockReflectance: {
  59045. name: string;
  59046. shader: string;
  59047. };
  59048. }
  59049. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  59050. /** @hidden */
  59051. export var pbrBlockDirectLighting: {
  59052. name: string;
  59053. shader: string;
  59054. };
  59055. }
  59056. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  59057. /** @hidden */
  59058. export var pbrBlockFinalLitComponents: {
  59059. name: string;
  59060. shader: string;
  59061. };
  59062. }
  59063. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  59064. /** @hidden */
  59065. export var pbrBlockFinalUnlitComponents: {
  59066. name: string;
  59067. shader: string;
  59068. };
  59069. }
  59070. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  59071. /** @hidden */
  59072. export var pbrBlockFinalColorComposition: {
  59073. name: string;
  59074. shader: string;
  59075. };
  59076. }
  59077. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  59078. /** @hidden */
  59079. export var pbrBlockImageProcessing: {
  59080. name: string;
  59081. shader: string;
  59082. };
  59083. }
  59084. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  59085. /** @hidden */
  59086. export var pbrDebug: {
  59087. name: string;
  59088. shader: string;
  59089. };
  59090. }
  59091. declare module "babylonjs/Shaders/pbr.fragment" {
  59092. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  59093. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  59094. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  59095. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  59096. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59097. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59098. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  59099. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59100. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  59101. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59102. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59103. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59104. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  59105. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  59106. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  59107. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59108. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59109. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  59110. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  59111. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  59112. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  59113. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  59114. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  59115. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  59116. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  59117. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  59118. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59119. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  59120. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  59121. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  59122. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  59123. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  59124. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  59125. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  59126. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  59127. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  59128. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59129. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  59130. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  59131. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  59132. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  59133. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  59134. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  59135. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  59136. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  59137. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  59138. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59139. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  59140. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  59141. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  59142. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  59143. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  59144. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  59145. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  59146. /** @hidden */
  59147. export var pbrPixelShader: {
  59148. name: string;
  59149. shader: string;
  59150. };
  59151. }
  59152. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  59153. /** @hidden */
  59154. export var pbrVertexDeclaration: {
  59155. name: string;
  59156. shader: string;
  59157. };
  59158. }
  59159. declare module "babylonjs/Shaders/pbr.vertex" {
  59160. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  59161. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  59162. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59163. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59164. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59165. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  59166. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  59167. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  59168. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59169. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59170. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59171. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59172. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59173. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59174. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59175. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59176. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59177. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59178. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  59179. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  59180. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59181. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59182. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59183. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  59184. /** @hidden */
  59185. export var pbrVertexShader: {
  59186. name: string;
  59187. shader: string;
  59188. };
  59189. }
  59190. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  59191. import { Nullable } from "babylonjs/types";
  59192. import { Scene } from "babylonjs/scene";
  59193. import { Matrix } from "babylonjs/Maths/math.vector";
  59194. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59196. import { Mesh } from "babylonjs/Meshes/mesh";
  59197. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  59198. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  59199. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  59200. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  59201. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  59202. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  59203. import { Color3 } from "babylonjs/Maths/math.color";
  59204. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59205. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  59206. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59207. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59209. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59210. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59211. import "babylonjs/Shaders/pbr.fragment";
  59212. import "babylonjs/Shaders/pbr.vertex";
  59213. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  59214. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  59215. /**
  59216. * Manages the defines for the PBR Material.
  59217. * @hidden
  59218. */
  59219. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  59220. PBR: boolean;
  59221. NUM_SAMPLES: string;
  59222. REALTIME_FILTERING: boolean;
  59223. MAINUV1: boolean;
  59224. MAINUV2: boolean;
  59225. UV1: boolean;
  59226. UV2: boolean;
  59227. ALBEDO: boolean;
  59228. GAMMAALBEDO: boolean;
  59229. ALBEDODIRECTUV: number;
  59230. VERTEXCOLOR: boolean;
  59231. DETAIL: boolean;
  59232. DETAILDIRECTUV: number;
  59233. DETAIL_NORMALBLENDMETHOD: number;
  59234. AMBIENT: boolean;
  59235. AMBIENTDIRECTUV: number;
  59236. AMBIENTINGRAYSCALE: boolean;
  59237. OPACITY: boolean;
  59238. VERTEXALPHA: boolean;
  59239. OPACITYDIRECTUV: number;
  59240. OPACITYRGB: boolean;
  59241. ALPHATEST: boolean;
  59242. DEPTHPREPASS: boolean;
  59243. ALPHABLEND: boolean;
  59244. ALPHAFROMALBEDO: boolean;
  59245. ALPHATESTVALUE: string;
  59246. SPECULAROVERALPHA: boolean;
  59247. RADIANCEOVERALPHA: boolean;
  59248. ALPHAFRESNEL: boolean;
  59249. LINEARALPHAFRESNEL: boolean;
  59250. PREMULTIPLYALPHA: boolean;
  59251. EMISSIVE: boolean;
  59252. EMISSIVEDIRECTUV: number;
  59253. REFLECTIVITY: boolean;
  59254. REFLECTIVITYDIRECTUV: number;
  59255. SPECULARTERM: boolean;
  59256. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  59257. MICROSURFACEAUTOMATIC: boolean;
  59258. LODBASEDMICROSFURACE: boolean;
  59259. MICROSURFACEMAP: boolean;
  59260. MICROSURFACEMAPDIRECTUV: number;
  59261. METALLICWORKFLOW: boolean;
  59262. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  59263. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  59264. METALLNESSSTOREINMETALMAPBLUE: boolean;
  59265. AOSTOREINMETALMAPRED: boolean;
  59266. METALLIC_REFLECTANCE: boolean;
  59267. METALLIC_REFLECTANCEDIRECTUV: number;
  59268. ENVIRONMENTBRDF: boolean;
  59269. ENVIRONMENTBRDF_RGBD: boolean;
  59270. NORMAL: boolean;
  59271. TANGENT: boolean;
  59272. BUMP: boolean;
  59273. BUMPDIRECTUV: number;
  59274. OBJECTSPACE_NORMALMAP: boolean;
  59275. PARALLAX: boolean;
  59276. PARALLAXOCCLUSION: boolean;
  59277. NORMALXYSCALE: boolean;
  59278. LIGHTMAP: boolean;
  59279. LIGHTMAPDIRECTUV: number;
  59280. USELIGHTMAPASSHADOWMAP: boolean;
  59281. GAMMALIGHTMAP: boolean;
  59282. RGBDLIGHTMAP: boolean;
  59283. REFLECTION: boolean;
  59284. REFLECTIONMAP_3D: boolean;
  59285. REFLECTIONMAP_SPHERICAL: boolean;
  59286. REFLECTIONMAP_PLANAR: boolean;
  59287. REFLECTIONMAP_CUBIC: boolean;
  59288. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  59289. REFLECTIONMAP_PROJECTION: boolean;
  59290. REFLECTIONMAP_SKYBOX: boolean;
  59291. REFLECTIONMAP_EXPLICIT: boolean;
  59292. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  59293. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  59294. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  59295. INVERTCUBICMAP: boolean;
  59296. USESPHERICALFROMREFLECTIONMAP: boolean;
  59297. USEIRRADIANCEMAP: boolean;
  59298. SPHERICAL_HARMONICS: boolean;
  59299. USESPHERICALINVERTEX: boolean;
  59300. REFLECTIONMAP_OPPOSITEZ: boolean;
  59301. LODINREFLECTIONALPHA: boolean;
  59302. GAMMAREFLECTION: boolean;
  59303. RGBDREFLECTION: boolean;
  59304. LINEARSPECULARREFLECTION: boolean;
  59305. RADIANCEOCCLUSION: boolean;
  59306. HORIZONOCCLUSION: boolean;
  59307. INSTANCES: boolean;
  59308. THIN_INSTANCES: boolean;
  59309. PREPASS: boolean;
  59310. PREPASS_IRRADIANCE: boolean;
  59311. PREPASS_IRRADIANCE_INDEX: number;
  59312. PREPASS_ALBEDO: boolean;
  59313. PREPASS_ALBEDO_INDEX: number;
  59314. PREPASS_DEPTHNORMAL: boolean;
  59315. PREPASS_DEPTHNORMAL_INDEX: number;
  59316. PREPASS_POSITION: boolean;
  59317. PREPASS_POSITION_INDEX: number;
  59318. PREPASS_VELOCITY: boolean;
  59319. PREPASS_VELOCITY_INDEX: number;
  59320. PREPASS_REFLECTIVITY: boolean;
  59321. PREPASS_REFLECTIVITY_INDEX: number;
  59322. SCENE_MRT_COUNT: number;
  59323. NUM_BONE_INFLUENCERS: number;
  59324. BonesPerMesh: number;
  59325. BONETEXTURE: boolean;
  59326. BONES_VELOCITY_ENABLED: boolean;
  59327. NONUNIFORMSCALING: boolean;
  59328. MORPHTARGETS: boolean;
  59329. MORPHTARGETS_NORMAL: boolean;
  59330. MORPHTARGETS_TANGENT: boolean;
  59331. MORPHTARGETS_UV: boolean;
  59332. NUM_MORPH_INFLUENCERS: number;
  59333. IMAGEPROCESSING: boolean;
  59334. VIGNETTE: boolean;
  59335. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59336. VIGNETTEBLENDMODEOPAQUE: boolean;
  59337. TONEMAPPING: boolean;
  59338. TONEMAPPING_ACES: boolean;
  59339. CONTRAST: boolean;
  59340. COLORCURVES: boolean;
  59341. COLORGRADING: boolean;
  59342. COLORGRADING3D: boolean;
  59343. SAMPLER3DGREENDEPTH: boolean;
  59344. SAMPLER3DBGRMAP: boolean;
  59345. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59346. EXPOSURE: boolean;
  59347. MULTIVIEW: boolean;
  59348. USEPHYSICALLIGHTFALLOFF: boolean;
  59349. USEGLTFLIGHTFALLOFF: boolean;
  59350. TWOSIDEDLIGHTING: boolean;
  59351. SHADOWFLOAT: boolean;
  59352. CLIPPLANE: boolean;
  59353. CLIPPLANE2: boolean;
  59354. CLIPPLANE3: boolean;
  59355. CLIPPLANE4: boolean;
  59356. CLIPPLANE5: boolean;
  59357. CLIPPLANE6: boolean;
  59358. POINTSIZE: boolean;
  59359. FOG: boolean;
  59360. LOGARITHMICDEPTH: boolean;
  59361. FORCENORMALFORWARD: boolean;
  59362. SPECULARAA: boolean;
  59363. CLEARCOAT: boolean;
  59364. CLEARCOAT_DEFAULTIOR: boolean;
  59365. CLEARCOAT_TEXTURE: boolean;
  59366. CLEARCOAT_TEXTUREDIRECTUV: number;
  59367. CLEARCOAT_BUMP: boolean;
  59368. CLEARCOAT_BUMPDIRECTUV: number;
  59369. CLEARCOAT_REMAP_F0: boolean;
  59370. CLEARCOAT_TINT: boolean;
  59371. CLEARCOAT_TINT_TEXTURE: boolean;
  59372. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59373. ANISOTROPIC: boolean;
  59374. ANISOTROPIC_TEXTURE: boolean;
  59375. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59376. BRDF_V_HEIGHT_CORRELATED: boolean;
  59377. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59378. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59379. SHEEN: boolean;
  59380. SHEEN_TEXTURE: boolean;
  59381. SHEEN_TEXTUREDIRECTUV: number;
  59382. SHEEN_LINKWITHALBEDO: boolean;
  59383. SHEEN_ROUGHNESS: boolean;
  59384. SHEEN_ALBEDOSCALING: boolean;
  59385. SUBSURFACE: boolean;
  59386. SS_REFRACTION: boolean;
  59387. SS_TRANSLUCENCY: boolean;
  59388. SS_SCATTERING: boolean;
  59389. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59390. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59391. SS_REFRACTIONMAP_3D: boolean;
  59392. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59393. SS_LODINREFRACTIONALPHA: boolean;
  59394. SS_GAMMAREFRACTION: boolean;
  59395. SS_RGBDREFRACTION: boolean;
  59396. SS_LINEARSPECULARREFRACTION: boolean;
  59397. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59398. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59399. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59400. UNLIT: boolean;
  59401. DEBUGMODE: number;
  59402. /**
  59403. * Initializes the PBR Material defines.
  59404. */
  59405. constructor();
  59406. /**
  59407. * Resets the PBR Material defines.
  59408. */
  59409. reset(): void;
  59410. }
  59411. /**
  59412. * The Physically based material base class of BJS.
  59413. *
  59414. * This offers the main features of a standard PBR material.
  59415. * For more information, please refer to the documentation :
  59416. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59417. */
  59418. export abstract class PBRBaseMaterial extends PushMaterial {
  59419. /**
  59420. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59421. */
  59422. static readonly PBRMATERIAL_OPAQUE: number;
  59423. /**
  59424. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59425. */
  59426. static readonly PBRMATERIAL_ALPHATEST: number;
  59427. /**
  59428. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59429. */
  59430. static readonly PBRMATERIAL_ALPHABLEND: number;
  59431. /**
  59432. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59433. * They are also discarded below the alpha cutoff threshold to improve performances.
  59434. */
  59435. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59436. /**
  59437. * Defines the default value of how much AO map is occluding the analytical lights
  59438. * (point spot...).
  59439. */
  59440. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59441. /**
  59442. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59443. */
  59444. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59445. /**
  59446. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59447. * to enhance interoperability with other engines.
  59448. */
  59449. static readonly LIGHTFALLOFF_GLTF: number;
  59450. /**
  59451. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59452. * to enhance interoperability with other materials.
  59453. */
  59454. static readonly LIGHTFALLOFF_STANDARD: number;
  59455. /**
  59456. * Intensity of the direct lights e.g. the four lights available in your scene.
  59457. * This impacts both the direct diffuse and specular highlights.
  59458. */
  59459. protected _directIntensity: number;
  59460. /**
  59461. * Intensity of the emissive part of the material.
  59462. * This helps controlling the emissive effect without modifying the emissive color.
  59463. */
  59464. protected _emissiveIntensity: number;
  59465. /**
  59466. * Intensity of the environment e.g. how much the environment will light the object
  59467. * either through harmonics for rough material or through the refelction for shiny ones.
  59468. */
  59469. protected _environmentIntensity: number;
  59470. /**
  59471. * This is a special control allowing the reduction of the specular highlights coming from the
  59472. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59473. */
  59474. protected _specularIntensity: number;
  59475. /**
  59476. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59477. */
  59478. private _lightingInfos;
  59479. /**
  59480. * Debug Control allowing disabling the bump map on this material.
  59481. */
  59482. protected _disableBumpMap: boolean;
  59483. /**
  59484. * AKA Diffuse Texture in standard nomenclature.
  59485. */
  59486. protected _albedoTexture: Nullable<BaseTexture>;
  59487. /**
  59488. * AKA Occlusion Texture in other nomenclature.
  59489. */
  59490. protected _ambientTexture: Nullable<BaseTexture>;
  59491. /**
  59492. * AKA Occlusion Texture Intensity in other nomenclature.
  59493. */
  59494. protected _ambientTextureStrength: number;
  59495. /**
  59496. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59497. * 1 means it completely occludes it
  59498. * 0 mean it has no impact
  59499. */
  59500. protected _ambientTextureImpactOnAnalyticalLights: number;
  59501. /**
  59502. * Stores the alpha values in a texture.
  59503. */
  59504. protected _opacityTexture: Nullable<BaseTexture>;
  59505. /**
  59506. * Stores the reflection values in a texture.
  59507. */
  59508. protected _reflectionTexture: Nullable<BaseTexture>;
  59509. /**
  59510. * Stores the emissive values in a texture.
  59511. */
  59512. protected _emissiveTexture: Nullable<BaseTexture>;
  59513. /**
  59514. * AKA Specular texture in other nomenclature.
  59515. */
  59516. protected _reflectivityTexture: Nullable<BaseTexture>;
  59517. /**
  59518. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59519. */
  59520. protected _metallicTexture: Nullable<BaseTexture>;
  59521. /**
  59522. * Specifies the metallic scalar of the metallic/roughness workflow.
  59523. * Can also be used to scale the metalness values of the metallic texture.
  59524. */
  59525. protected _metallic: Nullable<number>;
  59526. /**
  59527. * Specifies the roughness scalar of the metallic/roughness workflow.
  59528. * Can also be used to scale the roughness values of the metallic texture.
  59529. */
  59530. protected _roughness: Nullable<number>;
  59531. /**
  59532. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59533. * By default the indexOfrefraction is used to compute F0;
  59534. *
  59535. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59536. *
  59537. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59538. * F90 = metallicReflectanceColor;
  59539. */
  59540. protected _metallicF0Factor: number;
  59541. /**
  59542. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59543. * By default the F90 is always 1;
  59544. *
  59545. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59546. *
  59547. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59548. * F90 = metallicReflectanceColor;
  59549. */
  59550. protected _metallicReflectanceColor: Color3;
  59551. /**
  59552. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59553. * This is multiply against the scalar values defined in the material.
  59554. */
  59555. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59556. /**
  59557. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59558. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59559. */
  59560. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59561. /**
  59562. * Stores surface normal data used to displace a mesh in a texture.
  59563. */
  59564. protected _bumpTexture: Nullable<BaseTexture>;
  59565. /**
  59566. * Stores the pre-calculated light information of a mesh in a texture.
  59567. */
  59568. protected _lightmapTexture: Nullable<BaseTexture>;
  59569. /**
  59570. * The color of a material in ambient lighting.
  59571. */
  59572. protected _ambientColor: Color3;
  59573. /**
  59574. * AKA Diffuse Color in other nomenclature.
  59575. */
  59576. protected _albedoColor: Color3;
  59577. /**
  59578. * AKA Specular Color in other nomenclature.
  59579. */
  59580. protected _reflectivityColor: Color3;
  59581. /**
  59582. * The color applied when light is reflected from a material.
  59583. */
  59584. protected _reflectionColor: Color3;
  59585. /**
  59586. * The color applied when light is emitted from a material.
  59587. */
  59588. protected _emissiveColor: Color3;
  59589. /**
  59590. * AKA Glossiness in other nomenclature.
  59591. */
  59592. protected _microSurface: number;
  59593. /**
  59594. * Specifies that the material will use the light map as a show map.
  59595. */
  59596. protected _useLightmapAsShadowmap: boolean;
  59597. /**
  59598. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59599. * makes the reflect vector face the model (under horizon).
  59600. */
  59601. protected _useHorizonOcclusion: boolean;
  59602. /**
  59603. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59604. * too much the area relying on ambient texture to define their ambient occlusion.
  59605. */
  59606. protected _useRadianceOcclusion: boolean;
  59607. /**
  59608. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59609. */
  59610. protected _useAlphaFromAlbedoTexture: boolean;
  59611. /**
  59612. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59613. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59614. */
  59615. protected _useSpecularOverAlpha: boolean;
  59616. /**
  59617. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59618. */
  59619. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59620. /**
  59621. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59622. */
  59623. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59624. /**
  59625. * Specifies if the metallic texture contains the roughness information in its green channel.
  59626. */
  59627. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59628. /**
  59629. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59630. */
  59631. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59632. /**
  59633. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59634. */
  59635. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59636. /**
  59637. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59638. */
  59639. protected _useAmbientInGrayScale: boolean;
  59640. /**
  59641. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59642. * The material will try to infer what glossiness each pixel should be.
  59643. */
  59644. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59645. /**
  59646. * Defines the falloff type used in this material.
  59647. * It by default is Physical.
  59648. */
  59649. protected _lightFalloff: number;
  59650. /**
  59651. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59652. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59653. */
  59654. protected _useRadianceOverAlpha: boolean;
  59655. /**
  59656. * Allows using an object space normal map (instead of tangent space).
  59657. */
  59658. protected _useObjectSpaceNormalMap: boolean;
  59659. /**
  59660. * Allows using the bump map in parallax mode.
  59661. */
  59662. protected _useParallax: boolean;
  59663. /**
  59664. * Allows using the bump map in parallax occlusion mode.
  59665. */
  59666. protected _useParallaxOcclusion: boolean;
  59667. /**
  59668. * Controls the scale bias of the parallax mode.
  59669. */
  59670. protected _parallaxScaleBias: number;
  59671. /**
  59672. * If sets to true, disables all the lights affecting the material.
  59673. */
  59674. protected _disableLighting: boolean;
  59675. /**
  59676. * Number of Simultaneous lights allowed on the material.
  59677. */
  59678. protected _maxSimultaneousLights: number;
  59679. /**
  59680. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59681. */
  59682. protected _invertNormalMapX: boolean;
  59683. /**
  59684. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59685. */
  59686. protected _invertNormalMapY: boolean;
  59687. /**
  59688. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59689. */
  59690. protected _twoSidedLighting: boolean;
  59691. /**
  59692. * Defines the alpha limits in alpha test mode.
  59693. */
  59694. protected _alphaCutOff: number;
  59695. /**
  59696. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59697. */
  59698. protected _forceAlphaTest: boolean;
  59699. /**
  59700. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59701. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59702. */
  59703. protected _useAlphaFresnel: boolean;
  59704. /**
  59705. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59706. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59707. */
  59708. protected _useLinearAlphaFresnel: boolean;
  59709. /**
  59710. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59711. * from cos thetav and roughness:
  59712. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59713. */
  59714. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59715. /**
  59716. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59717. */
  59718. protected _forceIrradianceInFragment: boolean;
  59719. private _realTimeFiltering;
  59720. /**
  59721. * Enables realtime filtering on the texture.
  59722. */
  59723. get realTimeFiltering(): boolean;
  59724. set realTimeFiltering(b: boolean);
  59725. private _realTimeFilteringQuality;
  59726. /**
  59727. * Quality switch for realtime filtering
  59728. */
  59729. get realTimeFilteringQuality(): number;
  59730. set realTimeFilteringQuality(n: number);
  59731. /**
  59732. * Can this material render to several textures at once
  59733. */
  59734. get canRenderToMRT(): boolean;
  59735. /**
  59736. * Force normal to face away from face.
  59737. */
  59738. protected _forceNormalForward: boolean;
  59739. /**
  59740. * Enables specular anti aliasing in the PBR shader.
  59741. * It will both interacts on the Geometry for analytical and IBL lighting.
  59742. * It also prefilter the roughness map based on the bump values.
  59743. */
  59744. protected _enableSpecularAntiAliasing: boolean;
  59745. /**
  59746. * Default configuration related to image processing available in the PBR Material.
  59747. */
  59748. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59749. /**
  59750. * Keep track of the image processing observer to allow dispose and replace.
  59751. */
  59752. private _imageProcessingObserver;
  59753. /**
  59754. * Attaches a new image processing configuration to the PBR Material.
  59755. * @param configuration
  59756. */
  59757. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59758. /**
  59759. * Stores the available render targets.
  59760. */
  59761. private _renderTargets;
  59762. /**
  59763. * Sets the global ambient color for the material used in lighting calculations.
  59764. */
  59765. private _globalAmbientColor;
  59766. /**
  59767. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59768. */
  59769. private _useLogarithmicDepth;
  59770. /**
  59771. * If set to true, no lighting calculations will be applied.
  59772. */
  59773. private _unlit;
  59774. private _debugMode;
  59775. /**
  59776. * @hidden
  59777. * This is reserved for the inspector.
  59778. * Defines the material debug mode.
  59779. * It helps seeing only some components of the material while troubleshooting.
  59780. */
  59781. debugMode: number;
  59782. /**
  59783. * @hidden
  59784. * This is reserved for the inspector.
  59785. * Specify from where on screen the debug mode should start.
  59786. * The value goes from -1 (full screen) to 1 (not visible)
  59787. * It helps with side by side comparison against the final render
  59788. * This defaults to -1
  59789. */
  59790. private debugLimit;
  59791. /**
  59792. * @hidden
  59793. * This is reserved for the inspector.
  59794. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59795. * You can use the factor to better multiply the final value.
  59796. */
  59797. private debugFactor;
  59798. /**
  59799. * Defines the clear coat layer parameters for the material.
  59800. */
  59801. readonly clearCoat: PBRClearCoatConfiguration;
  59802. /**
  59803. * Defines the anisotropic parameters for the material.
  59804. */
  59805. readonly anisotropy: PBRAnisotropicConfiguration;
  59806. /**
  59807. * Defines the BRDF parameters for the material.
  59808. */
  59809. readonly brdf: PBRBRDFConfiguration;
  59810. /**
  59811. * Defines the Sheen parameters for the material.
  59812. */
  59813. readonly sheen: PBRSheenConfiguration;
  59814. /**
  59815. * Defines the SubSurface parameters for the material.
  59816. */
  59817. readonly subSurface: PBRSubSurfaceConfiguration;
  59818. /**
  59819. * Defines additionnal PrePass parameters for the material.
  59820. */
  59821. readonly prePassConfiguration: PrePassConfiguration;
  59822. /**
  59823. * Defines the detail map parameters for the material.
  59824. */
  59825. readonly detailMap: DetailMapConfiguration;
  59826. protected _rebuildInParallel: boolean;
  59827. /**
  59828. * Instantiates a new PBRMaterial instance.
  59829. *
  59830. * @param name The material name
  59831. * @param scene The scene the material will be use in.
  59832. */
  59833. constructor(name: string, scene: Scene);
  59834. /**
  59835. * Gets a boolean indicating that current material needs to register RTT
  59836. */
  59837. get hasRenderTargetTextures(): boolean;
  59838. /**
  59839. * Gets the name of the material class.
  59840. */
  59841. getClassName(): string;
  59842. /**
  59843. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59844. */
  59845. get useLogarithmicDepth(): boolean;
  59846. /**
  59847. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59848. */
  59849. set useLogarithmicDepth(value: boolean);
  59850. /**
  59851. * Returns true if alpha blending should be disabled.
  59852. */
  59853. protected get _disableAlphaBlending(): boolean;
  59854. /**
  59855. * Specifies whether or not this material should be rendered in alpha blend mode.
  59856. */
  59857. needAlphaBlending(): boolean;
  59858. /**
  59859. * Specifies whether or not this material should be rendered in alpha test mode.
  59860. */
  59861. needAlphaTesting(): boolean;
  59862. /**
  59863. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59864. */
  59865. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59866. /**
  59867. * Gets the texture used for the alpha test.
  59868. */
  59869. getAlphaTestTexture(): Nullable<BaseTexture>;
  59870. /**
  59871. * Specifies that the submesh is ready to be used.
  59872. * @param mesh - BJS mesh.
  59873. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59874. * @param useInstances - Specifies that instances should be used.
  59875. * @returns - boolean indicating that the submesh is ready or not.
  59876. */
  59877. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59878. /**
  59879. * Specifies if the material uses metallic roughness workflow.
  59880. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59881. */
  59882. isMetallicWorkflow(): boolean;
  59883. private _prepareEffect;
  59884. private _prepareDefines;
  59885. /**
  59886. * Force shader compilation
  59887. */
  59888. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59889. /**
  59890. * Initializes the uniform buffer layout for the shader.
  59891. */
  59892. buildUniformLayout(): void;
  59893. /**
  59894. * Unbinds the material from the mesh
  59895. */
  59896. unbind(): void;
  59897. /**
  59898. * Binds the submesh data.
  59899. * @param world - The world matrix.
  59900. * @param mesh - The BJS mesh.
  59901. * @param subMesh - A submesh of the BJS mesh.
  59902. */
  59903. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59904. /**
  59905. * Returns the animatable textures.
  59906. * @returns - Array of animatable textures.
  59907. */
  59908. getAnimatables(): IAnimatable[];
  59909. /**
  59910. * Returns the texture used for reflections.
  59911. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59912. */
  59913. private _getReflectionTexture;
  59914. /**
  59915. * Returns an array of the actively used textures.
  59916. * @returns - Array of BaseTextures
  59917. */
  59918. getActiveTextures(): BaseTexture[];
  59919. /**
  59920. * Checks to see if a texture is used in the material.
  59921. * @param texture - Base texture to use.
  59922. * @returns - Boolean specifying if a texture is used in the material.
  59923. */
  59924. hasTexture(texture: BaseTexture): boolean;
  59925. /**
  59926. * Sets the required values to the prepass renderer.
  59927. * @param prePassRenderer defines the prepass renderer to setup
  59928. */
  59929. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59930. /**
  59931. * Disposes the resources of the material.
  59932. * @param forceDisposeEffect - Forces the disposal of effects.
  59933. * @param forceDisposeTextures - Forces the disposal of all textures.
  59934. */
  59935. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59936. }
  59937. }
  59938. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59939. import { Nullable } from "babylonjs/types";
  59940. import { Scene } from "babylonjs/scene";
  59941. import { Color3 } from "babylonjs/Maths/math.color";
  59942. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59943. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59945. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59946. /**
  59947. * The Physically based material of BJS.
  59948. *
  59949. * This offers the main features of a standard PBR material.
  59950. * For more information, please refer to the documentation :
  59951. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59952. */
  59953. export class PBRMaterial extends PBRBaseMaterial {
  59954. /**
  59955. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59956. */
  59957. static readonly PBRMATERIAL_OPAQUE: number;
  59958. /**
  59959. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59960. */
  59961. static readonly PBRMATERIAL_ALPHATEST: number;
  59962. /**
  59963. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59964. */
  59965. static readonly PBRMATERIAL_ALPHABLEND: number;
  59966. /**
  59967. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59968. * They are also discarded below the alpha cutoff threshold to improve performances.
  59969. */
  59970. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59971. /**
  59972. * Defines the default value of how much AO map is occluding the analytical lights
  59973. * (point spot...).
  59974. */
  59975. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59976. /**
  59977. * Intensity of the direct lights e.g. the four lights available in your scene.
  59978. * This impacts both the direct diffuse and specular highlights.
  59979. */
  59980. directIntensity: number;
  59981. /**
  59982. * Intensity of the emissive part of the material.
  59983. * This helps controlling the emissive effect without modifying the emissive color.
  59984. */
  59985. emissiveIntensity: number;
  59986. /**
  59987. * Intensity of the environment e.g. how much the environment will light the object
  59988. * either through harmonics for rough material or through the refelction for shiny ones.
  59989. */
  59990. environmentIntensity: number;
  59991. /**
  59992. * This is a special control allowing the reduction of the specular highlights coming from the
  59993. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59994. */
  59995. specularIntensity: number;
  59996. /**
  59997. * Debug Control allowing disabling the bump map on this material.
  59998. */
  59999. disableBumpMap: boolean;
  60000. /**
  60001. * AKA Diffuse Texture in standard nomenclature.
  60002. */
  60003. albedoTexture: BaseTexture;
  60004. /**
  60005. * AKA Occlusion Texture in other nomenclature.
  60006. */
  60007. ambientTexture: BaseTexture;
  60008. /**
  60009. * AKA Occlusion Texture Intensity in other nomenclature.
  60010. */
  60011. ambientTextureStrength: number;
  60012. /**
  60013. * Defines how much the AO map is occluding the analytical lights (point spot...).
  60014. * 1 means it completely occludes it
  60015. * 0 mean it has no impact
  60016. */
  60017. ambientTextureImpactOnAnalyticalLights: number;
  60018. /**
  60019. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  60020. */
  60021. opacityTexture: BaseTexture;
  60022. /**
  60023. * Stores the reflection values in a texture.
  60024. */
  60025. reflectionTexture: Nullable<BaseTexture>;
  60026. /**
  60027. * Stores the emissive values in a texture.
  60028. */
  60029. emissiveTexture: BaseTexture;
  60030. /**
  60031. * AKA Specular texture in other nomenclature.
  60032. */
  60033. reflectivityTexture: BaseTexture;
  60034. /**
  60035. * Used to switch from specular/glossiness to metallic/roughness workflow.
  60036. */
  60037. metallicTexture: BaseTexture;
  60038. /**
  60039. * Specifies the metallic scalar of the metallic/roughness workflow.
  60040. * Can also be used to scale the metalness values of the metallic texture.
  60041. */
  60042. metallic: Nullable<number>;
  60043. /**
  60044. * Specifies the roughness scalar of the metallic/roughness workflow.
  60045. * Can also be used to scale the roughness values of the metallic texture.
  60046. */
  60047. roughness: Nullable<number>;
  60048. /**
  60049. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  60050. * By default the indexOfrefraction is used to compute F0;
  60051. *
  60052. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  60053. *
  60054. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  60055. * F90 = metallicReflectanceColor;
  60056. */
  60057. metallicF0Factor: number;
  60058. /**
  60059. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  60060. * By default the F90 is always 1;
  60061. *
  60062. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  60063. *
  60064. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  60065. * F90 = metallicReflectanceColor;
  60066. */
  60067. metallicReflectanceColor: Color3;
  60068. /**
  60069. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  60070. * This is multiply against the scalar values defined in the material.
  60071. */
  60072. metallicReflectanceTexture: Nullable<BaseTexture>;
  60073. /**
  60074. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  60075. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  60076. */
  60077. microSurfaceTexture: BaseTexture;
  60078. /**
  60079. * Stores surface normal data used to displace a mesh in a texture.
  60080. */
  60081. bumpTexture: BaseTexture;
  60082. /**
  60083. * Stores the pre-calculated light information of a mesh in a texture.
  60084. */
  60085. lightmapTexture: BaseTexture;
  60086. /**
  60087. * Stores the refracted light information in a texture.
  60088. */
  60089. get refractionTexture(): Nullable<BaseTexture>;
  60090. set refractionTexture(value: Nullable<BaseTexture>);
  60091. /**
  60092. * The color of a material in ambient lighting.
  60093. */
  60094. ambientColor: Color3;
  60095. /**
  60096. * AKA Diffuse Color in other nomenclature.
  60097. */
  60098. albedoColor: Color3;
  60099. /**
  60100. * AKA Specular Color in other nomenclature.
  60101. */
  60102. reflectivityColor: Color3;
  60103. /**
  60104. * The color reflected from the material.
  60105. */
  60106. reflectionColor: Color3;
  60107. /**
  60108. * The color emitted from the material.
  60109. */
  60110. emissiveColor: Color3;
  60111. /**
  60112. * AKA Glossiness in other nomenclature.
  60113. */
  60114. microSurface: number;
  60115. /**
  60116. * Index of refraction of the material base layer.
  60117. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  60118. *
  60119. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  60120. *
  60121. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  60122. */
  60123. get indexOfRefraction(): number;
  60124. set indexOfRefraction(value: number);
  60125. /**
  60126. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  60127. */
  60128. get invertRefractionY(): boolean;
  60129. set invertRefractionY(value: boolean);
  60130. /**
  60131. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  60132. * Materials half opaque for instance using refraction could benefit from this control.
  60133. */
  60134. get linkRefractionWithTransparency(): boolean;
  60135. set linkRefractionWithTransparency(value: boolean);
  60136. /**
  60137. * If true, the light map contains occlusion information instead of lighting info.
  60138. */
  60139. useLightmapAsShadowmap: boolean;
  60140. /**
  60141. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  60142. */
  60143. useAlphaFromAlbedoTexture: boolean;
  60144. /**
  60145. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  60146. */
  60147. forceAlphaTest: boolean;
  60148. /**
  60149. * Defines the alpha limits in alpha test mode.
  60150. */
  60151. alphaCutOff: number;
  60152. /**
  60153. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  60154. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  60155. */
  60156. useSpecularOverAlpha: boolean;
  60157. /**
  60158. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  60159. */
  60160. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  60161. /**
  60162. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  60163. */
  60164. useRoughnessFromMetallicTextureAlpha: boolean;
  60165. /**
  60166. * Specifies if the metallic texture contains the roughness information in its green channel.
  60167. */
  60168. useRoughnessFromMetallicTextureGreen: boolean;
  60169. /**
  60170. * Specifies if the metallic texture contains the metallness information in its blue channel.
  60171. */
  60172. useMetallnessFromMetallicTextureBlue: boolean;
  60173. /**
  60174. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  60175. */
  60176. useAmbientOcclusionFromMetallicTextureRed: boolean;
  60177. /**
  60178. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  60179. */
  60180. useAmbientInGrayScale: boolean;
  60181. /**
  60182. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  60183. * The material will try to infer what glossiness each pixel should be.
  60184. */
  60185. useAutoMicroSurfaceFromReflectivityMap: boolean;
  60186. /**
  60187. * BJS is using an harcoded light falloff based on a manually sets up range.
  60188. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60189. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60190. */
  60191. get usePhysicalLightFalloff(): boolean;
  60192. /**
  60193. * BJS is using an harcoded light falloff based on a manually sets up range.
  60194. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60195. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60196. */
  60197. set usePhysicalLightFalloff(value: boolean);
  60198. /**
  60199. * In order to support the falloff compatibility with gltf, a special mode has been added
  60200. * to reproduce the gltf light falloff.
  60201. */
  60202. get useGLTFLightFalloff(): boolean;
  60203. /**
  60204. * In order to support the falloff compatibility with gltf, a special mode has been added
  60205. * to reproduce the gltf light falloff.
  60206. */
  60207. set useGLTFLightFalloff(value: boolean);
  60208. /**
  60209. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  60210. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  60211. */
  60212. useRadianceOverAlpha: boolean;
  60213. /**
  60214. * Allows using an object space normal map (instead of tangent space).
  60215. */
  60216. useObjectSpaceNormalMap: boolean;
  60217. /**
  60218. * Allows using the bump map in parallax mode.
  60219. */
  60220. useParallax: boolean;
  60221. /**
  60222. * Allows using the bump map in parallax occlusion mode.
  60223. */
  60224. useParallaxOcclusion: boolean;
  60225. /**
  60226. * Controls the scale bias of the parallax mode.
  60227. */
  60228. parallaxScaleBias: number;
  60229. /**
  60230. * If sets to true, disables all the lights affecting the material.
  60231. */
  60232. disableLighting: boolean;
  60233. /**
  60234. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  60235. */
  60236. forceIrradianceInFragment: boolean;
  60237. /**
  60238. * Number of Simultaneous lights allowed on the material.
  60239. */
  60240. maxSimultaneousLights: number;
  60241. /**
  60242. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60243. */
  60244. invertNormalMapX: boolean;
  60245. /**
  60246. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60247. */
  60248. invertNormalMapY: boolean;
  60249. /**
  60250. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60251. */
  60252. twoSidedLighting: boolean;
  60253. /**
  60254. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60255. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  60256. */
  60257. useAlphaFresnel: boolean;
  60258. /**
  60259. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60260. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  60261. */
  60262. useLinearAlphaFresnel: boolean;
  60263. /**
  60264. * Let user defines the brdf lookup texture used for IBL.
  60265. * A default 8bit version is embedded but you could point at :
  60266. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  60267. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  60268. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  60269. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  60270. */
  60271. environmentBRDFTexture: Nullable<BaseTexture>;
  60272. /**
  60273. * Force normal to face away from face.
  60274. */
  60275. forceNormalForward: boolean;
  60276. /**
  60277. * Enables specular anti aliasing in the PBR shader.
  60278. * It will both interacts on the Geometry for analytical and IBL lighting.
  60279. * It also prefilter the roughness map based on the bump values.
  60280. */
  60281. enableSpecularAntiAliasing: boolean;
  60282. /**
  60283. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  60284. * makes the reflect vector face the model (under horizon).
  60285. */
  60286. useHorizonOcclusion: boolean;
  60287. /**
  60288. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  60289. * too much the area relying on ambient texture to define their ambient occlusion.
  60290. */
  60291. useRadianceOcclusion: boolean;
  60292. /**
  60293. * If set to true, no lighting calculations will be applied.
  60294. */
  60295. unlit: boolean;
  60296. /**
  60297. * Gets the image processing configuration used either in this material.
  60298. */
  60299. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60300. /**
  60301. * Sets the Default image processing configuration used either in the this material.
  60302. *
  60303. * If sets to null, the scene one is in use.
  60304. */
  60305. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60306. /**
  60307. * Gets wether the color curves effect is enabled.
  60308. */
  60309. get cameraColorCurvesEnabled(): boolean;
  60310. /**
  60311. * Sets wether the color curves effect is enabled.
  60312. */
  60313. set cameraColorCurvesEnabled(value: boolean);
  60314. /**
  60315. * Gets wether the color grading effect is enabled.
  60316. */
  60317. get cameraColorGradingEnabled(): boolean;
  60318. /**
  60319. * Gets wether the color grading effect is enabled.
  60320. */
  60321. set cameraColorGradingEnabled(value: boolean);
  60322. /**
  60323. * Gets wether tonemapping is enabled or not.
  60324. */
  60325. get cameraToneMappingEnabled(): boolean;
  60326. /**
  60327. * Sets wether tonemapping is enabled or not
  60328. */
  60329. set cameraToneMappingEnabled(value: boolean);
  60330. /**
  60331. * The camera exposure used on this material.
  60332. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60333. * This corresponds to a photographic exposure.
  60334. */
  60335. get cameraExposure(): number;
  60336. /**
  60337. * The camera exposure used on this material.
  60338. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60339. * This corresponds to a photographic exposure.
  60340. */
  60341. set cameraExposure(value: number);
  60342. /**
  60343. * Gets The camera contrast used on this material.
  60344. */
  60345. get cameraContrast(): number;
  60346. /**
  60347. * Sets The camera contrast used on this material.
  60348. */
  60349. set cameraContrast(value: number);
  60350. /**
  60351. * Gets the Color Grading 2D Lookup Texture.
  60352. */
  60353. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60354. /**
  60355. * Sets the Color Grading 2D Lookup Texture.
  60356. */
  60357. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60358. /**
  60359. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60360. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60361. * 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;
  60362. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60363. */
  60364. get cameraColorCurves(): Nullable<ColorCurves>;
  60365. /**
  60366. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60367. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60368. * 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;
  60369. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60370. */
  60371. set cameraColorCurves(value: Nullable<ColorCurves>);
  60372. /**
  60373. * Instantiates a new PBRMaterial instance.
  60374. *
  60375. * @param name The material name
  60376. * @param scene The scene the material will be use in.
  60377. */
  60378. constructor(name: string, scene: Scene);
  60379. /**
  60380. * Returns the name of this material class.
  60381. */
  60382. getClassName(): string;
  60383. /**
  60384. * Makes a duplicate of the current material.
  60385. * @param name - name to use for the new material.
  60386. */
  60387. clone(name: string): PBRMaterial;
  60388. /**
  60389. * Serializes this PBR Material.
  60390. * @returns - An object with the serialized material.
  60391. */
  60392. serialize(): any;
  60393. /**
  60394. * Parses a PBR Material from a serialized object.
  60395. * @param source - Serialized object.
  60396. * @param scene - BJS scene instance.
  60397. * @param rootUrl - url for the scene object
  60398. * @returns - PBRMaterial
  60399. */
  60400. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60401. }
  60402. }
  60403. declare module "babylonjs/Misc/dds" {
  60404. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60405. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60406. import { Nullable } from "babylonjs/types";
  60407. import { Scene } from "babylonjs/scene";
  60408. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60409. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60410. /**
  60411. * Direct draw surface info
  60412. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60413. */
  60414. export interface DDSInfo {
  60415. /**
  60416. * Width of the texture
  60417. */
  60418. width: number;
  60419. /**
  60420. * Width of the texture
  60421. */
  60422. height: number;
  60423. /**
  60424. * Number of Mipmaps for the texture
  60425. * @see https://en.wikipedia.org/wiki/Mipmap
  60426. */
  60427. mipmapCount: number;
  60428. /**
  60429. * If the textures format is a known fourCC format
  60430. * @see https://www.fourcc.org/
  60431. */
  60432. isFourCC: boolean;
  60433. /**
  60434. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60435. */
  60436. isRGB: boolean;
  60437. /**
  60438. * If the texture is a lumincance format
  60439. */
  60440. isLuminance: boolean;
  60441. /**
  60442. * If this is a cube texture
  60443. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60444. */
  60445. isCube: boolean;
  60446. /**
  60447. * If the texture is a compressed format eg. FOURCC_DXT1
  60448. */
  60449. isCompressed: boolean;
  60450. /**
  60451. * The dxgiFormat of the texture
  60452. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60453. */
  60454. dxgiFormat: number;
  60455. /**
  60456. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60457. */
  60458. textureType: number;
  60459. /**
  60460. * Sphericle polynomial created for the dds texture
  60461. */
  60462. sphericalPolynomial?: SphericalPolynomial;
  60463. }
  60464. /**
  60465. * Class used to provide DDS decompression tools
  60466. */
  60467. export class DDSTools {
  60468. /**
  60469. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60470. */
  60471. static StoreLODInAlphaChannel: boolean;
  60472. /**
  60473. * Gets DDS information from an array buffer
  60474. * @param data defines the array buffer view to read data from
  60475. * @returns the DDS information
  60476. */
  60477. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60478. private static _FloatView;
  60479. private static _Int32View;
  60480. private static _ToHalfFloat;
  60481. private static _FromHalfFloat;
  60482. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60483. private static _GetHalfFloatRGBAArrayBuffer;
  60484. private static _GetFloatRGBAArrayBuffer;
  60485. private static _GetFloatAsUIntRGBAArrayBuffer;
  60486. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60487. private static _GetRGBAArrayBuffer;
  60488. private static _ExtractLongWordOrder;
  60489. private static _GetRGBArrayBuffer;
  60490. private static _GetLuminanceArrayBuffer;
  60491. /**
  60492. * Uploads DDS Levels to a Babylon Texture
  60493. * @hidden
  60494. */
  60495. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60496. }
  60497. module "babylonjs/Engines/thinEngine" {
  60498. interface ThinEngine {
  60499. /**
  60500. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60501. * @param rootUrl defines the url where the file to load is located
  60502. * @param scene defines the current scene
  60503. * @param lodScale defines scale to apply to the mip map selection
  60504. * @param lodOffset defines offset to apply to the mip map selection
  60505. * @param onLoad defines an optional callback raised when the texture is loaded
  60506. * @param onError defines an optional callback raised if there is an issue to load the texture
  60507. * @param format defines the format of the data
  60508. * @param forcedExtension defines the extension to use to pick the right loader
  60509. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60510. * @returns the cube texture as an InternalTexture
  60511. */
  60512. 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;
  60513. }
  60514. }
  60515. }
  60516. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60517. import { Nullable } from "babylonjs/types";
  60518. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60519. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60520. /**
  60521. * Implementation of the DDS Texture Loader.
  60522. * @hidden
  60523. */
  60524. export class _DDSTextureLoader implements IInternalTextureLoader {
  60525. /**
  60526. * Defines wether the loader supports cascade loading the different faces.
  60527. */
  60528. readonly supportCascades: boolean;
  60529. /**
  60530. * This returns if the loader support the current file information.
  60531. * @param extension defines the file extension of the file being loaded
  60532. * @returns true if the loader can load the specified file
  60533. */
  60534. canLoad(extension: string): boolean;
  60535. /**
  60536. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60537. * @param data contains the texture data
  60538. * @param texture defines the BabylonJS internal texture
  60539. * @param createPolynomials will be true if polynomials have been requested
  60540. * @param onLoad defines the callback to trigger once the texture is ready
  60541. * @param onError defines the callback to trigger in case of error
  60542. */
  60543. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60544. /**
  60545. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60546. * @param data contains the texture data
  60547. * @param texture defines the BabylonJS internal texture
  60548. * @param callback defines the method to call once ready to upload
  60549. */
  60550. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60551. }
  60552. }
  60553. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60554. import { Nullable } from "babylonjs/types";
  60555. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60556. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60557. /**
  60558. * Implementation of the ENV Texture Loader.
  60559. * @hidden
  60560. */
  60561. export class _ENVTextureLoader implements IInternalTextureLoader {
  60562. /**
  60563. * Defines wether the loader supports cascade loading the different faces.
  60564. */
  60565. readonly supportCascades: boolean;
  60566. /**
  60567. * This returns if the loader support the current file information.
  60568. * @param extension defines the file extension of the file being loaded
  60569. * @returns true if the loader can load the specified file
  60570. */
  60571. canLoad(extension: string): boolean;
  60572. /**
  60573. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60574. * @param data contains the texture data
  60575. * @param texture defines the BabylonJS internal texture
  60576. * @param createPolynomials will be true if polynomials have been requested
  60577. * @param onLoad defines the callback to trigger once the texture is ready
  60578. * @param onError defines the callback to trigger in case of error
  60579. */
  60580. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60581. /**
  60582. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60583. * @param data contains the texture data
  60584. * @param texture defines the BabylonJS internal texture
  60585. * @param callback defines the method to call once ready to upload
  60586. */
  60587. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60588. }
  60589. }
  60590. declare module "babylonjs/Misc/khronosTextureContainer" {
  60591. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60592. /**
  60593. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60594. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60595. */
  60596. export class KhronosTextureContainer {
  60597. /** contents of the KTX container file */
  60598. data: ArrayBufferView;
  60599. private static HEADER_LEN;
  60600. private static COMPRESSED_2D;
  60601. private static COMPRESSED_3D;
  60602. private static TEX_2D;
  60603. private static TEX_3D;
  60604. /**
  60605. * Gets the openGL type
  60606. */
  60607. glType: number;
  60608. /**
  60609. * Gets the openGL type size
  60610. */
  60611. glTypeSize: number;
  60612. /**
  60613. * Gets the openGL format
  60614. */
  60615. glFormat: number;
  60616. /**
  60617. * Gets the openGL internal format
  60618. */
  60619. glInternalFormat: number;
  60620. /**
  60621. * Gets the base internal format
  60622. */
  60623. glBaseInternalFormat: number;
  60624. /**
  60625. * Gets image width in pixel
  60626. */
  60627. pixelWidth: number;
  60628. /**
  60629. * Gets image height in pixel
  60630. */
  60631. pixelHeight: number;
  60632. /**
  60633. * Gets image depth in pixels
  60634. */
  60635. pixelDepth: number;
  60636. /**
  60637. * Gets the number of array elements
  60638. */
  60639. numberOfArrayElements: number;
  60640. /**
  60641. * Gets the number of faces
  60642. */
  60643. numberOfFaces: number;
  60644. /**
  60645. * Gets the number of mipmap levels
  60646. */
  60647. numberOfMipmapLevels: number;
  60648. /**
  60649. * Gets the bytes of key value data
  60650. */
  60651. bytesOfKeyValueData: number;
  60652. /**
  60653. * Gets the load type
  60654. */
  60655. loadType: number;
  60656. /**
  60657. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60658. */
  60659. isInvalid: boolean;
  60660. /**
  60661. * Creates a new KhronosTextureContainer
  60662. * @param data contents of the KTX container file
  60663. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60664. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60665. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60666. */
  60667. constructor(
  60668. /** contents of the KTX container file */
  60669. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60670. /**
  60671. * Uploads KTX content to a Babylon Texture.
  60672. * It is assumed that the texture has already been created & is currently bound
  60673. * @hidden
  60674. */
  60675. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60676. private _upload2DCompressedLevels;
  60677. /**
  60678. * Checks if the given data starts with a KTX file identifier.
  60679. * @param data the data to check
  60680. * @returns true if the data is a KTX file or false otherwise
  60681. */
  60682. static IsValid(data: ArrayBufferView): boolean;
  60683. }
  60684. }
  60685. declare module "babylonjs/Misc/workerPool" {
  60686. import { IDisposable } from "babylonjs/scene";
  60687. /**
  60688. * Helper class to push actions to a pool of workers.
  60689. */
  60690. export class WorkerPool implements IDisposable {
  60691. private _workerInfos;
  60692. private _pendingActions;
  60693. /**
  60694. * Constructor
  60695. * @param workers Array of workers to use for actions
  60696. */
  60697. constructor(workers: Array<Worker>);
  60698. /**
  60699. * Terminates all workers and clears any pending actions.
  60700. */
  60701. dispose(): void;
  60702. /**
  60703. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60704. * pended until a worker has completed its action.
  60705. * @param action The action to perform. Call onComplete when the action is complete.
  60706. */
  60707. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60708. private _execute;
  60709. }
  60710. }
  60711. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60712. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60713. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60714. /**
  60715. * Class for loading KTX2 files
  60716. */
  60717. export class KhronosTextureContainer2 {
  60718. private static _WorkerPoolPromise?;
  60719. private static _Initialized;
  60720. private static _Ktx2Decoder;
  60721. /**
  60722. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  60723. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  60724. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  60725. * Urls you can change:
  60726. * URLConfig.jsDecoderModule
  60727. * URLConfig.wasmUASTCToASTC
  60728. * URLConfig.wasmUASTCToBC7
  60729. * URLConfig.jsMSCTranscoder
  60730. * URLConfig.wasmMSCTranscoder
  60731. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  60732. */
  60733. static URLConfig: {
  60734. jsDecoderModule: string;
  60735. wasmUASTCToASTC: null;
  60736. wasmUASTCToBC7: null;
  60737. jsMSCTranscoder: null;
  60738. wasmMSCTranscoder: null;
  60739. };
  60740. /**
  60741. * Default number of workers used to handle data decoding
  60742. */
  60743. static DefaultNumWorkers: number;
  60744. private static GetDefaultNumWorkers;
  60745. private _engine;
  60746. private static _CreateWorkerPool;
  60747. /**
  60748. * Constructor
  60749. * @param engine The engine to use
  60750. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60751. */
  60752. constructor(engine: ThinEngine, numWorkers?: number);
  60753. /** @hidden */
  60754. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60755. /**
  60756. * Stop all async operations and release resources.
  60757. */
  60758. dispose(): void;
  60759. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60760. /**
  60761. * Checks if the given data starts with a KTX2 file identifier.
  60762. * @param data the data to check
  60763. * @returns true if the data is a KTX2 file or false otherwise
  60764. */
  60765. static IsValid(data: ArrayBufferView): boolean;
  60766. }
  60767. }
  60768. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60769. import { Nullable } from "babylonjs/types";
  60770. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60771. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60772. /**
  60773. * Implementation of the KTX Texture Loader.
  60774. * @hidden
  60775. */
  60776. export class _KTXTextureLoader implements IInternalTextureLoader {
  60777. /**
  60778. * Defines wether the loader supports cascade loading the different faces.
  60779. */
  60780. readonly supportCascades: boolean;
  60781. /**
  60782. * This returns if the loader support the current file information.
  60783. * @param extension defines the file extension of the file being loaded
  60784. * @param mimeType defines the optional mime type of the file being loaded
  60785. * @returns true if the loader can load the specified file
  60786. */
  60787. canLoad(extension: string, mimeType?: string): boolean;
  60788. /**
  60789. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60790. * @param data contains the texture data
  60791. * @param texture defines the BabylonJS internal texture
  60792. * @param createPolynomials will be true if polynomials have been requested
  60793. * @param onLoad defines the callback to trigger once the texture is ready
  60794. * @param onError defines the callback to trigger in case of error
  60795. */
  60796. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60797. /**
  60798. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60799. * @param data contains the texture data
  60800. * @param texture defines the BabylonJS internal texture
  60801. * @param callback defines the method to call once ready to upload
  60802. */
  60803. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60804. }
  60805. }
  60806. declare module "babylonjs/Helpers/sceneHelpers" {
  60807. import { Nullable } from "babylonjs/types";
  60808. import { Mesh } from "babylonjs/Meshes/mesh";
  60809. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60810. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60811. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60812. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60813. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60814. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60815. import "babylonjs/Meshes/Builders/boxBuilder";
  60816. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60817. /** @hidden */
  60818. export var _forceSceneHelpersToBundle: boolean;
  60819. module "babylonjs/scene" {
  60820. interface Scene {
  60821. /**
  60822. * Creates a default light for the scene.
  60823. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60824. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60825. */
  60826. createDefaultLight(replace?: boolean): void;
  60827. /**
  60828. * Creates a default camera for the scene.
  60829. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60830. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60831. * @param replace has default false, when true replaces the active camera in the scene
  60832. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60833. */
  60834. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60835. /**
  60836. * Creates a default camera and a default light.
  60837. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60838. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60839. * @param replace has the default false, when true replaces the active camera/light in the scene
  60840. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60841. */
  60842. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60843. /**
  60844. * Creates a new sky box
  60845. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60846. * @param environmentTexture defines the texture to use as environment texture
  60847. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60848. * @param scale defines the overall scale of the skybox
  60849. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60850. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60851. * @returns a new mesh holding the sky box
  60852. */
  60853. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60854. /**
  60855. * Creates a new environment
  60856. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60857. * @param options defines the options you can use to configure the environment
  60858. * @returns the new EnvironmentHelper
  60859. */
  60860. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60861. /**
  60862. * Creates a new VREXperienceHelper
  60863. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60864. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60865. * @returns a new VREXperienceHelper
  60866. */
  60867. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60868. /**
  60869. * Creates a new WebXRDefaultExperience
  60870. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60871. * @param options experience options
  60872. * @returns a promise for a new WebXRDefaultExperience
  60873. */
  60874. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60875. }
  60876. }
  60877. }
  60878. declare module "babylonjs/Helpers/videoDome" {
  60879. import { Scene } from "babylonjs/scene";
  60880. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60881. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60882. /**
  60883. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60884. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60885. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60886. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60887. */
  60888. export class VideoDome extends TextureDome<VideoTexture> {
  60889. /**
  60890. * Define the video source as a Monoscopic panoramic 360 video.
  60891. */
  60892. static readonly MODE_MONOSCOPIC: number;
  60893. /**
  60894. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60895. */
  60896. static readonly MODE_TOPBOTTOM: number;
  60897. /**
  60898. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60899. */
  60900. static readonly MODE_SIDEBYSIDE: number;
  60901. /**
  60902. * Get the video texture associated with this video dome
  60903. */
  60904. get videoTexture(): VideoTexture;
  60905. /**
  60906. * Get the video mode of this dome
  60907. */
  60908. get videoMode(): number;
  60909. /**
  60910. * Set the video mode of this dome.
  60911. * @see textureMode
  60912. */
  60913. set videoMode(value: number);
  60914. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60915. }
  60916. }
  60917. declare module "babylonjs/Helpers/index" {
  60918. export * from "babylonjs/Helpers/environmentHelper";
  60919. export * from "babylonjs/Helpers/photoDome";
  60920. export * from "babylonjs/Helpers/sceneHelpers";
  60921. export * from "babylonjs/Helpers/videoDome";
  60922. }
  60923. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60924. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60925. import { IDisposable } from "babylonjs/scene";
  60926. import { Engine } from "babylonjs/Engines/engine";
  60927. /**
  60928. * This class can be used to get instrumentation data from a Babylon engine
  60929. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60930. */
  60931. export class EngineInstrumentation implements IDisposable {
  60932. /**
  60933. * Define the instrumented engine.
  60934. */
  60935. engine: Engine;
  60936. private _captureGPUFrameTime;
  60937. private _gpuFrameTimeToken;
  60938. private _gpuFrameTime;
  60939. private _captureShaderCompilationTime;
  60940. private _shaderCompilationTime;
  60941. private _onBeginFrameObserver;
  60942. private _onEndFrameObserver;
  60943. private _onBeforeShaderCompilationObserver;
  60944. private _onAfterShaderCompilationObserver;
  60945. /**
  60946. * Gets the perf counter used for GPU frame time
  60947. */
  60948. get gpuFrameTimeCounter(): PerfCounter;
  60949. /**
  60950. * Gets the GPU frame time capture status
  60951. */
  60952. get captureGPUFrameTime(): boolean;
  60953. /**
  60954. * Enable or disable the GPU frame time capture
  60955. */
  60956. set captureGPUFrameTime(value: boolean);
  60957. /**
  60958. * Gets the perf counter used for shader compilation time
  60959. */
  60960. get shaderCompilationTimeCounter(): PerfCounter;
  60961. /**
  60962. * Gets the shader compilation time capture status
  60963. */
  60964. get captureShaderCompilationTime(): boolean;
  60965. /**
  60966. * Enable or disable the shader compilation time capture
  60967. */
  60968. set captureShaderCompilationTime(value: boolean);
  60969. /**
  60970. * Instantiates a new engine instrumentation.
  60971. * This class can be used to get instrumentation data from a Babylon engine
  60972. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60973. * @param engine Defines the engine to instrument
  60974. */
  60975. constructor(
  60976. /**
  60977. * Define the instrumented engine.
  60978. */
  60979. engine: Engine);
  60980. /**
  60981. * Dispose and release associated resources.
  60982. */
  60983. dispose(): void;
  60984. }
  60985. }
  60986. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60987. import { Scene, IDisposable } from "babylonjs/scene";
  60988. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60989. /**
  60990. * This class can be used to get instrumentation data from a Babylon engine
  60991. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60992. */
  60993. export class SceneInstrumentation implements IDisposable {
  60994. /**
  60995. * Defines the scene to instrument
  60996. */
  60997. scene: Scene;
  60998. private _captureActiveMeshesEvaluationTime;
  60999. private _activeMeshesEvaluationTime;
  61000. private _captureRenderTargetsRenderTime;
  61001. private _renderTargetsRenderTime;
  61002. private _captureFrameTime;
  61003. private _frameTime;
  61004. private _captureRenderTime;
  61005. private _renderTime;
  61006. private _captureInterFrameTime;
  61007. private _interFrameTime;
  61008. private _captureParticlesRenderTime;
  61009. private _particlesRenderTime;
  61010. private _captureSpritesRenderTime;
  61011. private _spritesRenderTime;
  61012. private _capturePhysicsTime;
  61013. private _physicsTime;
  61014. private _captureAnimationsTime;
  61015. private _animationsTime;
  61016. private _captureCameraRenderTime;
  61017. private _cameraRenderTime;
  61018. private _onBeforeActiveMeshesEvaluationObserver;
  61019. private _onAfterActiveMeshesEvaluationObserver;
  61020. private _onBeforeRenderTargetsRenderObserver;
  61021. private _onAfterRenderTargetsRenderObserver;
  61022. private _onAfterRenderObserver;
  61023. private _onBeforeDrawPhaseObserver;
  61024. private _onAfterDrawPhaseObserver;
  61025. private _onBeforeAnimationsObserver;
  61026. private _onBeforeParticlesRenderingObserver;
  61027. private _onAfterParticlesRenderingObserver;
  61028. private _onBeforeSpritesRenderingObserver;
  61029. private _onAfterSpritesRenderingObserver;
  61030. private _onBeforePhysicsObserver;
  61031. private _onAfterPhysicsObserver;
  61032. private _onAfterAnimationsObserver;
  61033. private _onBeforeCameraRenderObserver;
  61034. private _onAfterCameraRenderObserver;
  61035. /**
  61036. * Gets the perf counter used for active meshes evaluation time
  61037. */
  61038. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61039. /**
  61040. * Gets the active meshes evaluation time capture status
  61041. */
  61042. get captureActiveMeshesEvaluationTime(): boolean;
  61043. /**
  61044. * Enable or disable the active meshes evaluation time capture
  61045. */
  61046. set captureActiveMeshesEvaluationTime(value: boolean);
  61047. /**
  61048. * Gets the perf counter used for render targets render time
  61049. */
  61050. get renderTargetsRenderTimeCounter(): PerfCounter;
  61051. /**
  61052. * Gets the render targets render time capture status
  61053. */
  61054. get captureRenderTargetsRenderTime(): boolean;
  61055. /**
  61056. * Enable or disable the render targets render time capture
  61057. */
  61058. set captureRenderTargetsRenderTime(value: boolean);
  61059. /**
  61060. * Gets the perf counter used for particles render time
  61061. */
  61062. get particlesRenderTimeCounter(): PerfCounter;
  61063. /**
  61064. * Gets the particles render time capture status
  61065. */
  61066. get captureParticlesRenderTime(): boolean;
  61067. /**
  61068. * Enable or disable the particles render time capture
  61069. */
  61070. set captureParticlesRenderTime(value: boolean);
  61071. /**
  61072. * Gets the perf counter used for sprites render time
  61073. */
  61074. get spritesRenderTimeCounter(): PerfCounter;
  61075. /**
  61076. * Gets the sprites render time capture status
  61077. */
  61078. get captureSpritesRenderTime(): boolean;
  61079. /**
  61080. * Enable or disable the sprites render time capture
  61081. */
  61082. set captureSpritesRenderTime(value: boolean);
  61083. /**
  61084. * Gets the perf counter used for physics time
  61085. */
  61086. get physicsTimeCounter(): PerfCounter;
  61087. /**
  61088. * Gets the physics time capture status
  61089. */
  61090. get capturePhysicsTime(): boolean;
  61091. /**
  61092. * Enable or disable the physics time capture
  61093. */
  61094. set capturePhysicsTime(value: boolean);
  61095. /**
  61096. * Gets the perf counter used for animations time
  61097. */
  61098. get animationsTimeCounter(): PerfCounter;
  61099. /**
  61100. * Gets the animations time capture status
  61101. */
  61102. get captureAnimationsTime(): boolean;
  61103. /**
  61104. * Enable or disable the animations time capture
  61105. */
  61106. set captureAnimationsTime(value: boolean);
  61107. /**
  61108. * Gets the perf counter used for frame time capture
  61109. */
  61110. get frameTimeCounter(): PerfCounter;
  61111. /**
  61112. * Gets the frame time capture status
  61113. */
  61114. get captureFrameTime(): boolean;
  61115. /**
  61116. * Enable or disable the frame time capture
  61117. */
  61118. set captureFrameTime(value: boolean);
  61119. /**
  61120. * Gets the perf counter used for inter-frames time capture
  61121. */
  61122. get interFrameTimeCounter(): PerfCounter;
  61123. /**
  61124. * Gets the inter-frames time capture status
  61125. */
  61126. get captureInterFrameTime(): boolean;
  61127. /**
  61128. * Enable or disable the inter-frames time capture
  61129. */
  61130. set captureInterFrameTime(value: boolean);
  61131. /**
  61132. * Gets the perf counter used for render time capture
  61133. */
  61134. get renderTimeCounter(): PerfCounter;
  61135. /**
  61136. * Gets the render time capture status
  61137. */
  61138. get captureRenderTime(): boolean;
  61139. /**
  61140. * Enable or disable the render time capture
  61141. */
  61142. set captureRenderTime(value: boolean);
  61143. /**
  61144. * Gets the perf counter used for camera render time capture
  61145. */
  61146. get cameraRenderTimeCounter(): PerfCounter;
  61147. /**
  61148. * Gets the camera render time capture status
  61149. */
  61150. get captureCameraRenderTime(): boolean;
  61151. /**
  61152. * Enable or disable the camera render time capture
  61153. */
  61154. set captureCameraRenderTime(value: boolean);
  61155. /**
  61156. * Gets the perf counter used for draw calls
  61157. */
  61158. get drawCallsCounter(): PerfCounter;
  61159. /**
  61160. * Instantiates a new scene instrumentation.
  61161. * This class can be used to get instrumentation data from a Babylon engine
  61162. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61163. * @param scene Defines the scene to instrument
  61164. */
  61165. constructor(
  61166. /**
  61167. * Defines the scene to instrument
  61168. */
  61169. scene: Scene);
  61170. /**
  61171. * Dispose and release associated resources.
  61172. */
  61173. dispose(): void;
  61174. }
  61175. }
  61176. declare module "babylonjs/Instrumentation/index" {
  61177. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61178. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61179. export * from "babylonjs/Instrumentation/timeToken";
  61180. }
  61181. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61182. /** @hidden */
  61183. export var glowMapGenerationPixelShader: {
  61184. name: string;
  61185. shader: string;
  61186. };
  61187. }
  61188. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61189. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61190. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61191. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61192. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61193. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61194. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61195. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61196. /** @hidden */
  61197. export var glowMapGenerationVertexShader: {
  61198. name: string;
  61199. shader: string;
  61200. };
  61201. }
  61202. declare module "babylonjs/Layers/effectLayer" {
  61203. import { Observable } from "babylonjs/Misc/observable";
  61204. import { Nullable } from "babylonjs/types";
  61205. import { Camera } from "babylonjs/Cameras/camera";
  61206. import { Scene } from "babylonjs/scene";
  61207. import { ISize } from "babylonjs/Maths/math.size";
  61208. import { Color4 } from "babylonjs/Maths/math.color";
  61209. import { Engine } from "babylonjs/Engines/engine";
  61210. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61212. import { Mesh } from "babylonjs/Meshes/mesh";
  61213. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61214. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61215. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61216. import { Effect } from "babylonjs/Materials/effect";
  61217. import { Material } from "babylonjs/Materials/material";
  61218. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61219. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61220. /**
  61221. * Effect layer options. This helps customizing the behaviour
  61222. * of the effect layer.
  61223. */
  61224. export interface IEffectLayerOptions {
  61225. /**
  61226. * Multiplication factor apply to the canvas size to compute the render target size
  61227. * used to generated the objects (the smaller the faster).
  61228. */
  61229. mainTextureRatio: number;
  61230. /**
  61231. * Enforces a fixed size texture to ensure effect stability across devices.
  61232. */
  61233. mainTextureFixedSize?: number;
  61234. /**
  61235. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61236. */
  61237. alphaBlendingMode: number;
  61238. /**
  61239. * The camera attached to the layer.
  61240. */
  61241. camera: Nullable<Camera>;
  61242. /**
  61243. * The rendering group to draw the layer in.
  61244. */
  61245. renderingGroupId: number;
  61246. }
  61247. /**
  61248. * The effect layer Helps adding post process effect blended with the main pass.
  61249. *
  61250. * This can be for instance use to generate glow or higlight effects on the scene.
  61251. *
  61252. * The effect layer class can not be used directly and is intented to inherited from to be
  61253. * customized per effects.
  61254. */
  61255. export abstract class EffectLayer {
  61256. private _vertexBuffers;
  61257. private _indexBuffer;
  61258. private _cachedDefines;
  61259. private _effectLayerMapGenerationEffect;
  61260. private _effectLayerOptions;
  61261. private _mergeEffect;
  61262. protected _scene: Scene;
  61263. protected _engine: Engine;
  61264. protected _maxSize: number;
  61265. protected _mainTextureDesiredSize: ISize;
  61266. protected _mainTexture: RenderTargetTexture;
  61267. protected _shouldRender: boolean;
  61268. protected _postProcesses: PostProcess[];
  61269. protected _textures: BaseTexture[];
  61270. protected _emissiveTextureAndColor: {
  61271. texture: Nullable<BaseTexture>;
  61272. color: Color4;
  61273. };
  61274. /**
  61275. * The name of the layer
  61276. */
  61277. name: string;
  61278. /**
  61279. * The clear color of the texture used to generate the glow map.
  61280. */
  61281. neutralColor: Color4;
  61282. /**
  61283. * Specifies whether the highlight layer is enabled or not.
  61284. */
  61285. isEnabled: boolean;
  61286. /**
  61287. * Gets the camera attached to the layer.
  61288. */
  61289. get camera(): Nullable<Camera>;
  61290. /**
  61291. * Gets the rendering group id the layer should render in.
  61292. */
  61293. get renderingGroupId(): number;
  61294. set renderingGroupId(renderingGroupId: number);
  61295. /**
  61296. * An event triggered when the effect layer has been disposed.
  61297. */
  61298. onDisposeObservable: Observable<EffectLayer>;
  61299. /**
  61300. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61301. */
  61302. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61303. /**
  61304. * An event triggered when the generated texture is being merged in the scene.
  61305. */
  61306. onBeforeComposeObservable: Observable<EffectLayer>;
  61307. /**
  61308. * An event triggered when the mesh is rendered into the effect render target.
  61309. */
  61310. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61311. /**
  61312. * An event triggered after the mesh has been rendered into the effect render target.
  61313. */
  61314. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61315. /**
  61316. * An event triggered when the generated texture has been merged in the scene.
  61317. */
  61318. onAfterComposeObservable: Observable<EffectLayer>;
  61319. /**
  61320. * An event triggered when the efffect layer changes its size.
  61321. */
  61322. onSizeChangedObservable: Observable<EffectLayer>;
  61323. /** @hidden */
  61324. static _SceneComponentInitialization: (scene: Scene) => void;
  61325. /**
  61326. * Instantiates a new effect Layer and references it in the scene.
  61327. * @param name The name of the layer
  61328. * @param scene The scene to use the layer in
  61329. */
  61330. constructor(
  61331. /** The Friendly of the effect in the scene */
  61332. name: string, scene: Scene);
  61333. /**
  61334. * Get the effect name of the layer.
  61335. * @return The effect name
  61336. */
  61337. abstract getEffectName(): string;
  61338. /**
  61339. * Checks for the readiness of the element composing the layer.
  61340. * @param subMesh the mesh to check for
  61341. * @param useInstances specify whether or not to use instances to render the mesh
  61342. * @return true if ready otherwise, false
  61343. */
  61344. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61345. /**
  61346. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61347. * @returns true if the effect requires stencil during the main canvas render pass.
  61348. */
  61349. abstract needStencil(): boolean;
  61350. /**
  61351. * Create the merge effect. This is the shader use to blit the information back
  61352. * to the main canvas at the end of the scene rendering.
  61353. * @returns The effect containing the shader used to merge the effect on the main canvas
  61354. */
  61355. protected abstract _createMergeEffect(): Effect;
  61356. /**
  61357. * Creates the render target textures and post processes used in the effect layer.
  61358. */
  61359. protected abstract _createTextureAndPostProcesses(): void;
  61360. /**
  61361. * Implementation specific of rendering the generating effect on the main canvas.
  61362. * @param effect The effect used to render through
  61363. */
  61364. protected abstract _internalRender(effect: Effect): void;
  61365. /**
  61366. * Sets the required values for both the emissive texture and and the main color.
  61367. */
  61368. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61369. /**
  61370. * Free any resources and references associated to a mesh.
  61371. * Internal use
  61372. * @param mesh The mesh to free.
  61373. */
  61374. abstract _disposeMesh(mesh: Mesh): void;
  61375. /**
  61376. * Serializes this layer (Glow or Highlight for example)
  61377. * @returns a serialized layer object
  61378. */
  61379. abstract serialize?(): any;
  61380. /**
  61381. * Initializes the effect layer with the required options.
  61382. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61383. */
  61384. protected _init(options: Partial<IEffectLayerOptions>): void;
  61385. /**
  61386. * Generates the index buffer of the full screen quad blending to the main canvas.
  61387. */
  61388. private _generateIndexBuffer;
  61389. /**
  61390. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61391. */
  61392. private _generateVertexBuffer;
  61393. /**
  61394. * Sets the main texture desired size which is the closest power of two
  61395. * of the engine canvas size.
  61396. */
  61397. private _setMainTextureSize;
  61398. /**
  61399. * Creates the main texture for the effect layer.
  61400. */
  61401. protected _createMainTexture(): void;
  61402. /**
  61403. * Adds specific effects defines.
  61404. * @param defines The defines to add specifics to.
  61405. */
  61406. protected _addCustomEffectDefines(defines: string[]): void;
  61407. /**
  61408. * Checks for the readiness of the element composing the layer.
  61409. * @param subMesh the mesh to check for
  61410. * @param useInstances specify whether or not to use instances to render the mesh
  61411. * @param emissiveTexture the associated emissive texture used to generate the glow
  61412. * @return true if ready otherwise, false
  61413. */
  61414. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61415. /**
  61416. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61417. */
  61418. render(): void;
  61419. /**
  61420. * Determine if a given mesh will be used in the current effect.
  61421. * @param mesh mesh to test
  61422. * @returns true if the mesh will be used
  61423. */
  61424. hasMesh(mesh: AbstractMesh): boolean;
  61425. /**
  61426. * Returns true if the layer contains information to display, otherwise false.
  61427. * @returns true if the glow layer should be rendered
  61428. */
  61429. shouldRender(): boolean;
  61430. /**
  61431. * Returns true if the mesh should render, otherwise false.
  61432. * @param mesh The mesh to render
  61433. * @returns true if it should render otherwise false
  61434. */
  61435. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61436. /**
  61437. * Returns true if the mesh can be rendered, otherwise false.
  61438. * @param mesh The mesh to render
  61439. * @param material The material used on the mesh
  61440. * @returns true if it can be rendered otherwise false
  61441. */
  61442. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61443. /**
  61444. * Returns true if the mesh should render, otherwise false.
  61445. * @param mesh The mesh to render
  61446. * @returns true if it should render otherwise false
  61447. */
  61448. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61449. /**
  61450. * Renders the submesh passed in parameter to the generation map.
  61451. */
  61452. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61453. /**
  61454. * Defines whether the current material of the mesh should be use to render the effect.
  61455. * @param mesh defines the current mesh to render
  61456. */
  61457. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61458. /**
  61459. * Rebuild the required buffers.
  61460. * @hidden Internal use only.
  61461. */
  61462. _rebuild(): void;
  61463. /**
  61464. * Dispose only the render target textures and post process.
  61465. */
  61466. private _disposeTextureAndPostProcesses;
  61467. /**
  61468. * Dispose the highlight layer and free resources.
  61469. */
  61470. dispose(): void;
  61471. /**
  61472. * Gets the class name of the effect layer
  61473. * @returns the string with the class name of the effect layer
  61474. */
  61475. getClassName(): string;
  61476. /**
  61477. * Creates an effect layer from parsed effect layer data
  61478. * @param parsedEffectLayer defines effect layer data
  61479. * @param scene defines the current scene
  61480. * @param rootUrl defines the root URL containing the effect layer information
  61481. * @returns a parsed effect Layer
  61482. */
  61483. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61484. }
  61485. }
  61486. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61487. import { Scene } from "babylonjs/scene";
  61488. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61489. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61490. import { AbstractScene } from "babylonjs/abstractScene";
  61491. module "babylonjs/abstractScene" {
  61492. interface AbstractScene {
  61493. /**
  61494. * The list of effect layers (highlights/glow) added to the scene
  61495. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61496. * @see https://doc.babylonjs.com/how_to/glow_layer
  61497. */
  61498. effectLayers: Array<EffectLayer>;
  61499. /**
  61500. * Removes the given effect layer from this scene.
  61501. * @param toRemove defines the effect layer to remove
  61502. * @returns the index of the removed effect layer
  61503. */
  61504. removeEffectLayer(toRemove: EffectLayer): number;
  61505. /**
  61506. * Adds the given effect layer to this scene
  61507. * @param newEffectLayer defines the effect layer to add
  61508. */
  61509. addEffectLayer(newEffectLayer: EffectLayer): void;
  61510. }
  61511. }
  61512. /**
  61513. * Defines the layer scene component responsible to manage any effect layers
  61514. * in a given scene.
  61515. */
  61516. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61517. /**
  61518. * The component name helpfull to identify the component in the list of scene components.
  61519. */
  61520. readonly name: string;
  61521. /**
  61522. * The scene the component belongs to.
  61523. */
  61524. scene: Scene;
  61525. private _engine;
  61526. private _renderEffects;
  61527. private _needStencil;
  61528. private _previousStencilState;
  61529. /**
  61530. * Creates a new instance of the component for the given scene
  61531. * @param scene Defines the scene to register the component in
  61532. */
  61533. constructor(scene: Scene);
  61534. /**
  61535. * Registers the component in a given scene
  61536. */
  61537. register(): void;
  61538. /**
  61539. * Rebuilds the elements related to this component in case of
  61540. * context lost for instance.
  61541. */
  61542. rebuild(): void;
  61543. /**
  61544. * Serializes the component data to the specified json object
  61545. * @param serializationObject The object to serialize to
  61546. */
  61547. serialize(serializationObject: any): void;
  61548. /**
  61549. * Adds all the elements from the container to the scene
  61550. * @param container the container holding the elements
  61551. */
  61552. addFromContainer(container: AbstractScene): void;
  61553. /**
  61554. * Removes all the elements in the container from the scene
  61555. * @param container contains the elements to remove
  61556. * @param dispose if the removed element should be disposed (default: false)
  61557. */
  61558. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61559. /**
  61560. * Disposes the component and the associated ressources.
  61561. */
  61562. dispose(): void;
  61563. private _isReadyForMesh;
  61564. private _renderMainTexture;
  61565. private _setStencil;
  61566. private _setStencilBack;
  61567. private _draw;
  61568. private _drawCamera;
  61569. private _drawRenderingGroup;
  61570. }
  61571. }
  61572. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61573. /** @hidden */
  61574. export var glowMapMergePixelShader: {
  61575. name: string;
  61576. shader: string;
  61577. };
  61578. }
  61579. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61580. /** @hidden */
  61581. export var glowMapMergeVertexShader: {
  61582. name: string;
  61583. shader: string;
  61584. };
  61585. }
  61586. declare module "babylonjs/Layers/glowLayer" {
  61587. import { Nullable } from "babylonjs/types";
  61588. import { Camera } from "babylonjs/Cameras/camera";
  61589. import { Scene } from "babylonjs/scene";
  61590. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61592. import { Mesh } from "babylonjs/Meshes/mesh";
  61593. import { Texture } from "babylonjs/Materials/Textures/texture";
  61594. import { Effect } from "babylonjs/Materials/effect";
  61595. import { Material } from "babylonjs/Materials/material";
  61596. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61597. import { Color4 } from "babylonjs/Maths/math.color";
  61598. import "babylonjs/Shaders/glowMapMerge.fragment";
  61599. import "babylonjs/Shaders/glowMapMerge.vertex";
  61600. import "babylonjs/Layers/effectLayerSceneComponent";
  61601. module "babylonjs/abstractScene" {
  61602. interface AbstractScene {
  61603. /**
  61604. * Return a the first highlight layer of the scene with a given name.
  61605. * @param name The name of the highlight layer to look for.
  61606. * @return The highlight layer if found otherwise null.
  61607. */
  61608. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61609. }
  61610. }
  61611. /**
  61612. * Glow layer options. This helps customizing the behaviour
  61613. * of the glow layer.
  61614. */
  61615. export interface IGlowLayerOptions {
  61616. /**
  61617. * Multiplication factor apply to the canvas size to compute the render target size
  61618. * used to generated the glowing objects (the smaller the faster).
  61619. */
  61620. mainTextureRatio: number;
  61621. /**
  61622. * Enforces a fixed size texture to ensure resize independant blur.
  61623. */
  61624. mainTextureFixedSize?: number;
  61625. /**
  61626. * How big is the kernel of the blur texture.
  61627. */
  61628. blurKernelSize: number;
  61629. /**
  61630. * The camera attached to the layer.
  61631. */
  61632. camera: Nullable<Camera>;
  61633. /**
  61634. * Enable MSAA by chosing the number of samples.
  61635. */
  61636. mainTextureSamples?: number;
  61637. /**
  61638. * The rendering group to draw the layer in.
  61639. */
  61640. renderingGroupId: number;
  61641. }
  61642. /**
  61643. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61644. *
  61645. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61646. *
  61647. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61648. */
  61649. export class GlowLayer extends EffectLayer {
  61650. /**
  61651. * Effect Name of the layer.
  61652. */
  61653. static readonly EffectName: string;
  61654. /**
  61655. * The default blur kernel size used for the glow.
  61656. */
  61657. static DefaultBlurKernelSize: number;
  61658. /**
  61659. * The default texture size ratio used for the glow.
  61660. */
  61661. static DefaultTextureRatio: number;
  61662. /**
  61663. * Sets the kernel size of the blur.
  61664. */
  61665. set blurKernelSize(value: number);
  61666. /**
  61667. * Gets the kernel size of the blur.
  61668. */
  61669. get blurKernelSize(): number;
  61670. /**
  61671. * Sets the glow intensity.
  61672. */
  61673. set intensity(value: number);
  61674. /**
  61675. * Gets the glow intensity.
  61676. */
  61677. get intensity(): number;
  61678. private _options;
  61679. private _intensity;
  61680. private _horizontalBlurPostprocess1;
  61681. private _verticalBlurPostprocess1;
  61682. private _horizontalBlurPostprocess2;
  61683. private _verticalBlurPostprocess2;
  61684. private _blurTexture1;
  61685. private _blurTexture2;
  61686. private _postProcesses1;
  61687. private _postProcesses2;
  61688. private _includedOnlyMeshes;
  61689. private _excludedMeshes;
  61690. private _meshesUsingTheirOwnMaterials;
  61691. /**
  61692. * Callback used to let the user override the color selection on a per mesh basis
  61693. */
  61694. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61695. /**
  61696. * Callback used to let the user override the texture selection on a per mesh basis
  61697. */
  61698. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61699. /**
  61700. * Instantiates a new glow Layer and references it to the scene.
  61701. * @param name The name of the layer
  61702. * @param scene The scene to use the layer in
  61703. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61704. */
  61705. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61706. /**
  61707. * Get the effect name of the layer.
  61708. * @return The effect name
  61709. */
  61710. getEffectName(): string;
  61711. /**
  61712. * Create the merge effect. This is the shader use to blit the information back
  61713. * to the main canvas at the end of the scene rendering.
  61714. */
  61715. protected _createMergeEffect(): Effect;
  61716. /**
  61717. * Creates the render target textures and post processes used in the glow layer.
  61718. */
  61719. protected _createTextureAndPostProcesses(): void;
  61720. /**
  61721. * Checks for the readiness of the element composing the layer.
  61722. * @param subMesh the mesh to check for
  61723. * @param useInstances specify wether or not to use instances to render the mesh
  61724. * @param emissiveTexture the associated emissive texture used to generate the glow
  61725. * @return true if ready otherwise, false
  61726. */
  61727. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61728. /**
  61729. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61730. */
  61731. needStencil(): boolean;
  61732. /**
  61733. * Returns true if the mesh can be rendered, otherwise false.
  61734. * @param mesh The mesh to render
  61735. * @param material The material used on the mesh
  61736. * @returns true if it can be rendered otherwise false
  61737. */
  61738. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61739. /**
  61740. * Implementation specific of rendering the generating effect on the main canvas.
  61741. * @param effect The effect used to render through
  61742. */
  61743. protected _internalRender(effect: Effect): void;
  61744. /**
  61745. * Sets the required values for both the emissive texture and and the main color.
  61746. */
  61747. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61748. /**
  61749. * Returns true if the mesh should render, otherwise false.
  61750. * @param mesh The mesh to render
  61751. * @returns true if it should render otherwise false
  61752. */
  61753. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61754. /**
  61755. * Adds specific effects defines.
  61756. * @param defines The defines to add specifics to.
  61757. */
  61758. protected _addCustomEffectDefines(defines: string[]): void;
  61759. /**
  61760. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61761. * @param mesh The mesh to exclude from the glow layer
  61762. */
  61763. addExcludedMesh(mesh: Mesh): void;
  61764. /**
  61765. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61766. * @param mesh The mesh to remove
  61767. */
  61768. removeExcludedMesh(mesh: Mesh): void;
  61769. /**
  61770. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61771. * @param mesh The mesh to include in the glow layer
  61772. */
  61773. addIncludedOnlyMesh(mesh: Mesh): void;
  61774. /**
  61775. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61776. * @param mesh The mesh to remove
  61777. */
  61778. removeIncludedOnlyMesh(mesh: Mesh): void;
  61779. /**
  61780. * Determine if a given mesh will be used in the glow layer
  61781. * @param mesh The mesh to test
  61782. * @returns true if the mesh will be highlighted by the current glow layer
  61783. */
  61784. hasMesh(mesh: AbstractMesh): boolean;
  61785. /**
  61786. * Defines whether the current material of the mesh should be use to render the effect.
  61787. * @param mesh defines the current mesh to render
  61788. */
  61789. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61790. /**
  61791. * Add a mesh to be rendered through its own material and not with emissive only.
  61792. * @param mesh The mesh for which we need to use its material
  61793. */
  61794. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61795. /**
  61796. * Remove a mesh from being rendered through its own material and not with emissive only.
  61797. * @param mesh The mesh for which we need to not use its material
  61798. */
  61799. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61800. /**
  61801. * Free any resources and references associated to a mesh.
  61802. * Internal use
  61803. * @param mesh The mesh to free.
  61804. * @hidden
  61805. */
  61806. _disposeMesh(mesh: Mesh): void;
  61807. /**
  61808. * Gets the class name of the effect layer
  61809. * @returns the string with the class name of the effect layer
  61810. */
  61811. getClassName(): string;
  61812. /**
  61813. * Serializes this glow layer
  61814. * @returns a serialized glow layer object
  61815. */
  61816. serialize(): any;
  61817. /**
  61818. * Creates a Glow Layer from parsed glow layer data
  61819. * @param parsedGlowLayer defines glow layer data
  61820. * @param scene defines the current scene
  61821. * @param rootUrl defines the root URL containing the glow layer information
  61822. * @returns a parsed Glow Layer
  61823. */
  61824. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61825. }
  61826. }
  61827. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61828. /** @hidden */
  61829. export var glowBlurPostProcessPixelShader: {
  61830. name: string;
  61831. shader: string;
  61832. };
  61833. }
  61834. declare module "babylonjs/Layers/highlightLayer" {
  61835. import { Observable } from "babylonjs/Misc/observable";
  61836. import { Nullable } from "babylonjs/types";
  61837. import { Camera } from "babylonjs/Cameras/camera";
  61838. import { Scene } from "babylonjs/scene";
  61839. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61841. import { Mesh } from "babylonjs/Meshes/mesh";
  61842. import { Effect } from "babylonjs/Materials/effect";
  61843. import { Material } from "babylonjs/Materials/material";
  61844. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61845. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61846. import "babylonjs/Shaders/glowMapMerge.fragment";
  61847. import "babylonjs/Shaders/glowMapMerge.vertex";
  61848. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61849. module "babylonjs/abstractScene" {
  61850. interface AbstractScene {
  61851. /**
  61852. * Return a the first highlight layer of the scene with a given name.
  61853. * @param name The name of the highlight layer to look for.
  61854. * @return The highlight layer if found otherwise null.
  61855. */
  61856. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61857. }
  61858. }
  61859. /**
  61860. * Highlight layer options. This helps customizing the behaviour
  61861. * of the highlight layer.
  61862. */
  61863. export interface IHighlightLayerOptions {
  61864. /**
  61865. * Multiplication factor apply to the canvas size to compute the render target size
  61866. * used to generated the glowing objects (the smaller the faster).
  61867. */
  61868. mainTextureRatio: number;
  61869. /**
  61870. * Enforces a fixed size texture to ensure resize independant blur.
  61871. */
  61872. mainTextureFixedSize?: number;
  61873. /**
  61874. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61875. * of the picture to blur (the smaller the faster).
  61876. */
  61877. blurTextureSizeRatio: number;
  61878. /**
  61879. * How big in texel of the blur texture is the vertical blur.
  61880. */
  61881. blurVerticalSize: number;
  61882. /**
  61883. * How big in texel of the blur texture is the horizontal blur.
  61884. */
  61885. blurHorizontalSize: number;
  61886. /**
  61887. * Alpha blending mode used to apply the blur. Default is combine.
  61888. */
  61889. alphaBlendingMode: number;
  61890. /**
  61891. * The camera attached to the layer.
  61892. */
  61893. camera: Nullable<Camera>;
  61894. /**
  61895. * Should we display highlight as a solid stroke?
  61896. */
  61897. isStroke?: boolean;
  61898. /**
  61899. * The rendering group to draw the layer in.
  61900. */
  61901. renderingGroupId: number;
  61902. }
  61903. /**
  61904. * The highlight layer Helps adding a glow effect around a mesh.
  61905. *
  61906. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61907. * glowy meshes to your scene.
  61908. *
  61909. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61910. */
  61911. export class HighlightLayer extends EffectLayer {
  61912. name: string;
  61913. /**
  61914. * Effect Name of the highlight layer.
  61915. */
  61916. static readonly EffectName: string;
  61917. /**
  61918. * The neutral color used during the preparation of the glow effect.
  61919. * This is black by default as the blend operation is a blend operation.
  61920. */
  61921. static NeutralColor: Color4;
  61922. /**
  61923. * Stencil value used for glowing meshes.
  61924. */
  61925. static GlowingMeshStencilReference: number;
  61926. /**
  61927. * Stencil value used for the other meshes in the scene.
  61928. */
  61929. static NormalMeshStencilReference: number;
  61930. /**
  61931. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61932. */
  61933. innerGlow: boolean;
  61934. /**
  61935. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61936. */
  61937. outerGlow: boolean;
  61938. /**
  61939. * Specifies the horizontal size of the blur.
  61940. */
  61941. set blurHorizontalSize(value: number);
  61942. /**
  61943. * Specifies the vertical size of the blur.
  61944. */
  61945. set blurVerticalSize(value: number);
  61946. /**
  61947. * Gets the horizontal size of the blur.
  61948. */
  61949. get blurHorizontalSize(): number;
  61950. /**
  61951. * Gets the vertical size of the blur.
  61952. */
  61953. get blurVerticalSize(): number;
  61954. /**
  61955. * An event triggered when the highlight layer is being blurred.
  61956. */
  61957. onBeforeBlurObservable: Observable<HighlightLayer>;
  61958. /**
  61959. * An event triggered when the highlight layer has been blurred.
  61960. */
  61961. onAfterBlurObservable: Observable<HighlightLayer>;
  61962. private _instanceGlowingMeshStencilReference;
  61963. private _options;
  61964. private _downSamplePostprocess;
  61965. private _horizontalBlurPostprocess;
  61966. private _verticalBlurPostprocess;
  61967. private _blurTexture;
  61968. private _meshes;
  61969. private _excludedMeshes;
  61970. /**
  61971. * Instantiates a new highlight Layer and references it to the scene..
  61972. * @param name The name of the layer
  61973. * @param scene The scene to use the layer in
  61974. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61975. */
  61976. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61977. /**
  61978. * Get the effect name of the layer.
  61979. * @return The effect name
  61980. */
  61981. getEffectName(): string;
  61982. /**
  61983. * Create the merge effect. This is the shader use to blit the information back
  61984. * to the main canvas at the end of the scene rendering.
  61985. */
  61986. protected _createMergeEffect(): Effect;
  61987. /**
  61988. * Creates the render target textures and post processes used in the highlight layer.
  61989. */
  61990. protected _createTextureAndPostProcesses(): void;
  61991. /**
  61992. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61993. */
  61994. needStencil(): boolean;
  61995. /**
  61996. * Checks for the readiness of the element composing the layer.
  61997. * @param subMesh the mesh to check for
  61998. * @param useInstances specify wether or not to use instances to render the mesh
  61999. * @param emissiveTexture the associated emissive texture used to generate the glow
  62000. * @return true if ready otherwise, false
  62001. */
  62002. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62003. /**
  62004. * Implementation specific of rendering the generating effect on the main canvas.
  62005. * @param effect The effect used to render through
  62006. */
  62007. protected _internalRender(effect: Effect): void;
  62008. /**
  62009. * Returns true if the layer contains information to display, otherwise false.
  62010. */
  62011. shouldRender(): boolean;
  62012. /**
  62013. * Returns true if the mesh should render, otherwise false.
  62014. * @param mesh The mesh to render
  62015. * @returns true if it should render otherwise false
  62016. */
  62017. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62018. /**
  62019. * Returns true if the mesh can be rendered, otherwise false.
  62020. * @param mesh The mesh to render
  62021. * @param material The material used on the mesh
  62022. * @returns true if it can be rendered otherwise false
  62023. */
  62024. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62025. /**
  62026. * Adds specific effects defines.
  62027. * @param defines The defines to add specifics to.
  62028. */
  62029. protected _addCustomEffectDefines(defines: string[]): void;
  62030. /**
  62031. * Sets the required values for both the emissive texture and and the main color.
  62032. */
  62033. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62034. /**
  62035. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62036. * @param mesh The mesh to exclude from the highlight layer
  62037. */
  62038. addExcludedMesh(mesh: Mesh): void;
  62039. /**
  62040. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62041. * @param mesh The mesh to highlight
  62042. */
  62043. removeExcludedMesh(mesh: Mesh): void;
  62044. /**
  62045. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62046. * @param mesh mesh to test
  62047. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62048. */
  62049. hasMesh(mesh: AbstractMesh): boolean;
  62050. /**
  62051. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62052. * @param mesh The mesh to highlight
  62053. * @param color The color of the highlight
  62054. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62055. */
  62056. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62057. /**
  62058. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62059. * @param mesh The mesh to highlight
  62060. */
  62061. removeMesh(mesh: Mesh): void;
  62062. /**
  62063. * Remove all the meshes currently referenced in the highlight layer
  62064. */
  62065. removeAllMeshes(): void;
  62066. /**
  62067. * Force the stencil to the normal expected value for none glowing parts
  62068. */
  62069. private _defaultStencilReference;
  62070. /**
  62071. * Free any resources and references associated to a mesh.
  62072. * Internal use
  62073. * @param mesh The mesh to free.
  62074. * @hidden
  62075. */
  62076. _disposeMesh(mesh: Mesh): void;
  62077. /**
  62078. * Dispose the highlight layer and free resources.
  62079. */
  62080. dispose(): void;
  62081. /**
  62082. * Gets the class name of the effect layer
  62083. * @returns the string with the class name of the effect layer
  62084. */
  62085. getClassName(): string;
  62086. /**
  62087. * Serializes this Highlight layer
  62088. * @returns a serialized Highlight layer object
  62089. */
  62090. serialize(): any;
  62091. /**
  62092. * Creates a Highlight layer from parsed Highlight layer data
  62093. * @param parsedHightlightLayer defines the Highlight layer data
  62094. * @param scene defines the current scene
  62095. * @param rootUrl defines the root URL containing the Highlight layer information
  62096. * @returns a parsed Highlight layer
  62097. */
  62098. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62099. }
  62100. }
  62101. declare module "babylonjs/Layers/layerSceneComponent" {
  62102. import { Scene } from "babylonjs/scene";
  62103. import { ISceneComponent } from "babylonjs/sceneComponent";
  62104. import { Layer } from "babylonjs/Layers/layer";
  62105. import { AbstractScene } from "babylonjs/abstractScene";
  62106. module "babylonjs/abstractScene" {
  62107. interface AbstractScene {
  62108. /**
  62109. * The list of layers (background and foreground) of the scene
  62110. */
  62111. layers: Array<Layer>;
  62112. }
  62113. }
  62114. /**
  62115. * Defines the layer scene component responsible to manage any layers
  62116. * in a given scene.
  62117. */
  62118. export class LayerSceneComponent implements ISceneComponent {
  62119. /**
  62120. * The component name helpfull to identify the component in the list of scene components.
  62121. */
  62122. readonly name: string;
  62123. /**
  62124. * The scene the component belongs to.
  62125. */
  62126. scene: Scene;
  62127. private _engine;
  62128. /**
  62129. * Creates a new instance of the component for the given scene
  62130. * @param scene Defines the scene to register the component in
  62131. */
  62132. constructor(scene: Scene);
  62133. /**
  62134. * Registers the component in a given scene
  62135. */
  62136. register(): void;
  62137. /**
  62138. * Rebuilds the elements related to this component in case of
  62139. * context lost for instance.
  62140. */
  62141. rebuild(): void;
  62142. /**
  62143. * Disposes the component and the associated ressources.
  62144. */
  62145. dispose(): void;
  62146. private _draw;
  62147. private _drawCameraPredicate;
  62148. private _drawCameraBackground;
  62149. private _drawCameraForeground;
  62150. private _drawRenderTargetPredicate;
  62151. private _drawRenderTargetBackground;
  62152. private _drawRenderTargetForeground;
  62153. /**
  62154. * Adds all the elements from the container to the scene
  62155. * @param container the container holding the elements
  62156. */
  62157. addFromContainer(container: AbstractScene): void;
  62158. /**
  62159. * Removes all the elements in the container from the scene
  62160. * @param container contains the elements to remove
  62161. * @param dispose if the removed element should be disposed (default: false)
  62162. */
  62163. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62164. }
  62165. }
  62166. declare module "babylonjs/Shaders/layer.fragment" {
  62167. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62168. /** @hidden */
  62169. export var layerPixelShader: {
  62170. name: string;
  62171. shader: string;
  62172. };
  62173. }
  62174. declare module "babylonjs/Shaders/layer.vertex" {
  62175. /** @hidden */
  62176. export var layerVertexShader: {
  62177. name: string;
  62178. shader: string;
  62179. };
  62180. }
  62181. declare module "babylonjs/Layers/layer" {
  62182. import { Observable } from "babylonjs/Misc/observable";
  62183. import { Nullable } from "babylonjs/types";
  62184. import { Scene } from "babylonjs/scene";
  62185. import { Vector2 } from "babylonjs/Maths/math.vector";
  62186. import { Color4 } from "babylonjs/Maths/math.color";
  62187. import { Texture } from "babylonjs/Materials/Textures/texture";
  62188. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62189. import "babylonjs/Shaders/layer.fragment";
  62190. import "babylonjs/Shaders/layer.vertex";
  62191. /**
  62192. * This represents a full screen 2d layer.
  62193. * This can be useful to display a picture in the background of your scene for instance.
  62194. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62195. */
  62196. export class Layer {
  62197. /**
  62198. * Define the name of the layer.
  62199. */
  62200. name: string;
  62201. /**
  62202. * Define the texture the layer should display.
  62203. */
  62204. texture: Nullable<Texture>;
  62205. /**
  62206. * Is the layer in background or foreground.
  62207. */
  62208. isBackground: boolean;
  62209. /**
  62210. * Define the color of the layer (instead of texture).
  62211. */
  62212. color: Color4;
  62213. /**
  62214. * Define the scale of the layer in order to zoom in out of the texture.
  62215. */
  62216. scale: Vector2;
  62217. /**
  62218. * Define an offset for the layer in order to shift the texture.
  62219. */
  62220. offset: Vector2;
  62221. /**
  62222. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62223. */
  62224. alphaBlendingMode: number;
  62225. /**
  62226. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62227. * Alpha test will not mix with the background color in case of transparency.
  62228. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62229. */
  62230. alphaTest: boolean;
  62231. /**
  62232. * Define a mask to restrict the layer to only some of the scene cameras.
  62233. */
  62234. layerMask: number;
  62235. /**
  62236. * Define the list of render target the layer is visible into.
  62237. */
  62238. renderTargetTextures: RenderTargetTexture[];
  62239. /**
  62240. * Define if the layer is only used in renderTarget or if it also
  62241. * renders in the main frame buffer of the canvas.
  62242. */
  62243. renderOnlyInRenderTargetTextures: boolean;
  62244. private _scene;
  62245. private _vertexBuffers;
  62246. private _indexBuffer;
  62247. private _effect;
  62248. private _previousDefines;
  62249. /**
  62250. * An event triggered when the layer is disposed.
  62251. */
  62252. onDisposeObservable: Observable<Layer>;
  62253. private _onDisposeObserver;
  62254. /**
  62255. * Back compatibility with callback before the onDisposeObservable existed.
  62256. * The set callback will be triggered when the layer has been disposed.
  62257. */
  62258. set onDispose(callback: () => void);
  62259. /**
  62260. * An event triggered before rendering the scene
  62261. */
  62262. onBeforeRenderObservable: Observable<Layer>;
  62263. private _onBeforeRenderObserver;
  62264. /**
  62265. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62266. * The set callback will be triggered just before rendering the layer.
  62267. */
  62268. set onBeforeRender(callback: () => void);
  62269. /**
  62270. * An event triggered after rendering the scene
  62271. */
  62272. onAfterRenderObservable: Observable<Layer>;
  62273. private _onAfterRenderObserver;
  62274. /**
  62275. * Back compatibility with callback before the onAfterRenderObservable existed.
  62276. * The set callback will be triggered just after rendering the layer.
  62277. */
  62278. set onAfterRender(callback: () => void);
  62279. /**
  62280. * Instantiates a new layer.
  62281. * This represents a full screen 2d layer.
  62282. * This can be useful to display a picture in the background of your scene for instance.
  62283. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62284. * @param name Define the name of the layer in the scene
  62285. * @param imgUrl Define the url of the texture to display in the layer
  62286. * @param scene Define the scene the layer belongs to
  62287. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62288. * @param color Defines a color for the layer
  62289. */
  62290. constructor(
  62291. /**
  62292. * Define the name of the layer.
  62293. */
  62294. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62295. private _createIndexBuffer;
  62296. /** @hidden */
  62297. _rebuild(): void;
  62298. /**
  62299. * Renders the layer in the scene.
  62300. */
  62301. render(): void;
  62302. /**
  62303. * Disposes and releases the associated ressources.
  62304. */
  62305. dispose(): void;
  62306. }
  62307. }
  62308. declare module "babylonjs/Layers/index" {
  62309. export * from "babylonjs/Layers/effectLayer";
  62310. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62311. export * from "babylonjs/Layers/glowLayer";
  62312. export * from "babylonjs/Layers/highlightLayer";
  62313. export * from "babylonjs/Layers/layer";
  62314. export * from "babylonjs/Layers/layerSceneComponent";
  62315. }
  62316. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62317. /** @hidden */
  62318. export var lensFlarePixelShader: {
  62319. name: string;
  62320. shader: string;
  62321. };
  62322. }
  62323. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62324. /** @hidden */
  62325. export var lensFlareVertexShader: {
  62326. name: string;
  62327. shader: string;
  62328. };
  62329. }
  62330. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62331. import { Scene } from "babylonjs/scene";
  62332. import { Vector3 } from "babylonjs/Maths/math.vector";
  62333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62334. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62335. import "babylonjs/Shaders/lensFlare.fragment";
  62336. import "babylonjs/Shaders/lensFlare.vertex";
  62337. import { Viewport } from "babylonjs/Maths/math.viewport";
  62338. /**
  62339. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62340. * It is usually composed of several `lensFlare`.
  62341. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62342. */
  62343. export class LensFlareSystem {
  62344. /**
  62345. * Define the name of the lens flare system
  62346. */
  62347. name: string;
  62348. /**
  62349. * List of lens flares used in this system.
  62350. */
  62351. lensFlares: LensFlare[];
  62352. /**
  62353. * Define a limit from the border the lens flare can be visible.
  62354. */
  62355. borderLimit: number;
  62356. /**
  62357. * Define a viewport border we do not want to see the lens flare in.
  62358. */
  62359. viewportBorder: number;
  62360. /**
  62361. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62362. */
  62363. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62364. /**
  62365. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62366. */
  62367. layerMask: number;
  62368. /**
  62369. * Define the id of the lens flare system in the scene.
  62370. * (equal to name by default)
  62371. */
  62372. id: string;
  62373. private _scene;
  62374. private _emitter;
  62375. private _vertexBuffers;
  62376. private _indexBuffer;
  62377. private _effect;
  62378. private _positionX;
  62379. private _positionY;
  62380. private _isEnabled;
  62381. /** @hidden */
  62382. static _SceneComponentInitialization: (scene: Scene) => void;
  62383. /**
  62384. * Instantiates a lens flare system.
  62385. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62386. * It is usually composed of several `lensFlare`.
  62387. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62388. * @param name Define the name of the lens flare system in the scene
  62389. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62390. * @param scene Define the scene the lens flare system belongs to
  62391. */
  62392. constructor(
  62393. /**
  62394. * Define the name of the lens flare system
  62395. */
  62396. name: string, emitter: any, scene: Scene);
  62397. /**
  62398. * Define if the lens flare system is enabled.
  62399. */
  62400. get isEnabled(): boolean;
  62401. set isEnabled(value: boolean);
  62402. /**
  62403. * Get the scene the effects belongs to.
  62404. * @returns the scene holding the lens flare system
  62405. */
  62406. getScene(): Scene;
  62407. /**
  62408. * Get the emitter of the lens flare system.
  62409. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62410. * @returns the emitter of the lens flare system
  62411. */
  62412. getEmitter(): any;
  62413. /**
  62414. * Set the emitter of the lens flare system.
  62415. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62416. * @param newEmitter Define the new emitter of the system
  62417. */
  62418. setEmitter(newEmitter: any): void;
  62419. /**
  62420. * Get the lens flare system emitter position.
  62421. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62422. * @returns the position
  62423. */
  62424. getEmitterPosition(): Vector3;
  62425. /**
  62426. * @hidden
  62427. */
  62428. computeEffectivePosition(globalViewport: Viewport): boolean;
  62429. /** @hidden */
  62430. _isVisible(): boolean;
  62431. /**
  62432. * @hidden
  62433. */
  62434. render(): boolean;
  62435. /**
  62436. * Dispose and release the lens flare with its associated resources.
  62437. */
  62438. dispose(): void;
  62439. /**
  62440. * Parse a lens flare system from a JSON repressentation
  62441. * @param parsedLensFlareSystem Define the JSON to parse
  62442. * @param scene Define the scene the parsed system should be instantiated in
  62443. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62444. * @returns the parsed system
  62445. */
  62446. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62447. /**
  62448. * Serialize the current Lens Flare System into a JSON representation.
  62449. * @returns the serialized JSON
  62450. */
  62451. serialize(): any;
  62452. }
  62453. }
  62454. declare module "babylonjs/LensFlares/lensFlare" {
  62455. import { Nullable } from "babylonjs/types";
  62456. import { Color3 } from "babylonjs/Maths/math.color";
  62457. import { Texture } from "babylonjs/Materials/Textures/texture";
  62458. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62459. /**
  62460. * This represents one of the lens effect in a `lensFlareSystem`.
  62461. * It controls one of the indiviual texture used in the effect.
  62462. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62463. */
  62464. export class LensFlare {
  62465. /**
  62466. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62467. */
  62468. size: number;
  62469. /**
  62470. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  62471. */
  62472. position: number;
  62473. /**
  62474. * Define the lens color.
  62475. */
  62476. color: Color3;
  62477. /**
  62478. * Define the lens texture.
  62479. */
  62480. texture: Nullable<Texture>;
  62481. /**
  62482. * Define the alpha mode to render this particular lens.
  62483. */
  62484. alphaMode: number;
  62485. private _system;
  62486. /**
  62487. * Creates a new Lens Flare.
  62488. * This represents one of the lens effect in a `lensFlareSystem`.
  62489. * It controls one of the indiviual texture used in the effect.
  62490. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62491. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62492. * @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.
  62493. * @param color Define the lens color
  62494. * @param imgUrl Define the lens texture url
  62495. * @param system Define the `lensFlareSystem` this flare is part of
  62496. * @returns The newly created Lens Flare
  62497. */
  62498. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62499. /**
  62500. * Instantiates a new Lens Flare.
  62501. * This represents one of the lens effect in a `lensFlareSystem`.
  62502. * It controls one of the indiviual texture used in the effect.
  62503. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62504. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62505. * @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.
  62506. * @param color Define the lens color
  62507. * @param imgUrl Define the lens texture url
  62508. * @param system Define the `lensFlareSystem` this flare is part of
  62509. */
  62510. constructor(
  62511. /**
  62512. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62513. */
  62514. size: number,
  62515. /**
  62516. * 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.
  62517. */
  62518. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62519. /**
  62520. * Dispose and release the lens flare with its associated resources.
  62521. */
  62522. dispose(): void;
  62523. }
  62524. }
  62525. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62526. import { Nullable } from "babylonjs/types";
  62527. import { Scene } from "babylonjs/scene";
  62528. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62529. import { AbstractScene } from "babylonjs/abstractScene";
  62530. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62531. module "babylonjs/abstractScene" {
  62532. interface AbstractScene {
  62533. /**
  62534. * The list of lens flare system added to the scene
  62535. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62536. */
  62537. lensFlareSystems: Array<LensFlareSystem>;
  62538. /**
  62539. * Removes the given lens flare system from this scene.
  62540. * @param toRemove The lens flare system to remove
  62541. * @returns The index of the removed lens flare system
  62542. */
  62543. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62544. /**
  62545. * Adds the given lens flare system to this scene
  62546. * @param newLensFlareSystem The lens flare system to add
  62547. */
  62548. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62549. /**
  62550. * Gets a lens flare system using its name
  62551. * @param name defines the name to look for
  62552. * @returns the lens flare system or null if not found
  62553. */
  62554. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62555. /**
  62556. * Gets a lens flare system using its id
  62557. * @param id defines the id to look for
  62558. * @returns the lens flare system or null if not found
  62559. */
  62560. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62561. }
  62562. }
  62563. /**
  62564. * Defines the lens flare scene component responsible to manage any lens flares
  62565. * in a given scene.
  62566. */
  62567. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62568. /**
  62569. * The component name helpfull to identify the component in the list of scene components.
  62570. */
  62571. readonly name: string;
  62572. /**
  62573. * The scene the component belongs to.
  62574. */
  62575. scene: Scene;
  62576. /**
  62577. * Creates a new instance of the component for the given scene
  62578. * @param scene Defines the scene to register the component in
  62579. */
  62580. constructor(scene: Scene);
  62581. /**
  62582. * Registers the component in a given scene
  62583. */
  62584. register(): void;
  62585. /**
  62586. * Rebuilds the elements related to this component in case of
  62587. * context lost for instance.
  62588. */
  62589. rebuild(): void;
  62590. /**
  62591. * Adds all the elements from the container to the scene
  62592. * @param container the container holding the elements
  62593. */
  62594. addFromContainer(container: AbstractScene): void;
  62595. /**
  62596. * Removes all the elements in the container from the scene
  62597. * @param container contains the elements to remove
  62598. * @param dispose if the removed element should be disposed (default: false)
  62599. */
  62600. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62601. /**
  62602. * Serializes the component data to the specified json object
  62603. * @param serializationObject The object to serialize to
  62604. */
  62605. serialize(serializationObject: any): void;
  62606. /**
  62607. * Disposes the component and the associated ressources.
  62608. */
  62609. dispose(): void;
  62610. private _draw;
  62611. }
  62612. }
  62613. declare module "babylonjs/LensFlares/index" {
  62614. export * from "babylonjs/LensFlares/lensFlare";
  62615. export * from "babylonjs/LensFlares/lensFlareSystem";
  62616. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62617. }
  62618. declare module "babylonjs/Shaders/depth.fragment" {
  62619. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62620. /** @hidden */
  62621. export var depthPixelShader: {
  62622. name: string;
  62623. shader: string;
  62624. };
  62625. }
  62626. declare module "babylonjs/Shaders/depth.vertex" {
  62627. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62628. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62629. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62630. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62631. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62632. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62633. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62634. /** @hidden */
  62635. export var depthVertexShader: {
  62636. name: string;
  62637. shader: string;
  62638. };
  62639. }
  62640. declare module "babylonjs/Rendering/depthRenderer" {
  62641. import { Nullable } from "babylonjs/types";
  62642. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62643. import { Scene } from "babylonjs/scene";
  62644. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62645. import { Camera } from "babylonjs/Cameras/camera";
  62646. import "babylonjs/Shaders/depth.fragment";
  62647. import "babylonjs/Shaders/depth.vertex";
  62648. /**
  62649. * This represents a depth renderer in Babylon.
  62650. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62651. */
  62652. export class DepthRenderer {
  62653. private _scene;
  62654. private _depthMap;
  62655. private _effect;
  62656. private readonly _storeNonLinearDepth;
  62657. private readonly _clearColor;
  62658. /** Get if the depth renderer is using packed depth or not */
  62659. readonly isPacked: boolean;
  62660. private _cachedDefines;
  62661. private _camera;
  62662. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62663. enabled: boolean;
  62664. /**
  62665. * Specifiess that the depth renderer will only be used within
  62666. * the camera it is created for.
  62667. * This can help forcing its rendering during the camera processing.
  62668. */
  62669. useOnlyInActiveCamera: boolean;
  62670. /** @hidden */
  62671. static _SceneComponentInitialization: (scene: Scene) => void;
  62672. /**
  62673. * Instantiates a depth renderer
  62674. * @param scene The scene the renderer belongs to
  62675. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62676. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62677. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62678. */
  62679. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62680. /**
  62681. * Creates the depth rendering effect and checks if the effect is ready.
  62682. * @param subMesh The submesh to be used to render the depth map of
  62683. * @param useInstances If multiple world instances should be used
  62684. * @returns if the depth renderer is ready to render the depth map
  62685. */
  62686. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62687. /**
  62688. * Gets the texture which the depth map will be written to.
  62689. * @returns The depth map texture
  62690. */
  62691. getDepthMap(): RenderTargetTexture;
  62692. /**
  62693. * Disposes of the depth renderer.
  62694. */
  62695. dispose(): void;
  62696. }
  62697. }
  62698. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62699. /** @hidden */
  62700. export var minmaxReduxPixelShader: {
  62701. name: string;
  62702. shader: string;
  62703. };
  62704. }
  62705. declare module "babylonjs/Misc/minMaxReducer" {
  62706. import { Nullable } from "babylonjs/types";
  62707. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62708. import { Camera } from "babylonjs/Cameras/camera";
  62709. import { Observer } from "babylonjs/Misc/observable";
  62710. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62711. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62712. import { Observable } from "babylonjs/Misc/observable";
  62713. import "babylonjs/Shaders/minmaxRedux.fragment";
  62714. /**
  62715. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62716. * and maximum values from all values of the texture.
  62717. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62718. * The source values are read from the red channel of the texture.
  62719. */
  62720. export class MinMaxReducer {
  62721. /**
  62722. * Observable triggered when the computation has been performed
  62723. */
  62724. onAfterReductionPerformed: Observable<{
  62725. min: number;
  62726. max: number;
  62727. }>;
  62728. protected _camera: Camera;
  62729. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62730. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62731. protected _postProcessManager: PostProcessManager;
  62732. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62733. protected _forceFullscreenViewport: boolean;
  62734. /**
  62735. * Creates a min/max reducer
  62736. * @param camera The camera to use for the post processes
  62737. */
  62738. constructor(camera: Camera);
  62739. /**
  62740. * Gets the texture used to read the values from.
  62741. */
  62742. get sourceTexture(): Nullable<RenderTargetTexture>;
  62743. /**
  62744. * Sets the source texture to read the values from.
  62745. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62746. * because in such textures '1' value must not be taken into account to compute the maximum
  62747. * as this value is used to clear the texture.
  62748. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62749. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62750. * @param depthRedux Indicates if the texture is a depth texture or not
  62751. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62752. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62753. */
  62754. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62755. /**
  62756. * Defines the refresh rate of the computation.
  62757. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62758. */
  62759. get refreshRate(): number;
  62760. set refreshRate(value: number);
  62761. protected _activated: boolean;
  62762. /**
  62763. * Gets the activation status of the reducer
  62764. */
  62765. get activated(): boolean;
  62766. /**
  62767. * Activates the reduction computation.
  62768. * When activated, the observers registered in onAfterReductionPerformed are
  62769. * called after the compuation is performed
  62770. */
  62771. activate(): void;
  62772. /**
  62773. * Deactivates the reduction computation.
  62774. */
  62775. deactivate(): void;
  62776. /**
  62777. * Disposes the min/max reducer
  62778. * @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.
  62779. */
  62780. dispose(disposeAll?: boolean): void;
  62781. }
  62782. }
  62783. declare module "babylonjs/Misc/depthReducer" {
  62784. import { Nullable } from "babylonjs/types";
  62785. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62786. import { Camera } from "babylonjs/Cameras/camera";
  62787. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62788. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62789. /**
  62790. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62791. */
  62792. export class DepthReducer extends MinMaxReducer {
  62793. private _depthRenderer;
  62794. private _depthRendererId;
  62795. /**
  62796. * Gets the depth renderer used for the computation.
  62797. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62798. */
  62799. get depthRenderer(): Nullable<DepthRenderer>;
  62800. /**
  62801. * Creates a depth reducer
  62802. * @param camera The camera used to render the depth texture
  62803. */
  62804. constructor(camera: Camera);
  62805. /**
  62806. * Sets the depth renderer to use to generate the depth map
  62807. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62808. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62809. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62810. */
  62811. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62812. /** @hidden */
  62813. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62814. /**
  62815. * Activates the reduction computation.
  62816. * When activated, the observers registered in onAfterReductionPerformed are
  62817. * called after the compuation is performed
  62818. */
  62819. activate(): void;
  62820. /**
  62821. * Deactivates the reduction computation.
  62822. */
  62823. deactivate(): void;
  62824. /**
  62825. * Disposes the depth reducer
  62826. * @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.
  62827. */
  62828. dispose(disposeAll?: boolean): void;
  62829. }
  62830. }
  62831. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62832. import { Nullable } from "babylonjs/types";
  62833. import { Scene } from "babylonjs/scene";
  62834. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62835. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62837. import { Effect } from "babylonjs/Materials/effect";
  62838. import "babylonjs/Shaders/shadowMap.fragment";
  62839. import "babylonjs/Shaders/shadowMap.vertex";
  62840. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62841. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62842. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62843. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62844. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62845. /**
  62846. * A CSM implementation allowing casting shadows on large scenes.
  62847. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62848. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62849. */
  62850. export class CascadedShadowGenerator extends ShadowGenerator {
  62851. private static readonly frustumCornersNDCSpace;
  62852. /**
  62853. * Name of the CSM class
  62854. */
  62855. static CLASSNAME: string;
  62856. /**
  62857. * Defines the default number of cascades used by the CSM.
  62858. */
  62859. static readonly DEFAULT_CASCADES_COUNT: number;
  62860. /**
  62861. * Defines the minimum number of cascades used by the CSM.
  62862. */
  62863. static readonly MIN_CASCADES_COUNT: number;
  62864. /**
  62865. * Defines the maximum number of cascades used by the CSM.
  62866. */
  62867. static readonly MAX_CASCADES_COUNT: number;
  62868. protected _validateFilter(filter: number): number;
  62869. /**
  62870. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62871. */
  62872. penumbraDarkness: number;
  62873. private _numCascades;
  62874. /**
  62875. * Gets or set the number of cascades used by the CSM.
  62876. */
  62877. get numCascades(): number;
  62878. set numCascades(value: number);
  62879. /**
  62880. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62881. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62882. */
  62883. stabilizeCascades: boolean;
  62884. private _freezeShadowCastersBoundingInfo;
  62885. private _freezeShadowCastersBoundingInfoObservable;
  62886. /**
  62887. * Enables or disables the shadow casters bounding info computation.
  62888. * If your shadow casters don't move, you can disable this feature.
  62889. * If it is enabled, the bounding box computation is done every frame.
  62890. */
  62891. get freezeShadowCastersBoundingInfo(): boolean;
  62892. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62893. private _scbiMin;
  62894. private _scbiMax;
  62895. protected _computeShadowCastersBoundingInfo(): void;
  62896. protected _shadowCastersBoundingInfo: BoundingInfo;
  62897. /**
  62898. * Gets or sets the shadow casters bounding info.
  62899. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62900. * so that the system won't overwrite the bounds you provide
  62901. */
  62902. get shadowCastersBoundingInfo(): BoundingInfo;
  62903. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62904. protected _breaksAreDirty: boolean;
  62905. protected _minDistance: number;
  62906. protected _maxDistance: number;
  62907. /**
  62908. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62909. *
  62910. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62911. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62912. * @param min minimal distance for the breaks (default to 0.)
  62913. * @param max maximal distance for the breaks (default to 1.)
  62914. */
  62915. setMinMaxDistance(min: number, max: number): void;
  62916. /** Gets the minimal distance used in the cascade break computation */
  62917. get minDistance(): number;
  62918. /** Gets the maximal distance used in the cascade break computation */
  62919. get maxDistance(): number;
  62920. /**
  62921. * Gets the class name of that object
  62922. * @returns "CascadedShadowGenerator"
  62923. */
  62924. getClassName(): string;
  62925. private _cascadeMinExtents;
  62926. private _cascadeMaxExtents;
  62927. /**
  62928. * Gets a cascade minimum extents
  62929. * @param cascadeIndex index of the cascade
  62930. * @returns the minimum cascade extents
  62931. */
  62932. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62933. /**
  62934. * Gets a cascade maximum extents
  62935. * @param cascadeIndex index of the cascade
  62936. * @returns the maximum cascade extents
  62937. */
  62938. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62939. private _cascades;
  62940. private _currentLayer;
  62941. private _viewSpaceFrustumsZ;
  62942. private _viewMatrices;
  62943. private _projectionMatrices;
  62944. private _transformMatrices;
  62945. private _transformMatricesAsArray;
  62946. private _frustumLengths;
  62947. private _lightSizeUVCorrection;
  62948. private _depthCorrection;
  62949. private _frustumCornersWorldSpace;
  62950. private _frustumCenter;
  62951. private _shadowCameraPos;
  62952. private _shadowMaxZ;
  62953. /**
  62954. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62955. * It defaults to camera.maxZ
  62956. */
  62957. get shadowMaxZ(): number;
  62958. /**
  62959. * Sets the shadow max z distance.
  62960. */
  62961. set shadowMaxZ(value: number);
  62962. protected _debug: boolean;
  62963. /**
  62964. * Gets or sets the debug flag.
  62965. * When enabled, the cascades are materialized by different colors on the screen.
  62966. */
  62967. get debug(): boolean;
  62968. set debug(dbg: boolean);
  62969. private _depthClamp;
  62970. /**
  62971. * Gets or sets the depth clamping value.
  62972. *
  62973. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62974. * to account for the shadow casters far away.
  62975. *
  62976. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62977. */
  62978. get depthClamp(): boolean;
  62979. set depthClamp(value: boolean);
  62980. private _cascadeBlendPercentage;
  62981. /**
  62982. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62983. * It defaults to 0.1 (10% blending).
  62984. */
  62985. get cascadeBlendPercentage(): number;
  62986. set cascadeBlendPercentage(value: number);
  62987. private _lambda;
  62988. /**
  62989. * Gets or set the lambda parameter.
  62990. * This parameter is used to split the camera frustum and create the cascades.
  62991. * 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.
  62992. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62993. */
  62994. get lambda(): number;
  62995. set lambda(value: number);
  62996. /**
  62997. * Gets the view matrix corresponding to a given cascade
  62998. * @param cascadeNum cascade to retrieve the view matrix from
  62999. * @returns the cascade view matrix
  63000. */
  63001. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  63002. /**
  63003. * Gets the projection matrix corresponding to a given cascade
  63004. * @param cascadeNum cascade to retrieve the projection matrix from
  63005. * @returns the cascade projection matrix
  63006. */
  63007. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  63008. /**
  63009. * Gets the transformation matrix corresponding to a given cascade
  63010. * @param cascadeNum cascade to retrieve the transformation matrix from
  63011. * @returns the cascade transformation matrix
  63012. */
  63013. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  63014. private _depthRenderer;
  63015. /**
  63016. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  63017. *
  63018. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  63019. *
  63020. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63021. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63022. * @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
  63023. */
  63024. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63025. private _depthReducer;
  63026. private _autoCalcDepthBounds;
  63027. /**
  63028. * Gets or sets the autoCalcDepthBounds property.
  63029. *
  63030. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63031. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63032. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63033. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63034. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63035. */
  63036. get autoCalcDepthBounds(): boolean;
  63037. set autoCalcDepthBounds(value: boolean);
  63038. /**
  63039. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63040. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63041. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63042. * for setting the refresh rate on the renderer yourself!
  63043. */
  63044. get autoCalcDepthBoundsRefreshRate(): number;
  63045. set autoCalcDepthBoundsRefreshRate(value: number);
  63046. /**
  63047. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63048. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63049. * you change the camera near/far planes!
  63050. */
  63051. splitFrustum(): void;
  63052. private _splitFrustum;
  63053. private _computeMatrices;
  63054. private _computeFrustumInWorldSpace;
  63055. private _computeCascadeFrustum;
  63056. /**
  63057. * Support test.
  63058. */
  63059. static get IsSupported(): boolean;
  63060. /** @hidden */
  63061. static _SceneComponentInitialization: (scene: Scene) => void;
  63062. /**
  63063. * Creates a Cascaded Shadow Generator object.
  63064. * A ShadowGenerator is the required tool to use the shadows.
  63065. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63066. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63067. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63068. * @param light The directional light object generating the shadows.
  63069. * @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.
  63070. */
  63071. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63072. protected _initializeGenerator(): void;
  63073. protected _createTargetRenderTexture(): void;
  63074. protected _initializeShadowMap(): void;
  63075. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63076. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63077. /**
  63078. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63079. * @param defines Defines of the material we want to update
  63080. * @param lightIndex Index of the light in the enabled light list of the material
  63081. */
  63082. prepareDefines(defines: any, lightIndex: number): void;
  63083. /**
  63084. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63085. * defined in the generator but impacting the effect).
  63086. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63087. * @param effect The effect we are binfing the information for
  63088. */
  63089. bindShadowLight(lightIndex: string, effect: Effect): void;
  63090. /**
  63091. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63092. * (eq to view projection * shadow projection matrices)
  63093. * @returns The transform matrix used to create the shadow map
  63094. */
  63095. getTransformMatrix(): Matrix;
  63096. /**
  63097. * Disposes the ShadowGenerator.
  63098. * Returns nothing.
  63099. */
  63100. dispose(): void;
  63101. /**
  63102. * Serializes the shadow generator setup to a json object.
  63103. * @returns The serialized JSON object
  63104. */
  63105. serialize(): any;
  63106. /**
  63107. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63108. * @param parsedShadowGenerator The JSON object to parse
  63109. * @param scene The scene to create the shadow map for
  63110. * @returns The parsed shadow generator
  63111. */
  63112. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63113. }
  63114. }
  63115. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63116. import { Scene } from "babylonjs/scene";
  63117. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63118. import { AbstractScene } from "babylonjs/abstractScene";
  63119. /**
  63120. * Defines the shadow generator component responsible to manage any shadow generators
  63121. * in a given scene.
  63122. */
  63123. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63124. /**
  63125. * The component name helpfull to identify the component in the list of scene components.
  63126. */
  63127. readonly name: string;
  63128. /**
  63129. * The scene the component belongs to.
  63130. */
  63131. scene: Scene;
  63132. /**
  63133. * Creates a new instance of the component for the given scene
  63134. * @param scene Defines the scene to register the component in
  63135. */
  63136. constructor(scene: Scene);
  63137. /**
  63138. * Registers the component in a given scene
  63139. */
  63140. register(): void;
  63141. /**
  63142. * Rebuilds the elements related to this component in case of
  63143. * context lost for instance.
  63144. */
  63145. rebuild(): void;
  63146. /**
  63147. * Serializes the component data to the specified json object
  63148. * @param serializationObject The object to serialize to
  63149. */
  63150. serialize(serializationObject: any): void;
  63151. /**
  63152. * Adds all the elements from the container to the scene
  63153. * @param container the container holding the elements
  63154. */
  63155. addFromContainer(container: AbstractScene): void;
  63156. /**
  63157. * Removes all the elements in the container from the scene
  63158. * @param container contains the elements to remove
  63159. * @param dispose if the removed element should be disposed (default: false)
  63160. */
  63161. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63162. /**
  63163. * Rebuilds the elements related to this component in case of
  63164. * context lost for instance.
  63165. */
  63166. dispose(): void;
  63167. private _gatherRenderTargets;
  63168. }
  63169. }
  63170. declare module "babylonjs/Lights/Shadows/index" {
  63171. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63172. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63173. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63174. }
  63175. declare module "babylonjs/Lights/pointLight" {
  63176. import { Scene } from "babylonjs/scene";
  63177. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63179. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63180. import { Effect } from "babylonjs/Materials/effect";
  63181. /**
  63182. * A point light is a light defined by an unique point in world space.
  63183. * The light is emitted in every direction from this point.
  63184. * A good example of a point light is a standard light bulb.
  63185. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63186. */
  63187. export class PointLight extends ShadowLight {
  63188. private _shadowAngle;
  63189. /**
  63190. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63191. * This specifies what angle the shadow will use to be created.
  63192. *
  63193. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63194. */
  63195. get shadowAngle(): number;
  63196. /**
  63197. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63198. * This specifies what angle the shadow will use to be created.
  63199. *
  63200. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63201. */
  63202. set shadowAngle(value: number);
  63203. /**
  63204. * Gets the direction if it has been set.
  63205. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63206. */
  63207. get direction(): Vector3;
  63208. /**
  63209. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63210. */
  63211. set direction(value: Vector3);
  63212. /**
  63213. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63214. * A PointLight emits the light in every direction.
  63215. * It can cast shadows.
  63216. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63217. * ```javascript
  63218. * var pointLight = new PointLight("pl", camera.position, scene);
  63219. * ```
  63220. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63221. * @param name The light friendly name
  63222. * @param position The position of the point light in the scene
  63223. * @param scene The scene the lights belongs to
  63224. */
  63225. constructor(name: string, position: Vector3, scene: Scene);
  63226. /**
  63227. * Returns the string "PointLight"
  63228. * @returns the class name
  63229. */
  63230. getClassName(): string;
  63231. /**
  63232. * Returns the integer 0.
  63233. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63234. */
  63235. getTypeID(): number;
  63236. /**
  63237. * Specifies wether or not the shadowmap should be a cube texture.
  63238. * @returns true if the shadowmap needs to be a cube texture.
  63239. */
  63240. needCube(): boolean;
  63241. /**
  63242. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63243. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63244. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63245. */
  63246. getShadowDirection(faceIndex?: number): Vector3;
  63247. /**
  63248. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63249. * - fov = PI / 2
  63250. * - aspect ratio : 1.0
  63251. * - z-near and far equal to the active camera minZ and maxZ.
  63252. * Returns the PointLight.
  63253. */
  63254. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63255. protected _buildUniformLayout(): void;
  63256. /**
  63257. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63258. * @param effect The effect to update
  63259. * @param lightIndex The index of the light in the effect to update
  63260. * @returns The point light
  63261. */
  63262. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63263. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63264. /**
  63265. * Prepares the list of defines specific to the light type.
  63266. * @param defines the list of defines
  63267. * @param lightIndex defines the index of the light for the effect
  63268. */
  63269. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63270. }
  63271. }
  63272. declare module "babylonjs/Lights/index" {
  63273. export * from "babylonjs/Lights/light";
  63274. export * from "babylonjs/Lights/shadowLight";
  63275. export * from "babylonjs/Lights/Shadows/index";
  63276. export * from "babylonjs/Lights/directionalLight";
  63277. export * from "babylonjs/Lights/hemisphericLight";
  63278. export * from "babylonjs/Lights/pointLight";
  63279. export * from "babylonjs/Lights/spotLight";
  63280. }
  63281. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63282. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63283. /**
  63284. * Header information of HDR texture files.
  63285. */
  63286. export interface HDRInfo {
  63287. /**
  63288. * The height of the texture in pixels.
  63289. */
  63290. height: number;
  63291. /**
  63292. * The width of the texture in pixels.
  63293. */
  63294. width: number;
  63295. /**
  63296. * The index of the beginning of the data in the binary file.
  63297. */
  63298. dataPosition: number;
  63299. }
  63300. /**
  63301. * This groups tools to convert HDR texture to native colors array.
  63302. */
  63303. export class HDRTools {
  63304. private static Ldexp;
  63305. private static Rgbe2float;
  63306. private static readStringLine;
  63307. /**
  63308. * Reads header information from an RGBE texture stored in a native array.
  63309. * More information on this format are available here:
  63310. * https://en.wikipedia.org/wiki/RGBE_image_format
  63311. *
  63312. * @param uint8array The binary file stored in native array.
  63313. * @return The header information.
  63314. */
  63315. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63316. /**
  63317. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63318. * This RGBE texture needs to store the information as a panorama.
  63319. *
  63320. * More information on this format are available here:
  63321. * https://en.wikipedia.org/wiki/RGBE_image_format
  63322. *
  63323. * @param buffer The binary file stored in an array buffer.
  63324. * @param size The expected size of the extracted cubemap.
  63325. * @return The Cube Map information.
  63326. */
  63327. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63328. /**
  63329. * Returns the pixels data extracted from an RGBE texture.
  63330. * This pixels will be stored left to right up to down in the R G B order in one array.
  63331. *
  63332. * More information on this format are available here:
  63333. * https://en.wikipedia.org/wiki/RGBE_image_format
  63334. *
  63335. * @param uint8array The binary file stored in an array buffer.
  63336. * @param hdrInfo The header information of the file.
  63337. * @return The pixels data in RGB right to left up to down order.
  63338. */
  63339. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63340. private static RGBE_ReadPixels_RLE;
  63341. private static RGBE_ReadPixels_NOT_RLE;
  63342. }
  63343. }
  63344. declare module "babylonjs/Materials/effectRenderer" {
  63345. import { Nullable } from "babylonjs/types";
  63346. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63347. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63348. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63349. import { Viewport } from "babylonjs/Maths/math.viewport";
  63350. import { Observable } from "babylonjs/Misc/observable";
  63351. import { Effect } from "babylonjs/Materials/effect";
  63352. import "babylonjs/Shaders/postprocess.vertex";
  63353. /**
  63354. * Effect Render Options
  63355. */
  63356. export interface IEffectRendererOptions {
  63357. /**
  63358. * Defines the vertices positions.
  63359. */
  63360. positions?: number[];
  63361. /**
  63362. * Defines the indices.
  63363. */
  63364. indices?: number[];
  63365. }
  63366. /**
  63367. * Helper class to render one or more effects.
  63368. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63369. */
  63370. export class EffectRenderer {
  63371. private engine;
  63372. private static _DefaultOptions;
  63373. private _vertexBuffers;
  63374. private _indexBuffer;
  63375. private _fullscreenViewport;
  63376. /**
  63377. * Creates an effect renderer
  63378. * @param engine the engine to use for rendering
  63379. * @param options defines the options of the effect renderer
  63380. */
  63381. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63382. /**
  63383. * Sets the current viewport in normalized coordinates 0-1
  63384. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63385. */
  63386. setViewport(viewport?: Viewport): void;
  63387. /**
  63388. * Binds the embedded attributes buffer to the effect.
  63389. * @param effect Defines the effect to bind the attributes for
  63390. */
  63391. bindBuffers(effect: Effect): void;
  63392. /**
  63393. * Sets the current effect wrapper to use during draw.
  63394. * The effect needs to be ready before calling this api.
  63395. * This also sets the default full screen position attribute.
  63396. * @param effectWrapper Defines the effect to draw with
  63397. */
  63398. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63399. /**
  63400. * Restores engine states
  63401. */
  63402. restoreStates(): void;
  63403. /**
  63404. * Draws a full screen quad.
  63405. */
  63406. draw(): void;
  63407. private isRenderTargetTexture;
  63408. /**
  63409. * renders one or more effects to a specified texture
  63410. * @param effectWrapper the effect to renderer
  63411. * @param outputTexture texture to draw to, if null it will render to the screen.
  63412. */
  63413. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63414. /**
  63415. * Disposes of the effect renderer
  63416. */
  63417. dispose(): void;
  63418. }
  63419. /**
  63420. * Options to create an EffectWrapper
  63421. */
  63422. interface EffectWrapperCreationOptions {
  63423. /**
  63424. * Engine to use to create the effect
  63425. */
  63426. engine: ThinEngine;
  63427. /**
  63428. * Fragment shader for the effect
  63429. */
  63430. fragmentShader: string;
  63431. /**
  63432. * Use the shader store instead of direct source code
  63433. */
  63434. useShaderStore?: boolean;
  63435. /**
  63436. * Vertex shader for the effect
  63437. */
  63438. vertexShader?: string;
  63439. /**
  63440. * Attributes to use in the shader
  63441. */
  63442. attributeNames?: Array<string>;
  63443. /**
  63444. * Uniforms to use in the shader
  63445. */
  63446. uniformNames?: Array<string>;
  63447. /**
  63448. * Texture sampler names to use in the shader
  63449. */
  63450. samplerNames?: Array<string>;
  63451. /**
  63452. * Defines to use in the shader
  63453. */
  63454. defines?: Array<string>;
  63455. /**
  63456. * Callback when effect is compiled
  63457. */
  63458. onCompiled?: Nullable<(effect: Effect) => void>;
  63459. /**
  63460. * The friendly name of the effect displayed in Spector.
  63461. */
  63462. name?: string;
  63463. }
  63464. /**
  63465. * Wraps an effect to be used for rendering
  63466. */
  63467. export class EffectWrapper {
  63468. /**
  63469. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63470. */
  63471. onApplyObservable: Observable<{}>;
  63472. /**
  63473. * The underlying effect
  63474. */
  63475. effect: Effect;
  63476. /**
  63477. * Creates an effect to be renderer
  63478. * @param creationOptions options to create the effect
  63479. */
  63480. constructor(creationOptions: EffectWrapperCreationOptions);
  63481. /**
  63482. * Disposes of the effect wrapper
  63483. */
  63484. dispose(): void;
  63485. }
  63486. }
  63487. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63488. /** @hidden */
  63489. export var hdrFilteringVertexShader: {
  63490. name: string;
  63491. shader: string;
  63492. };
  63493. }
  63494. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63495. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63496. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63497. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63498. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63499. /** @hidden */
  63500. export var hdrFilteringPixelShader: {
  63501. name: string;
  63502. shader: string;
  63503. };
  63504. }
  63505. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63506. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63507. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63508. import { Nullable } from "babylonjs/types";
  63509. import "babylonjs/Shaders/hdrFiltering.vertex";
  63510. import "babylonjs/Shaders/hdrFiltering.fragment";
  63511. /**
  63512. * Options for texture filtering
  63513. */
  63514. interface IHDRFilteringOptions {
  63515. /**
  63516. * Scales pixel intensity for the input HDR map.
  63517. */
  63518. hdrScale?: number;
  63519. /**
  63520. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63521. */
  63522. quality?: number;
  63523. }
  63524. /**
  63525. * Filters HDR maps to get correct renderings of PBR reflections
  63526. */
  63527. export class HDRFiltering {
  63528. private _engine;
  63529. private _effectRenderer;
  63530. private _effectWrapper;
  63531. private _lodGenerationOffset;
  63532. private _lodGenerationScale;
  63533. /**
  63534. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63535. * you care about baking speed.
  63536. */
  63537. quality: number;
  63538. /**
  63539. * Scales pixel intensity for the input HDR map.
  63540. */
  63541. hdrScale: number;
  63542. /**
  63543. * Instantiates HDR filter for reflection maps
  63544. *
  63545. * @param engine Thin engine
  63546. * @param options Options
  63547. */
  63548. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63549. private _createRenderTarget;
  63550. private _prefilterInternal;
  63551. private _createEffect;
  63552. /**
  63553. * Get a value indicating if the filter is ready to be used
  63554. * @param texture Texture to filter
  63555. * @returns true if the filter is ready
  63556. */
  63557. isReady(texture: BaseTexture): boolean;
  63558. /**
  63559. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63560. * Prefiltering will be invoked at the end of next rendering pass.
  63561. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63562. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63563. * @param texture Texture to filter
  63564. * @param onFinished Callback when filtering is done
  63565. * @return Promise called when prefiltering is done
  63566. */
  63567. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63568. }
  63569. }
  63570. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63571. import { Nullable } from "babylonjs/types";
  63572. import { Scene } from "babylonjs/scene";
  63573. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63574. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63575. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63576. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63577. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63578. /**
  63579. * This represents a texture coming from an HDR input.
  63580. *
  63581. * The only supported format is currently panorama picture stored in RGBE format.
  63582. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63583. */
  63584. export class HDRCubeTexture extends BaseTexture {
  63585. private static _facesMapping;
  63586. private _generateHarmonics;
  63587. private _noMipmap;
  63588. private _prefilterOnLoad;
  63589. private _textureMatrix;
  63590. private _size;
  63591. private _onLoad;
  63592. private _onError;
  63593. /**
  63594. * The texture URL.
  63595. */
  63596. url: string;
  63597. protected _isBlocking: boolean;
  63598. /**
  63599. * Sets wether or not the texture is blocking during loading.
  63600. */
  63601. set isBlocking(value: boolean);
  63602. /**
  63603. * Gets wether or not the texture is blocking during loading.
  63604. */
  63605. get isBlocking(): boolean;
  63606. protected _rotationY: number;
  63607. /**
  63608. * Sets texture matrix rotation angle around Y axis in radians.
  63609. */
  63610. set rotationY(value: number);
  63611. /**
  63612. * Gets texture matrix rotation angle around Y axis radians.
  63613. */
  63614. get rotationY(): number;
  63615. /**
  63616. * Gets or sets the center of the bounding box associated with the cube texture
  63617. * It must define where the camera used to render the texture was set
  63618. */
  63619. boundingBoxPosition: Vector3;
  63620. private _boundingBoxSize;
  63621. /**
  63622. * Gets or sets the size of the bounding box associated with the cube texture
  63623. * When defined, the cubemap will switch to local mode
  63624. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63625. * @example https://www.babylonjs-playground.com/#RNASML
  63626. */
  63627. set boundingBoxSize(value: Vector3);
  63628. get boundingBoxSize(): Vector3;
  63629. /**
  63630. * Instantiates an HDRTexture from the following parameters.
  63631. *
  63632. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63633. * @param sceneOrEngine The scene or engine the texture will be used in
  63634. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63635. * @param noMipmap Forces to not generate the mipmap if true
  63636. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63637. * @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)
  63638. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63639. */
  63640. 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>);
  63641. /**
  63642. * Get the current class name of the texture useful for serialization or dynamic coding.
  63643. * @returns "HDRCubeTexture"
  63644. */
  63645. getClassName(): string;
  63646. /**
  63647. * Occurs when the file is raw .hdr file.
  63648. */
  63649. private loadTexture;
  63650. clone(): HDRCubeTexture;
  63651. delayLoad(): void;
  63652. /**
  63653. * Get the texture reflection matrix used to rotate/transform the reflection.
  63654. * @returns the reflection matrix
  63655. */
  63656. getReflectionTextureMatrix(): Matrix;
  63657. /**
  63658. * Set the texture reflection matrix used to rotate/transform the reflection.
  63659. * @param value Define the reflection matrix to set
  63660. */
  63661. setReflectionTextureMatrix(value: Matrix): void;
  63662. /**
  63663. * Parses a JSON representation of an HDR Texture in order to create the texture
  63664. * @param parsedTexture Define the JSON representation
  63665. * @param scene Define the scene the texture should be created in
  63666. * @param rootUrl Define the root url in case we need to load relative dependencies
  63667. * @returns the newly created texture after parsing
  63668. */
  63669. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63670. serialize(): any;
  63671. }
  63672. }
  63673. declare module "babylonjs/Physics/physicsEngine" {
  63674. import { Nullable } from "babylonjs/types";
  63675. import { Vector3 } from "babylonjs/Maths/math.vector";
  63676. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63677. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63678. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63679. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63680. /**
  63681. * Class used to control physics engine
  63682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63683. */
  63684. export class PhysicsEngine implements IPhysicsEngine {
  63685. private _physicsPlugin;
  63686. /**
  63687. * Global value used to control the smallest number supported by the simulation
  63688. */
  63689. static Epsilon: number;
  63690. private _impostors;
  63691. private _joints;
  63692. private _subTimeStep;
  63693. /**
  63694. * Gets the gravity vector used by the simulation
  63695. */
  63696. gravity: Vector3;
  63697. /**
  63698. * Factory used to create the default physics plugin.
  63699. * @returns The default physics plugin
  63700. */
  63701. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63702. /**
  63703. * Creates a new Physics Engine
  63704. * @param gravity defines the gravity vector used by the simulation
  63705. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63706. */
  63707. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63708. /**
  63709. * Sets the gravity vector used by the simulation
  63710. * @param gravity defines the gravity vector to use
  63711. */
  63712. setGravity(gravity: Vector3): void;
  63713. /**
  63714. * Set the time step of the physics engine.
  63715. * Default is 1/60.
  63716. * To slow it down, enter 1/600 for example.
  63717. * To speed it up, 1/30
  63718. * @param newTimeStep defines the new timestep to apply to this world.
  63719. */
  63720. setTimeStep(newTimeStep?: number): void;
  63721. /**
  63722. * Get the time step of the physics engine.
  63723. * @returns the current time step
  63724. */
  63725. getTimeStep(): number;
  63726. /**
  63727. * Set the sub time step of the physics engine.
  63728. * Default is 0 meaning there is no sub steps
  63729. * To increase physics resolution precision, set a small value (like 1 ms)
  63730. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63731. */
  63732. setSubTimeStep(subTimeStep?: number): void;
  63733. /**
  63734. * Get the sub time step of the physics engine.
  63735. * @returns the current sub time step
  63736. */
  63737. getSubTimeStep(): number;
  63738. /**
  63739. * Release all resources
  63740. */
  63741. dispose(): void;
  63742. /**
  63743. * Gets the name of the current physics plugin
  63744. * @returns the name of the plugin
  63745. */
  63746. getPhysicsPluginName(): string;
  63747. /**
  63748. * Adding a new impostor for the impostor tracking.
  63749. * This will be done by the impostor itself.
  63750. * @param impostor the impostor to add
  63751. */
  63752. addImpostor(impostor: PhysicsImpostor): void;
  63753. /**
  63754. * Remove an impostor from the engine.
  63755. * This impostor and its mesh will not longer be updated by the physics engine.
  63756. * @param impostor the impostor to remove
  63757. */
  63758. removeImpostor(impostor: PhysicsImpostor): void;
  63759. /**
  63760. * Add a joint to the physics engine
  63761. * @param mainImpostor defines the main impostor to which the joint is added.
  63762. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63763. * @param joint defines the joint that will connect both impostors.
  63764. */
  63765. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63766. /**
  63767. * Removes a joint from the simulation
  63768. * @param mainImpostor defines the impostor used with the joint
  63769. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63770. * @param joint defines the joint to remove
  63771. */
  63772. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63773. /**
  63774. * Called by the scene. No need to call it.
  63775. * @param delta defines the timespam between frames
  63776. */
  63777. _step(delta: number): void;
  63778. /**
  63779. * Gets the current plugin used to run the simulation
  63780. * @returns current plugin
  63781. */
  63782. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63783. /**
  63784. * Gets the list of physic impostors
  63785. * @returns an array of PhysicsImpostor
  63786. */
  63787. getImpostors(): Array<PhysicsImpostor>;
  63788. /**
  63789. * Gets the impostor for a physics enabled object
  63790. * @param object defines the object impersonated by the impostor
  63791. * @returns the PhysicsImpostor or null if not found
  63792. */
  63793. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63794. /**
  63795. * Gets the impostor for a physics body object
  63796. * @param body defines physics body used by the impostor
  63797. * @returns the PhysicsImpostor or null if not found
  63798. */
  63799. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63800. /**
  63801. * Does a raycast in the physics world
  63802. * @param from when should the ray start?
  63803. * @param to when should the ray end?
  63804. * @returns PhysicsRaycastResult
  63805. */
  63806. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63807. }
  63808. }
  63809. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63810. import { Nullable } from "babylonjs/types";
  63811. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63813. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63814. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63815. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63816. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63817. /** @hidden */
  63818. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63819. private _useDeltaForWorldStep;
  63820. world: any;
  63821. name: string;
  63822. private _physicsMaterials;
  63823. private _fixedTimeStep;
  63824. private _cannonRaycastResult;
  63825. private _raycastResult;
  63826. private _physicsBodysToRemoveAfterStep;
  63827. private _firstFrame;
  63828. BJSCANNON: any;
  63829. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63830. setGravity(gravity: Vector3): void;
  63831. setTimeStep(timeStep: number): void;
  63832. getTimeStep(): number;
  63833. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63834. private _removeMarkedPhysicsBodiesFromWorld;
  63835. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63836. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63837. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63838. private _processChildMeshes;
  63839. removePhysicsBody(impostor: PhysicsImpostor): void;
  63840. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63841. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63842. private _addMaterial;
  63843. private _checkWithEpsilon;
  63844. private _createShape;
  63845. private _createHeightmap;
  63846. private _minus90X;
  63847. private _plus90X;
  63848. private _tmpPosition;
  63849. private _tmpDeltaPosition;
  63850. private _tmpUnityRotation;
  63851. private _updatePhysicsBodyTransformation;
  63852. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63853. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63854. isSupported(): boolean;
  63855. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63856. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63857. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63858. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63859. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63860. getBodyMass(impostor: PhysicsImpostor): number;
  63861. getBodyFriction(impostor: PhysicsImpostor): number;
  63862. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63863. getBodyRestitution(impostor: PhysicsImpostor): number;
  63864. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63865. sleepBody(impostor: PhysicsImpostor): void;
  63866. wakeUpBody(impostor: PhysicsImpostor): void;
  63867. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63868. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63869. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63870. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63871. getRadius(impostor: PhysicsImpostor): number;
  63872. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63873. dispose(): void;
  63874. private _extendNamespace;
  63875. /**
  63876. * Does a raycast in the physics world
  63877. * @param from when should the ray start?
  63878. * @param to when should the ray end?
  63879. * @returns PhysicsRaycastResult
  63880. */
  63881. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63882. }
  63883. }
  63884. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63885. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63886. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63887. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63889. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63890. import { Nullable } from "babylonjs/types";
  63891. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63892. /** @hidden */
  63893. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63894. private _useDeltaForWorldStep;
  63895. world: any;
  63896. name: string;
  63897. BJSOIMO: any;
  63898. private _raycastResult;
  63899. private _fixedTimeStep;
  63900. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63901. setGravity(gravity: Vector3): void;
  63902. setTimeStep(timeStep: number): void;
  63903. getTimeStep(): number;
  63904. private _tmpImpostorsArray;
  63905. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63906. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63907. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63908. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63909. private _tmpPositionVector;
  63910. removePhysicsBody(impostor: PhysicsImpostor): void;
  63911. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63912. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63913. isSupported(): boolean;
  63914. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63915. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63916. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63917. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63918. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63919. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63920. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63921. getBodyMass(impostor: PhysicsImpostor): number;
  63922. getBodyFriction(impostor: PhysicsImpostor): number;
  63923. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63924. getBodyRestitution(impostor: PhysicsImpostor): number;
  63925. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63926. sleepBody(impostor: PhysicsImpostor): void;
  63927. wakeUpBody(impostor: PhysicsImpostor): void;
  63928. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63929. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63930. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63931. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63932. getRadius(impostor: PhysicsImpostor): number;
  63933. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63934. dispose(): void;
  63935. /**
  63936. * Does a raycast in the physics world
  63937. * @param from when should the ray start?
  63938. * @param to when should the ray end?
  63939. * @returns PhysicsRaycastResult
  63940. */
  63941. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63942. }
  63943. }
  63944. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63945. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63946. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63947. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63948. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63949. import { Nullable } from "babylonjs/types";
  63950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63951. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63952. /**
  63953. * AmmoJS Physics plugin
  63954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63955. * @see https://github.com/kripken/ammo.js/
  63956. */
  63957. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63958. private _useDeltaForWorldStep;
  63959. /**
  63960. * Reference to the Ammo library
  63961. */
  63962. bjsAMMO: any;
  63963. /**
  63964. * Created ammoJS world which physics bodies are added to
  63965. */
  63966. world: any;
  63967. /**
  63968. * Name of the plugin
  63969. */
  63970. name: string;
  63971. private _timeStep;
  63972. private _fixedTimeStep;
  63973. private _maxSteps;
  63974. private _tmpQuaternion;
  63975. private _tmpAmmoTransform;
  63976. private _tmpAmmoQuaternion;
  63977. private _tmpAmmoConcreteContactResultCallback;
  63978. private _collisionConfiguration;
  63979. private _dispatcher;
  63980. private _overlappingPairCache;
  63981. private _solver;
  63982. private _softBodySolver;
  63983. private _tmpAmmoVectorA;
  63984. private _tmpAmmoVectorB;
  63985. private _tmpAmmoVectorC;
  63986. private _tmpAmmoVectorD;
  63987. private _tmpContactCallbackResult;
  63988. private _tmpAmmoVectorRCA;
  63989. private _tmpAmmoVectorRCB;
  63990. private _raycastResult;
  63991. private static readonly DISABLE_COLLISION_FLAG;
  63992. private static readonly KINEMATIC_FLAG;
  63993. private static readonly DISABLE_DEACTIVATION_FLAG;
  63994. /**
  63995. * Initializes the ammoJS plugin
  63996. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63997. * @param ammoInjection can be used to inject your own ammo reference
  63998. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63999. */
  64000. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64001. /**
  64002. * Sets the gravity of the physics world (m/(s^2))
  64003. * @param gravity Gravity to set
  64004. */
  64005. setGravity(gravity: Vector3): void;
  64006. /**
  64007. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64008. * @param timeStep timestep to use in seconds
  64009. */
  64010. setTimeStep(timeStep: number): void;
  64011. /**
  64012. * 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)
  64013. * @param fixedTimeStep fixedTimeStep to use in seconds
  64014. */
  64015. setFixedTimeStep(fixedTimeStep: number): void;
  64016. /**
  64017. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  64018. * @param maxSteps the maximum number of steps by the physics engine per frame
  64019. */
  64020. setMaxSteps(maxSteps: number): void;
  64021. /**
  64022. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64023. * @returns the current timestep in seconds
  64024. */
  64025. getTimeStep(): number;
  64026. /**
  64027. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64028. */
  64029. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64030. private _isImpostorInContact;
  64031. private _isImpostorPairInContact;
  64032. private _stepSimulation;
  64033. /**
  64034. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64035. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64036. * After the step the babylon meshes are set to the position of the physics imposters
  64037. * @param delta amount of time to step forward
  64038. * @param impostors array of imposters to update before/after the step
  64039. */
  64040. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64041. /**
  64042. * Update babylon mesh to match physics world object
  64043. * @param impostor imposter to match
  64044. */
  64045. private _afterSoftStep;
  64046. /**
  64047. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64048. * @param impostor imposter to match
  64049. */
  64050. private _ropeStep;
  64051. /**
  64052. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64053. * @param impostor imposter to match
  64054. */
  64055. private _softbodyOrClothStep;
  64056. private _tmpMatrix;
  64057. /**
  64058. * Applies an impulse on the imposter
  64059. * @param impostor imposter to apply impulse to
  64060. * @param force amount of force to be applied to the imposter
  64061. * @param contactPoint the location to apply the impulse on the imposter
  64062. */
  64063. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64064. /**
  64065. * Applies a force on the imposter
  64066. * @param impostor imposter to apply force
  64067. * @param force amount of force to be applied to the imposter
  64068. * @param contactPoint the location to apply the force on the imposter
  64069. */
  64070. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64071. /**
  64072. * Creates a physics body using the plugin
  64073. * @param impostor the imposter to create the physics body on
  64074. */
  64075. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64076. /**
  64077. * Removes the physics body from the imposter and disposes of the body's memory
  64078. * @param impostor imposter to remove the physics body from
  64079. */
  64080. removePhysicsBody(impostor: PhysicsImpostor): void;
  64081. /**
  64082. * Generates a joint
  64083. * @param impostorJoint the imposter joint to create the joint with
  64084. */
  64085. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64086. /**
  64087. * Removes a joint
  64088. * @param impostorJoint the imposter joint to remove the joint from
  64089. */
  64090. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64091. private _addMeshVerts;
  64092. /**
  64093. * Initialise the soft body vertices to match its object's (mesh) vertices
  64094. * Softbody vertices (nodes) are in world space and to match this
  64095. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64096. * @param impostor to create the softbody for
  64097. */
  64098. private _softVertexData;
  64099. /**
  64100. * Create an impostor's soft body
  64101. * @param impostor to create the softbody for
  64102. */
  64103. private _createSoftbody;
  64104. /**
  64105. * Create cloth for an impostor
  64106. * @param impostor to create the softbody for
  64107. */
  64108. private _createCloth;
  64109. /**
  64110. * Create rope for an impostor
  64111. * @param impostor to create the softbody for
  64112. */
  64113. private _createRope;
  64114. /**
  64115. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64116. * @param impostor to create the custom physics shape for
  64117. */
  64118. private _createCustom;
  64119. private _addHullVerts;
  64120. private _createShape;
  64121. /**
  64122. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64123. * @param impostor imposter containing the physics body and babylon object
  64124. */
  64125. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64126. /**
  64127. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64128. * @param impostor imposter containing the physics body and babylon object
  64129. * @param newPosition new position
  64130. * @param newRotation new rotation
  64131. */
  64132. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64133. /**
  64134. * If this plugin is supported
  64135. * @returns true if its supported
  64136. */
  64137. isSupported(): boolean;
  64138. /**
  64139. * Sets the linear velocity of the physics body
  64140. * @param impostor imposter to set the velocity on
  64141. * @param velocity velocity to set
  64142. */
  64143. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64144. /**
  64145. * Sets the angular velocity of the physics body
  64146. * @param impostor imposter to set the velocity on
  64147. * @param velocity velocity to set
  64148. */
  64149. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64150. /**
  64151. * gets the linear velocity
  64152. * @param impostor imposter to get linear velocity from
  64153. * @returns linear velocity
  64154. */
  64155. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64156. /**
  64157. * gets the angular velocity
  64158. * @param impostor imposter to get angular velocity from
  64159. * @returns angular velocity
  64160. */
  64161. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64162. /**
  64163. * Sets the mass of physics body
  64164. * @param impostor imposter to set the mass on
  64165. * @param mass mass to set
  64166. */
  64167. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64168. /**
  64169. * Gets the mass of the physics body
  64170. * @param impostor imposter to get the mass from
  64171. * @returns mass
  64172. */
  64173. getBodyMass(impostor: PhysicsImpostor): number;
  64174. /**
  64175. * Gets friction of the impostor
  64176. * @param impostor impostor to get friction from
  64177. * @returns friction value
  64178. */
  64179. getBodyFriction(impostor: PhysicsImpostor): number;
  64180. /**
  64181. * Sets friction of the impostor
  64182. * @param impostor impostor to set friction on
  64183. * @param friction friction value
  64184. */
  64185. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64186. /**
  64187. * Gets restitution of the impostor
  64188. * @param impostor impostor to get restitution from
  64189. * @returns restitution value
  64190. */
  64191. getBodyRestitution(impostor: PhysicsImpostor): number;
  64192. /**
  64193. * Sets resitution of the impostor
  64194. * @param impostor impostor to set resitution on
  64195. * @param restitution resitution value
  64196. */
  64197. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64198. /**
  64199. * Gets pressure inside the impostor
  64200. * @param impostor impostor to get pressure from
  64201. * @returns pressure value
  64202. */
  64203. getBodyPressure(impostor: PhysicsImpostor): number;
  64204. /**
  64205. * Sets pressure inside a soft body impostor
  64206. * Cloth and rope must remain 0 pressure
  64207. * @param impostor impostor to set pressure on
  64208. * @param pressure pressure value
  64209. */
  64210. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64211. /**
  64212. * Gets stiffness of the impostor
  64213. * @param impostor impostor to get stiffness from
  64214. * @returns pressure value
  64215. */
  64216. getBodyStiffness(impostor: PhysicsImpostor): number;
  64217. /**
  64218. * Sets stiffness of the impostor
  64219. * @param impostor impostor to set stiffness on
  64220. * @param stiffness stiffness value from 0 to 1
  64221. */
  64222. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64223. /**
  64224. * Gets velocityIterations of the impostor
  64225. * @param impostor impostor to get velocity iterations from
  64226. * @returns velocityIterations value
  64227. */
  64228. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64229. /**
  64230. * Sets velocityIterations of the impostor
  64231. * @param impostor impostor to set velocity iterations on
  64232. * @param velocityIterations velocityIterations value
  64233. */
  64234. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64235. /**
  64236. * Gets positionIterations of the impostor
  64237. * @param impostor impostor to get position iterations from
  64238. * @returns positionIterations value
  64239. */
  64240. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64241. /**
  64242. * Sets positionIterations of the impostor
  64243. * @param impostor impostor to set position on
  64244. * @param positionIterations positionIterations value
  64245. */
  64246. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64247. /**
  64248. * Append an anchor to a cloth object
  64249. * @param impostor is the cloth impostor to add anchor to
  64250. * @param otherImpostor is the rigid impostor to anchor to
  64251. * @param width ratio across width from 0 to 1
  64252. * @param height ratio up height from 0 to 1
  64253. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64254. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64255. */
  64256. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64257. /**
  64258. * Append an hook to a rope object
  64259. * @param impostor is the rope impostor to add hook to
  64260. * @param otherImpostor is the rigid impostor to hook to
  64261. * @param length ratio along the rope from 0 to 1
  64262. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64263. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64264. */
  64265. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64266. /**
  64267. * Sleeps the physics body and stops it from being active
  64268. * @param impostor impostor to sleep
  64269. */
  64270. sleepBody(impostor: PhysicsImpostor): void;
  64271. /**
  64272. * Activates the physics body
  64273. * @param impostor impostor to activate
  64274. */
  64275. wakeUpBody(impostor: PhysicsImpostor): void;
  64276. /**
  64277. * Updates the distance parameters of the joint
  64278. * @param joint joint to update
  64279. * @param maxDistance maximum distance of the joint
  64280. * @param minDistance minimum distance of the joint
  64281. */
  64282. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64283. /**
  64284. * Sets a motor on the joint
  64285. * @param joint joint to set motor on
  64286. * @param speed speed of the motor
  64287. * @param maxForce maximum force of the motor
  64288. * @param motorIndex index of the motor
  64289. */
  64290. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64291. /**
  64292. * Sets the motors limit
  64293. * @param joint joint to set limit on
  64294. * @param upperLimit upper limit
  64295. * @param lowerLimit lower limit
  64296. */
  64297. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64298. /**
  64299. * Syncs the position and rotation of a mesh with the impostor
  64300. * @param mesh mesh to sync
  64301. * @param impostor impostor to update the mesh with
  64302. */
  64303. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64304. /**
  64305. * Gets the radius of the impostor
  64306. * @param impostor impostor to get radius from
  64307. * @returns the radius
  64308. */
  64309. getRadius(impostor: PhysicsImpostor): number;
  64310. /**
  64311. * Gets the box size of the impostor
  64312. * @param impostor impostor to get box size from
  64313. * @param result the resulting box size
  64314. */
  64315. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64316. /**
  64317. * Disposes of the impostor
  64318. */
  64319. dispose(): void;
  64320. /**
  64321. * Does a raycast in the physics world
  64322. * @param from when should the ray start?
  64323. * @param to when should the ray end?
  64324. * @returns PhysicsRaycastResult
  64325. */
  64326. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64327. }
  64328. }
  64329. declare module "babylonjs/Probes/reflectionProbe" {
  64330. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64331. import { Vector3 } from "babylonjs/Maths/math.vector";
  64332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64333. import { Nullable } from "babylonjs/types";
  64334. import { Scene } from "babylonjs/scene";
  64335. module "babylonjs/abstractScene" {
  64336. interface AbstractScene {
  64337. /**
  64338. * The list of reflection probes added to the scene
  64339. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64340. */
  64341. reflectionProbes: Array<ReflectionProbe>;
  64342. /**
  64343. * Removes the given reflection probe from this scene.
  64344. * @param toRemove The reflection probe to remove
  64345. * @returns The index of the removed reflection probe
  64346. */
  64347. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64348. /**
  64349. * Adds the given reflection probe to this scene.
  64350. * @param newReflectionProbe The reflection probe to add
  64351. */
  64352. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64353. }
  64354. }
  64355. /**
  64356. * Class used to generate realtime reflection / refraction cube textures
  64357. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64358. */
  64359. export class ReflectionProbe {
  64360. /** defines the name of the probe */
  64361. name: string;
  64362. private _scene;
  64363. private _renderTargetTexture;
  64364. private _projectionMatrix;
  64365. private _viewMatrix;
  64366. private _target;
  64367. private _add;
  64368. private _attachedMesh;
  64369. private _invertYAxis;
  64370. /** Gets or sets probe position (center of the cube map) */
  64371. position: Vector3;
  64372. /**
  64373. * Creates a new reflection probe
  64374. * @param name defines the name of the probe
  64375. * @param size defines the texture resolution (for each face)
  64376. * @param scene defines the hosting scene
  64377. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64378. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64379. */
  64380. constructor(
  64381. /** defines the name of the probe */
  64382. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64383. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64384. get samples(): number;
  64385. set samples(value: number);
  64386. /** Gets or sets the refresh rate to use (on every frame by default) */
  64387. get refreshRate(): number;
  64388. set refreshRate(value: number);
  64389. /**
  64390. * Gets the hosting scene
  64391. * @returns a Scene
  64392. */
  64393. getScene(): Scene;
  64394. /** Gets the internal CubeTexture used to render to */
  64395. get cubeTexture(): RenderTargetTexture;
  64396. /** Gets the list of meshes to render */
  64397. get renderList(): Nullable<AbstractMesh[]>;
  64398. /**
  64399. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64400. * @param mesh defines the mesh to attach to
  64401. */
  64402. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64403. /**
  64404. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64405. * @param renderingGroupId The rendering group id corresponding to its index
  64406. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64407. */
  64408. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64409. /**
  64410. * Clean all associated resources
  64411. */
  64412. dispose(): void;
  64413. /**
  64414. * Converts the reflection probe information to a readable string for debug purpose.
  64415. * @param fullDetails Supports for multiple levels of logging within scene loading
  64416. * @returns the human readable reflection probe info
  64417. */
  64418. toString(fullDetails?: boolean): string;
  64419. /**
  64420. * Get the class name of the relfection probe.
  64421. * @returns "ReflectionProbe"
  64422. */
  64423. getClassName(): string;
  64424. /**
  64425. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64426. * @returns The JSON representation of the texture
  64427. */
  64428. serialize(): any;
  64429. /**
  64430. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64431. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64432. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64433. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64434. * @returns The parsed reflection probe if successful
  64435. */
  64436. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64437. }
  64438. }
  64439. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64440. /** @hidden */
  64441. export var _BabylonLoaderRegistered: boolean;
  64442. /**
  64443. * Helps setting up some configuration for the babylon file loader.
  64444. */
  64445. export class BabylonFileLoaderConfiguration {
  64446. /**
  64447. * The loader does not allow injecting custom physix engine into the plugins.
  64448. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64449. * So you could set this variable to your engine import to make it work.
  64450. */
  64451. static LoaderInjectedPhysicsEngine: any;
  64452. }
  64453. }
  64454. declare module "babylonjs/Loading/Plugins/index" {
  64455. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64456. }
  64457. declare module "babylonjs/Loading/index" {
  64458. export * from "babylonjs/Loading/loadingScreen";
  64459. export * from "babylonjs/Loading/Plugins/index";
  64460. export * from "babylonjs/Loading/sceneLoader";
  64461. export * from "babylonjs/Loading/sceneLoaderFlags";
  64462. }
  64463. declare module "babylonjs/Materials/Background/index" {
  64464. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64465. }
  64466. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64467. import { Scene } from "babylonjs/scene";
  64468. import { Color3 } from "babylonjs/Maths/math.color";
  64469. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64470. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64471. /**
  64472. * The Physically based simple base material of BJS.
  64473. *
  64474. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64475. * It is used as the base class for both the specGloss and metalRough conventions.
  64476. */
  64477. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64478. /**
  64479. * Number of Simultaneous lights allowed on the material.
  64480. */
  64481. maxSimultaneousLights: number;
  64482. /**
  64483. * If sets to true, disables all the lights affecting the material.
  64484. */
  64485. disableLighting: boolean;
  64486. /**
  64487. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64488. */
  64489. environmentTexture: BaseTexture;
  64490. /**
  64491. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64492. */
  64493. invertNormalMapX: boolean;
  64494. /**
  64495. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64496. */
  64497. invertNormalMapY: boolean;
  64498. /**
  64499. * Normal map used in the model.
  64500. */
  64501. normalTexture: BaseTexture;
  64502. /**
  64503. * Emissivie color used to self-illuminate the model.
  64504. */
  64505. emissiveColor: Color3;
  64506. /**
  64507. * Emissivie texture used to self-illuminate the model.
  64508. */
  64509. emissiveTexture: BaseTexture;
  64510. /**
  64511. * Occlusion Channel Strenght.
  64512. */
  64513. occlusionStrength: number;
  64514. /**
  64515. * Occlusion Texture of the material (adding extra occlusion effects).
  64516. */
  64517. occlusionTexture: BaseTexture;
  64518. /**
  64519. * Defines the alpha limits in alpha test mode.
  64520. */
  64521. alphaCutOff: number;
  64522. /**
  64523. * Gets the current double sided mode.
  64524. */
  64525. get doubleSided(): boolean;
  64526. /**
  64527. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64528. */
  64529. set doubleSided(value: boolean);
  64530. /**
  64531. * Stores the pre-calculated light information of a mesh in a texture.
  64532. */
  64533. lightmapTexture: BaseTexture;
  64534. /**
  64535. * If true, the light map contains occlusion information instead of lighting info.
  64536. */
  64537. useLightmapAsShadowmap: boolean;
  64538. /**
  64539. * Instantiates a new PBRMaterial instance.
  64540. *
  64541. * @param name The material name
  64542. * @param scene The scene the material will be use in.
  64543. */
  64544. constructor(name: string, scene: Scene);
  64545. getClassName(): string;
  64546. }
  64547. }
  64548. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64549. import { Scene } from "babylonjs/scene";
  64550. import { Color3 } from "babylonjs/Maths/math.color";
  64551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64552. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64553. /**
  64554. * The PBR material of BJS following the metal roughness convention.
  64555. *
  64556. * This fits to the PBR convention in the GLTF definition:
  64557. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64558. */
  64559. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64560. /**
  64561. * The base color has two different interpretations depending on the value of metalness.
  64562. * When the material is a metal, the base color is the specific measured reflectance value
  64563. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64564. * of the material.
  64565. */
  64566. baseColor: Color3;
  64567. /**
  64568. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64569. * well as opacity information in the alpha channel.
  64570. */
  64571. baseTexture: BaseTexture;
  64572. /**
  64573. * Specifies the metallic scalar value of the material.
  64574. * Can also be used to scale the metalness values of the metallic texture.
  64575. */
  64576. metallic: number;
  64577. /**
  64578. * Specifies the roughness scalar value of the material.
  64579. * Can also be used to scale the roughness values of the metallic texture.
  64580. */
  64581. roughness: number;
  64582. /**
  64583. * Texture containing both the metallic value in the B channel and the
  64584. * roughness value in the G channel to keep better precision.
  64585. */
  64586. metallicRoughnessTexture: BaseTexture;
  64587. /**
  64588. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64589. *
  64590. * @param name The material name
  64591. * @param scene The scene the material will be use in.
  64592. */
  64593. constructor(name: string, scene: Scene);
  64594. /**
  64595. * Return the currrent class name of the material.
  64596. */
  64597. getClassName(): string;
  64598. /**
  64599. * Makes a duplicate of the current material.
  64600. * @param name - name to use for the new material.
  64601. */
  64602. clone(name: string): PBRMetallicRoughnessMaterial;
  64603. /**
  64604. * Serialize the material to a parsable JSON object.
  64605. */
  64606. serialize(): any;
  64607. /**
  64608. * Parses a JSON object correponding to the serialize function.
  64609. */
  64610. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64611. }
  64612. }
  64613. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64614. import { Scene } from "babylonjs/scene";
  64615. import { Color3 } from "babylonjs/Maths/math.color";
  64616. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64617. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64618. /**
  64619. * The PBR material of BJS following the specular glossiness convention.
  64620. *
  64621. * This fits to the PBR convention in the GLTF definition:
  64622. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64623. */
  64624. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64625. /**
  64626. * Specifies the diffuse color of the material.
  64627. */
  64628. diffuseColor: Color3;
  64629. /**
  64630. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64631. * channel.
  64632. */
  64633. diffuseTexture: BaseTexture;
  64634. /**
  64635. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64636. */
  64637. specularColor: Color3;
  64638. /**
  64639. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64640. */
  64641. glossiness: number;
  64642. /**
  64643. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64644. */
  64645. specularGlossinessTexture: BaseTexture;
  64646. /**
  64647. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64648. *
  64649. * @param name The material name
  64650. * @param scene The scene the material will be use in.
  64651. */
  64652. constructor(name: string, scene: Scene);
  64653. /**
  64654. * Return the currrent class name of the material.
  64655. */
  64656. getClassName(): string;
  64657. /**
  64658. * Makes a duplicate of the current material.
  64659. * @param name - name to use for the new material.
  64660. */
  64661. clone(name: string): PBRSpecularGlossinessMaterial;
  64662. /**
  64663. * Serialize the material to a parsable JSON object.
  64664. */
  64665. serialize(): any;
  64666. /**
  64667. * Parses a JSON object correponding to the serialize function.
  64668. */
  64669. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64670. }
  64671. }
  64672. declare module "babylonjs/Materials/PBR/index" {
  64673. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64674. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64675. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64676. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64677. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64678. }
  64679. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64680. import { Nullable } from "babylonjs/types";
  64681. import { Scene } from "babylonjs/scene";
  64682. import { Matrix } from "babylonjs/Maths/math.vector";
  64683. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64684. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64685. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64686. /**
  64687. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64688. * It can help converting any input color in a desired output one. This can then be used to create effects
  64689. * from sepia, black and white to sixties or futuristic rendering...
  64690. *
  64691. * The only supported format is currently 3dl.
  64692. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64693. */
  64694. export class ColorGradingTexture extends BaseTexture {
  64695. /**
  64696. * The texture URL.
  64697. */
  64698. url: string;
  64699. /**
  64700. * Empty line regex stored for GC.
  64701. */
  64702. private static _noneEmptyLineRegex;
  64703. private _textureMatrix;
  64704. private _onLoad;
  64705. /**
  64706. * Instantiates a ColorGradingTexture from the following parameters.
  64707. *
  64708. * @param url The location of the color gradind data (currently only supporting 3dl)
  64709. * @param sceneOrEngine The scene or engine the texture will be used in
  64710. * @param onLoad defines a callback triggered when the texture has been loaded
  64711. */
  64712. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64713. /**
  64714. * Fires the onload event from the constructor if requested.
  64715. */
  64716. private _triggerOnLoad;
  64717. /**
  64718. * Returns the texture matrix used in most of the material.
  64719. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64720. */
  64721. getTextureMatrix(): Matrix;
  64722. /**
  64723. * Occurs when the file being loaded is a .3dl LUT file.
  64724. */
  64725. private load3dlTexture;
  64726. /**
  64727. * Starts the loading process of the texture.
  64728. */
  64729. private loadTexture;
  64730. /**
  64731. * Clones the color gradind texture.
  64732. */
  64733. clone(): ColorGradingTexture;
  64734. /**
  64735. * Called during delayed load for textures.
  64736. */
  64737. delayLoad(): void;
  64738. /**
  64739. * Parses a color grading texture serialized by Babylon.
  64740. * @param parsedTexture The texture information being parsedTexture
  64741. * @param scene The scene to load the texture in
  64742. * @param rootUrl The root url of the data assets to load
  64743. * @return A color gradind texture
  64744. */
  64745. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64746. /**
  64747. * Serializes the LUT texture to json format.
  64748. */
  64749. serialize(): any;
  64750. }
  64751. }
  64752. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64753. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64754. import { Scene } from "babylonjs/scene";
  64755. import { Nullable } from "babylonjs/types";
  64756. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64757. /**
  64758. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64759. */
  64760. export class EquiRectangularCubeTexture extends BaseTexture {
  64761. /** The six faces of the cube. */
  64762. private static _FacesMapping;
  64763. private _noMipmap;
  64764. private _onLoad;
  64765. private _onError;
  64766. /** The size of the cubemap. */
  64767. private _size;
  64768. /** The buffer of the image. */
  64769. private _buffer;
  64770. /** The width of the input image. */
  64771. private _width;
  64772. /** The height of the input image. */
  64773. private _height;
  64774. /** The URL to the image. */
  64775. url: string;
  64776. /**
  64777. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64778. * @param url The location of the image
  64779. * @param scene The scene the texture will be used in
  64780. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64781. * @param noMipmap Forces to not generate the mipmap if true
  64782. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64783. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64784. * @param onLoad — defines a callback called when texture is loaded
  64785. * @param onError — defines a callback called if there is an error
  64786. */
  64787. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64788. /**
  64789. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64790. */
  64791. private loadImage;
  64792. /**
  64793. * Convert the image buffer into a cubemap and create a CubeTexture.
  64794. */
  64795. private loadTexture;
  64796. /**
  64797. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64798. * @param buffer The ArrayBuffer that should be converted.
  64799. * @returns The buffer as Float32Array.
  64800. */
  64801. private getFloat32ArrayFromArrayBuffer;
  64802. /**
  64803. * Get the current class name of the texture useful for serialization or dynamic coding.
  64804. * @returns "EquiRectangularCubeTexture"
  64805. */
  64806. getClassName(): string;
  64807. /**
  64808. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64809. * @returns A clone of the current EquiRectangularCubeTexture.
  64810. */
  64811. clone(): EquiRectangularCubeTexture;
  64812. }
  64813. }
  64814. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64815. import { Nullable } from "babylonjs/types";
  64816. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64817. import { Matrix } from "babylonjs/Maths/math.vector";
  64818. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64819. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64820. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64821. import { Scene } from "babylonjs/scene";
  64822. /**
  64823. * Defines the options related to the creation of an HtmlElementTexture
  64824. */
  64825. export interface IHtmlElementTextureOptions {
  64826. /**
  64827. * Defines wether mip maps should be created or not.
  64828. */
  64829. generateMipMaps?: boolean;
  64830. /**
  64831. * Defines the sampling mode of the texture.
  64832. */
  64833. samplingMode?: number;
  64834. /**
  64835. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64836. */
  64837. engine: Nullable<ThinEngine>;
  64838. /**
  64839. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64840. */
  64841. scene: Nullable<Scene>;
  64842. }
  64843. /**
  64844. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64845. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64846. * is automatically managed.
  64847. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64848. * in your application.
  64849. *
  64850. * As the update is not automatic, you need to call them manually.
  64851. */
  64852. export class HtmlElementTexture extends BaseTexture {
  64853. /**
  64854. * The texture URL.
  64855. */
  64856. element: HTMLVideoElement | HTMLCanvasElement;
  64857. private static readonly DefaultOptions;
  64858. private _textureMatrix;
  64859. private _isVideo;
  64860. private _generateMipMaps;
  64861. private _samplingMode;
  64862. /**
  64863. * Instantiates a HtmlElementTexture from the following parameters.
  64864. *
  64865. * @param name Defines the name of the texture
  64866. * @param element Defines the video or canvas the texture is filled with
  64867. * @param options Defines the other none mandatory texture creation options
  64868. */
  64869. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64870. private _createInternalTexture;
  64871. /**
  64872. * Returns the texture matrix used in most of the material.
  64873. */
  64874. getTextureMatrix(): Matrix;
  64875. /**
  64876. * Updates the content of the texture.
  64877. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64878. */
  64879. update(invertY?: Nullable<boolean>): void;
  64880. }
  64881. }
  64882. declare module "babylonjs/Misc/tga" {
  64883. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64884. /**
  64885. * Based on jsTGALoader - Javascript loader for TGA file
  64886. * By Vincent Thibault
  64887. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64888. */
  64889. export class TGATools {
  64890. private static _TYPE_INDEXED;
  64891. private static _TYPE_RGB;
  64892. private static _TYPE_GREY;
  64893. private static _TYPE_RLE_INDEXED;
  64894. private static _TYPE_RLE_RGB;
  64895. private static _TYPE_RLE_GREY;
  64896. private static _ORIGIN_MASK;
  64897. private static _ORIGIN_SHIFT;
  64898. private static _ORIGIN_BL;
  64899. private static _ORIGIN_BR;
  64900. private static _ORIGIN_UL;
  64901. private static _ORIGIN_UR;
  64902. /**
  64903. * Gets the header of a TGA file
  64904. * @param data defines the TGA data
  64905. * @returns the header
  64906. */
  64907. static GetTGAHeader(data: Uint8Array): any;
  64908. /**
  64909. * Uploads TGA content to a Babylon Texture
  64910. * @hidden
  64911. */
  64912. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64913. /** @hidden */
  64914. 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;
  64915. /** @hidden */
  64916. 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;
  64917. /** @hidden */
  64918. 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;
  64919. /** @hidden */
  64920. 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;
  64921. /** @hidden */
  64922. 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;
  64923. /** @hidden */
  64924. 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;
  64925. }
  64926. }
  64927. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64928. import { Nullable } from "babylonjs/types";
  64929. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64930. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64931. /**
  64932. * Implementation of the TGA Texture Loader.
  64933. * @hidden
  64934. */
  64935. export class _TGATextureLoader implements IInternalTextureLoader {
  64936. /**
  64937. * Defines wether the loader supports cascade loading the different faces.
  64938. */
  64939. readonly supportCascades: boolean;
  64940. /**
  64941. * This returns if the loader support the current file information.
  64942. * @param extension defines the file extension of the file being loaded
  64943. * @returns true if the loader can load the specified file
  64944. */
  64945. canLoad(extension: string): boolean;
  64946. /**
  64947. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64948. * @param data contains the texture data
  64949. * @param texture defines the BabylonJS internal texture
  64950. * @param createPolynomials will be true if polynomials have been requested
  64951. * @param onLoad defines the callback to trigger once the texture is ready
  64952. * @param onError defines the callback to trigger in case of error
  64953. */
  64954. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64955. /**
  64956. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64957. * @param data contains the texture data
  64958. * @param texture defines the BabylonJS internal texture
  64959. * @param callback defines the method to call once ready to upload
  64960. */
  64961. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64962. }
  64963. }
  64964. declare module "babylonjs/Misc/basis" {
  64965. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64966. /**
  64967. * Info about the .basis files
  64968. */
  64969. class BasisFileInfo {
  64970. /**
  64971. * If the file has alpha
  64972. */
  64973. hasAlpha: boolean;
  64974. /**
  64975. * Info about each image of the basis file
  64976. */
  64977. images: Array<{
  64978. levels: Array<{
  64979. width: number;
  64980. height: number;
  64981. transcodedPixels: ArrayBufferView;
  64982. }>;
  64983. }>;
  64984. }
  64985. /**
  64986. * Result of transcoding a basis file
  64987. */
  64988. class TranscodeResult {
  64989. /**
  64990. * Info about the .basis file
  64991. */
  64992. fileInfo: BasisFileInfo;
  64993. /**
  64994. * Format to use when loading the file
  64995. */
  64996. format: number;
  64997. }
  64998. /**
  64999. * Configuration options for the Basis transcoder
  65000. */
  65001. export class BasisTranscodeConfiguration {
  65002. /**
  65003. * Supported compression formats used to determine the supported output format of the transcoder
  65004. */
  65005. supportedCompressionFormats?: {
  65006. /**
  65007. * etc1 compression format
  65008. */
  65009. etc1?: boolean;
  65010. /**
  65011. * s3tc compression format
  65012. */
  65013. s3tc?: boolean;
  65014. /**
  65015. * pvrtc compression format
  65016. */
  65017. pvrtc?: boolean;
  65018. /**
  65019. * etc2 compression format
  65020. */
  65021. etc2?: boolean;
  65022. };
  65023. /**
  65024. * If mipmap levels should be loaded for transcoded images (Default: true)
  65025. */
  65026. loadMipmapLevels?: boolean;
  65027. /**
  65028. * Index of a single image to load (Default: all images)
  65029. */
  65030. loadSingleImage?: number;
  65031. }
  65032. /**
  65033. * Used to load .Basis files
  65034. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65035. */
  65036. export class BasisTools {
  65037. private static _IgnoreSupportedFormats;
  65038. /**
  65039. * URL to use when loading the basis transcoder
  65040. */
  65041. static JSModuleURL: string;
  65042. /**
  65043. * URL to use when loading the wasm module for the transcoder
  65044. */
  65045. static WasmModuleURL: string;
  65046. /**
  65047. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65048. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65049. * @returns internal format corresponding to the Basis format
  65050. */
  65051. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65052. private static _WorkerPromise;
  65053. private static _Worker;
  65054. private static _actionId;
  65055. private static _CreateWorkerAsync;
  65056. /**
  65057. * Transcodes a loaded image file to compressed pixel data
  65058. * @param data image data to transcode
  65059. * @param config configuration options for the transcoding
  65060. * @returns a promise resulting in the transcoded image
  65061. */
  65062. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65063. /**
  65064. * Loads a texture from the transcode result
  65065. * @param texture texture load to
  65066. * @param transcodeResult the result of transcoding the basis file to load from
  65067. */
  65068. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65069. }
  65070. }
  65071. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65072. import { Nullable } from "babylonjs/types";
  65073. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65074. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65075. /**
  65076. * Loader for .basis file format
  65077. */
  65078. export class _BasisTextureLoader implements IInternalTextureLoader {
  65079. /**
  65080. * Defines whether the loader supports cascade loading the different faces.
  65081. */
  65082. readonly supportCascades: boolean;
  65083. /**
  65084. * This returns if the loader support the current file information.
  65085. * @param extension defines the file extension of the file being loaded
  65086. * @returns true if the loader can load the specified file
  65087. */
  65088. canLoad(extension: string): boolean;
  65089. /**
  65090. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65091. * @param data contains the texture data
  65092. * @param texture defines the BabylonJS internal texture
  65093. * @param createPolynomials will be true if polynomials have been requested
  65094. * @param onLoad defines the callback to trigger once the texture is ready
  65095. * @param onError defines the callback to trigger in case of error
  65096. */
  65097. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65098. /**
  65099. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65100. * @param data contains the texture data
  65101. * @param texture defines the BabylonJS internal texture
  65102. * @param callback defines the method to call once ready to upload
  65103. */
  65104. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65105. }
  65106. }
  65107. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65108. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65109. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65110. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65111. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65112. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65113. }
  65114. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65115. import { Vector2 } from "babylonjs/Maths/math.vector";
  65116. /**
  65117. * Defines the basic options interface of a TexturePacker Frame
  65118. */
  65119. export interface ITexturePackerFrame {
  65120. /**
  65121. * The frame ID
  65122. */
  65123. id: number;
  65124. /**
  65125. * The frames Scale
  65126. */
  65127. scale: Vector2;
  65128. /**
  65129. * The Frames offset
  65130. */
  65131. offset: Vector2;
  65132. }
  65133. /**
  65134. * This is a support class for frame Data on texture packer sets.
  65135. */
  65136. export class TexturePackerFrame implements ITexturePackerFrame {
  65137. /**
  65138. * The frame ID
  65139. */
  65140. id: number;
  65141. /**
  65142. * The frames Scale
  65143. */
  65144. scale: Vector2;
  65145. /**
  65146. * The Frames offset
  65147. */
  65148. offset: Vector2;
  65149. /**
  65150. * Initializes a texture package frame.
  65151. * @param id The numerical frame identifier
  65152. * @param scale Scalar Vector2 for UV frame
  65153. * @param offset Vector2 for the frame position in UV units.
  65154. * @returns TexturePackerFrame
  65155. */
  65156. constructor(id: number, scale: Vector2, offset: Vector2);
  65157. }
  65158. }
  65159. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65161. import { Scene } from "babylonjs/scene";
  65162. import { Nullable } from "babylonjs/types";
  65163. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65164. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65165. /**
  65166. * Defines the basic options interface of a TexturePacker
  65167. */
  65168. export interface ITexturePackerOptions {
  65169. /**
  65170. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65171. */
  65172. map?: string[];
  65173. /**
  65174. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65175. */
  65176. uvsIn?: string;
  65177. /**
  65178. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65179. */
  65180. uvsOut?: string;
  65181. /**
  65182. * number representing the layout style. Defaults to LAYOUT_STRIP
  65183. */
  65184. layout?: number;
  65185. /**
  65186. * number of columns if using custom column count layout(2). This defaults to 4.
  65187. */
  65188. colnum?: number;
  65189. /**
  65190. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65191. */
  65192. updateInputMeshes?: boolean;
  65193. /**
  65194. * boolean flag to dispose all the source textures. Defaults to true.
  65195. */
  65196. disposeSources?: boolean;
  65197. /**
  65198. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65199. */
  65200. fillBlanks?: boolean;
  65201. /**
  65202. * string value representing the context fill style color. Defaults to 'black'.
  65203. */
  65204. customFillColor?: string;
  65205. /**
  65206. * Width and Height Value of each Frame in the TexturePacker Sets
  65207. */
  65208. frameSize?: number;
  65209. /**
  65210. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65211. */
  65212. paddingRatio?: number;
  65213. /**
  65214. * Number that declares the fill method for the padding gutter.
  65215. */
  65216. paddingMode?: number;
  65217. /**
  65218. * If in SUBUV_COLOR padding mode what color to use.
  65219. */
  65220. paddingColor?: Color3 | Color4;
  65221. }
  65222. /**
  65223. * Defines the basic interface of a TexturePacker JSON File
  65224. */
  65225. export interface ITexturePackerJSON {
  65226. /**
  65227. * The frame ID
  65228. */
  65229. name: string;
  65230. /**
  65231. * The base64 channel data
  65232. */
  65233. sets: any;
  65234. /**
  65235. * The options of the Packer
  65236. */
  65237. options: ITexturePackerOptions;
  65238. /**
  65239. * The frame data of the Packer
  65240. */
  65241. frames: Array<number>;
  65242. }
  65243. /**
  65244. * This is a support class that generates a series of packed texture sets.
  65245. * @see https://doc.babylonjs.com/babylon101/materials
  65246. */
  65247. export class TexturePacker {
  65248. /** Packer Layout Constant 0 */
  65249. static readonly LAYOUT_STRIP: number;
  65250. /** Packer Layout Constant 1 */
  65251. static readonly LAYOUT_POWER2: number;
  65252. /** Packer Layout Constant 2 */
  65253. static readonly LAYOUT_COLNUM: number;
  65254. /** Packer Layout Constant 0 */
  65255. static readonly SUBUV_WRAP: number;
  65256. /** Packer Layout Constant 1 */
  65257. static readonly SUBUV_EXTEND: number;
  65258. /** Packer Layout Constant 2 */
  65259. static readonly SUBUV_COLOR: number;
  65260. /** The Name of the Texture Package */
  65261. name: string;
  65262. /** The scene scope of the TexturePacker */
  65263. scene: Scene;
  65264. /** The Meshes to target */
  65265. meshes: AbstractMesh[];
  65266. /** Arguments passed with the Constructor */
  65267. options: ITexturePackerOptions;
  65268. /** The promise that is started upon initialization */
  65269. promise: Nullable<Promise<TexturePacker | string>>;
  65270. /** The Container object for the channel sets that are generated */
  65271. sets: object;
  65272. /** The Container array for the frames that are generated */
  65273. frames: TexturePackerFrame[];
  65274. /** The expected number of textures the system is parsing. */
  65275. private _expecting;
  65276. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65277. private _paddingValue;
  65278. /**
  65279. * Initializes a texture package series from an array of meshes or a single mesh.
  65280. * @param name The name of the package
  65281. * @param meshes The target meshes to compose the package from
  65282. * @param options The arguments that texture packer should follow while building.
  65283. * @param scene The scene which the textures are scoped to.
  65284. * @returns TexturePacker
  65285. */
  65286. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65287. /**
  65288. * Starts the package process
  65289. * @param resolve The promises resolution function
  65290. * @returns TexturePacker
  65291. */
  65292. private _createFrames;
  65293. /**
  65294. * Calculates the Size of the Channel Sets
  65295. * @returns Vector2
  65296. */
  65297. private _calculateSize;
  65298. /**
  65299. * Calculates the UV data for the frames.
  65300. * @param baseSize the base frameSize
  65301. * @param padding the base frame padding
  65302. * @param dtSize size of the Dynamic Texture for that channel
  65303. * @param dtUnits is 1/dtSize
  65304. * @param update flag to update the input meshes
  65305. */
  65306. private _calculateMeshUVFrames;
  65307. /**
  65308. * Calculates the frames Offset.
  65309. * @param index of the frame
  65310. * @returns Vector2
  65311. */
  65312. private _getFrameOffset;
  65313. /**
  65314. * Updates a Mesh to the frame data
  65315. * @param mesh that is the target
  65316. * @param frameID or the frame index
  65317. */
  65318. private _updateMeshUV;
  65319. /**
  65320. * Updates a Meshes materials to use the texture packer channels
  65321. * @param m is the mesh to target
  65322. * @param force all channels on the packer to be set.
  65323. */
  65324. private _updateTextureReferences;
  65325. /**
  65326. * Public method to set a Mesh to a frame
  65327. * @param m that is the target
  65328. * @param frameID or the frame index
  65329. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65330. */
  65331. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65332. /**
  65333. * Starts the async promise to compile the texture packer.
  65334. * @returns Promise<void>
  65335. */
  65336. processAsync(): Promise<void>;
  65337. /**
  65338. * Disposes all textures associated with this packer
  65339. */
  65340. dispose(): void;
  65341. /**
  65342. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65343. * @param imageType is the image type to use.
  65344. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65345. */
  65346. download(imageType?: string, quality?: number): void;
  65347. /**
  65348. * Public method to load a texturePacker JSON file.
  65349. * @param data of the JSON file in string format.
  65350. */
  65351. updateFromJSON(data: string): void;
  65352. }
  65353. }
  65354. declare module "babylonjs/Materials/Textures/Packer/index" {
  65355. export * from "babylonjs/Materials/Textures/Packer/packer";
  65356. export * from "babylonjs/Materials/Textures/Packer/frame";
  65357. }
  65358. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65359. import { Scene } from "babylonjs/scene";
  65360. import { Texture } from "babylonjs/Materials/Textures/texture";
  65361. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65362. /**
  65363. * 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.
  65364. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65365. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65366. */
  65367. export class CustomProceduralTexture extends ProceduralTexture {
  65368. private _animate;
  65369. private _time;
  65370. private _config;
  65371. private _texturePath;
  65372. /**
  65373. * Instantiates a new Custom Procedural Texture.
  65374. * 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.
  65375. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65376. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65377. * @param name Define the name of the texture
  65378. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65379. * @param size Define the size of the texture to create
  65380. * @param scene Define the scene the texture belongs to
  65381. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65382. * @param generateMipMaps Define if the texture should creates mip maps or not
  65383. */
  65384. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65385. private _loadJson;
  65386. /**
  65387. * Is the texture ready to be used ? (rendered at least once)
  65388. * @returns true if ready, otherwise, false.
  65389. */
  65390. isReady(): boolean;
  65391. /**
  65392. * Render the texture to its associated render target.
  65393. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65394. */
  65395. render(useCameraPostProcess?: boolean): void;
  65396. /**
  65397. * Update the list of dependant textures samplers in the shader.
  65398. */
  65399. updateTextures(): void;
  65400. /**
  65401. * Update the uniform values of the procedural texture in the shader.
  65402. */
  65403. updateShaderUniforms(): void;
  65404. /**
  65405. * Define if the texture animates or not.
  65406. */
  65407. get animate(): boolean;
  65408. set animate(value: boolean);
  65409. }
  65410. }
  65411. declare module "babylonjs/Shaders/noise.fragment" {
  65412. /** @hidden */
  65413. export var noisePixelShader: {
  65414. name: string;
  65415. shader: string;
  65416. };
  65417. }
  65418. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65419. import { Nullable } from "babylonjs/types";
  65420. import { Scene } from "babylonjs/scene";
  65421. import { Texture } from "babylonjs/Materials/Textures/texture";
  65422. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65423. import "babylonjs/Shaders/noise.fragment";
  65424. /**
  65425. * Class used to generate noise procedural textures
  65426. */
  65427. export class NoiseProceduralTexture extends ProceduralTexture {
  65428. /** Gets or sets the start time (default is 0) */
  65429. time: number;
  65430. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65431. brightness: number;
  65432. /** Defines the number of octaves to process */
  65433. octaves: number;
  65434. /** Defines the level of persistence (0.8 by default) */
  65435. persistence: number;
  65436. /** Gets or sets animation speed factor (default is 1) */
  65437. animationSpeedFactor: number;
  65438. /**
  65439. * Creates a new NoiseProceduralTexture
  65440. * @param name defines the name fo the texture
  65441. * @param size defines the size of the texture (default is 256)
  65442. * @param scene defines the hosting scene
  65443. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65444. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65445. */
  65446. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65447. private _updateShaderUniforms;
  65448. protected _getDefines(): string;
  65449. /** Generate the current state of the procedural texture */
  65450. render(useCameraPostProcess?: boolean): void;
  65451. /**
  65452. * Serializes this noise procedural texture
  65453. * @returns a serialized noise procedural texture object
  65454. */
  65455. serialize(): any;
  65456. /**
  65457. * Clone the texture.
  65458. * @returns the cloned texture
  65459. */
  65460. clone(): NoiseProceduralTexture;
  65461. /**
  65462. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65463. * @param parsedTexture defines parsed texture data
  65464. * @param scene defines the current scene
  65465. * @param rootUrl defines the root URL containing noise procedural texture information
  65466. * @returns a parsed NoiseProceduralTexture
  65467. */
  65468. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65469. }
  65470. }
  65471. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65472. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65473. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65474. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65475. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65476. }
  65477. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65478. import { Nullable } from "babylonjs/types";
  65479. import { Scene } from "babylonjs/scene";
  65480. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65481. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65482. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65483. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65484. /**
  65485. * Raw cube texture where the raw buffers are passed in
  65486. */
  65487. export class RawCubeTexture extends CubeTexture {
  65488. /**
  65489. * Creates a cube texture where the raw buffers are passed in.
  65490. * @param scene defines the scene the texture is attached to
  65491. * @param data defines the array of data to use to create each face
  65492. * @param size defines the size of the textures
  65493. * @param format defines the format of the data
  65494. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65495. * @param generateMipMaps defines if the engine should generate the mip levels
  65496. * @param invertY defines if data must be stored with Y axis inverted
  65497. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65498. * @param compression defines the compression used (null by default)
  65499. */
  65500. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65501. /**
  65502. * Updates the raw cube texture.
  65503. * @param data defines the data to store
  65504. * @param format defines the data format
  65505. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65506. * @param invertY defines if data must be stored with Y axis inverted
  65507. * @param compression defines the compression used (null by default)
  65508. * @param level defines which level of the texture to update
  65509. */
  65510. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65511. /**
  65512. * Updates a raw cube texture with RGBD encoded data.
  65513. * @param data defines the array of data [mipmap][face] to use to create each face
  65514. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65515. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65516. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65517. * @returns a promsie that resolves when the operation is complete
  65518. */
  65519. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65520. /**
  65521. * Clones the raw cube texture.
  65522. * @return a new cube texture
  65523. */
  65524. clone(): CubeTexture;
  65525. /** @hidden */
  65526. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65527. }
  65528. }
  65529. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65530. import { Scene } from "babylonjs/scene";
  65531. import { Texture } from "babylonjs/Materials/Textures/texture";
  65532. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65533. /**
  65534. * Class used to store 2D array textures containing user data
  65535. */
  65536. export class RawTexture2DArray extends Texture {
  65537. /** Gets or sets the texture format to use */
  65538. format: number;
  65539. /**
  65540. * Create a new RawTexture2DArray
  65541. * @param data defines the data of the texture
  65542. * @param width defines the width of the texture
  65543. * @param height defines the height of the texture
  65544. * @param depth defines the number of layers of the texture
  65545. * @param format defines the texture format to use
  65546. * @param scene defines the hosting scene
  65547. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65548. * @param invertY defines if texture must be stored with Y axis inverted
  65549. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65550. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65551. */
  65552. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65553. /** Gets or sets the texture format to use */
  65554. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65555. /**
  65556. * Update the texture with new data
  65557. * @param data defines the data to store in the texture
  65558. */
  65559. update(data: ArrayBufferView): void;
  65560. }
  65561. }
  65562. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65563. import { Scene } from "babylonjs/scene";
  65564. import { Texture } from "babylonjs/Materials/Textures/texture";
  65565. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65566. /**
  65567. * Class used to store 3D textures containing user data
  65568. */
  65569. export class RawTexture3D extends Texture {
  65570. /** Gets or sets the texture format to use */
  65571. format: number;
  65572. /**
  65573. * Create a new RawTexture3D
  65574. * @param data defines the data of the texture
  65575. * @param width defines the width of the texture
  65576. * @param height defines the height of the texture
  65577. * @param depth defines the depth of the texture
  65578. * @param format defines the texture format to use
  65579. * @param scene defines the hosting scene
  65580. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65581. * @param invertY defines if texture must be stored with Y axis inverted
  65582. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65583. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65584. */
  65585. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65586. /** Gets or sets the texture format to use */
  65587. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65588. /**
  65589. * Update the texture with new data
  65590. * @param data defines the data to store in the texture
  65591. */
  65592. update(data: ArrayBufferView): void;
  65593. }
  65594. }
  65595. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65596. import { Scene } from "babylonjs/scene";
  65597. import { Plane } from "babylonjs/Maths/math.plane";
  65598. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65599. /**
  65600. * Creates a refraction texture used by refraction channel of the standard material.
  65601. * It is like a mirror but to see through a material.
  65602. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65603. */
  65604. export class RefractionTexture extends RenderTargetTexture {
  65605. /**
  65606. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65607. * 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.
  65608. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65609. */
  65610. refractionPlane: Plane;
  65611. /**
  65612. * Define how deep under the surface we should see.
  65613. */
  65614. depth: number;
  65615. /**
  65616. * Creates a refraction texture used by refraction channel of the standard material.
  65617. * It is like a mirror but to see through a material.
  65618. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65619. * @param name Define the texture name
  65620. * @param size Define the size of the underlying texture
  65621. * @param scene Define the scene the refraction belongs to
  65622. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65623. */
  65624. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65625. /**
  65626. * Clone the refraction texture.
  65627. * @returns the cloned texture
  65628. */
  65629. clone(): RefractionTexture;
  65630. /**
  65631. * Serialize the texture to a JSON representation you could use in Parse later on
  65632. * @returns the serialized JSON representation
  65633. */
  65634. serialize(): any;
  65635. }
  65636. }
  65637. declare module "babylonjs/Materials/Textures/index" {
  65638. export * from "babylonjs/Materials/Textures/baseTexture";
  65639. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65640. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65641. export * from "babylonjs/Materials/Textures/cubeTexture";
  65642. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65643. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65644. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65645. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65646. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65647. export * from "babylonjs/Materials/Textures/internalTexture";
  65648. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65649. export * from "babylonjs/Materials/Textures/Loaders/index";
  65650. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65651. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65652. export * from "babylonjs/Materials/Textures/Packer/index";
  65653. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65654. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65655. export * from "babylonjs/Materials/Textures/rawTexture";
  65656. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65657. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65658. export * from "babylonjs/Materials/Textures/refractionTexture";
  65659. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65660. export * from "babylonjs/Materials/Textures/texture";
  65661. export * from "babylonjs/Materials/Textures/videoTexture";
  65662. }
  65663. declare module "babylonjs/Materials/Node/Enums/index" {
  65664. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65665. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65666. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65667. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65668. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65669. }
  65670. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65671. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65672. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65674. import { Mesh } from "babylonjs/Meshes/mesh";
  65675. import { Effect } from "babylonjs/Materials/effect";
  65676. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65677. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65678. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65679. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65680. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65681. /**
  65682. * Block used to add support for vertex skinning (bones)
  65683. */
  65684. export class BonesBlock extends NodeMaterialBlock {
  65685. /**
  65686. * Creates a new BonesBlock
  65687. * @param name defines the block name
  65688. */
  65689. constructor(name: string);
  65690. /**
  65691. * Initialize the block and prepare the context for build
  65692. * @param state defines the state that will be used for the build
  65693. */
  65694. initialize(state: NodeMaterialBuildState): void;
  65695. /**
  65696. * Gets the current class name
  65697. * @returns the class name
  65698. */
  65699. getClassName(): string;
  65700. /**
  65701. * Gets the matrix indices input component
  65702. */
  65703. get matricesIndices(): NodeMaterialConnectionPoint;
  65704. /**
  65705. * Gets the matrix weights input component
  65706. */
  65707. get matricesWeights(): NodeMaterialConnectionPoint;
  65708. /**
  65709. * Gets the extra matrix indices input component
  65710. */
  65711. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65712. /**
  65713. * Gets the extra matrix weights input component
  65714. */
  65715. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65716. /**
  65717. * Gets the world input component
  65718. */
  65719. get world(): NodeMaterialConnectionPoint;
  65720. /**
  65721. * Gets the output component
  65722. */
  65723. get output(): NodeMaterialConnectionPoint;
  65724. autoConfigure(material: NodeMaterial): void;
  65725. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65726. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65727. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65728. protected _buildBlock(state: NodeMaterialBuildState): this;
  65729. }
  65730. }
  65731. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65733. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65734. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65736. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65737. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65738. /**
  65739. * Block used to add support for instances
  65740. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65741. */
  65742. export class InstancesBlock extends NodeMaterialBlock {
  65743. /**
  65744. * Creates a new InstancesBlock
  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 first world row input component
  65755. */
  65756. get world0(): NodeMaterialConnectionPoint;
  65757. /**
  65758. * Gets the second world row input component
  65759. */
  65760. get world1(): NodeMaterialConnectionPoint;
  65761. /**
  65762. * Gets the third world row input component
  65763. */
  65764. get world2(): NodeMaterialConnectionPoint;
  65765. /**
  65766. * Gets the forth world row input component
  65767. */
  65768. get world3(): NodeMaterialConnectionPoint;
  65769. /**
  65770. * Gets the world input component
  65771. */
  65772. get world(): NodeMaterialConnectionPoint;
  65773. /**
  65774. * Gets the output component
  65775. */
  65776. get output(): NodeMaterialConnectionPoint;
  65777. /**
  65778. * Gets the isntanceID component
  65779. */
  65780. get instanceID(): NodeMaterialConnectionPoint;
  65781. autoConfigure(material: NodeMaterial): void;
  65782. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65783. protected _buildBlock(state: NodeMaterialBuildState): this;
  65784. }
  65785. }
  65786. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65788. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65789. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65791. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65792. import { Effect } from "babylonjs/Materials/effect";
  65793. import { Mesh } from "babylonjs/Meshes/mesh";
  65794. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65795. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65796. /**
  65797. * Block used to add morph targets support to vertex shader
  65798. */
  65799. export class MorphTargetsBlock extends NodeMaterialBlock {
  65800. private _repeatableContentAnchor;
  65801. /**
  65802. * Create a new MorphTargetsBlock
  65803. * @param name defines the block name
  65804. */
  65805. constructor(name: string);
  65806. /**
  65807. * Gets the current class name
  65808. * @returns the class name
  65809. */
  65810. getClassName(): string;
  65811. /**
  65812. * Gets the position input component
  65813. */
  65814. get position(): NodeMaterialConnectionPoint;
  65815. /**
  65816. * Gets the normal input component
  65817. */
  65818. get normal(): NodeMaterialConnectionPoint;
  65819. /**
  65820. * Gets the tangent input component
  65821. */
  65822. get tangent(): NodeMaterialConnectionPoint;
  65823. /**
  65824. * Gets the tangent input component
  65825. */
  65826. get uv(): NodeMaterialConnectionPoint;
  65827. /**
  65828. * Gets the position output component
  65829. */
  65830. get positionOutput(): NodeMaterialConnectionPoint;
  65831. /**
  65832. * Gets the normal output component
  65833. */
  65834. get normalOutput(): NodeMaterialConnectionPoint;
  65835. /**
  65836. * Gets the tangent output component
  65837. */
  65838. get tangentOutput(): NodeMaterialConnectionPoint;
  65839. /**
  65840. * Gets the tangent output component
  65841. */
  65842. get uvOutput(): NodeMaterialConnectionPoint;
  65843. initialize(state: NodeMaterialBuildState): void;
  65844. autoConfigure(material: NodeMaterial): void;
  65845. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65846. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65847. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65848. protected _buildBlock(state: NodeMaterialBuildState): this;
  65849. }
  65850. }
  65851. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65855. import { Nullable } from "babylonjs/types";
  65856. import { Scene } from "babylonjs/scene";
  65857. import { Effect } from "babylonjs/Materials/effect";
  65858. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65859. import { Mesh } from "babylonjs/Meshes/mesh";
  65860. import { Light } from "babylonjs/Lights/light";
  65861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65862. /**
  65863. * Block used to get data information from a light
  65864. */
  65865. export class LightInformationBlock extends NodeMaterialBlock {
  65866. private _lightDataUniformName;
  65867. private _lightColorUniformName;
  65868. private _lightTypeDefineName;
  65869. /**
  65870. * Gets or sets the light associated with this block
  65871. */
  65872. light: Nullable<Light>;
  65873. /**
  65874. * Creates a new LightInformationBlock
  65875. * @param name defines the block name
  65876. */
  65877. constructor(name: string);
  65878. /**
  65879. * Gets the current class name
  65880. * @returns the class name
  65881. */
  65882. getClassName(): string;
  65883. /**
  65884. * Gets the world position input component
  65885. */
  65886. get worldPosition(): NodeMaterialConnectionPoint;
  65887. /**
  65888. * Gets the direction output component
  65889. */
  65890. get direction(): NodeMaterialConnectionPoint;
  65891. /**
  65892. * Gets the direction output component
  65893. */
  65894. get color(): NodeMaterialConnectionPoint;
  65895. /**
  65896. * Gets the direction output component
  65897. */
  65898. get intensity(): NodeMaterialConnectionPoint;
  65899. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65900. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65901. protected _buildBlock(state: NodeMaterialBuildState): this;
  65902. serialize(): any;
  65903. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65904. }
  65905. }
  65906. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65907. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65908. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65909. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65910. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65911. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65912. }
  65913. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65918. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65919. import { Effect } from "babylonjs/Materials/effect";
  65920. import { Mesh } from "babylonjs/Meshes/mesh";
  65921. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65922. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65923. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65924. /**
  65925. * Block used to add image processing support to fragment shader
  65926. */
  65927. export class ImageProcessingBlock extends NodeMaterialBlock {
  65928. /**
  65929. * Create a new ImageProcessingBlock
  65930. * @param name defines the block name
  65931. */
  65932. constructor(name: string);
  65933. /**
  65934. * Gets the current class name
  65935. * @returns the class name
  65936. */
  65937. getClassName(): string;
  65938. /**
  65939. * Gets the color input component
  65940. */
  65941. get color(): NodeMaterialConnectionPoint;
  65942. /**
  65943. * Gets the output component
  65944. */
  65945. get output(): NodeMaterialConnectionPoint;
  65946. /**
  65947. * Initialize the block and prepare the context for build
  65948. * @param state defines the state that will be used for the build
  65949. */
  65950. initialize(state: NodeMaterialBuildState): void;
  65951. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65952. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65953. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65954. protected _buildBlock(state: NodeMaterialBuildState): this;
  65955. }
  65956. }
  65957. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65961. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65963. import { Effect } from "babylonjs/Materials/effect";
  65964. import { Mesh } from "babylonjs/Meshes/mesh";
  65965. import { Scene } from "babylonjs/scene";
  65966. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65967. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65968. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65969. /**
  65970. * Block used to pertub normals based on a normal map
  65971. */
  65972. export class PerturbNormalBlock extends NodeMaterialBlock {
  65973. private _tangentSpaceParameterName;
  65974. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65975. invertX: boolean;
  65976. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65977. invertY: boolean;
  65978. /**
  65979. * Create a new PerturbNormalBlock
  65980. * @param name defines the block name
  65981. */
  65982. constructor(name: string);
  65983. /**
  65984. * Gets the current class name
  65985. * @returns the class name
  65986. */
  65987. getClassName(): string;
  65988. /**
  65989. * Gets the world position input component
  65990. */
  65991. get worldPosition(): NodeMaterialConnectionPoint;
  65992. /**
  65993. * Gets the world normal input component
  65994. */
  65995. get worldNormal(): NodeMaterialConnectionPoint;
  65996. /**
  65997. * Gets the world tangent input component
  65998. */
  65999. get worldTangent(): NodeMaterialConnectionPoint;
  66000. /**
  66001. * Gets the uv input component
  66002. */
  66003. get uv(): NodeMaterialConnectionPoint;
  66004. /**
  66005. * Gets the normal map color input component
  66006. */
  66007. get normalMapColor(): NodeMaterialConnectionPoint;
  66008. /**
  66009. * Gets the strength input component
  66010. */
  66011. get strength(): NodeMaterialConnectionPoint;
  66012. /**
  66013. * Gets the output component
  66014. */
  66015. get output(): NodeMaterialConnectionPoint;
  66016. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66017. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66018. autoConfigure(material: NodeMaterial): void;
  66019. protected _buildBlock(state: NodeMaterialBuildState): this;
  66020. protected _dumpPropertiesCode(): string;
  66021. serialize(): any;
  66022. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66023. }
  66024. }
  66025. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66026. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66027. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66028. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66029. /**
  66030. * Block used to discard a pixel if a value is smaller than a cutoff
  66031. */
  66032. export class DiscardBlock extends NodeMaterialBlock {
  66033. /**
  66034. * Create a new DiscardBlock
  66035. * @param name defines the block name
  66036. */
  66037. constructor(name: string);
  66038. /**
  66039. * Gets the current class name
  66040. * @returns the class name
  66041. */
  66042. getClassName(): string;
  66043. /**
  66044. * Gets the color input component
  66045. */
  66046. get value(): NodeMaterialConnectionPoint;
  66047. /**
  66048. * Gets the cutoff input component
  66049. */
  66050. get cutoff(): NodeMaterialConnectionPoint;
  66051. protected _buildBlock(state: NodeMaterialBuildState): this;
  66052. }
  66053. }
  66054. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66055. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66056. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66057. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66058. /**
  66059. * Block used to test if the fragment shader is front facing
  66060. */
  66061. export class FrontFacingBlock extends NodeMaterialBlock {
  66062. /**
  66063. * Creates a new FrontFacingBlock
  66064. * @param name defines the block name
  66065. */
  66066. constructor(name: string);
  66067. /**
  66068. * Gets the current class name
  66069. * @returns the class name
  66070. */
  66071. getClassName(): string;
  66072. /**
  66073. * Gets the output component
  66074. */
  66075. get output(): NodeMaterialConnectionPoint;
  66076. protected _buildBlock(state: NodeMaterialBuildState): this;
  66077. }
  66078. }
  66079. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66080. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66081. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66082. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66083. /**
  66084. * Block used to get the derivative value on x and y of a given input
  66085. */
  66086. export class DerivativeBlock extends NodeMaterialBlock {
  66087. /**
  66088. * Create a new DerivativeBlock
  66089. * @param name defines the block name
  66090. */
  66091. constructor(name: string);
  66092. /**
  66093. * Gets the current class name
  66094. * @returns the class name
  66095. */
  66096. getClassName(): string;
  66097. /**
  66098. * Gets the input component
  66099. */
  66100. get input(): NodeMaterialConnectionPoint;
  66101. /**
  66102. * Gets the derivative output on x
  66103. */
  66104. get dx(): NodeMaterialConnectionPoint;
  66105. /**
  66106. * Gets the derivative output on y
  66107. */
  66108. get dy(): NodeMaterialConnectionPoint;
  66109. protected _buildBlock(state: NodeMaterialBuildState): this;
  66110. }
  66111. }
  66112. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66113. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66114. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66115. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66116. /**
  66117. * Block used to make gl_FragCoord available
  66118. */
  66119. export class FragCoordBlock extends NodeMaterialBlock {
  66120. /**
  66121. * Creates a new FragCoordBlock
  66122. * @param name defines the block name
  66123. */
  66124. constructor(name: string);
  66125. /**
  66126. * Gets the current class name
  66127. * @returns the class name
  66128. */
  66129. getClassName(): string;
  66130. /**
  66131. * Gets the xy component
  66132. */
  66133. get xy(): NodeMaterialConnectionPoint;
  66134. /**
  66135. * Gets the xyz component
  66136. */
  66137. get xyz(): NodeMaterialConnectionPoint;
  66138. /**
  66139. * Gets the xyzw component
  66140. */
  66141. get xyzw(): NodeMaterialConnectionPoint;
  66142. /**
  66143. * Gets the x component
  66144. */
  66145. get x(): NodeMaterialConnectionPoint;
  66146. /**
  66147. * Gets the y component
  66148. */
  66149. get y(): NodeMaterialConnectionPoint;
  66150. /**
  66151. * Gets the z component
  66152. */
  66153. get z(): NodeMaterialConnectionPoint;
  66154. /**
  66155. * Gets the w component
  66156. */
  66157. get output(): NodeMaterialConnectionPoint;
  66158. protected writeOutputs(state: NodeMaterialBuildState): string;
  66159. protected _buildBlock(state: NodeMaterialBuildState): this;
  66160. }
  66161. }
  66162. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66163. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66164. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66165. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66166. import { Effect } from "babylonjs/Materials/effect";
  66167. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66168. import { Mesh } from "babylonjs/Meshes/mesh";
  66169. /**
  66170. * Block used to get the screen sizes
  66171. */
  66172. export class ScreenSizeBlock extends NodeMaterialBlock {
  66173. private _varName;
  66174. private _scene;
  66175. /**
  66176. * Creates a new ScreenSizeBlock
  66177. * @param name defines the block name
  66178. */
  66179. constructor(name: string);
  66180. /**
  66181. * Gets the current class name
  66182. * @returns the class name
  66183. */
  66184. getClassName(): string;
  66185. /**
  66186. * Gets the xy component
  66187. */
  66188. get xy(): NodeMaterialConnectionPoint;
  66189. /**
  66190. * Gets the x component
  66191. */
  66192. get x(): NodeMaterialConnectionPoint;
  66193. /**
  66194. * Gets the y component
  66195. */
  66196. get y(): NodeMaterialConnectionPoint;
  66197. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66198. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66199. protected _buildBlock(state: NodeMaterialBuildState): this;
  66200. }
  66201. }
  66202. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66203. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66204. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66205. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66206. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66207. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66208. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66209. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66210. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66211. }
  66212. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66215. import { Mesh } from "babylonjs/Meshes/mesh";
  66216. import { Effect } from "babylonjs/Materials/effect";
  66217. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66219. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66220. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66221. /**
  66222. * Block used to add support for scene fog
  66223. */
  66224. export class FogBlock extends NodeMaterialBlock {
  66225. private _fogDistanceName;
  66226. private _fogParameters;
  66227. /**
  66228. * Create a new FogBlock
  66229. * @param name defines the block name
  66230. */
  66231. constructor(name: string);
  66232. /**
  66233. * Gets the current class name
  66234. * @returns the class name
  66235. */
  66236. getClassName(): string;
  66237. /**
  66238. * Gets the world position input component
  66239. */
  66240. get worldPosition(): NodeMaterialConnectionPoint;
  66241. /**
  66242. * Gets the view input component
  66243. */
  66244. get view(): NodeMaterialConnectionPoint;
  66245. /**
  66246. * Gets the color input component
  66247. */
  66248. get input(): NodeMaterialConnectionPoint;
  66249. /**
  66250. * Gets the fog color input component
  66251. */
  66252. get fogColor(): NodeMaterialConnectionPoint;
  66253. /**
  66254. * Gets the output component
  66255. */
  66256. get output(): NodeMaterialConnectionPoint;
  66257. autoConfigure(material: NodeMaterial): void;
  66258. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66259. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66260. protected _buildBlock(state: NodeMaterialBuildState): this;
  66261. }
  66262. }
  66263. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  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 { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66268. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66269. import { Effect } from "babylonjs/Materials/effect";
  66270. import { Mesh } from "babylonjs/Meshes/mesh";
  66271. import { Light } from "babylonjs/Lights/light";
  66272. import { Nullable } from "babylonjs/types";
  66273. import { Scene } from "babylonjs/scene";
  66274. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66275. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66276. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66277. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66278. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66279. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66280. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66281. /**
  66282. * Block used to add light in the fragment shader
  66283. */
  66284. export class LightBlock extends NodeMaterialBlock {
  66285. private _lightId;
  66286. /**
  66287. * Gets or sets the light associated with this block
  66288. */
  66289. light: Nullable<Light>;
  66290. /**
  66291. * Create a new LightBlock
  66292. * @param name defines the block name
  66293. */
  66294. constructor(name: string);
  66295. /**
  66296. * Gets the current class name
  66297. * @returns the class name
  66298. */
  66299. getClassName(): string;
  66300. /**
  66301. * Gets the world position input component
  66302. */
  66303. get worldPosition(): NodeMaterialConnectionPoint;
  66304. /**
  66305. * Gets the world normal input component
  66306. */
  66307. get worldNormal(): NodeMaterialConnectionPoint;
  66308. /**
  66309. * Gets the camera (or eye) position component
  66310. */
  66311. get cameraPosition(): NodeMaterialConnectionPoint;
  66312. /**
  66313. * Gets the glossiness component
  66314. */
  66315. get glossiness(): NodeMaterialConnectionPoint;
  66316. /**
  66317. * Gets the glossinness power component
  66318. */
  66319. get glossPower(): NodeMaterialConnectionPoint;
  66320. /**
  66321. * Gets the diffuse color component
  66322. */
  66323. get diffuseColor(): NodeMaterialConnectionPoint;
  66324. /**
  66325. * Gets the specular color component
  66326. */
  66327. get specularColor(): NodeMaterialConnectionPoint;
  66328. /**
  66329. * Gets the diffuse output component
  66330. */
  66331. get diffuseOutput(): NodeMaterialConnectionPoint;
  66332. /**
  66333. * Gets the specular output component
  66334. */
  66335. get specularOutput(): NodeMaterialConnectionPoint;
  66336. /**
  66337. * Gets the shadow output component
  66338. */
  66339. get shadow(): NodeMaterialConnectionPoint;
  66340. autoConfigure(material: NodeMaterial): void;
  66341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66342. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66344. private _injectVertexCode;
  66345. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66346. serialize(): any;
  66347. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66348. }
  66349. }
  66350. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66351. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66352. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66353. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66354. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66355. /**
  66356. * Block used to read a reflection texture from a sampler
  66357. */
  66358. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66359. /**
  66360. * Create a new ReflectionTextureBlock
  66361. * @param name defines the block name
  66362. */
  66363. constructor(name: string);
  66364. /**
  66365. * Gets the current class name
  66366. * @returns the class name
  66367. */
  66368. getClassName(): string;
  66369. /**
  66370. * Gets the world position input component
  66371. */
  66372. get position(): NodeMaterialConnectionPoint;
  66373. /**
  66374. * Gets the world position input component
  66375. */
  66376. get worldPosition(): NodeMaterialConnectionPoint;
  66377. /**
  66378. * Gets the world normal input component
  66379. */
  66380. get worldNormal(): NodeMaterialConnectionPoint;
  66381. /**
  66382. * Gets the world input component
  66383. */
  66384. get world(): NodeMaterialConnectionPoint;
  66385. /**
  66386. * Gets the camera (or eye) position component
  66387. */
  66388. get cameraPosition(): NodeMaterialConnectionPoint;
  66389. /**
  66390. * Gets the view input component
  66391. */
  66392. get view(): NodeMaterialConnectionPoint;
  66393. /**
  66394. * Gets the rgb output component
  66395. */
  66396. get rgb(): NodeMaterialConnectionPoint;
  66397. /**
  66398. * Gets the rgba output component
  66399. */
  66400. get rgba(): NodeMaterialConnectionPoint;
  66401. /**
  66402. * Gets the r output component
  66403. */
  66404. get r(): NodeMaterialConnectionPoint;
  66405. /**
  66406. * Gets the g output component
  66407. */
  66408. get g(): NodeMaterialConnectionPoint;
  66409. /**
  66410. * Gets the b output component
  66411. */
  66412. get b(): NodeMaterialConnectionPoint;
  66413. /**
  66414. * Gets the a output component
  66415. */
  66416. get a(): NodeMaterialConnectionPoint;
  66417. autoConfigure(material: NodeMaterial): void;
  66418. protected _buildBlock(state: NodeMaterialBuildState): this;
  66419. }
  66420. }
  66421. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66422. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66423. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66424. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66425. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66426. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66427. }
  66428. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66429. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66430. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66431. }
  66432. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66435. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66436. /**
  66437. * Block used to add 2 vectors
  66438. */
  66439. export class AddBlock extends NodeMaterialBlock {
  66440. /**
  66441. * Creates a new AddBlock
  66442. * @param name defines the block name
  66443. */
  66444. constructor(name: string);
  66445. /**
  66446. * Gets the current class name
  66447. * @returns the class name
  66448. */
  66449. getClassName(): string;
  66450. /**
  66451. * Gets the left operand input component
  66452. */
  66453. get left(): NodeMaterialConnectionPoint;
  66454. /**
  66455. * Gets the right operand input component
  66456. */
  66457. get right(): NodeMaterialConnectionPoint;
  66458. /**
  66459. * Gets the output component
  66460. */
  66461. get output(): NodeMaterialConnectionPoint;
  66462. protected _buildBlock(state: NodeMaterialBuildState): this;
  66463. }
  66464. }
  66465. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66469. /**
  66470. * Block used to scale a vector by a float
  66471. */
  66472. export class ScaleBlock extends NodeMaterialBlock {
  66473. /**
  66474. * Creates a new ScaleBlock
  66475. * @param name defines the block name
  66476. */
  66477. constructor(name: string);
  66478. /**
  66479. * Gets the current class name
  66480. * @returns the class name
  66481. */
  66482. getClassName(): string;
  66483. /**
  66484. * Gets the input component
  66485. */
  66486. get input(): NodeMaterialConnectionPoint;
  66487. /**
  66488. * Gets the factor input component
  66489. */
  66490. get factor(): NodeMaterialConnectionPoint;
  66491. /**
  66492. * Gets the output component
  66493. */
  66494. get output(): NodeMaterialConnectionPoint;
  66495. protected _buildBlock(state: NodeMaterialBuildState): this;
  66496. }
  66497. }
  66498. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66500. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66502. import { Scene } from "babylonjs/scene";
  66503. /**
  66504. * Block used to clamp a float
  66505. */
  66506. export class ClampBlock extends NodeMaterialBlock {
  66507. /** Gets or sets the minimum range */
  66508. minimum: number;
  66509. /** Gets or sets the maximum range */
  66510. maximum: number;
  66511. /**
  66512. * Creates a new ClampBlock
  66513. * @param name defines the block name
  66514. */
  66515. constructor(name: string);
  66516. /**
  66517. * Gets the current class name
  66518. * @returns the class name
  66519. */
  66520. getClassName(): string;
  66521. /**
  66522. * Gets the value input component
  66523. */
  66524. get value(): NodeMaterialConnectionPoint;
  66525. /**
  66526. * Gets the output component
  66527. */
  66528. get output(): NodeMaterialConnectionPoint;
  66529. protected _buildBlock(state: NodeMaterialBuildState): this;
  66530. protected _dumpPropertiesCode(): string;
  66531. serialize(): any;
  66532. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66533. }
  66534. }
  66535. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66536. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66537. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66538. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66539. /**
  66540. * Block used to apply a cross product between 2 vectors
  66541. */
  66542. export class CrossBlock extends NodeMaterialBlock {
  66543. /**
  66544. * Creates a new CrossBlock
  66545. * @param name defines the block name
  66546. */
  66547. constructor(name: string);
  66548. /**
  66549. * Gets the current class name
  66550. * @returns the class name
  66551. */
  66552. getClassName(): string;
  66553. /**
  66554. * Gets the left operand input component
  66555. */
  66556. get left(): NodeMaterialConnectionPoint;
  66557. /**
  66558. * Gets the right operand input component
  66559. */
  66560. get right(): NodeMaterialConnectionPoint;
  66561. /**
  66562. * Gets the output component
  66563. */
  66564. get output(): NodeMaterialConnectionPoint;
  66565. protected _buildBlock(state: NodeMaterialBuildState): this;
  66566. }
  66567. }
  66568. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66572. /**
  66573. * Block used to apply a dot product between 2 vectors
  66574. */
  66575. export class DotBlock extends NodeMaterialBlock {
  66576. /**
  66577. * Creates a new DotBlock
  66578. * @param name defines the block name
  66579. */
  66580. constructor(name: string);
  66581. /**
  66582. * Gets the current class name
  66583. * @returns the class name
  66584. */
  66585. getClassName(): string;
  66586. /**
  66587. * Gets the left operand input component
  66588. */
  66589. get left(): NodeMaterialConnectionPoint;
  66590. /**
  66591. * Gets the right operand input component
  66592. */
  66593. get right(): NodeMaterialConnectionPoint;
  66594. /**
  66595. * Gets the output component
  66596. */
  66597. get output(): NodeMaterialConnectionPoint;
  66598. protected _buildBlock(state: NodeMaterialBuildState): this;
  66599. }
  66600. }
  66601. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66602. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66603. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66604. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66605. /**
  66606. * Block used to normalize a vector
  66607. */
  66608. export class NormalizeBlock extends NodeMaterialBlock {
  66609. /**
  66610. * Creates a new NormalizeBlock
  66611. * @param name defines the block name
  66612. */
  66613. constructor(name: string);
  66614. /**
  66615. * Gets the current class name
  66616. * @returns the class name
  66617. */
  66618. getClassName(): string;
  66619. /**
  66620. * Gets the input component
  66621. */
  66622. get input(): NodeMaterialConnectionPoint;
  66623. /**
  66624. * Gets the output component
  66625. */
  66626. get output(): NodeMaterialConnectionPoint;
  66627. protected _buildBlock(state: NodeMaterialBuildState): this;
  66628. }
  66629. }
  66630. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66631. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66633. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66634. /**
  66635. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66636. */
  66637. export class ColorMergerBlock extends NodeMaterialBlock {
  66638. /**
  66639. * Create a new ColorMergerBlock
  66640. * @param name defines the block name
  66641. */
  66642. constructor(name: string);
  66643. /**
  66644. * Gets the current class name
  66645. * @returns the class name
  66646. */
  66647. getClassName(): string;
  66648. /**
  66649. * Gets the rgb component (input)
  66650. */
  66651. get rgbIn(): NodeMaterialConnectionPoint;
  66652. /**
  66653. * Gets the r component (input)
  66654. */
  66655. get r(): NodeMaterialConnectionPoint;
  66656. /**
  66657. * Gets the g component (input)
  66658. */
  66659. get g(): NodeMaterialConnectionPoint;
  66660. /**
  66661. * Gets the b component (input)
  66662. */
  66663. get b(): NodeMaterialConnectionPoint;
  66664. /**
  66665. * Gets the a component (input)
  66666. */
  66667. get a(): NodeMaterialConnectionPoint;
  66668. /**
  66669. * Gets the rgba component (output)
  66670. */
  66671. get rgba(): NodeMaterialConnectionPoint;
  66672. /**
  66673. * Gets the rgb component (output)
  66674. */
  66675. get rgbOut(): NodeMaterialConnectionPoint;
  66676. /**
  66677. * Gets the rgb component (output)
  66678. * @deprecated Please use rgbOut instead.
  66679. */
  66680. get rgb(): NodeMaterialConnectionPoint;
  66681. protected _buildBlock(state: NodeMaterialBuildState): this;
  66682. }
  66683. }
  66684. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66685. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66686. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66687. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66688. /**
  66689. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66690. */
  66691. export class VectorSplitterBlock extends NodeMaterialBlock {
  66692. /**
  66693. * Create a new VectorSplitterBlock
  66694. * @param name defines the block name
  66695. */
  66696. constructor(name: string);
  66697. /**
  66698. * Gets the current class name
  66699. * @returns the class name
  66700. */
  66701. getClassName(): string;
  66702. /**
  66703. * Gets the xyzw component (input)
  66704. */
  66705. get xyzw(): NodeMaterialConnectionPoint;
  66706. /**
  66707. * Gets the xyz component (input)
  66708. */
  66709. get xyzIn(): NodeMaterialConnectionPoint;
  66710. /**
  66711. * Gets the xy component (input)
  66712. */
  66713. get xyIn(): NodeMaterialConnectionPoint;
  66714. /**
  66715. * Gets the xyz component (output)
  66716. */
  66717. get xyzOut(): NodeMaterialConnectionPoint;
  66718. /**
  66719. * Gets the xy component (output)
  66720. */
  66721. get xyOut(): NodeMaterialConnectionPoint;
  66722. /**
  66723. * Gets the x component (output)
  66724. */
  66725. get x(): NodeMaterialConnectionPoint;
  66726. /**
  66727. * Gets the y component (output)
  66728. */
  66729. get y(): NodeMaterialConnectionPoint;
  66730. /**
  66731. * Gets the z component (output)
  66732. */
  66733. get z(): NodeMaterialConnectionPoint;
  66734. /**
  66735. * Gets the w component (output)
  66736. */
  66737. get w(): NodeMaterialConnectionPoint;
  66738. protected _inputRename(name: string): string;
  66739. protected _outputRename(name: string): string;
  66740. protected _buildBlock(state: NodeMaterialBuildState): this;
  66741. }
  66742. }
  66743. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66744. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66745. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66746. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66747. /**
  66748. * Block used to lerp between 2 values
  66749. */
  66750. export class LerpBlock extends NodeMaterialBlock {
  66751. /**
  66752. * Creates a new LerpBlock
  66753. * @param name defines the block name
  66754. */
  66755. constructor(name: string);
  66756. /**
  66757. * Gets the current class name
  66758. * @returns the class name
  66759. */
  66760. getClassName(): string;
  66761. /**
  66762. * Gets the left operand input component
  66763. */
  66764. get left(): NodeMaterialConnectionPoint;
  66765. /**
  66766. * Gets the right operand input component
  66767. */
  66768. get right(): NodeMaterialConnectionPoint;
  66769. /**
  66770. * Gets the gradient operand input component
  66771. */
  66772. get gradient(): NodeMaterialConnectionPoint;
  66773. /**
  66774. * Gets the output component
  66775. */
  66776. get output(): NodeMaterialConnectionPoint;
  66777. protected _buildBlock(state: NodeMaterialBuildState): this;
  66778. }
  66779. }
  66780. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66781. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66782. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66783. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66784. /**
  66785. * Block used to divide 2 vectors
  66786. */
  66787. export class DivideBlock extends NodeMaterialBlock {
  66788. /**
  66789. * Creates a new DivideBlock
  66790. * @param name defines the block name
  66791. */
  66792. constructor(name: string);
  66793. /**
  66794. * Gets the current class name
  66795. * @returns the class name
  66796. */
  66797. getClassName(): string;
  66798. /**
  66799. * Gets the left operand input component
  66800. */
  66801. get left(): NodeMaterialConnectionPoint;
  66802. /**
  66803. * Gets the right operand input component
  66804. */
  66805. get right(): NodeMaterialConnectionPoint;
  66806. /**
  66807. * Gets the output component
  66808. */
  66809. get output(): NodeMaterialConnectionPoint;
  66810. protected _buildBlock(state: NodeMaterialBuildState): this;
  66811. }
  66812. }
  66813. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66814. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66815. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66816. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66817. /**
  66818. * Block used to subtract 2 vectors
  66819. */
  66820. export class SubtractBlock extends NodeMaterialBlock {
  66821. /**
  66822. * Creates a new SubtractBlock
  66823. * @param name defines the block name
  66824. */
  66825. constructor(name: string);
  66826. /**
  66827. * Gets the current class name
  66828. * @returns the class name
  66829. */
  66830. getClassName(): string;
  66831. /**
  66832. * Gets the left operand input component
  66833. */
  66834. get left(): NodeMaterialConnectionPoint;
  66835. /**
  66836. * Gets the right operand input component
  66837. */
  66838. get right(): NodeMaterialConnectionPoint;
  66839. /**
  66840. * Gets the output component
  66841. */
  66842. get output(): NodeMaterialConnectionPoint;
  66843. protected _buildBlock(state: NodeMaterialBuildState): this;
  66844. }
  66845. }
  66846. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66848. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66849. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66850. /**
  66851. * Block used to step a value
  66852. */
  66853. export class StepBlock extends NodeMaterialBlock {
  66854. /**
  66855. * Creates a new StepBlock
  66856. * @param name defines the block name
  66857. */
  66858. constructor(name: string);
  66859. /**
  66860. * Gets the current class name
  66861. * @returns the class name
  66862. */
  66863. getClassName(): string;
  66864. /**
  66865. * Gets the value operand input component
  66866. */
  66867. get value(): NodeMaterialConnectionPoint;
  66868. /**
  66869. * Gets the edge operand input component
  66870. */
  66871. get edge(): NodeMaterialConnectionPoint;
  66872. /**
  66873. * Gets the output component
  66874. */
  66875. get output(): NodeMaterialConnectionPoint;
  66876. protected _buildBlock(state: NodeMaterialBuildState): this;
  66877. }
  66878. }
  66879. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66880. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66881. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66882. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66883. /**
  66884. * Block used to get the opposite (1 - x) of a value
  66885. */
  66886. export class OneMinusBlock extends NodeMaterialBlock {
  66887. /**
  66888. * Creates a new OneMinusBlock
  66889. * @param name defines the block name
  66890. */
  66891. constructor(name: string);
  66892. /**
  66893. * Gets the current class name
  66894. * @returns the class name
  66895. */
  66896. getClassName(): string;
  66897. /**
  66898. * Gets the input component
  66899. */
  66900. get input(): NodeMaterialConnectionPoint;
  66901. /**
  66902. * Gets the output component
  66903. */
  66904. get output(): NodeMaterialConnectionPoint;
  66905. protected _buildBlock(state: NodeMaterialBuildState): this;
  66906. }
  66907. }
  66908. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66909. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66910. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66911. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66912. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66913. /**
  66914. * Block used to get the view direction
  66915. */
  66916. export class ViewDirectionBlock extends NodeMaterialBlock {
  66917. /**
  66918. * Creates a new ViewDirectionBlock
  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 world position component
  66929. */
  66930. get worldPosition(): NodeMaterialConnectionPoint;
  66931. /**
  66932. * Gets the camera position component
  66933. */
  66934. get cameraPosition(): NodeMaterialConnectionPoint;
  66935. /**
  66936. * Gets the output component
  66937. */
  66938. get output(): NodeMaterialConnectionPoint;
  66939. autoConfigure(material: NodeMaterial): void;
  66940. protected _buildBlock(state: NodeMaterialBuildState): this;
  66941. }
  66942. }
  66943. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66945. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66946. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66947. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66948. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66949. /**
  66950. * Block used to compute fresnel value
  66951. */
  66952. export class FresnelBlock extends NodeMaterialBlock {
  66953. /**
  66954. * Create a new FresnelBlock
  66955. * @param name defines the block name
  66956. */
  66957. constructor(name: string);
  66958. /**
  66959. * Gets the current class name
  66960. * @returns the class name
  66961. */
  66962. getClassName(): string;
  66963. /**
  66964. * Gets the world normal input component
  66965. */
  66966. get worldNormal(): NodeMaterialConnectionPoint;
  66967. /**
  66968. * Gets the view direction input component
  66969. */
  66970. get viewDirection(): NodeMaterialConnectionPoint;
  66971. /**
  66972. * Gets the bias input component
  66973. */
  66974. get bias(): NodeMaterialConnectionPoint;
  66975. /**
  66976. * Gets the camera (or eye) position component
  66977. */
  66978. get power(): NodeMaterialConnectionPoint;
  66979. /**
  66980. * Gets the fresnel output component
  66981. */
  66982. get fresnel(): NodeMaterialConnectionPoint;
  66983. autoConfigure(material: NodeMaterial): void;
  66984. protected _buildBlock(state: NodeMaterialBuildState): this;
  66985. }
  66986. }
  66987. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66988. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66989. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66990. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66991. /**
  66992. * Block used to get the max of 2 values
  66993. */
  66994. export class MaxBlock extends NodeMaterialBlock {
  66995. /**
  66996. * Creates a new MaxBlock
  66997. * @param name defines the block name
  66998. */
  66999. constructor(name: string);
  67000. /**
  67001. * Gets the current class name
  67002. * @returns the class name
  67003. */
  67004. getClassName(): string;
  67005. /**
  67006. * Gets the left operand input component
  67007. */
  67008. get left(): NodeMaterialConnectionPoint;
  67009. /**
  67010. * Gets the right operand input component
  67011. */
  67012. get right(): NodeMaterialConnectionPoint;
  67013. /**
  67014. * Gets the output component
  67015. */
  67016. get output(): NodeMaterialConnectionPoint;
  67017. protected _buildBlock(state: NodeMaterialBuildState): this;
  67018. }
  67019. }
  67020. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67021. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67022. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67024. /**
  67025. * Block used to get the min of 2 values
  67026. */
  67027. export class MinBlock extends NodeMaterialBlock {
  67028. /**
  67029. * Creates a new MinBlock
  67030. * @param name defines the block name
  67031. */
  67032. constructor(name: string);
  67033. /**
  67034. * Gets the current class name
  67035. * @returns the class name
  67036. */
  67037. getClassName(): string;
  67038. /**
  67039. * Gets the left operand input component
  67040. */
  67041. get left(): NodeMaterialConnectionPoint;
  67042. /**
  67043. * Gets the right operand input component
  67044. */
  67045. get right(): NodeMaterialConnectionPoint;
  67046. /**
  67047. * Gets the output component
  67048. */
  67049. get output(): NodeMaterialConnectionPoint;
  67050. protected _buildBlock(state: NodeMaterialBuildState): this;
  67051. }
  67052. }
  67053. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67054. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67055. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67056. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67057. /**
  67058. * Block used to get the distance between 2 values
  67059. */
  67060. export class DistanceBlock extends NodeMaterialBlock {
  67061. /**
  67062. * Creates a new DistanceBlock
  67063. * @param name defines the block name
  67064. */
  67065. constructor(name: string);
  67066. /**
  67067. * Gets the current class name
  67068. * @returns the class name
  67069. */
  67070. getClassName(): string;
  67071. /**
  67072. * Gets the left operand input component
  67073. */
  67074. get left(): NodeMaterialConnectionPoint;
  67075. /**
  67076. * Gets the right operand input component
  67077. */
  67078. get right(): NodeMaterialConnectionPoint;
  67079. /**
  67080. * Gets the output component
  67081. */
  67082. get output(): NodeMaterialConnectionPoint;
  67083. protected _buildBlock(state: NodeMaterialBuildState): this;
  67084. }
  67085. }
  67086. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67090. /**
  67091. * Block used to get the length of a vector
  67092. */
  67093. export class LengthBlock extends NodeMaterialBlock {
  67094. /**
  67095. * Creates a new LengthBlock
  67096. * @param name defines the block name
  67097. */
  67098. constructor(name: string);
  67099. /**
  67100. * Gets the current class name
  67101. * @returns the class name
  67102. */
  67103. getClassName(): string;
  67104. /**
  67105. * Gets the value input component
  67106. */
  67107. get value(): NodeMaterialConnectionPoint;
  67108. /**
  67109. * Gets the output component
  67110. */
  67111. get output(): NodeMaterialConnectionPoint;
  67112. protected _buildBlock(state: NodeMaterialBuildState): this;
  67113. }
  67114. }
  67115. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  67116. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67117. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67118. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67119. /**
  67120. * Block used to get negative version of a value (i.e. x * -1)
  67121. */
  67122. export class NegateBlock extends NodeMaterialBlock {
  67123. /**
  67124. * Creates a new NegateBlock
  67125. * @param name defines the block name
  67126. */
  67127. constructor(name: string);
  67128. /**
  67129. * Gets the current class name
  67130. * @returns the class name
  67131. */
  67132. getClassName(): string;
  67133. /**
  67134. * Gets the value input component
  67135. */
  67136. get value(): NodeMaterialConnectionPoint;
  67137. /**
  67138. * Gets the output component
  67139. */
  67140. get output(): NodeMaterialConnectionPoint;
  67141. protected _buildBlock(state: NodeMaterialBuildState): this;
  67142. }
  67143. }
  67144. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67148. /**
  67149. * Block used to get the value of the first parameter raised to the power of the second
  67150. */
  67151. export class PowBlock extends NodeMaterialBlock {
  67152. /**
  67153. * Creates a new PowBlock
  67154. * @param name defines the block name
  67155. */
  67156. constructor(name: string);
  67157. /**
  67158. * Gets the current class name
  67159. * @returns the class name
  67160. */
  67161. getClassName(): string;
  67162. /**
  67163. * Gets the value operand input component
  67164. */
  67165. get value(): NodeMaterialConnectionPoint;
  67166. /**
  67167. * Gets the power operand input component
  67168. */
  67169. get power(): NodeMaterialConnectionPoint;
  67170. /**
  67171. * Gets the output component
  67172. */
  67173. get output(): NodeMaterialConnectionPoint;
  67174. protected _buildBlock(state: NodeMaterialBuildState): this;
  67175. }
  67176. }
  67177. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67181. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67182. /**
  67183. * Block used to get a random number
  67184. */
  67185. export class RandomNumberBlock extends NodeMaterialBlock {
  67186. /**
  67187. * Creates a new RandomNumberBlock
  67188. * @param name defines the block name
  67189. */
  67190. constructor(name: string);
  67191. /**
  67192. * Gets the current class name
  67193. * @returns the class name
  67194. */
  67195. getClassName(): string;
  67196. /**
  67197. * Gets the seed input component
  67198. */
  67199. get seed(): NodeMaterialConnectionPoint;
  67200. /**
  67201. * Gets the output component
  67202. */
  67203. get output(): NodeMaterialConnectionPoint;
  67204. protected _buildBlock(state: NodeMaterialBuildState): this;
  67205. }
  67206. }
  67207. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67211. /**
  67212. * Block used to compute arc tangent of 2 values
  67213. */
  67214. export class ArcTan2Block extends NodeMaterialBlock {
  67215. /**
  67216. * Creates a new ArcTan2Block
  67217. * @param name defines the block name
  67218. */
  67219. constructor(name: string);
  67220. /**
  67221. * Gets the current class name
  67222. * @returns the class name
  67223. */
  67224. getClassName(): string;
  67225. /**
  67226. * Gets the x operand input component
  67227. */
  67228. get x(): NodeMaterialConnectionPoint;
  67229. /**
  67230. * Gets the y operand input component
  67231. */
  67232. get y(): NodeMaterialConnectionPoint;
  67233. /**
  67234. * Gets the output component
  67235. */
  67236. get output(): NodeMaterialConnectionPoint;
  67237. protected _buildBlock(state: NodeMaterialBuildState): this;
  67238. }
  67239. }
  67240. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67241. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67243. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67244. /**
  67245. * Block used to smooth step a value
  67246. */
  67247. export class SmoothStepBlock extends NodeMaterialBlock {
  67248. /**
  67249. * Creates a new SmoothStepBlock
  67250. * @param name defines the block name
  67251. */
  67252. constructor(name: string);
  67253. /**
  67254. * Gets the current class name
  67255. * @returns the class name
  67256. */
  67257. getClassName(): string;
  67258. /**
  67259. * Gets the value operand input component
  67260. */
  67261. get value(): NodeMaterialConnectionPoint;
  67262. /**
  67263. * Gets the first edge operand input component
  67264. */
  67265. get edge0(): NodeMaterialConnectionPoint;
  67266. /**
  67267. * Gets the second edge operand input component
  67268. */
  67269. get edge1(): NodeMaterialConnectionPoint;
  67270. /**
  67271. * Gets the output component
  67272. */
  67273. get output(): NodeMaterialConnectionPoint;
  67274. protected _buildBlock(state: NodeMaterialBuildState): this;
  67275. }
  67276. }
  67277. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67278. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67279. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67280. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67281. /**
  67282. * Block used to get the reciprocal (1 / x) of a value
  67283. */
  67284. export class ReciprocalBlock extends NodeMaterialBlock {
  67285. /**
  67286. * Creates a new ReciprocalBlock
  67287. * @param name defines the block name
  67288. */
  67289. constructor(name: string);
  67290. /**
  67291. * Gets the current class name
  67292. * @returns the class name
  67293. */
  67294. getClassName(): string;
  67295. /**
  67296. * Gets the input component
  67297. */
  67298. get input(): NodeMaterialConnectionPoint;
  67299. /**
  67300. * Gets the output component
  67301. */
  67302. get output(): NodeMaterialConnectionPoint;
  67303. protected _buildBlock(state: NodeMaterialBuildState): this;
  67304. }
  67305. }
  67306. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67307. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67308. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67309. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67310. /**
  67311. * Block used to replace a color by another one
  67312. */
  67313. export class ReplaceColorBlock extends NodeMaterialBlock {
  67314. /**
  67315. * Creates a new ReplaceColorBlock
  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 value input component
  67326. */
  67327. get value(): NodeMaterialConnectionPoint;
  67328. /**
  67329. * Gets the reference input component
  67330. */
  67331. get reference(): NodeMaterialConnectionPoint;
  67332. /**
  67333. * Gets the distance input component
  67334. */
  67335. get distance(): NodeMaterialConnectionPoint;
  67336. /**
  67337. * Gets the replacement input component
  67338. */
  67339. get replacement(): NodeMaterialConnectionPoint;
  67340. /**
  67341. * Gets the output component
  67342. */
  67343. get output(): NodeMaterialConnectionPoint;
  67344. protected _buildBlock(state: NodeMaterialBuildState): this;
  67345. }
  67346. }
  67347. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67348. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67349. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67351. /**
  67352. * Block used to posterize a value
  67353. * @see https://en.wikipedia.org/wiki/Posterization
  67354. */
  67355. export class PosterizeBlock extends NodeMaterialBlock {
  67356. /**
  67357. * Creates a new PosterizeBlock
  67358. * @param name defines the block name
  67359. */
  67360. constructor(name: string);
  67361. /**
  67362. * Gets the current class name
  67363. * @returns the class name
  67364. */
  67365. getClassName(): string;
  67366. /**
  67367. * Gets the value input component
  67368. */
  67369. get value(): NodeMaterialConnectionPoint;
  67370. /**
  67371. * Gets the steps input component
  67372. */
  67373. get steps(): NodeMaterialConnectionPoint;
  67374. /**
  67375. * Gets the output component
  67376. */
  67377. get output(): NodeMaterialConnectionPoint;
  67378. protected _buildBlock(state: NodeMaterialBuildState): this;
  67379. }
  67380. }
  67381. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67385. import { Scene } from "babylonjs/scene";
  67386. /**
  67387. * Operations supported by the Wave block
  67388. */
  67389. export enum WaveBlockKind {
  67390. /** SawTooth */
  67391. SawTooth = 0,
  67392. /** Square */
  67393. Square = 1,
  67394. /** Triangle */
  67395. Triangle = 2
  67396. }
  67397. /**
  67398. * Block used to apply wave operation to floats
  67399. */
  67400. export class WaveBlock extends NodeMaterialBlock {
  67401. /**
  67402. * Gets or sets the kibnd of wave to be applied by the block
  67403. */
  67404. kind: WaveBlockKind;
  67405. /**
  67406. * Creates a new WaveBlock
  67407. * @param name defines the block name
  67408. */
  67409. constructor(name: string);
  67410. /**
  67411. * Gets the current class name
  67412. * @returns the class name
  67413. */
  67414. getClassName(): string;
  67415. /**
  67416. * Gets the input component
  67417. */
  67418. get input(): NodeMaterialConnectionPoint;
  67419. /**
  67420. * Gets the output component
  67421. */
  67422. get output(): NodeMaterialConnectionPoint;
  67423. protected _buildBlock(state: NodeMaterialBuildState): this;
  67424. serialize(): any;
  67425. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67426. }
  67427. }
  67428. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67432. import { Color3 } from "babylonjs/Maths/math.color";
  67433. import { Scene } from "babylonjs/scene";
  67434. import { Observable } from "babylonjs/Misc/observable";
  67435. /**
  67436. * Class used to store a color step for the GradientBlock
  67437. */
  67438. export class GradientBlockColorStep {
  67439. private _step;
  67440. /**
  67441. * Gets value indicating which step this color is associated with (between 0 and 1)
  67442. */
  67443. get step(): number;
  67444. /**
  67445. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67446. */
  67447. set step(val: number);
  67448. private _color;
  67449. /**
  67450. * Gets the color associated with this step
  67451. */
  67452. get color(): Color3;
  67453. /**
  67454. * Sets the color associated with this step
  67455. */
  67456. set color(val: Color3);
  67457. /**
  67458. * Creates a new GradientBlockColorStep
  67459. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67460. * @param color defines the color associated with this step
  67461. */
  67462. constructor(step: number, color: Color3);
  67463. }
  67464. /**
  67465. * Block used to return a color from a gradient based on an input value between 0 and 1
  67466. */
  67467. export class GradientBlock extends NodeMaterialBlock {
  67468. /**
  67469. * Gets or sets the list of color steps
  67470. */
  67471. colorSteps: GradientBlockColorStep[];
  67472. /** Gets an observable raised when the value is changed */
  67473. onValueChangedObservable: Observable<GradientBlock>;
  67474. /** calls observable when the value is changed*/
  67475. colorStepsUpdated(): void;
  67476. /**
  67477. * Creates a new GradientBlock
  67478. * @param name defines the block name
  67479. */
  67480. constructor(name: string);
  67481. /**
  67482. * Gets the current class name
  67483. * @returns the class name
  67484. */
  67485. getClassName(): string;
  67486. /**
  67487. * Gets the gradient input component
  67488. */
  67489. get gradient(): NodeMaterialConnectionPoint;
  67490. /**
  67491. * Gets the output component
  67492. */
  67493. get output(): NodeMaterialConnectionPoint;
  67494. private _writeColorConstant;
  67495. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67496. serialize(): any;
  67497. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67498. protected _dumpPropertiesCode(): string;
  67499. }
  67500. }
  67501. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67503. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67505. /**
  67506. * Block used to normalize lerp between 2 values
  67507. */
  67508. export class NLerpBlock extends NodeMaterialBlock {
  67509. /**
  67510. * Creates a new NLerpBlock
  67511. * @param name defines the block name
  67512. */
  67513. constructor(name: string);
  67514. /**
  67515. * Gets the current class name
  67516. * @returns the class name
  67517. */
  67518. getClassName(): string;
  67519. /**
  67520. * Gets the left operand input component
  67521. */
  67522. get left(): NodeMaterialConnectionPoint;
  67523. /**
  67524. * Gets the right operand input component
  67525. */
  67526. get right(): NodeMaterialConnectionPoint;
  67527. /**
  67528. * Gets the gradient operand input component
  67529. */
  67530. get gradient(): NodeMaterialConnectionPoint;
  67531. /**
  67532. * Gets the output component
  67533. */
  67534. get output(): NodeMaterialConnectionPoint;
  67535. protected _buildBlock(state: NodeMaterialBuildState): this;
  67536. }
  67537. }
  67538. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67540. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67541. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67542. import { Scene } from "babylonjs/scene";
  67543. /**
  67544. * block used to Generate a Worley Noise 3D Noise Pattern
  67545. */
  67546. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67547. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67548. manhattanDistance: boolean;
  67549. /**
  67550. * Creates a new WorleyNoise3DBlock
  67551. * @param name defines the block name
  67552. */
  67553. constructor(name: string);
  67554. /**
  67555. * Gets the current class name
  67556. * @returns the class name
  67557. */
  67558. getClassName(): string;
  67559. /**
  67560. * Gets the seed input component
  67561. */
  67562. get seed(): NodeMaterialConnectionPoint;
  67563. /**
  67564. * Gets the jitter input component
  67565. */
  67566. get jitter(): NodeMaterialConnectionPoint;
  67567. /**
  67568. * Gets the output component
  67569. */
  67570. get output(): NodeMaterialConnectionPoint;
  67571. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67572. /**
  67573. * Exposes the properties to the UI?
  67574. */
  67575. protected _dumpPropertiesCode(): string;
  67576. /**
  67577. * Exposes the properties to the Seralize?
  67578. */
  67579. serialize(): any;
  67580. /**
  67581. * Exposes the properties to the deseralize?
  67582. */
  67583. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67584. }
  67585. }
  67586. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67588. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67589. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67590. /**
  67591. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67592. */
  67593. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67594. /**
  67595. * Creates a new SimplexPerlin3DBlock
  67596. * @param name defines the block name
  67597. */
  67598. constructor(name: string);
  67599. /**
  67600. * Gets the current class name
  67601. * @returns the class name
  67602. */
  67603. getClassName(): string;
  67604. /**
  67605. * Gets the seed operand input component
  67606. */
  67607. get seed(): NodeMaterialConnectionPoint;
  67608. /**
  67609. * Gets the output component
  67610. */
  67611. get output(): NodeMaterialConnectionPoint;
  67612. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67613. }
  67614. }
  67615. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67616. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67617. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67618. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67619. /**
  67620. * Block used to blend normals
  67621. */
  67622. export class NormalBlendBlock extends NodeMaterialBlock {
  67623. /**
  67624. * Creates a new NormalBlendBlock
  67625. * @param name defines the block name
  67626. */
  67627. constructor(name: string);
  67628. /**
  67629. * Gets the current class name
  67630. * @returns the class name
  67631. */
  67632. getClassName(): string;
  67633. /**
  67634. * Gets the first input component
  67635. */
  67636. get normalMap0(): NodeMaterialConnectionPoint;
  67637. /**
  67638. * Gets the second input component
  67639. */
  67640. get normalMap1(): NodeMaterialConnectionPoint;
  67641. /**
  67642. * Gets the output component
  67643. */
  67644. get output(): NodeMaterialConnectionPoint;
  67645. protected _buildBlock(state: NodeMaterialBuildState): this;
  67646. }
  67647. }
  67648. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67649. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67652. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67653. /**
  67654. * Block used to rotate a 2d vector by a given angle
  67655. */
  67656. export class Rotate2dBlock extends NodeMaterialBlock {
  67657. /**
  67658. * Creates a new Rotate2dBlock
  67659. * @param name defines the block name
  67660. */
  67661. constructor(name: string);
  67662. /**
  67663. * Gets the current class name
  67664. * @returns the class name
  67665. */
  67666. getClassName(): string;
  67667. /**
  67668. * Gets the input vector
  67669. */
  67670. get input(): NodeMaterialConnectionPoint;
  67671. /**
  67672. * Gets the input angle
  67673. */
  67674. get angle(): NodeMaterialConnectionPoint;
  67675. /**
  67676. * Gets the output component
  67677. */
  67678. get output(): NodeMaterialConnectionPoint;
  67679. autoConfigure(material: NodeMaterial): void;
  67680. protected _buildBlock(state: NodeMaterialBuildState): this;
  67681. }
  67682. }
  67683. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67684. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67685. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67686. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67687. /**
  67688. * Block used to get the reflected vector from a direction and a normal
  67689. */
  67690. export class ReflectBlock extends NodeMaterialBlock {
  67691. /**
  67692. * Creates a new ReflectBlock
  67693. * @param name defines the block name
  67694. */
  67695. constructor(name: string);
  67696. /**
  67697. * Gets the current class name
  67698. * @returns the class name
  67699. */
  67700. getClassName(): string;
  67701. /**
  67702. * Gets the incident component
  67703. */
  67704. get incident(): NodeMaterialConnectionPoint;
  67705. /**
  67706. * Gets the normal component
  67707. */
  67708. get normal(): NodeMaterialConnectionPoint;
  67709. /**
  67710. * Gets the output component
  67711. */
  67712. get output(): NodeMaterialConnectionPoint;
  67713. protected _buildBlock(state: NodeMaterialBuildState): this;
  67714. }
  67715. }
  67716. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67717. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67718. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67719. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67720. /**
  67721. * Block used to get the refracted vector from a direction and a normal
  67722. */
  67723. export class RefractBlock extends NodeMaterialBlock {
  67724. /**
  67725. * Creates a new RefractBlock
  67726. * @param name defines the block name
  67727. */
  67728. constructor(name: string);
  67729. /**
  67730. * Gets the current class name
  67731. * @returns the class name
  67732. */
  67733. getClassName(): string;
  67734. /**
  67735. * Gets the incident component
  67736. */
  67737. get incident(): NodeMaterialConnectionPoint;
  67738. /**
  67739. * Gets the normal component
  67740. */
  67741. get normal(): NodeMaterialConnectionPoint;
  67742. /**
  67743. * Gets the index of refraction component
  67744. */
  67745. get ior(): NodeMaterialConnectionPoint;
  67746. /**
  67747. * Gets the output component
  67748. */
  67749. get output(): NodeMaterialConnectionPoint;
  67750. protected _buildBlock(state: NodeMaterialBuildState): this;
  67751. }
  67752. }
  67753. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67754. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67755. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67756. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67757. /**
  67758. * Block used to desaturate a color
  67759. */
  67760. export class DesaturateBlock extends NodeMaterialBlock {
  67761. /**
  67762. * Creates a new DesaturateBlock
  67763. * @param name defines the block name
  67764. */
  67765. constructor(name: string);
  67766. /**
  67767. * Gets the current class name
  67768. * @returns the class name
  67769. */
  67770. getClassName(): string;
  67771. /**
  67772. * Gets the color operand input component
  67773. */
  67774. get color(): NodeMaterialConnectionPoint;
  67775. /**
  67776. * Gets the level operand input component
  67777. */
  67778. get level(): NodeMaterialConnectionPoint;
  67779. /**
  67780. * Gets the output component
  67781. */
  67782. get output(): NodeMaterialConnectionPoint;
  67783. protected _buildBlock(state: NodeMaterialBuildState): this;
  67784. }
  67785. }
  67786. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67788. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67789. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67790. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67791. import { Nullable } from "babylonjs/types";
  67792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67793. import { Scene } from "babylonjs/scene";
  67794. /**
  67795. * Block used to implement the ambient occlusion module of the PBR material
  67796. */
  67797. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67798. /**
  67799. * Create a new AmbientOcclusionBlock
  67800. * @param name defines the block name
  67801. */
  67802. constructor(name: string);
  67803. /**
  67804. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67805. */
  67806. useAmbientInGrayScale: boolean;
  67807. /**
  67808. * Initialize the block and prepare the context for build
  67809. * @param state defines the state that will be used for the build
  67810. */
  67811. initialize(state: NodeMaterialBuildState): void;
  67812. /**
  67813. * Gets the current class name
  67814. * @returns the class name
  67815. */
  67816. getClassName(): string;
  67817. /**
  67818. * Gets the texture input component
  67819. */
  67820. get texture(): NodeMaterialConnectionPoint;
  67821. /**
  67822. * Gets the texture intensity component
  67823. */
  67824. get intensity(): NodeMaterialConnectionPoint;
  67825. /**
  67826. * Gets the direct light intensity input component
  67827. */
  67828. get directLightIntensity(): NodeMaterialConnectionPoint;
  67829. /**
  67830. * Gets the ambient occlusion object output component
  67831. */
  67832. get ambientOcc(): NodeMaterialConnectionPoint;
  67833. /**
  67834. * Gets the main code of the block (fragment side)
  67835. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67836. * @returns the shader code
  67837. */
  67838. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67839. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67840. protected _buildBlock(state: NodeMaterialBuildState): this;
  67841. protected _dumpPropertiesCode(): string;
  67842. serialize(): any;
  67843. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67844. }
  67845. }
  67846. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67847. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67848. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67849. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67850. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67852. import { Nullable } from "babylonjs/types";
  67853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67854. import { Mesh } from "babylonjs/Meshes/mesh";
  67855. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67856. import { Effect } from "babylonjs/Materials/effect";
  67857. import { Scene } from "babylonjs/scene";
  67858. /**
  67859. * Block used to implement the reflection module of the PBR material
  67860. */
  67861. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67862. /** @hidden */
  67863. _defineLODReflectionAlpha: string;
  67864. /** @hidden */
  67865. _defineLinearSpecularReflection: string;
  67866. private _vEnvironmentIrradianceName;
  67867. /** @hidden */
  67868. _vReflectionMicrosurfaceInfosName: string;
  67869. /** @hidden */
  67870. _vReflectionInfosName: string;
  67871. /** @hidden */
  67872. _vReflectionFilteringInfoName: string;
  67873. private _scene;
  67874. /**
  67875. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67876. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67877. * It's less burden on the user side in the editor part.
  67878. */
  67879. /** @hidden */
  67880. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67881. /** @hidden */
  67882. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67883. /** @hidden */
  67884. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67885. /**
  67886. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67887. * diffuse part of the IBL.
  67888. */
  67889. useSphericalHarmonics: boolean;
  67890. /**
  67891. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67892. */
  67893. forceIrradianceInFragment: boolean;
  67894. /**
  67895. * Create a new ReflectionBlock
  67896. * @param name defines the block name
  67897. */
  67898. constructor(name: string);
  67899. /**
  67900. * Gets the current class name
  67901. * @returns the class name
  67902. */
  67903. getClassName(): string;
  67904. /**
  67905. * Gets the position input component
  67906. */
  67907. get position(): NodeMaterialConnectionPoint;
  67908. /**
  67909. * Gets the world position input component
  67910. */
  67911. get worldPosition(): NodeMaterialConnectionPoint;
  67912. /**
  67913. * Gets the world normal input component
  67914. */
  67915. get worldNormal(): NodeMaterialConnectionPoint;
  67916. /**
  67917. * Gets the world input component
  67918. */
  67919. get world(): NodeMaterialConnectionPoint;
  67920. /**
  67921. * Gets the camera (or eye) position component
  67922. */
  67923. get cameraPosition(): NodeMaterialConnectionPoint;
  67924. /**
  67925. * Gets the view input component
  67926. */
  67927. get view(): NodeMaterialConnectionPoint;
  67928. /**
  67929. * Gets the color input component
  67930. */
  67931. get color(): NodeMaterialConnectionPoint;
  67932. /**
  67933. * Gets the reflection object output component
  67934. */
  67935. get reflection(): NodeMaterialConnectionPoint;
  67936. /**
  67937. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67938. */
  67939. get hasTexture(): boolean;
  67940. /**
  67941. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67942. */
  67943. get reflectionColor(): string;
  67944. protected _getTexture(): Nullable<BaseTexture>;
  67945. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67946. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67947. /**
  67948. * Gets the code to inject in the vertex shader
  67949. * @param state current state of the node material building
  67950. * @returns the shader code
  67951. */
  67952. handleVertexSide(state: NodeMaterialBuildState): string;
  67953. /**
  67954. * Gets the main code of the block (fragment side)
  67955. * @param state current state of the node material building
  67956. * @param normalVarName name of the existing variable corresponding to the normal
  67957. * @returns the shader code
  67958. */
  67959. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67960. protected _buildBlock(state: NodeMaterialBuildState): this;
  67961. protected _dumpPropertiesCode(): string;
  67962. serialize(): any;
  67963. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67964. }
  67965. }
  67966. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67967. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67968. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67969. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67970. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67972. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67973. import { Scene } from "babylonjs/scene";
  67974. import { Nullable } from "babylonjs/types";
  67975. /**
  67976. * Block used to implement the sheen module of the PBR material
  67977. */
  67978. export class SheenBlock extends NodeMaterialBlock {
  67979. /**
  67980. * Create a new SheenBlock
  67981. * @param name defines the block name
  67982. */
  67983. constructor(name: string);
  67984. /**
  67985. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67986. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67987. * making it easier to setup and tweak the effect
  67988. */
  67989. albedoScaling: boolean;
  67990. /**
  67991. * Defines if the sheen is linked to the sheen color.
  67992. */
  67993. linkSheenWithAlbedo: boolean;
  67994. /**
  67995. * Initialize the block and prepare the context for build
  67996. * @param state defines the state that will be used for the build
  67997. */
  67998. initialize(state: NodeMaterialBuildState): void;
  67999. /**
  68000. * Gets the current class name
  68001. * @returns the class name
  68002. */
  68003. getClassName(): string;
  68004. /**
  68005. * Gets the intensity input component
  68006. */
  68007. get intensity(): NodeMaterialConnectionPoint;
  68008. /**
  68009. * Gets the color input component
  68010. */
  68011. get color(): NodeMaterialConnectionPoint;
  68012. /**
  68013. * Gets the roughness input component
  68014. */
  68015. get roughness(): NodeMaterialConnectionPoint;
  68016. /**
  68017. * Gets the sheen object output component
  68018. */
  68019. get sheen(): NodeMaterialConnectionPoint;
  68020. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68021. /**
  68022. * Gets the main code of the block (fragment side)
  68023. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68024. * @returns the shader code
  68025. */
  68026. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68027. protected _buildBlock(state: NodeMaterialBuildState): this;
  68028. protected _dumpPropertiesCode(): string;
  68029. serialize(): any;
  68030. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68031. }
  68032. }
  68033. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68034. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68035. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68036. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68038. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68039. import { Scene } from "babylonjs/scene";
  68040. import { Nullable } from "babylonjs/types";
  68041. import { Mesh } from "babylonjs/Meshes/mesh";
  68042. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68043. import { Effect } from "babylonjs/Materials/effect";
  68044. /**
  68045. * Block used to implement the reflectivity module of the PBR material
  68046. */
  68047. export class ReflectivityBlock extends NodeMaterialBlock {
  68048. private _metallicReflectanceColor;
  68049. private _metallicF0Factor;
  68050. /** @hidden */
  68051. _vMetallicReflectanceFactorsName: string;
  68052. /**
  68053. * The property below is set by the main PBR block prior to calling methods of this class.
  68054. */
  68055. /** @hidden */
  68056. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68057. /**
  68058. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68059. */
  68060. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68061. /**
  68062. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68063. */
  68064. useMetallnessFromMetallicTextureBlue: boolean;
  68065. /**
  68066. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68067. */
  68068. useRoughnessFromMetallicTextureAlpha: boolean;
  68069. /**
  68070. * Specifies if the metallic texture contains the roughness information in its green channel.
  68071. */
  68072. useRoughnessFromMetallicTextureGreen: boolean;
  68073. /**
  68074. * Create a new ReflectivityBlock
  68075. * @param name defines the block name
  68076. */
  68077. constructor(name: string);
  68078. /**
  68079. * Initialize the block and prepare the context for build
  68080. * @param state defines the state that will be used for the build
  68081. */
  68082. initialize(state: NodeMaterialBuildState): void;
  68083. /**
  68084. * Gets the current class name
  68085. * @returns the class name
  68086. */
  68087. getClassName(): string;
  68088. /**
  68089. * Gets the metallic input component
  68090. */
  68091. get metallic(): NodeMaterialConnectionPoint;
  68092. /**
  68093. * Gets the roughness input component
  68094. */
  68095. get roughness(): NodeMaterialConnectionPoint;
  68096. /**
  68097. * Gets the texture input component
  68098. */
  68099. get texture(): NodeMaterialConnectionPoint;
  68100. /**
  68101. * Gets the reflectivity object output component
  68102. */
  68103. get reflectivity(): NodeMaterialConnectionPoint;
  68104. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68105. /**
  68106. * Gets the main code of the block (fragment side)
  68107. * @param state current state of the node material building
  68108. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68109. * @returns the shader code
  68110. */
  68111. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68113. protected _buildBlock(state: NodeMaterialBuildState): this;
  68114. protected _dumpPropertiesCode(): string;
  68115. serialize(): any;
  68116. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68117. }
  68118. }
  68119. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68120. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68125. /**
  68126. * Block used to implement the anisotropy module of the PBR material
  68127. */
  68128. export class AnisotropyBlock extends NodeMaterialBlock {
  68129. /**
  68130. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68131. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68132. * It's less burden on the user side in the editor part.
  68133. */
  68134. /** @hidden */
  68135. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68136. /** @hidden */
  68137. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68138. /**
  68139. * Create a new AnisotropyBlock
  68140. * @param name defines the block name
  68141. */
  68142. constructor(name: string);
  68143. /**
  68144. * Initialize the block and prepare the context for build
  68145. * @param state defines the state that will be used for the build
  68146. */
  68147. initialize(state: NodeMaterialBuildState): void;
  68148. /**
  68149. * Gets the current class name
  68150. * @returns the class name
  68151. */
  68152. getClassName(): string;
  68153. /**
  68154. * Gets the intensity input component
  68155. */
  68156. get intensity(): NodeMaterialConnectionPoint;
  68157. /**
  68158. * Gets the direction input component
  68159. */
  68160. get direction(): NodeMaterialConnectionPoint;
  68161. /**
  68162. * Gets the texture input component
  68163. */
  68164. get texture(): NodeMaterialConnectionPoint;
  68165. /**
  68166. * Gets the uv input component
  68167. */
  68168. get uv(): NodeMaterialConnectionPoint;
  68169. /**
  68170. * Gets the worldTangent input component
  68171. */
  68172. get worldTangent(): NodeMaterialConnectionPoint;
  68173. /**
  68174. * Gets the anisotropy object output component
  68175. */
  68176. get anisotropy(): NodeMaterialConnectionPoint;
  68177. private _generateTBNSpace;
  68178. /**
  68179. * Gets the main code of the block (fragment side)
  68180. * @param state current state of the node material building
  68181. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68182. * @returns the shader code
  68183. */
  68184. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68186. protected _buildBlock(state: NodeMaterialBuildState): this;
  68187. }
  68188. }
  68189. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68190. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68191. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68192. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68193. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68195. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68196. import { Nullable } from "babylonjs/types";
  68197. import { Mesh } from "babylonjs/Meshes/mesh";
  68198. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68199. import { Effect } from "babylonjs/Materials/effect";
  68200. /**
  68201. * Block used to implement the clear coat module of the PBR material
  68202. */
  68203. export class ClearCoatBlock extends NodeMaterialBlock {
  68204. private _scene;
  68205. /**
  68206. * Create a new ClearCoatBlock
  68207. * @param name defines the block name
  68208. */
  68209. constructor(name: string);
  68210. /**
  68211. * Initialize the block and prepare the context for build
  68212. * @param state defines the state that will be used for the build
  68213. */
  68214. initialize(state: NodeMaterialBuildState): void;
  68215. /**
  68216. * Gets the current class name
  68217. * @returns the class name
  68218. */
  68219. getClassName(): string;
  68220. /**
  68221. * Gets the intensity input component
  68222. */
  68223. get intensity(): NodeMaterialConnectionPoint;
  68224. /**
  68225. * Gets the roughness input component
  68226. */
  68227. get roughness(): NodeMaterialConnectionPoint;
  68228. /**
  68229. * Gets the ior input component
  68230. */
  68231. get ior(): NodeMaterialConnectionPoint;
  68232. /**
  68233. * Gets the texture input component
  68234. */
  68235. get texture(): NodeMaterialConnectionPoint;
  68236. /**
  68237. * Gets the bump texture input component
  68238. */
  68239. get bumpTexture(): NodeMaterialConnectionPoint;
  68240. /**
  68241. * Gets the uv input component
  68242. */
  68243. get uv(): NodeMaterialConnectionPoint;
  68244. /**
  68245. * Gets the tint color input component
  68246. */
  68247. get tintColor(): NodeMaterialConnectionPoint;
  68248. /**
  68249. * Gets the tint "at distance" input component
  68250. */
  68251. get tintAtDistance(): NodeMaterialConnectionPoint;
  68252. /**
  68253. * Gets the tint thickness input component
  68254. */
  68255. get tintThickness(): NodeMaterialConnectionPoint;
  68256. /**
  68257. * Gets the world tangent input component
  68258. */
  68259. get worldTangent(): NodeMaterialConnectionPoint;
  68260. /**
  68261. * Gets the clear coat object output component
  68262. */
  68263. get clearcoat(): NodeMaterialConnectionPoint;
  68264. autoConfigure(material: NodeMaterial): void;
  68265. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68266. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68267. private _generateTBNSpace;
  68268. /**
  68269. * Gets the main code of the block (fragment side)
  68270. * @param state current state of the node material building
  68271. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68272. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68273. * @param worldPosVarName name of the variable holding the world position
  68274. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68275. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68276. * @param worldNormalVarName name of the variable holding the world normal
  68277. * @returns the shader code
  68278. */
  68279. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68280. protected _buildBlock(state: NodeMaterialBuildState): this;
  68281. }
  68282. }
  68283. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68284. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68285. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68287. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68289. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68290. import { Nullable } from "babylonjs/types";
  68291. /**
  68292. * Block used to implement the sub surface module of the PBR material
  68293. */
  68294. export class SubSurfaceBlock extends NodeMaterialBlock {
  68295. /**
  68296. * Create a new SubSurfaceBlock
  68297. * @param name defines the block name
  68298. */
  68299. constructor(name: string);
  68300. /**
  68301. * Stores the intensity of the different subsurface effects in the thickness texture.
  68302. * * the green channel is the translucency intensity.
  68303. * * the blue channel is the scattering intensity.
  68304. * * the alpha channel is the refraction intensity.
  68305. */
  68306. useMaskFromThicknessTexture: boolean;
  68307. /**
  68308. * Initialize the block and prepare the context for build
  68309. * @param state defines the state that will be used for the build
  68310. */
  68311. initialize(state: NodeMaterialBuildState): void;
  68312. /**
  68313. * Gets the current class name
  68314. * @returns the class name
  68315. */
  68316. getClassName(): string;
  68317. /**
  68318. * Gets the min thickness input component
  68319. */
  68320. get minThickness(): NodeMaterialConnectionPoint;
  68321. /**
  68322. * Gets the max thickness input component
  68323. */
  68324. get maxThickness(): NodeMaterialConnectionPoint;
  68325. /**
  68326. * Gets the thickness texture component
  68327. */
  68328. get thicknessTexture(): NodeMaterialConnectionPoint;
  68329. /**
  68330. * Gets the tint color input component
  68331. */
  68332. get tintColor(): NodeMaterialConnectionPoint;
  68333. /**
  68334. * Gets the translucency intensity input component
  68335. */
  68336. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68337. /**
  68338. * Gets the translucency diffusion distance input component
  68339. */
  68340. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68341. /**
  68342. * Gets the refraction object parameters
  68343. */
  68344. get refraction(): NodeMaterialConnectionPoint;
  68345. /**
  68346. * Gets the sub surface object output component
  68347. */
  68348. get subsurface(): NodeMaterialConnectionPoint;
  68349. autoConfigure(material: NodeMaterial): void;
  68350. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68351. /**
  68352. * Gets the main code of the block (fragment side)
  68353. * @param state current state of the node material building
  68354. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68355. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68356. * @param worldPosVarName name of the variable holding the world position
  68357. * @returns the shader code
  68358. */
  68359. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68360. protected _buildBlock(state: NodeMaterialBuildState): this;
  68361. }
  68362. }
  68363. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68366. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68367. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68368. import { Light } from "babylonjs/Lights/light";
  68369. import { Nullable } from "babylonjs/types";
  68370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68371. import { Effect } from "babylonjs/Materials/effect";
  68372. import { Mesh } from "babylonjs/Meshes/mesh";
  68373. import { Scene } from "babylonjs/scene";
  68374. /**
  68375. * Block used to implement the PBR metallic/roughness model
  68376. */
  68377. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68378. /**
  68379. * Gets or sets the light associated with this block
  68380. */
  68381. light: Nullable<Light>;
  68382. private _lightId;
  68383. private _scene;
  68384. private _environmentBRDFTexture;
  68385. private _environmentBrdfSamplerName;
  68386. private _vNormalWName;
  68387. private _invertNormalName;
  68388. /**
  68389. * Create a new ReflectionBlock
  68390. * @param name defines the block name
  68391. */
  68392. constructor(name: string);
  68393. /**
  68394. * Intensity of the direct lights e.g. the four lights available in your scene.
  68395. * This impacts both the direct diffuse and specular highlights.
  68396. */
  68397. directIntensity: number;
  68398. /**
  68399. * Intensity of the environment e.g. how much the environment will light the object
  68400. * either through harmonics for rough material or through the refelction for shiny ones.
  68401. */
  68402. environmentIntensity: number;
  68403. /**
  68404. * This is a special control allowing the reduction of the specular highlights coming from the
  68405. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68406. */
  68407. specularIntensity: number;
  68408. /**
  68409. * Defines the falloff type used in this material.
  68410. * It by default is Physical.
  68411. */
  68412. lightFalloff: number;
  68413. /**
  68414. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68415. */
  68416. useAlphaFromAlbedoTexture: boolean;
  68417. /**
  68418. * Specifies that alpha test should be used
  68419. */
  68420. useAlphaTest: boolean;
  68421. /**
  68422. * Defines the alpha limits in alpha test mode.
  68423. */
  68424. alphaTestCutoff: number;
  68425. /**
  68426. * Specifies that alpha blending should be used
  68427. */
  68428. useAlphaBlending: boolean;
  68429. /**
  68430. * Defines if the alpha value should be determined via the rgb values.
  68431. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68432. */
  68433. opacityRGB: boolean;
  68434. /**
  68435. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68436. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68437. */
  68438. useRadianceOverAlpha: boolean;
  68439. /**
  68440. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68441. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68442. */
  68443. useSpecularOverAlpha: boolean;
  68444. /**
  68445. * Enables specular anti aliasing in the PBR shader.
  68446. * It will both interacts on the Geometry for analytical and IBL lighting.
  68447. * It also prefilter the roughness map based on the bump values.
  68448. */
  68449. enableSpecularAntiAliasing: boolean;
  68450. /**
  68451. * Enables realtime filtering on the texture.
  68452. */
  68453. realTimeFiltering: boolean;
  68454. /**
  68455. * Quality switch for realtime filtering
  68456. */
  68457. realTimeFilteringQuality: number;
  68458. /**
  68459. * Defines if the material uses energy conservation.
  68460. */
  68461. useEnergyConservation: boolean;
  68462. /**
  68463. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68464. * too much the area relying on ambient texture to define their ambient occlusion.
  68465. */
  68466. useRadianceOcclusion: boolean;
  68467. /**
  68468. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68469. * makes the reflect vector face the model (under horizon).
  68470. */
  68471. useHorizonOcclusion: boolean;
  68472. /**
  68473. * If set to true, no lighting calculations will be applied.
  68474. */
  68475. unlit: boolean;
  68476. /**
  68477. * Force normal to face away from face.
  68478. */
  68479. forceNormalForward: boolean;
  68480. /**
  68481. * Defines the material debug mode.
  68482. * It helps seeing only some components of the material while troubleshooting.
  68483. */
  68484. debugMode: number;
  68485. /**
  68486. * Specify from where on screen the debug mode should start.
  68487. * The value goes from -1 (full screen) to 1 (not visible)
  68488. * It helps with side by side comparison against the final render
  68489. * This defaults to 0
  68490. */
  68491. debugLimit: number;
  68492. /**
  68493. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68494. * You can use the factor to better multiply the final value.
  68495. */
  68496. debugFactor: number;
  68497. /**
  68498. * Initialize the block and prepare the context for build
  68499. * @param state defines the state that will be used for the build
  68500. */
  68501. initialize(state: NodeMaterialBuildState): void;
  68502. /**
  68503. * Gets the current class name
  68504. * @returns the class name
  68505. */
  68506. getClassName(): string;
  68507. /**
  68508. * Gets the world position input component
  68509. */
  68510. get worldPosition(): NodeMaterialConnectionPoint;
  68511. /**
  68512. * Gets the world normal input component
  68513. */
  68514. get worldNormal(): NodeMaterialConnectionPoint;
  68515. /**
  68516. * Gets the perturbed normal input component
  68517. */
  68518. get perturbedNormal(): NodeMaterialConnectionPoint;
  68519. /**
  68520. * Gets the camera position input component
  68521. */
  68522. get cameraPosition(): NodeMaterialConnectionPoint;
  68523. /**
  68524. * Gets the base color input component
  68525. */
  68526. get baseColor(): NodeMaterialConnectionPoint;
  68527. /**
  68528. * Gets the opacity texture input component
  68529. */
  68530. get opacityTexture(): NodeMaterialConnectionPoint;
  68531. /**
  68532. * Gets the ambient color input component
  68533. */
  68534. get ambientColor(): NodeMaterialConnectionPoint;
  68535. /**
  68536. * Gets the reflectivity object parameters
  68537. */
  68538. get reflectivity(): NodeMaterialConnectionPoint;
  68539. /**
  68540. * Gets the ambient occlusion object parameters
  68541. */
  68542. get ambientOcc(): NodeMaterialConnectionPoint;
  68543. /**
  68544. * Gets the reflection object parameters
  68545. */
  68546. get reflection(): NodeMaterialConnectionPoint;
  68547. /**
  68548. * Gets the sheen object parameters
  68549. */
  68550. get sheen(): NodeMaterialConnectionPoint;
  68551. /**
  68552. * Gets the clear coat object parameters
  68553. */
  68554. get clearcoat(): NodeMaterialConnectionPoint;
  68555. /**
  68556. * Gets the sub surface object parameters
  68557. */
  68558. get subsurface(): NodeMaterialConnectionPoint;
  68559. /**
  68560. * Gets the anisotropy object parameters
  68561. */
  68562. get anisotropy(): NodeMaterialConnectionPoint;
  68563. /**
  68564. * Gets the ambient output component
  68565. */
  68566. get ambient(): NodeMaterialConnectionPoint;
  68567. /**
  68568. * Gets the diffuse output component
  68569. */
  68570. get diffuse(): NodeMaterialConnectionPoint;
  68571. /**
  68572. * Gets the specular output component
  68573. */
  68574. get specular(): NodeMaterialConnectionPoint;
  68575. /**
  68576. * Gets the sheen output component
  68577. */
  68578. get sheenDir(): NodeMaterialConnectionPoint;
  68579. /**
  68580. * Gets the clear coat output component
  68581. */
  68582. get clearcoatDir(): NodeMaterialConnectionPoint;
  68583. /**
  68584. * Gets the indirect diffuse output component
  68585. */
  68586. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68587. /**
  68588. * Gets the indirect specular output component
  68589. */
  68590. get specularIndirect(): NodeMaterialConnectionPoint;
  68591. /**
  68592. * Gets the indirect sheen output component
  68593. */
  68594. get sheenIndirect(): NodeMaterialConnectionPoint;
  68595. /**
  68596. * Gets the indirect clear coat output component
  68597. */
  68598. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68599. /**
  68600. * Gets the refraction output component
  68601. */
  68602. get refraction(): NodeMaterialConnectionPoint;
  68603. /**
  68604. * Gets the global lighting output component
  68605. */
  68606. get lighting(): NodeMaterialConnectionPoint;
  68607. /**
  68608. * Gets the shadow output component
  68609. */
  68610. get shadow(): NodeMaterialConnectionPoint;
  68611. /**
  68612. * Gets the alpha output component
  68613. */
  68614. get alpha(): NodeMaterialConnectionPoint;
  68615. autoConfigure(material: NodeMaterial): void;
  68616. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68617. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68618. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68619. private _injectVertexCode;
  68620. /**
  68621. * Gets the code corresponding to the albedo/opacity module
  68622. * @returns the shader code
  68623. */
  68624. getAlbedoOpacityCode(): string;
  68625. protected _buildBlock(state: NodeMaterialBuildState): this;
  68626. protected _dumpPropertiesCode(): string;
  68627. serialize(): any;
  68628. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68629. }
  68630. }
  68631. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68632. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68633. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68634. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68635. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68636. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68637. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68638. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68639. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68640. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68641. }
  68642. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68643. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68644. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68645. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68646. }
  68647. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68651. /**
  68652. * Block used to compute value of one parameter modulo another
  68653. */
  68654. export class ModBlock extends NodeMaterialBlock {
  68655. /**
  68656. * Creates a new ModBlock
  68657. * @param name defines the block name
  68658. */
  68659. constructor(name: string);
  68660. /**
  68661. * Gets the current class name
  68662. * @returns the class name
  68663. */
  68664. getClassName(): string;
  68665. /**
  68666. * Gets the left operand input component
  68667. */
  68668. get left(): NodeMaterialConnectionPoint;
  68669. /**
  68670. * Gets the right operand input component
  68671. */
  68672. get right(): NodeMaterialConnectionPoint;
  68673. /**
  68674. * Gets the output component
  68675. */
  68676. get output(): NodeMaterialConnectionPoint;
  68677. protected _buildBlock(state: NodeMaterialBuildState): this;
  68678. }
  68679. }
  68680. declare module "babylonjs/Materials/Node/Blocks/index" {
  68681. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68682. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68683. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68684. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68685. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68686. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68687. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68688. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68689. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68690. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68691. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68692. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68693. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68694. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68695. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68696. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68697. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68698. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68699. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68700. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68701. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68702. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68703. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68704. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68705. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68706. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68707. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68708. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68709. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68710. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68711. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68712. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68713. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68714. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68715. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68716. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68717. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68718. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68719. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68720. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68721. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68722. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68723. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68724. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68725. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68726. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68727. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68728. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68729. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68730. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68731. }
  68732. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68733. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68734. }
  68735. declare module "babylonjs/Materials/Node/index" {
  68736. export * from "babylonjs/Materials/Node/Enums/index";
  68737. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68738. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68739. export * from "babylonjs/Materials/Node/nodeMaterial";
  68740. export * from "babylonjs/Materials/Node/Blocks/index";
  68741. export * from "babylonjs/Materials/Node/Optimizers/index";
  68742. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68743. }
  68744. declare module "babylonjs/Materials/index" {
  68745. export * from "babylonjs/Materials/Background/index";
  68746. export * from "babylonjs/Materials/colorCurves";
  68747. export * from "babylonjs/Materials/iEffectFallbacks";
  68748. export * from "babylonjs/Materials/effectFallbacks";
  68749. export * from "babylonjs/Materials/effect";
  68750. export * from "babylonjs/Materials/fresnelParameters";
  68751. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68752. export * from "babylonjs/Materials/material";
  68753. export * from "babylonjs/Materials/materialDefines";
  68754. export * from "babylonjs/Materials/thinMaterialHelper";
  68755. export * from "babylonjs/Materials/materialHelper";
  68756. export * from "babylonjs/Materials/multiMaterial";
  68757. export * from "babylonjs/Materials/PBR/index";
  68758. export * from "babylonjs/Materials/pushMaterial";
  68759. export * from "babylonjs/Materials/shaderMaterial";
  68760. export * from "babylonjs/Materials/standardMaterial";
  68761. export * from "babylonjs/Materials/Textures/index";
  68762. export * from "babylonjs/Materials/uniformBuffer";
  68763. export * from "babylonjs/Materials/materialFlags";
  68764. export * from "babylonjs/Materials/Node/index";
  68765. export * from "babylonjs/Materials/effectRenderer";
  68766. export * from "babylonjs/Materials/shadowDepthWrapper";
  68767. }
  68768. declare module "babylonjs/Maths/index" {
  68769. export * from "babylonjs/Maths/math.scalar";
  68770. export * from "babylonjs/Maths/math";
  68771. export * from "babylonjs/Maths/sphericalPolynomial";
  68772. }
  68773. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68774. import { IDisposable } from "babylonjs/scene";
  68775. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68776. /**
  68777. * Configuration for Draco compression
  68778. */
  68779. export interface IDracoCompressionConfiguration {
  68780. /**
  68781. * Configuration for the decoder.
  68782. */
  68783. decoder: {
  68784. /**
  68785. * The url to the WebAssembly module.
  68786. */
  68787. wasmUrl?: string;
  68788. /**
  68789. * The url to the WebAssembly binary.
  68790. */
  68791. wasmBinaryUrl?: string;
  68792. /**
  68793. * The url to the fallback JavaScript module.
  68794. */
  68795. fallbackUrl?: string;
  68796. };
  68797. }
  68798. /**
  68799. * Draco compression (https://google.github.io/draco/)
  68800. *
  68801. * This class wraps the Draco module.
  68802. *
  68803. * **Encoder**
  68804. *
  68805. * The encoder is not currently implemented.
  68806. *
  68807. * **Decoder**
  68808. *
  68809. * 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.
  68810. *
  68811. * To update the configuration, use the following code:
  68812. * ```javascript
  68813. * DracoCompression.Configuration = {
  68814. * decoder: {
  68815. * wasmUrl: "<url to the WebAssembly library>",
  68816. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68817. * fallbackUrl: "<url to the fallback JavaScript library>",
  68818. * }
  68819. * };
  68820. * ```
  68821. *
  68822. * 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.
  68823. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68824. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68825. *
  68826. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68827. * ```javascript
  68828. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68829. * ```
  68830. *
  68831. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68832. */
  68833. export class DracoCompression implements IDisposable {
  68834. private _workerPoolPromise?;
  68835. private _decoderModulePromise?;
  68836. /**
  68837. * The configuration. Defaults to the following urls:
  68838. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68839. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68840. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68841. */
  68842. static Configuration: IDracoCompressionConfiguration;
  68843. /**
  68844. * Returns true if the decoder configuration is available.
  68845. */
  68846. static get DecoderAvailable(): boolean;
  68847. /**
  68848. * Default number of workers to create when creating the draco compression object.
  68849. */
  68850. static DefaultNumWorkers: number;
  68851. private static GetDefaultNumWorkers;
  68852. private static _Default;
  68853. /**
  68854. * Default instance for the draco compression object.
  68855. */
  68856. static get Default(): DracoCompression;
  68857. /**
  68858. * Constructor
  68859. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68860. */
  68861. constructor(numWorkers?: number);
  68862. /**
  68863. * Stop all async operations and release resources.
  68864. */
  68865. dispose(): void;
  68866. /**
  68867. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68868. * @returns a promise that resolves when ready
  68869. */
  68870. whenReadyAsync(): Promise<void>;
  68871. /**
  68872. * Decode Draco compressed mesh data to vertex data.
  68873. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68874. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68875. * @returns A promise that resolves with the decoded vertex data
  68876. */
  68877. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68878. [kind: string]: number;
  68879. }): Promise<VertexData>;
  68880. }
  68881. }
  68882. declare module "babylonjs/Meshes/Compression/index" {
  68883. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68884. }
  68885. declare module "babylonjs/Meshes/csg" {
  68886. import { Nullable } from "babylonjs/types";
  68887. import { Scene } from "babylonjs/scene";
  68888. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68889. import { Mesh } from "babylonjs/Meshes/mesh";
  68890. import { Material } from "babylonjs/Materials/material";
  68891. /**
  68892. * Class for building Constructive Solid Geometry
  68893. */
  68894. export class CSG {
  68895. private polygons;
  68896. /**
  68897. * The world matrix
  68898. */
  68899. matrix: Matrix;
  68900. /**
  68901. * Stores the position
  68902. */
  68903. position: Vector3;
  68904. /**
  68905. * Stores the rotation
  68906. */
  68907. rotation: Vector3;
  68908. /**
  68909. * Stores the rotation quaternion
  68910. */
  68911. rotationQuaternion: Nullable<Quaternion>;
  68912. /**
  68913. * Stores the scaling vector
  68914. */
  68915. scaling: Vector3;
  68916. /**
  68917. * Convert the Mesh to CSG
  68918. * @param mesh The Mesh to convert to CSG
  68919. * @returns A new CSG from the Mesh
  68920. */
  68921. static FromMesh(mesh: Mesh): CSG;
  68922. /**
  68923. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68924. * @param polygons Polygons used to construct a CSG solid
  68925. */
  68926. private static FromPolygons;
  68927. /**
  68928. * Clones, or makes a deep copy, of the CSG
  68929. * @returns A new CSG
  68930. */
  68931. clone(): CSG;
  68932. /**
  68933. * Unions this CSG with another CSG
  68934. * @param csg The CSG to union against this CSG
  68935. * @returns The unioned CSG
  68936. */
  68937. union(csg: CSG): CSG;
  68938. /**
  68939. * Unions this CSG with another CSG in place
  68940. * @param csg The CSG to union against this CSG
  68941. */
  68942. unionInPlace(csg: CSG): void;
  68943. /**
  68944. * Subtracts this CSG with another CSG
  68945. * @param csg The CSG to subtract against this CSG
  68946. * @returns A new CSG
  68947. */
  68948. subtract(csg: CSG): CSG;
  68949. /**
  68950. * Subtracts this CSG with another CSG in place
  68951. * @param csg The CSG to subtact against this CSG
  68952. */
  68953. subtractInPlace(csg: CSG): void;
  68954. /**
  68955. * Intersect this CSG with another CSG
  68956. * @param csg The CSG to intersect against this CSG
  68957. * @returns A new CSG
  68958. */
  68959. intersect(csg: CSG): CSG;
  68960. /**
  68961. * Intersects this CSG with another CSG in place
  68962. * @param csg The CSG to intersect against this CSG
  68963. */
  68964. intersectInPlace(csg: CSG): void;
  68965. /**
  68966. * Return a new CSG solid with solid and empty space switched. This solid is
  68967. * not modified.
  68968. * @returns A new CSG solid with solid and empty space switched
  68969. */
  68970. inverse(): CSG;
  68971. /**
  68972. * Inverses the CSG in place
  68973. */
  68974. inverseInPlace(): void;
  68975. /**
  68976. * This is used to keep meshes transformations so they can be restored
  68977. * when we build back a Babylon Mesh
  68978. * NB : All CSG operations are performed in world coordinates
  68979. * @param csg The CSG to copy the transform attributes from
  68980. * @returns This CSG
  68981. */
  68982. copyTransformAttributes(csg: CSG): CSG;
  68983. /**
  68984. * Build Raw mesh from CSG
  68985. * Coordinates here are in world space
  68986. * @param name The name of the mesh geometry
  68987. * @param scene The Scene
  68988. * @param keepSubMeshes Specifies if the submeshes should be kept
  68989. * @returns A new Mesh
  68990. */
  68991. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68992. /**
  68993. * Build Mesh from CSG taking material and transforms into account
  68994. * @param name The name of the Mesh
  68995. * @param material The material of the Mesh
  68996. * @param scene The Scene
  68997. * @param keepSubMeshes Specifies if submeshes should be kept
  68998. * @returns The new Mesh
  68999. */
  69000. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69001. }
  69002. }
  69003. declare module "babylonjs/Meshes/trailMesh" {
  69004. import { Mesh } from "babylonjs/Meshes/mesh";
  69005. import { Scene } from "babylonjs/scene";
  69006. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69007. /**
  69008. * Class used to create a trail following a mesh
  69009. */
  69010. export class TrailMesh extends Mesh {
  69011. private _generator;
  69012. private _autoStart;
  69013. private _running;
  69014. private _diameter;
  69015. private _length;
  69016. private _sectionPolygonPointsCount;
  69017. private _sectionVectors;
  69018. private _sectionNormalVectors;
  69019. private _beforeRenderObserver;
  69020. /**
  69021. * @constructor
  69022. * @param name The value used by scene.getMeshByName() to do a lookup.
  69023. * @param generator The mesh or transform node to generate a trail.
  69024. * @param scene The scene to add this mesh to.
  69025. * @param diameter Diameter of trailing mesh. Default is 1.
  69026. * @param length Length of trailing mesh. Default is 60.
  69027. * @param autoStart Automatically start trailing mesh. Default true.
  69028. */
  69029. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69030. /**
  69031. * "TrailMesh"
  69032. * @returns "TrailMesh"
  69033. */
  69034. getClassName(): string;
  69035. private _createMesh;
  69036. /**
  69037. * Start trailing mesh.
  69038. */
  69039. start(): void;
  69040. /**
  69041. * Stop trailing mesh.
  69042. */
  69043. stop(): void;
  69044. /**
  69045. * Update trailing mesh geometry.
  69046. */
  69047. update(): void;
  69048. /**
  69049. * Returns a new TrailMesh object.
  69050. * @param name is a string, the name given to the new mesh
  69051. * @param newGenerator use new generator object for cloned trail mesh
  69052. * @returns a new mesh
  69053. */
  69054. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69055. /**
  69056. * Serializes this trail mesh
  69057. * @param serializationObject object to write serialization to
  69058. */
  69059. serialize(serializationObject: any): void;
  69060. /**
  69061. * Parses a serialized trail mesh
  69062. * @param parsedMesh the serialized mesh
  69063. * @param scene the scene to create the trail mesh in
  69064. * @returns the created trail mesh
  69065. */
  69066. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69067. }
  69068. }
  69069. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69070. import { Nullable } from "babylonjs/types";
  69071. import { Scene } from "babylonjs/scene";
  69072. import { Vector4 } from "babylonjs/Maths/math.vector";
  69073. import { Color4 } from "babylonjs/Maths/math.color";
  69074. import { Mesh } from "babylonjs/Meshes/mesh";
  69075. /**
  69076. * Class containing static functions to help procedurally build meshes
  69077. */
  69078. export class TiledBoxBuilder {
  69079. /**
  69080. * Creates a box mesh
  69081. * 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)
  69082. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69084. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69086. * @param name defines the name of the mesh
  69087. * @param options defines the options used to create the mesh
  69088. * @param scene defines the hosting scene
  69089. * @returns the box mesh
  69090. */
  69091. static CreateTiledBox(name: string, options: {
  69092. pattern?: number;
  69093. width?: number;
  69094. height?: number;
  69095. depth?: number;
  69096. tileSize?: number;
  69097. tileWidth?: number;
  69098. tileHeight?: number;
  69099. alignHorizontal?: number;
  69100. alignVertical?: number;
  69101. faceUV?: Vector4[];
  69102. faceColors?: Color4[];
  69103. sideOrientation?: number;
  69104. updatable?: boolean;
  69105. }, scene?: Nullable<Scene>): Mesh;
  69106. }
  69107. }
  69108. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69109. import { Vector4 } from "babylonjs/Maths/math.vector";
  69110. import { Mesh } from "babylonjs/Meshes/mesh";
  69111. /**
  69112. * Class containing static functions to help procedurally build meshes
  69113. */
  69114. export class TorusKnotBuilder {
  69115. /**
  69116. * Creates a torus knot mesh
  69117. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69118. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69119. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69120. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69122. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69124. * @param name defines the name of the mesh
  69125. * @param options defines the options used to create the mesh
  69126. * @param scene defines the hosting scene
  69127. * @returns the torus knot mesh
  69128. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69129. */
  69130. static CreateTorusKnot(name: string, options: {
  69131. radius?: number;
  69132. tube?: number;
  69133. radialSegments?: number;
  69134. tubularSegments?: number;
  69135. p?: number;
  69136. q?: number;
  69137. updatable?: boolean;
  69138. sideOrientation?: number;
  69139. frontUVs?: Vector4;
  69140. backUVs?: Vector4;
  69141. }, scene: any): Mesh;
  69142. }
  69143. }
  69144. declare module "babylonjs/Meshes/polygonMesh" {
  69145. import { Scene } from "babylonjs/scene";
  69146. import { Vector2 } from "babylonjs/Maths/math.vector";
  69147. import { Mesh } from "babylonjs/Meshes/mesh";
  69148. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69149. import { Path2 } from "babylonjs/Maths/math.path";
  69150. /**
  69151. * Polygon
  69152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69153. */
  69154. export class Polygon {
  69155. /**
  69156. * Creates a rectangle
  69157. * @param xmin bottom X coord
  69158. * @param ymin bottom Y coord
  69159. * @param xmax top X coord
  69160. * @param ymax top Y coord
  69161. * @returns points that make the resulting rectation
  69162. */
  69163. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69164. /**
  69165. * Creates a circle
  69166. * @param radius radius of circle
  69167. * @param cx scale in x
  69168. * @param cy scale in y
  69169. * @param numberOfSides number of sides that make up the circle
  69170. * @returns points that make the resulting circle
  69171. */
  69172. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69173. /**
  69174. * Creates a polygon from input string
  69175. * @param input Input polygon data
  69176. * @returns the parsed points
  69177. */
  69178. static Parse(input: string): Vector2[];
  69179. /**
  69180. * Starts building a polygon from x and y coordinates
  69181. * @param x x coordinate
  69182. * @param y y coordinate
  69183. * @returns the started path2
  69184. */
  69185. static StartingAt(x: number, y: number): Path2;
  69186. }
  69187. /**
  69188. * Builds a polygon
  69189. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69190. */
  69191. export class PolygonMeshBuilder {
  69192. private _points;
  69193. private _outlinepoints;
  69194. private _holes;
  69195. private _name;
  69196. private _scene;
  69197. private _epoints;
  69198. private _eholes;
  69199. private _addToepoint;
  69200. /**
  69201. * Babylon reference to the earcut plugin.
  69202. */
  69203. bjsEarcut: any;
  69204. /**
  69205. * Creates a PolygonMeshBuilder
  69206. * @param name name of the builder
  69207. * @param contours Path of the polygon
  69208. * @param scene scene to add to when creating the mesh
  69209. * @param earcutInjection can be used to inject your own earcut reference
  69210. */
  69211. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69212. /**
  69213. * Adds a whole within the polygon
  69214. * @param hole Array of points defining the hole
  69215. * @returns this
  69216. */
  69217. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69218. /**
  69219. * Creates the polygon
  69220. * @param updatable If the mesh should be updatable
  69221. * @param depth The depth of the mesh created
  69222. * @returns the created mesh
  69223. */
  69224. build(updatable?: boolean, depth?: number): Mesh;
  69225. /**
  69226. * Creates the polygon
  69227. * @param depth The depth of the mesh created
  69228. * @returns the created VertexData
  69229. */
  69230. buildVertexData(depth?: number): VertexData;
  69231. /**
  69232. * Adds a side to the polygon
  69233. * @param positions points that make the polygon
  69234. * @param normals normals of the polygon
  69235. * @param uvs uvs of the polygon
  69236. * @param indices indices of the polygon
  69237. * @param bounds bounds of the polygon
  69238. * @param points points of the polygon
  69239. * @param depth depth of the polygon
  69240. * @param flip flip of the polygon
  69241. */
  69242. private addSide;
  69243. }
  69244. }
  69245. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69246. import { Scene } from "babylonjs/scene";
  69247. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69248. import { Color4 } from "babylonjs/Maths/math.color";
  69249. import { Mesh } from "babylonjs/Meshes/mesh";
  69250. import { Nullable } from "babylonjs/types";
  69251. /**
  69252. * Class containing static functions to help procedurally build meshes
  69253. */
  69254. export class PolygonBuilder {
  69255. /**
  69256. * Creates a polygon mesh
  69257. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69258. * * 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
  69259. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69262. * * Remember you can only change the shape positions, not their number when updating a polygon
  69263. * @param name defines the name of the mesh
  69264. * @param options defines the options used to create the mesh
  69265. * @param scene defines the hosting scene
  69266. * @param earcutInjection can be used to inject your own earcut reference
  69267. * @returns the polygon mesh
  69268. */
  69269. static CreatePolygon(name: string, options: {
  69270. shape: Vector3[];
  69271. holes?: Vector3[][];
  69272. depth?: number;
  69273. faceUV?: Vector4[];
  69274. faceColors?: Color4[];
  69275. updatable?: boolean;
  69276. sideOrientation?: number;
  69277. frontUVs?: Vector4;
  69278. backUVs?: Vector4;
  69279. wrap?: boolean;
  69280. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69281. /**
  69282. * Creates an extruded polygon mesh, with depth in the Y direction.
  69283. * * 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)
  69284. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69285. * @param name defines the name of the mesh
  69286. * @param options defines the options used to create the mesh
  69287. * @param scene defines the hosting scene
  69288. * @param earcutInjection can be used to inject your own earcut reference
  69289. * @returns the polygon mesh
  69290. */
  69291. static ExtrudePolygon(name: string, options: {
  69292. shape: Vector3[];
  69293. holes?: Vector3[][];
  69294. depth?: number;
  69295. faceUV?: Vector4[];
  69296. faceColors?: Color4[];
  69297. updatable?: boolean;
  69298. sideOrientation?: number;
  69299. frontUVs?: Vector4;
  69300. backUVs?: Vector4;
  69301. wrap?: boolean;
  69302. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69303. }
  69304. }
  69305. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69306. import { Scene } from "babylonjs/scene";
  69307. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69308. import { Mesh } from "babylonjs/Meshes/mesh";
  69309. import { Nullable } from "babylonjs/types";
  69310. /**
  69311. * Class containing static functions to help procedurally build meshes
  69312. */
  69313. export class LatheBuilder {
  69314. /**
  69315. * Creates lathe mesh.
  69316. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69317. * * 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
  69318. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69319. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69320. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69321. * * 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
  69322. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69323. * * 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
  69324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69325. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69326. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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 lathe mesh
  69332. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69333. */
  69334. static CreateLathe(name: string, options: {
  69335. shape: Vector3[];
  69336. radius?: number;
  69337. tessellation?: number;
  69338. clip?: number;
  69339. arc?: number;
  69340. closed?: boolean;
  69341. updatable?: boolean;
  69342. sideOrientation?: number;
  69343. frontUVs?: Vector4;
  69344. backUVs?: Vector4;
  69345. cap?: number;
  69346. invertUV?: boolean;
  69347. }, scene?: Nullable<Scene>): Mesh;
  69348. }
  69349. }
  69350. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69351. import { Nullable } from "babylonjs/types";
  69352. import { Scene } from "babylonjs/scene";
  69353. import { Vector4 } from "babylonjs/Maths/math.vector";
  69354. import { Mesh } from "babylonjs/Meshes/mesh";
  69355. /**
  69356. * Class containing static functions to help procedurally build meshes
  69357. */
  69358. export class TiledPlaneBuilder {
  69359. /**
  69360. * Creates a tiled plane mesh
  69361. * * The parameter `pattern` will, depending on value, do nothing or
  69362. * * * flip (reflect about central vertical) alternate tiles across and up
  69363. * * * flip every tile on alternate rows
  69364. * * * rotate (180 degs) alternate tiles across and up
  69365. * * * rotate every tile on alternate rows
  69366. * * * flip and rotate alternate tiles across and up
  69367. * * * flip and rotate every tile on alternate rows
  69368. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69369. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69371. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69372. * * 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)
  69373. * * 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)
  69374. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69375. * @param name defines the name of the mesh
  69376. * @param options defines the options used to create the mesh
  69377. * @param scene defines the hosting scene
  69378. * @returns the box mesh
  69379. */
  69380. static CreateTiledPlane(name: string, options: {
  69381. pattern?: number;
  69382. tileSize?: number;
  69383. tileWidth?: number;
  69384. tileHeight?: number;
  69385. size?: number;
  69386. width?: number;
  69387. height?: number;
  69388. alignHorizontal?: number;
  69389. alignVertical?: number;
  69390. sideOrientation?: number;
  69391. frontUVs?: Vector4;
  69392. backUVs?: Vector4;
  69393. updatable?: boolean;
  69394. }, scene?: Nullable<Scene>): Mesh;
  69395. }
  69396. }
  69397. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69398. import { Nullable } from "babylonjs/types";
  69399. import { Scene } from "babylonjs/scene";
  69400. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69401. import { Mesh } from "babylonjs/Meshes/mesh";
  69402. /**
  69403. * Class containing static functions to help procedurally build meshes
  69404. */
  69405. export class TubeBuilder {
  69406. /**
  69407. * Creates a tube mesh.
  69408. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69409. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69410. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69411. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69412. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69413. * * 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)
  69414. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69415. * * 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
  69416. * * 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
  69417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69418. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69419. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69421. * @param name defines the name of the mesh
  69422. * @param options defines the options used to create the mesh
  69423. * @param scene defines the hosting scene
  69424. * @returns the tube mesh
  69425. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69426. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69427. */
  69428. static CreateTube(name: string, options: {
  69429. path: Vector3[];
  69430. radius?: number;
  69431. tessellation?: number;
  69432. radiusFunction?: {
  69433. (i: number, distance: number): number;
  69434. };
  69435. cap?: number;
  69436. arc?: number;
  69437. updatable?: boolean;
  69438. sideOrientation?: number;
  69439. frontUVs?: Vector4;
  69440. backUVs?: Vector4;
  69441. instance?: Mesh;
  69442. invertUV?: boolean;
  69443. }, scene?: Nullable<Scene>): Mesh;
  69444. }
  69445. }
  69446. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69447. import { Scene } from "babylonjs/scene";
  69448. import { Vector4 } from "babylonjs/Maths/math.vector";
  69449. import { Mesh } from "babylonjs/Meshes/mesh";
  69450. import { Nullable } from "babylonjs/types";
  69451. /**
  69452. * Class containing static functions to help procedurally build meshes
  69453. */
  69454. export class IcoSphereBuilder {
  69455. /**
  69456. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69457. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69458. * * 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`)
  69459. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69460. * * 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
  69461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69464. * @param name defines the name of the mesh
  69465. * @param options defines the options used to create the mesh
  69466. * @param scene defines the hosting scene
  69467. * @returns the icosahedron mesh
  69468. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69469. */
  69470. static CreateIcoSphere(name: string, options: {
  69471. radius?: number;
  69472. radiusX?: number;
  69473. radiusY?: number;
  69474. radiusZ?: number;
  69475. flat?: boolean;
  69476. subdivisions?: number;
  69477. sideOrientation?: number;
  69478. frontUVs?: Vector4;
  69479. backUVs?: Vector4;
  69480. updatable?: boolean;
  69481. }, scene?: Nullable<Scene>): Mesh;
  69482. }
  69483. }
  69484. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69485. import { Vector3 } from "babylonjs/Maths/math.vector";
  69486. import { Mesh } from "babylonjs/Meshes/mesh";
  69487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69488. /**
  69489. * Class containing static functions to help procedurally build meshes
  69490. */
  69491. export class DecalBuilder {
  69492. /**
  69493. * Creates a decal mesh.
  69494. * 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
  69495. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69496. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69497. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69498. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69499. * @param name defines the name of the mesh
  69500. * @param sourceMesh defines the mesh where the decal must be applied
  69501. * @param options defines the options used to create the mesh
  69502. * @param scene defines the hosting scene
  69503. * @returns the decal mesh
  69504. * @see https://doc.babylonjs.com/how_to/decals
  69505. */
  69506. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69507. position?: Vector3;
  69508. normal?: Vector3;
  69509. size?: Vector3;
  69510. angle?: number;
  69511. }): Mesh;
  69512. }
  69513. }
  69514. declare module "babylonjs/Meshes/meshBuilder" {
  69515. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69516. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69517. import { Nullable } from "babylonjs/types";
  69518. import { Scene } from "babylonjs/scene";
  69519. import { Mesh } from "babylonjs/Meshes/mesh";
  69520. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69521. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69523. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69524. import { Plane } from "babylonjs/Maths/math.plane";
  69525. /**
  69526. * Class containing static functions to help procedurally build meshes
  69527. */
  69528. export class MeshBuilder {
  69529. /**
  69530. * Creates a box mesh
  69531. * * The parameter `size` sets the size (float) of each box side (default 1)
  69532. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69533. * * 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)
  69534. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69536. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69538. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69539. * @param name defines the name of the mesh
  69540. * @param options defines the options used to create the mesh
  69541. * @param scene defines the hosting scene
  69542. * @returns the box mesh
  69543. */
  69544. static CreateBox(name: string, options: {
  69545. size?: number;
  69546. width?: number;
  69547. height?: number;
  69548. depth?: number;
  69549. faceUV?: Vector4[];
  69550. faceColors?: Color4[];
  69551. sideOrientation?: number;
  69552. frontUVs?: Vector4;
  69553. backUVs?: Vector4;
  69554. wrap?: boolean;
  69555. topBaseAt?: number;
  69556. bottomBaseAt?: number;
  69557. updatable?: boolean;
  69558. }, scene?: Nullable<Scene>): Mesh;
  69559. /**
  69560. * Creates a tiled box mesh
  69561. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69563. * @param name defines the name of the mesh
  69564. * @param options defines the options used to create the mesh
  69565. * @param scene defines the hosting scene
  69566. * @returns the tiled box mesh
  69567. */
  69568. static CreateTiledBox(name: string, options: {
  69569. pattern?: number;
  69570. size?: number;
  69571. width?: number;
  69572. height?: number;
  69573. depth: number;
  69574. tileSize?: number;
  69575. tileWidth?: number;
  69576. tileHeight?: number;
  69577. faceUV?: Vector4[];
  69578. faceColors?: Color4[];
  69579. alignHorizontal?: number;
  69580. alignVertical?: number;
  69581. sideOrientation?: number;
  69582. updatable?: boolean;
  69583. }, scene?: Nullable<Scene>): Mesh;
  69584. /**
  69585. * Creates a sphere mesh
  69586. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69587. * * 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`)
  69588. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69589. * * 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
  69590. * * 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)
  69591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69592. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69594. * @param name defines the name of the mesh
  69595. * @param options defines the options used to create the mesh
  69596. * @param scene defines the hosting scene
  69597. * @returns the sphere mesh
  69598. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69599. */
  69600. static CreateSphere(name: string, options: {
  69601. segments?: number;
  69602. diameter?: number;
  69603. diameterX?: number;
  69604. diameterY?: number;
  69605. diameterZ?: number;
  69606. arc?: number;
  69607. slice?: number;
  69608. sideOrientation?: number;
  69609. frontUVs?: Vector4;
  69610. backUVs?: Vector4;
  69611. updatable?: boolean;
  69612. }, scene?: Nullable<Scene>): Mesh;
  69613. /**
  69614. * Creates a plane polygonal mesh. By default, this is a disc
  69615. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69616. * * 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
  69617. * * 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
  69618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69621. * @param name defines the name of the mesh
  69622. * @param options defines the options used to create the mesh
  69623. * @param scene defines the hosting scene
  69624. * @returns the plane polygonal mesh
  69625. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69626. */
  69627. static CreateDisc(name: string, options: {
  69628. radius?: number;
  69629. tessellation?: number;
  69630. arc?: number;
  69631. updatable?: boolean;
  69632. sideOrientation?: number;
  69633. frontUVs?: Vector4;
  69634. backUVs?: Vector4;
  69635. }, scene?: Nullable<Scene>): Mesh;
  69636. /**
  69637. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69638. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69639. * * 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`)
  69640. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69641. * * 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
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69645. * @param name defines the name of the mesh
  69646. * @param options defines the options used to create the mesh
  69647. * @param scene defines the hosting scene
  69648. * @returns the icosahedron mesh
  69649. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69650. */
  69651. static CreateIcoSphere(name: string, options: {
  69652. radius?: number;
  69653. radiusX?: number;
  69654. radiusY?: number;
  69655. radiusZ?: number;
  69656. flat?: boolean;
  69657. subdivisions?: number;
  69658. sideOrientation?: number;
  69659. frontUVs?: Vector4;
  69660. backUVs?: Vector4;
  69661. updatable?: boolean;
  69662. }, scene?: Nullable<Scene>): Mesh;
  69663. /**
  69664. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69665. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69666. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69667. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69668. * * 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
  69669. * * 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
  69670. * * 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
  69671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69673. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69674. * * 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
  69675. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69676. * * 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
  69677. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69679. * @param name defines the name of the mesh
  69680. * @param options defines the options used to create the mesh
  69681. * @param scene defines the hosting scene
  69682. * @returns the ribbon mesh
  69683. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69684. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69685. */
  69686. static CreateRibbon(name: string, options: {
  69687. pathArray: Vector3[][];
  69688. closeArray?: boolean;
  69689. closePath?: boolean;
  69690. offset?: number;
  69691. updatable?: boolean;
  69692. sideOrientation?: number;
  69693. frontUVs?: Vector4;
  69694. backUVs?: Vector4;
  69695. instance?: Mesh;
  69696. invertUV?: boolean;
  69697. uvs?: Vector2[];
  69698. colors?: Color4[];
  69699. }, scene?: Nullable<Scene>): Mesh;
  69700. /**
  69701. * Creates a cylinder or a cone mesh
  69702. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69703. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69704. * * 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.
  69705. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69706. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69707. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69708. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69709. * * 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).
  69710. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69711. * * 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).
  69712. * * 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
  69713. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69714. * * 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
  69715. * * 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.
  69716. * * If `enclose` is false, a ring surface is one element.
  69717. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69718. * * 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
  69719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69722. * @param name defines the name of the mesh
  69723. * @param options defines the options used to create the mesh
  69724. * @param scene defines the hosting scene
  69725. * @returns the cylinder mesh
  69726. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69727. */
  69728. static CreateCylinder(name: string, options: {
  69729. height?: number;
  69730. diameterTop?: number;
  69731. diameterBottom?: number;
  69732. diameter?: number;
  69733. tessellation?: number;
  69734. subdivisions?: number;
  69735. arc?: number;
  69736. faceColors?: Color4[];
  69737. faceUV?: Vector4[];
  69738. updatable?: boolean;
  69739. hasRings?: boolean;
  69740. enclose?: boolean;
  69741. cap?: number;
  69742. sideOrientation?: number;
  69743. frontUVs?: Vector4;
  69744. backUVs?: Vector4;
  69745. }, scene?: Nullable<Scene>): Mesh;
  69746. /**
  69747. * Creates a torus mesh
  69748. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69749. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69750. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69754. * @param name defines the name of the mesh
  69755. * @param options defines the options used to create the mesh
  69756. * @param scene defines the hosting scene
  69757. * @returns the torus mesh
  69758. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69759. */
  69760. static CreateTorus(name: string, options: {
  69761. diameter?: number;
  69762. thickness?: number;
  69763. tessellation?: number;
  69764. updatable?: boolean;
  69765. sideOrientation?: number;
  69766. frontUVs?: Vector4;
  69767. backUVs?: Vector4;
  69768. }, scene?: Nullable<Scene>): Mesh;
  69769. /**
  69770. * Creates a torus knot mesh
  69771. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69772. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69773. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69774. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69778. * @param name defines the name of the mesh
  69779. * @param options defines the options used to create the mesh
  69780. * @param scene defines the hosting scene
  69781. * @returns the torus knot mesh
  69782. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69783. */
  69784. static CreateTorusKnot(name: string, options: {
  69785. radius?: number;
  69786. tube?: number;
  69787. radialSegments?: number;
  69788. tubularSegments?: number;
  69789. p?: number;
  69790. q?: number;
  69791. updatable?: boolean;
  69792. sideOrientation?: number;
  69793. frontUVs?: Vector4;
  69794. backUVs?: Vector4;
  69795. }, scene?: Nullable<Scene>): Mesh;
  69796. /**
  69797. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69798. * * 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
  69799. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69800. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69801. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69802. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69803. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69804. * * 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
  69805. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69807. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69808. * @param name defines the name of the new line system
  69809. * @param options defines the options used to create the line system
  69810. * @param scene defines the hosting scene
  69811. * @returns a new line system mesh
  69812. */
  69813. static CreateLineSystem(name: string, options: {
  69814. lines: Vector3[][];
  69815. updatable?: boolean;
  69816. instance?: Nullable<LinesMesh>;
  69817. colors?: Nullable<Color4[][]>;
  69818. useVertexAlpha?: boolean;
  69819. }, scene: Nullable<Scene>): LinesMesh;
  69820. /**
  69821. * Creates a line mesh
  69822. * 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
  69823. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69824. * * The parameter `points` is an array successive Vector3
  69825. * * 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
  69826. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69827. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69828. * * When updating an instance, remember that only point positions can change, not the number of points
  69829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69831. * @param name defines the name of the new line system
  69832. * @param options defines the options used to create the line system
  69833. * @param scene defines the hosting scene
  69834. * @returns a new line mesh
  69835. */
  69836. static CreateLines(name: string, options: {
  69837. points: Vector3[];
  69838. updatable?: boolean;
  69839. instance?: Nullable<LinesMesh>;
  69840. colors?: Color4[];
  69841. useVertexAlpha?: boolean;
  69842. }, scene?: Nullable<Scene>): LinesMesh;
  69843. /**
  69844. * Creates a dashed line mesh
  69845. * * 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
  69846. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69847. * * The parameter `points` is an array successive Vector3
  69848. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69849. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69850. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69851. * * 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
  69852. * * When updating an instance, remember that only point positions can change, not the number of points
  69853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69854. * @param name defines the name of the mesh
  69855. * @param options defines the options used to create the mesh
  69856. * @param scene defines the hosting scene
  69857. * @returns the dashed line mesh
  69858. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69859. */
  69860. static CreateDashedLines(name: string, options: {
  69861. points: Vector3[];
  69862. dashSize?: number;
  69863. gapSize?: number;
  69864. dashNb?: number;
  69865. updatable?: boolean;
  69866. instance?: LinesMesh;
  69867. }, scene?: Nullable<Scene>): LinesMesh;
  69868. /**
  69869. * 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.
  69870. * * 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.
  69871. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69872. * * 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.
  69873. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69874. * * 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
  69875. * * 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
  69876. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69879. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69881. * @param name defines the name of the mesh
  69882. * @param options defines the options used to create the mesh
  69883. * @param scene defines the hosting scene
  69884. * @returns the extruded shape mesh
  69885. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69887. */
  69888. static ExtrudeShape(name: string, options: {
  69889. shape: Vector3[];
  69890. path: Vector3[];
  69891. scale?: number;
  69892. rotation?: number;
  69893. cap?: number;
  69894. updatable?: boolean;
  69895. sideOrientation?: number;
  69896. frontUVs?: Vector4;
  69897. backUVs?: Vector4;
  69898. instance?: Mesh;
  69899. invertUV?: boolean;
  69900. }, scene?: Nullable<Scene>): Mesh;
  69901. /**
  69902. * Creates an custom extruded shape mesh.
  69903. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69904. * * 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.
  69905. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69906. * * 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
  69907. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69908. * * 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
  69909. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69910. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69911. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69912. * * 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
  69913. * * 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
  69914. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69919. * @param name defines the name of the mesh
  69920. * @param options defines the options used to create the mesh
  69921. * @param scene defines the hosting scene
  69922. * @returns the custom extruded shape mesh
  69923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69924. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69925. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69926. */
  69927. static ExtrudeShapeCustom(name: string, options: {
  69928. shape: Vector3[];
  69929. path: Vector3[];
  69930. scaleFunction?: any;
  69931. rotationFunction?: any;
  69932. ribbonCloseArray?: boolean;
  69933. ribbonClosePath?: boolean;
  69934. cap?: number;
  69935. updatable?: boolean;
  69936. sideOrientation?: number;
  69937. frontUVs?: Vector4;
  69938. backUVs?: Vector4;
  69939. instance?: Mesh;
  69940. invertUV?: boolean;
  69941. }, scene?: Nullable<Scene>): Mesh;
  69942. /**
  69943. * Creates lathe mesh.
  69944. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69945. * * 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
  69946. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69947. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69948. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69949. * * 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
  69950. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69951. * * 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
  69952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69954. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69956. * @param name defines the name of the mesh
  69957. * @param options defines the options used to create the mesh
  69958. * @param scene defines the hosting scene
  69959. * @returns the lathe mesh
  69960. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69961. */
  69962. static CreateLathe(name: string, options: {
  69963. shape: Vector3[];
  69964. radius?: number;
  69965. tessellation?: number;
  69966. clip?: number;
  69967. arc?: number;
  69968. closed?: boolean;
  69969. updatable?: boolean;
  69970. sideOrientation?: number;
  69971. frontUVs?: Vector4;
  69972. backUVs?: Vector4;
  69973. cap?: number;
  69974. invertUV?: boolean;
  69975. }, scene?: Nullable<Scene>): Mesh;
  69976. /**
  69977. * Creates a tiled plane mesh
  69978. * * You can set a limited pattern arrangement with the tiles
  69979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69980. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69982. * @param name defines the name of the mesh
  69983. * @param options defines the options used to create the mesh
  69984. * @param scene defines the hosting scene
  69985. * @returns the plane mesh
  69986. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69987. */
  69988. static CreateTiledPlane(name: string, options: {
  69989. pattern?: number;
  69990. tileSize?: number;
  69991. tileWidth?: number;
  69992. tileHeight?: number;
  69993. size?: number;
  69994. width?: number;
  69995. height?: number;
  69996. alignHorizontal?: number;
  69997. alignVertical?: number;
  69998. sideOrientation?: number;
  69999. frontUVs?: Vector4;
  70000. backUVs?: Vector4;
  70001. updatable?: boolean;
  70002. }, scene?: Nullable<Scene>): Mesh;
  70003. /**
  70004. * Creates a plane mesh
  70005. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70006. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70007. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70011. * @param name defines the name of the mesh
  70012. * @param options defines the options used to create the mesh
  70013. * @param scene defines the hosting scene
  70014. * @returns the plane mesh
  70015. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70016. */
  70017. static CreatePlane(name: string, options: {
  70018. size?: number;
  70019. width?: number;
  70020. height?: number;
  70021. sideOrientation?: number;
  70022. frontUVs?: Vector4;
  70023. backUVs?: Vector4;
  70024. updatable?: boolean;
  70025. sourcePlane?: Plane;
  70026. }, scene?: Nullable<Scene>): Mesh;
  70027. /**
  70028. * Creates a ground mesh
  70029. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70030. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70032. * @param name defines the name of the mesh
  70033. * @param options defines the options used to create the mesh
  70034. * @param scene defines the hosting scene
  70035. * @returns the ground mesh
  70036. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70037. */
  70038. static CreateGround(name: string, options: {
  70039. width?: number;
  70040. height?: number;
  70041. subdivisions?: number;
  70042. subdivisionsX?: number;
  70043. subdivisionsY?: number;
  70044. updatable?: boolean;
  70045. }, scene?: Nullable<Scene>): Mesh;
  70046. /**
  70047. * Creates a tiled ground mesh
  70048. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70049. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70050. * * 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
  70051. * * 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
  70052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70053. * @param name defines the name of the mesh
  70054. * @param options defines the options used to create the mesh
  70055. * @param scene defines the hosting scene
  70056. * @returns the tiled ground mesh
  70057. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70058. */
  70059. static CreateTiledGround(name: string, options: {
  70060. xmin: number;
  70061. zmin: number;
  70062. xmax: number;
  70063. zmax: number;
  70064. subdivisions?: {
  70065. w: number;
  70066. h: number;
  70067. };
  70068. precision?: {
  70069. w: number;
  70070. h: number;
  70071. };
  70072. updatable?: boolean;
  70073. }, scene?: Nullable<Scene>): Mesh;
  70074. /**
  70075. * Creates a ground mesh from a height map
  70076. * * The parameter `url` sets the URL of the height map image resource.
  70077. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70078. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70079. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70080. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70081. * * 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.
  70082. * * 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).
  70083. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70085. * @param name defines the name of the mesh
  70086. * @param url defines the url to the height map
  70087. * @param options defines the options used to create the mesh
  70088. * @param scene defines the hosting scene
  70089. * @returns the ground mesh
  70090. * @see https://doc.babylonjs.com/babylon101/height_map
  70091. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70092. */
  70093. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70094. width?: number;
  70095. height?: number;
  70096. subdivisions?: number;
  70097. minHeight?: number;
  70098. maxHeight?: number;
  70099. colorFilter?: Color3;
  70100. alphaFilter?: number;
  70101. updatable?: boolean;
  70102. onReady?: (mesh: GroundMesh) => void;
  70103. }, scene?: Nullable<Scene>): GroundMesh;
  70104. /**
  70105. * Creates a polygon mesh
  70106. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70107. * * 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
  70108. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70110. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70111. * * Remember you can only change the shape positions, not their number when updating a polygon
  70112. * @param name defines the name of the mesh
  70113. * @param options defines the options used to create the mesh
  70114. * @param scene defines the hosting scene
  70115. * @param earcutInjection can be used to inject your own earcut reference
  70116. * @returns the polygon mesh
  70117. */
  70118. static CreatePolygon(name: string, options: {
  70119. shape: Vector3[];
  70120. holes?: Vector3[][];
  70121. depth?: number;
  70122. faceUV?: Vector4[];
  70123. faceColors?: Color4[];
  70124. updatable?: boolean;
  70125. sideOrientation?: number;
  70126. frontUVs?: Vector4;
  70127. backUVs?: Vector4;
  70128. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70129. /**
  70130. * Creates an extruded polygon mesh, with depth in the Y direction.
  70131. * * 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)
  70132. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70133. * @param name defines the name of the mesh
  70134. * @param options defines the options used to create the mesh
  70135. * @param scene defines the hosting scene
  70136. * @param earcutInjection can be used to inject your own earcut reference
  70137. * @returns the polygon mesh
  70138. */
  70139. static ExtrudePolygon(name: string, options: {
  70140. shape: Vector3[];
  70141. holes?: Vector3[][];
  70142. depth?: number;
  70143. faceUV?: Vector4[];
  70144. faceColors?: Color4[];
  70145. updatable?: boolean;
  70146. sideOrientation?: number;
  70147. frontUVs?: Vector4;
  70148. backUVs?: Vector4;
  70149. wrap?: boolean;
  70150. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70151. /**
  70152. * Creates a tube mesh.
  70153. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70154. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70155. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70156. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70157. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70158. * * 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)
  70159. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70160. * * 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
  70161. * * 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
  70162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70164. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70166. * @param name defines the name of the mesh
  70167. * @param options defines the options used to create the mesh
  70168. * @param scene defines the hosting scene
  70169. * @returns the tube mesh
  70170. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70171. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70172. */
  70173. static CreateTube(name: string, options: {
  70174. path: Vector3[];
  70175. radius?: number;
  70176. tessellation?: number;
  70177. radiusFunction?: {
  70178. (i: number, distance: number): number;
  70179. };
  70180. cap?: number;
  70181. arc?: number;
  70182. updatable?: boolean;
  70183. sideOrientation?: number;
  70184. frontUVs?: Vector4;
  70185. backUVs?: Vector4;
  70186. instance?: Mesh;
  70187. invertUV?: boolean;
  70188. }, scene?: Nullable<Scene>): Mesh;
  70189. /**
  70190. * Creates a polyhedron mesh
  70191. * * 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
  70192. * * The parameter `size` (positive float, default 1) sets the polygon size
  70193. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70194. * * 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`
  70195. * * 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
  70196. * * 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)`)
  70197. * * 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
  70198. * * 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
  70199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70202. * @param name defines the name of the mesh
  70203. * @param options defines the options used to create the mesh
  70204. * @param scene defines the hosting scene
  70205. * @returns the polyhedron mesh
  70206. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70207. */
  70208. static CreatePolyhedron(name: string, options: {
  70209. type?: number;
  70210. size?: number;
  70211. sizeX?: number;
  70212. sizeY?: number;
  70213. sizeZ?: number;
  70214. custom?: any;
  70215. faceUV?: Vector4[];
  70216. faceColors?: Color4[];
  70217. flat?: boolean;
  70218. updatable?: boolean;
  70219. sideOrientation?: number;
  70220. frontUVs?: Vector4;
  70221. backUVs?: Vector4;
  70222. }, scene?: Nullable<Scene>): Mesh;
  70223. /**
  70224. * Creates a decal mesh.
  70225. * 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
  70226. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70227. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70228. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70229. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70230. * @param name defines the name of the mesh
  70231. * @param sourceMesh defines the mesh where the decal must be applied
  70232. * @param options defines the options used to create the mesh
  70233. * @param scene defines the hosting scene
  70234. * @returns the decal mesh
  70235. * @see https://doc.babylonjs.com/how_to/decals
  70236. */
  70237. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70238. position?: Vector3;
  70239. normal?: Vector3;
  70240. size?: Vector3;
  70241. angle?: number;
  70242. }): Mesh;
  70243. /**
  70244. * Creates a Capsule Mesh
  70245. * @param name defines the name of the mesh.
  70246. * @param options the constructors options used to shape the mesh.
  70247. * @param scene defines the scene the mesh is scoped to.
  70248. * @returns the capsule mesh
  70249. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70250. */
  70251. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70252. }
  70253. }
  70254. declare module "babylonjs/Meshes/meshSimplification" {
  70255. import { Mesh } from "babylonjs/Meshes/mesh";
  70256. /**
  70257. * A simplifier interface for future simplification implementations
  70258. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70259. */
  70260. export interface ISimplifier {
  70261. /**
  70262. * Simplification of a given mesh according to the given settings.
  70263. * Since this requires computation, it is assumed that the function runs async.
  70264. * @param settings The settings of the simplification, including quality and distance
  70265. * @param successCallback A callback that will be called after the mesh was simplified.
  70266. * @param errorCallback in case of an error, this callback will be called. optional.
  70267. */
  70268. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70269. }
  70270. /**
  70271. * Expected simplification settings.
  70272. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70273. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70274. */
  70275. export interface ISimplificationSettings {
  70276. /**
  70277. * Gets or sets the expected quality
  70278. */
  70279. quality: number;
  70280. /**
  70281. * Gets or sets the distance when this optimized version should be used
  70282. */
  70283. distance: number;
  70284. /**
  70285. * Gets an already optimized mesh
  70286. */
  70287. optimizeMesh?: boolean;
  70288. }
  70289. /**
  70290. * Class used to specify simplification options
  70291. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70292. */
  70293. export class SimplificationSettings implements ISimplificationSettings {
  70294. /** expected quality */
  70295. quality: number;
  70296. /** distance when this optimized version should be used */
  70297. distance: number;
  70298. /** already optimized mesh */
  70299. optimizeMesh?: boolean | undefined;
  70300. /**
  70301. * Creates a SimplificationSettings
  70302. * @param quality expected quality
  70303. * @param distance distance when this optimized version should be used
  70304. * @param optimizeMesh already optimized mesh
  70305. */
  70306. constructor(
  70307. /** expected quality */
  70308. quality: number,
  70309. /** distance when this optimized version should be used */
  70310. distance: number,
  70311. /** already optimized mesh */
  70312. optimizeMesh?: boolean | undefined);
  70313. }
  70314. /**
  70315. * Interface used to define a simplification task
  70316. */
  70317. export interface ISimplificationTask {
  70318. /**
  70319. * Array of settings
  70320. */
  70321. settings: Array<ISimplificationSettings>;
  70322. /**
  70323. * Simplification type
  70324. */
  70325. simplificationType: SimplificationType;
  70326. /**
  70327. * Mesh to simplify
  70328. */
  70329. mesh: Mesh;
  70330. /**
  70331. * Callback called on success
  70332. */
  70333. successCallback?: () => void;
  70334. /**
  70335. * Defines if parallel processing can be used
  70336. */
  70337. parallelProcessing: boolean;
  70338. }
  70339. /**
  70340. * Queue used to order the simplification tasks
  70341. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70342. */
  70343. export class SimplificationQueue {
  70344. private _simplificationArray;
  70345. /**
  70346. * Gets a boolean indicating that the process is still running
  70347. */
  70348. running: boolean;
  70349. /**
  70350. * Creates a new queue
  70351. */
  70352. constructor();
  70353. /**
  70354. * Adds a new simplification task
  70355. * @param task defines a task to add
  70356. */
  70357. addTask(task: ISimplificationTask): void;
  70358. /**
  70359. * Execute next task
  70360. */
  70361. executeNext(): void;
  70362. /**
  70363. * Execute a simplification task
  70364. * @param task defines the task to run
  70365. */
  70366. runSimplification(task: ISimplificationTask): void;
  70367. private getSimplifier;
  70368. }
  70369. /**
  70370. * The implemented types of simplification
  70371. * At the moment only Quadratic Error Decimation is implemented
  70372. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70373. */
  70374. export enum SimplificationType {
  70375. /** Quadratic error decimation */
  70376. QUADRATIC = 0
  70377. }
  70378. /**
  70379. * An implementation of the Quadratic Error simplification algorithm.
  70380. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70381. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70382. * @author RaananW
  70383. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70384. */
  70385. export class QuadraticErrorSimplification implements ISimplifier {
  70386. private _mesh;
  70387. private triangles;
  70388. private vertices;
  70389. private references;
  70390. private _reconstructedMesh;
  70391. /** Gets or sets the number pf sync interations */
  70392. syncIterations: number;
  70393. /** Gets or sets the aggressiveness of the simplifier */
  70394. aggressiveness: number;
  70395. /** Gets or sets the number of allowed iterations for decimation */
  70396. decimationIterations: number;
  70397. /** Gets or sets the espilon to use for bounding box computation */
  70398. boundingBoxEpsilon: number;
  70399. /**
  70400. * Creates a new QuadraticErrorSimplification
  70401. * @param _mesh defines the target mesh
  70402. */
  70403. constructor(_mesh: Mesh);
  70404. /**
  70405. * Simplification of a given mesh according to the given settings.
  70406. * Since this requires computation, it is assumed that the function runs async.
  70407. * @param settings The settings of the simplification, including quality and distance
  70408. * @param successCallback A callback that will be called after the mesh was simplified.
  70409. */
  70410. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70411. private runDecimation;
  70412. private initWithMesh;
  70413. private init;
  70414. private reconstructMesh;
  70415. private initDecimatedMesh;
  70416. private isFlipped;
  70417. private updateTriangles;
  70418. private identifyBorder;
  70419. private updateMesh;
  70420. private vertexError;
  70421. private calculateError;
  70422. }
  70423. }
  70424. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70425. import { Scene } from "babylonjs/scene";
  70426. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70427. import { ISceneComponent } from "babylonjs/sceneComponent";
  70428. module "babylonjs/scene" {
  70429. interface Scene {
  70430. /** @hidden (Backing field) */
  70431. _simplificationQueue: SimplificationQueue;
  70432. /**
  70433. * Gets or sets the simplification queue attached to the scene
  70434. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70435. */
  70436. simplificationQueue: SimplificationQueue;
  70437. }
  70438. }
  70439. module "babylonjs/Meshes/mesh" {
  70440. interface Mesh {
  70441. /**
  70442. * Simplify the mesh according to the given array of settings.
  70443. * Function will return immediately and will simplify async
  70444. * @param settings a collection of simplification settings
  70445. * @param parallelProcessing should all levels calculate parallel or one after the other
  70446. * @param simplificationType the type of simplification to run
  70447. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70448. * @returns the current mesh
  70449. */
  70450. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70451. }
  70452. }
  70453. /**
  70454. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70455. * created in a scene
  70456. */
  70457. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70458. /**
  70459. * The component name helpfull to identify the component in the list of scene components.
  70460. */
  70461. readonly name: string;
  70462. /**
  70463. * The scene the component belongs to.
  70464. */
  70465. scene: Scene;
  70466. /**
  70467. * Creates a new instance of the component for the given scene
  70468. * @param scene Defines the scene to register the component in
  70469. */
  70470. constructor(scene: Scene);
  70471. /**
  70472. * Registers the component in a given scene
  70473. */
  70474. register(): void;
  70475. /**
  70476. * Rebuilds the elements related to this component in case of
  70477. * context lost for instance.
  70478. */
  70479. rebuild(): void;
  70480. /**
  70481. * Disposes the component and the associated ressources
  70482. */
  70483. dispose(): void;
  70484. private _beforeCameraUpdate;
  70485. }
  70486. }
  70487. declare module "babylonjs/Meshes/Builders/index" {
  70488. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70489. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70490. export * from "babylonjs/Meshes/Builders/discBuilder";
  70491. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70492. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70493. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70494. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70495. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70496. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70497. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70498. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70499. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70500. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70501. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70502. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70503. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70504. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70505. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70506. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70507. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70508. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70509. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70510. }
  70511. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70512. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70513. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70514. import { Matrix } from "babylonjs/Maths/math.vector";
  70515. module "babylonjs/Meshes/mesh" {
  70516. interface Mesh {
  70517. /**
  70518. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70519. */
  70520. thinInstanceEnablePicking: boolean;
  70521. /**
  70522. * Creates a new thin instance
  70523. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70524. * @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
  70525. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70526. */
  70527. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70528. /**
  70529. * Adds the transformation (matrix) of the current mesh as a thin instance
  70530. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  70531. * @returns the thin instance index number
  70532. */
  70533. thinInstanceAddSelf(refresh: boolean): number;
  70534. /**
  70535. * Registers a custom attribute to be used with thin instances
  70536. * @param kind name of the attribute
  70537. * @param stride size in floats of the attribute
  70538. */
  70539. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70540. /**
  70541. * Sets the matrix of a thin instance
  70542. * @param index index of the thin instance
  70543. * @param matrix matrix to set
  70544. * @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
  70545. */
  70546. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70547. /**
  70548. * Sets the value of a custom attribute for a thin instance
  70549. * @param kind name of the attribute
  70550. * @param index index of the thin instance
  70551. * @param value value to set
  70552. * @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
  70553. */
  70554. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70555. /**
  70556. * 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.
  70557. */
  70558. thinInstanceCount: number;
  70559. /**
  70560. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70561. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70562. * @param buffer buffer to set
  70563. * @param stride size in floats of each value of the buffer
  70564. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70565. */
  70566. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70567. /**
  70568. * Gets the list of world matrices
  70569. * @return an array containing all the world matrices from the thin instances
  70570. */
  70571. thinInstanceGetWorldMatrices(): Matrix[];
  70572. /**
  70573. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70574. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70575. */
  70576. thinInstanceBufferUpdated(kind: string): void;
  70577. /**
  70578. * Applies a partial update to a buffer directly on the GPU
  70579. * 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
  70580. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70581. * @param data the data to set in the GPU buffer
  70582. * @param offset the offset in the GPU buffer where to update the data
  70583. */
  70584. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70585. /**
  70586. * Refreshes the bounding info, taking into account all the thin instances defined
  70587. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70588. */
  70589. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70590. /** @hidden */
  70591. _thinInstanceInitializeUserStorage(): void;
  70592. /** @hidden */
  70593. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70594. /** @hidden */
  70595. _userThinInstanceBuffersStorage: {
  70596. data: {
  70597. [key: string]: Float32Array;
  70598. };
  70599. sizes: {
  70600. [key: string]: number;
  70601. };
  70602. vertexBuffers: {
  70603. [key: string]: Nullable<VertexBuffer>;
  70604. };
  70605. strides: {
  70606. [key: string]: number;
  70607. };
  70608. };
  70609. }
  70610. }
  70611. }
  70612. declare module "babylonjs/Meshes/index" {
  70613. export * from "babylonjs/Meshes/abstractMesh";
  70614. export * from "babylonjs/Meshes/buffer";
  70615. export * from "babylonjs/Meshes/Compression/index";
  70616. export * from "babylonjs/Meshes/csg";
  70617. export * from "babylonjs/Meshes/geometry";
  70618. export * from "babylonjs/Meshes/groundMesh";
  70619. export * from "babylonjs/Meshes/trailMesh";
  70620. export * from "babylonjs/Meshes/instancedMesh";
  70621. export * from "babylonjs/Meshes/linesMesh";
  70622. export * from "babylonjs/Meshes/mesh";
  70623. export * from "babylonjs/Meshes/mesh.vertexData";
  70624. export * from "babylonjs/Meshes/meshBuilder";
  70625. export * from "babylonjs/Meshes/meshSimplification";
  70626. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70627. export * from "babylonjs/Meshes/polygonMesh";
  70628. export * from "babylonjs/Meshes/subMesh";
  70629. export * from "babylonjs/Meshes/meshLODLevel";
  70630. export * from "babylonjs/Meshes/transformNode";
  70631. export * from "babylonjs/Meshes/Builders/index";
  70632. export * from "babylonjs/Meshes/dataBuffer";
  70633. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70634. import "babylonjs/Meshes/thinInstanceMesh";
  70635. export * from "babylonjs/Meshes/thinInstanceMesh";
  70636. }
  70637. declare module "babylonjs/Morph/index" {
  70638. export * from "babylonjs/Morph/morphTarget";
  70639. export * from "babylonjs/Morph/morphTargetManager";
  70640. }
  70641. declare module "babylonjs/Navigation/INavigationEngine" {
  70642. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70643. import { Vector3 } from "babylonjs/Maths/math";
  70644. import { Mesh } from "babylonjs/Meshes/mesh";
  70645. import { Scene } from "babylonjs/scene";
  70646. /**
  70647. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70648. */
  70649. export interface INavigationEnginePlugin {
  70650. /**
  70651. * plugin name
  70652. */
  70653. name: string;
  70654. /**
  70655. * Creates a navigation mesh
  70656. * @param meshes array of all the geometry used to compute the navigatio mesh
  70657. * @param parameters bunch of parameters used to filter geometry
  70658. */
  70659. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70660. /**
  70661. * Create a navigation mesh debug mesh
  70662. * @param scene is where the mesh will be added
  70663. * @returns debug display mesh
  70664. */
  70665. createDebugNavMesh(scene: Scene): Mesh;
  70666. /**
  70667. * Get a navigation mesh constrained position, closest to the parameter position
  70668. * @param position world position
  70669. * @returns the closest point to position constrained by the navigation mesh
  70670. */
  70671. getClosestPoint(position: Vector3): Vector3;
  70672. /**
  70673. * Get a navigation mesh constrained position, closest to the parameter position
  70674. * @param position world position
  70675. * @param result output the closest point to position constrained by the navigation mesh
  70676. */
  70677. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70678. /**
  70679. * Get a navigation mesh constrained position, within a particular radius
  70680. * @param position world position
  70681. * @param maxRadius the maximum distance to the constrained world position
  70682. * @returns the closest point to position constrained by the navigation mesh
  70683. */
  70684. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70685. /**
  70686. * Get a navigation mesh constrained position, within a particular radius
  70687. * @param position world position
  70688. * @param maxRadius the maximum distance to the constrained world position
  70689. * @param result output the closest point to position constrained by the navigation mesh
  70690. */
  70691. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70692. /**
  70693. * Compute the final position from a segment made of destination-position
  70694. * @param position world position
  70695. * @param destination world position
  70696. * @returns the resulting point along the navmesh
  70697. */
  70698. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70699. /**
  70700. * Compute the final position from a segment made of destination-position
  70701. * @param position world position
  70702. * @param destination world position
  70703. * @param result output the resulting point along the navmesh
  70704. */
  70705. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70706. /**
  70707. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70708. * @param start world position
  70709. * @param end world position
  70710. * @returns array containing world position composing the path
  70711. */
  70712. computePath(start: Vector3, end: Vector3): Vector3[];
  70713. /**
  70714. * If this plugin is supported
  70715. * @returns true if plugin is supported
  70716. */
  70717. isSupported(): boolean;
  70718. /**
  70719. * Create a new Crowd so you can add agents
  70720. * @param maxAgents the maximum agent count in the crowd
  70721. * @param maxAgentRadius the maximum radius an agent can have
  70722. * @param scene to attach the crowd to
  70723. * @returns the crowd you can add agents to
  70724. */
  70725. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70726. /**
  70727. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70728. * The queries will try to find a solution within those bounds
  70729. * default is (1,1,1)
  70730. * @param extent x,y,z value that define the extent around the queries point of reference
  70731. */
  70732. setDefaultQueryExtent(extent: Vector3): void;
  70733. /**
  70734. * Get the Bounding box extent specified by setDefaultQueryExtent
  70735. * @returns the box extent values
  70736. */
  70737. getDefaultQueryExtent(): Vector3;
  70738. /**
  70739. * build the navmesh from a previously saved state using getNavmeshData
  70740. * @param data the Uint8Array returned by getNavmeshData
  70741. */
  70742. buildFromNavmeshData(data: Uint8Array): void;
  70743. /**
  70744. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70745. * @returns data the Uint8Array that can be saved and reused
  70746. */
  70747. getNavmeshData(): Uint8Array;
  70748. /**
  70749. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70750. * @param result output the box extent values
  70751. */
  70752. getDefaultQueryExtentToRef(result: Vector3): void;
  70753. /**
  70754. * Release all resources
  70755. */
  70756. dispose(): void;
  70757. }
  70758. /**
  70759. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70760. */
  70761. export interface ICrowd {
  70762. /**
  70763. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70764. * You can attach anything to that node. The node position is updated in the scene update tick.
  70765. * @param pos world position that will be constrained by the navigation mesh
  70766. * @param parameters agent parameters
  70767. * @param transform hooked to the agent that will be update by the scene
  70768. * @returns agent index
  70769. */
  70770. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70771. /**
  70772. * Returns the agent position in world space
  70773. * @param index agent index returned by addAgent
  70774. * @returns world space position
  70775. */
  70776. getAgentPosition(index: number): Vector3;
  70777. /**
  70778. * Gets the agent position result in world space
  70779. * @param index agent index returned by addAgent
  70780. * @param result output world space position
  70781. */
  70782. getAgentPositionToRef(index: number, result: Vector3): void;
  70783. /**
  70784. * Gets the agent velocity in world space
  70785. * @param index agent index returned by addAgent
  70786. * @returns world space velocity
  70787. */
  70788. getAgentVelocity(index: number): Vector3;
  70789. /**
  70790. * Gets the agent velocity result in world space
  70791. * @param index agent index returned by addAgent
  70792. * @param result output world space velocity
  70793. */
  70794. getAgentVelocityToRef(index: number, result: Vector3): void;
  70795. /**
  70796. * remove a particular agent previously created
  70797. * @param index agent index returned by addAgent
  70798. */
  70799. removeAgent(index: number): void;
  70800. /**
  70801. * get the list of all agents attached to this crowd
  70802. * @returns list of agent indices
  70803. */
  70804. getAgents(): number[];
  70805. /**
  70806. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70807. * @param deltaTime in seconds
  70808. */
  70809. update(deltaTime: number): void;
  70810. /**
  70811. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70812. * @param index agent index returned by addAgent
  70813. * @param destination targeted world position
  70814. */
  70815. agentGoto(index: number, destination: Vector3): void;
  70816. /**
  70817. * Teleport the agent to a new position
  70818. * @param index agent index returned by addAgent
  70819. * @param destination targeted world position
  70820. */
  70821. agentTeleport(index: number, destination: Vector3): void;
  70822. /**
  70823. * Update agent parameters
  70824. * @param index agent index returned by addAgent
  70825. * @param parameters agent parameters
  70826. */
  70827. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70828. /**
  70829. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70830. * The queries will try to find a solution within those bounds
  70831. * default is (1,1,1)
  70832. * @param extent x,y,z value that define the extent around the queries point of reference
  70833. */
  70834. setDefaultQueryExtent(extent: Vector3): void;
  70835. /**
  70836. * Get the Bounding box extent specified by setDefaultQueryExtent
  70837. * @returns the box extent values
  70838. */
  70839. getDefaultQueryExtent(): Vector3;
  70840. /**
  70841. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70842. * @param result output the box extent values
  70843. */
  70844. getDefaultQueryExtentToRef(result: Vector3): void;
  70845. /**
  70846. * Release all resources
  70847. */
  70848. dispose(): void;
  70849. }
  70850. /**
  70851. * Configures an agent
  70852. */
  70853. export interface IAgentParameters {
  70854. /**
  70855. * Agent radius. [Limit: >= 0]
  70856. */
  70857. radius: number;
  70858. /**
  70859. * Agent height. [Limit: > 0]
  70860. */
  70861. height: number;
  70862. /**
  70863. * Maximum allowed acceleration. [Limit: >= 0]
  70864. */
  70865. maxAcceleration: number;
  70866. /**
  70867. * Maximum allowed speed. [Limit: >= 0]
  70868. */
  70869. maxSpeed: number;
  70870. /**
  70871. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70872. */
  70873. collisionQueryRange: number;
  70874. /**
  70875. * The path visibility optimization range. [Limit: > 0]
  70876. */
  70877. pathOptimizationRange: number;
  70878. /**
  70879. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70880. */
  70881. separationWeight: number;
  70882. }
  70883. /**
  70884. * Configures the navigation mesh creation
  70885. */
  70886. export interface INavMeshParameters {
  70887. /**
  70888. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70889. */
  70890. cs: number;
  70891. /**
  70892. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70893. */
  70894. ch: number;
  70895. /**
  70896. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70897. */
  70898. walkableSlopeAngle: number;
  70899. /**
  70900. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70901. * be considered walkable. [Limit: >= 3] [Units: vx]
  70902. */
  70903. walkableHeight: number;
  70904. /**
  70905. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70906. */
  70907. walkableClimb: number;
  70908. /**
  70909. * The distance to erode/shrink the walkable area of the heightfield away from
  70910. * obstructions. [Limit: >=0] [Units: vx]
  70911. */
  70912. walkableRadius: number;
  70913. /**
  70914. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70915. */
  70916. maxEdgeLen: number;
  70917. /**
  70918. * The maximum distance a simplfied contour's border edges should deviate
  70919. * the original raw contour. [Limit: >=0] [Units: vx]
  70920. */
  70921. maxSimplificationError: number;
  70922. /**
  70923. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70924. */
  70925. minRegionArea: number;
  70926. /**
  70927. * Any regions with a span count smaller than this value will, if possible,
  70928. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70929. */
  70930. mergeRegionArea: number;
  70931. /**
  70932. * The maximum number of vertices allowed for polygons generated during the
  70933. * contour to polygon conversion process. [Limit: >= 3]
  70934. */
  70935. maxVertsPerPoly: number;
  70936. /**
  70937. * Sets the sampling distance to use when generating the detail mesh.
  70938. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70939. */
  70940. detailSampleDist: number;
  70941. /**
  70942. * The maximum distance the detail mesh surface should deviate from heightfield
  70943. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70944. */
  70945. detailSampleMaxError: number;
  70946. }
  70947. }
  70948. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70949. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70950. import { Mesh } from "babylonjs/Meshes/mesh";
  70951. import { Scene } from "babylonjs/scene";
  70952. import { Vector3 } from "babylonjs/Maths/math";
  70953. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70954. /**
  70955. * RecastJS navigation plugin
  70956. */
  70957. export class RecastJSPlugin implements INavigationEnginePlugin {
  70958. /**
  70959. * Reference to the Recast library
  70960. */
  70961. bjsRECAST: any;
  70962. /**
  70963. * plugin name
  70964. */
  70965. name: string;
  70966. /**
  70967. * the first navmesh created. We might extend this to support multiple navmeshes
  70968. */
  70969. navMesh: any;
  70970. /**
  70971. * Initializes the recastJS plugin
  70972. * @param recastInjection can be used to inject your own recast reference
  70973. */
  70974. constructor(recastInjection?: any);
  70975. /**
  70976. * Creates a navigation mesh
  70977. * @param meshes array of all the geometry used to compute the navigatio mesh
  70978. * @param parameters bunch of parameters used to filter geometry
  70979. */
  70980. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70981. /**
  70982. * Create a navigation mesh debug mesh
  70983. * @param scene is where the mesh will be added
  70984. * @returns debug display mesh
  70985. */
  70986. createDebugNavMesh(scene: Scene): Mesh;
  70987. /**
  70988. * Get a navigation mesh constrained position, closest to the parameter position
  70989. * @param position world position
  70990. * @returns the closest point to position constrained by the navigation mesh
  70991. */
  70992. getClosestPoint(position: Vector3): Vector3;
  70993. /**
  70994. * Get a navigation mesh constrained position, closest to the parameter position
  70995. * @param position world position
  70996. * @param result output the closest point to position constrained by the navigation mesh
  70997. */
  70998. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70999. /**
  71000. * Get a navigation mesh constrained position, within a particular radius
  71001. * @param position world position
  71002. * @param maxRadius the maximum distance to the constrained world position
  71003. * @returns the closest point to position constrained by the navigation mesh
  71004. */
  71005. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71006. /**
  71007. * Get a navigation mesh constrained position, within a particular radius
  71008. * @param position world position
  71009. * @param maxRadius the maximum distance to the constrained world position
  71010. * @param result output the closest point to position constrained by the navigation mesh
  71011. */
  71012. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71013. /**
  71014. * Compute the final position from a segment made of destination-position
  71015. * @param position world position
  71016. * @param destination world position
  71017. * @returns the resulting point along the navmesh
  71018. */
  71019. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71020. /**
  71021. * Compute the final position from a segment made of destination-position
  71022. * @param position world position
  71023. * @param destination world position
  71024. * @param result output the resulting point along the navmesh
  71025. */
  71026. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71027. /**
  71028. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71029. * @param start world position
  71030. * @param end world position
  71031. * @returns array containing world position composing the path
  71032. */
  71033. computePath(start: Vector3, end: Vector3): Vector3[];
  71034. /**
  71035. * Create a new Crowd so you can add agents
  71036. * @param maxAgents the maximum agent count in the crowd
  71037. * @param maxAgentRadius the maximum radius an agent can have
  71038. * @param scene to attach the crowd to
  71039. * @returns the crowd you can add agents to
  71040. */
  71041. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71042. /**
  71043. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71044. * The queries will try to find a solution within those bounds
  71045. * default is (1,1,1)
  71046. * @param extent x,y,z value that define the extent around the queries point of reference
  71047. */
  71048. setDefaultQueryExtent(extent: Vector3): void;
  71049. /**
  71050. * Get the Bounding box extent specified by setDefaultQueryExtent
  71051. * @returns the box extent values
  71052. */
  71053. getDefaultQueryExtent(): Vector3;
  71054. /**
  71055. * build the navmesh from a previously saved state using getNavmeshData
  71056. * @param data the Uint8Array returned by getNavmeshData
  71057. */
  71058. buildFromNavmeshData(data: Uint8Array): void;
  71059. /**
  71060. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71061. * @returns data the Uint8Array that can be saved and reused
  71062. */
  71063. getNavmeshData(): Uint8Array;
  71064. /**
  71065. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71066. * @param result output the box extent values
  71067. */
  71068. getDefaultQueryExtentToRef(result: Vector3): void;
  71069. /**
  71070. * Disposes
  71071. */
  71072. dispose(): void;
  71073. /**
  71074. * If this plugin is supported
  71075. * @returns true if plugin is supported
  71076. */
  71077. isSupported(): boolean;
  71078. }
  71079. /**
  71080. * Recast detour crowd implementation
  71081. */
  71082. export class RecastJSCrowd implements ICrowd {
  71083. /**
  71084. * Recast/detour plugin
  71085. */
  71086. bjsRECASTPlugin: RecastJSPlugin;
  71087. /**
  71088. * Link to the detour crowd
  71089. */
  71090. recastCrowd: any;
  71091. /**
  71092. * One transform per agent
  71093. */
  71094. transforms: TransformNode[];
  71095. /**
  71096. * All agents created
  71097. */
  71098. agents: number[];
  71099. /**
  71100. * Link to the scene is kept to unregister the crowd from the scene
  71101. */
  71102. private _scene;
  71103. /**
  71104. * Observer for crowd updates
  71105. */
  71106. private _onBeforeAnimationsObserver;
  71107. /**
  71108. * Constructor
  71109. * @param plugin recastJS plugin
  71110. * @param maxAgents the maximum agent count in the crowd
  71111. * @param maxAgentRadius the maximum radius an agent can have
  71112. * @param scene to attach the crowd to
  71113. * @returns the crowd you can add agents to
  71114. */
  71115. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71116. /**
  71117. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71118. * You can attach anything to that node. The node position is updated in the scene update tick.
  71119. * @param pos world position that will be constrained by the navigation mesh
  71120. * @param parameters agent parameters
  71121. * @param transform hooked to the agent that will be update by the scene
  71122. * @returns agent index
  71123. */
  71124. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71125. /**
  71126. * Returns the agent position in world space
  71127. * @param index agent index returned by addAgent
  71128. * @returns world space position
  71129. */
  71130. getAgentPosition(index: number): Vector3;
  71131. /**
  71132. * Returns the agent position result in world space
  71133. * @param index agent index returned by addAgent
  71134. * @param result output world space position
  71135. */
  71136. getAgentPositionToRef(index: number, result: Vector3): void;
  71137. /**
  71138. * Returns the agent velocity in world space
  71139. * @param index agent index returned by addAgent
  71140. * @returns world space velocity
  71141. */
  71142. getAgentVelocity(index: number): Vector3;
  71143. /**
  71144. * Returns the agent velocity result in world space
  71145. * @param index agent index returned by addAgent
  71146. * @param result output world space velocity
  71147. */
  71148. getAgentVelocityToRef(index: number, result: Vector3): void;
  71149. /**
  71150. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71151. * @param index agent index returned by addAgent
  71152. * @param destination targeted world position
  71153. */
  71154. agentGoto(index: number, destination: Vector3): void;
  71155. /**
  71156. * Teleport the agent to a new position
  71157. * @param index agent index returned by addAgent
  71158. * @param destination targeted world position
  71159. */
  71160. agentTeleport(index: number, destination: Vector3): void;
  71161. /**
  71162. * Update agent parameters
  71163. * @param index agent index returned by addAgent
  71164. * @param parameters agent parameters
  71165. */
  71166. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71167. /**
  71168. * remove a particular agent previously created
  71169. * @param index agent index returned by addAgent
  71170. */
  71171. removeAgent(index: number): void;
  71172. /**
  71173. * get the list of all agents attached to this crowd
  71174. * @returns list of agent indices
  71175. */
  71176. getAgents(): number[];
  71177. /**
  71178. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71179. * @param deltaTime in seconds
  71180. */
  71181. update(deltaTime: number): void;
  71182. /**
  71183. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71184. * The queries will try to find a solution within those bounds
  71185. * default is (1,1,1)
  71186. * @param extent x,y,z value that define the extent around the queries point of reference
  71187. */
  71188. setDefaultQueryExtent(extent: Vector3): void;
  71189. /**
  71190. * Get the Bounding box extent specified by setDefaultQueryExtent
  71191. * @returns the box extent values
  71192. */
  71193. getDefaultQueryExtent(): Vector3;
  71194. /**
  71195. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71196. * @param result output the box extent values
  71197. */
  71198. getDefaultQueryExtentToRef(result: Vector3): void;
  71199. /**
  71200. * Release all resources
  71201. */
  71202. dispose(): void;
  71203. }
  71204. }
  71205. declare module "babylonjs/Navigation/Plugins/index" {
  71206. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71207. }
  71208. declare module "babylonjs/Navigation/index" {
  71209. export * from "babylonjs/Navigation/INavigationEngine";
  71210. export * from "babylonjs/Navigation/Plugins/index";
  71211. }
  71212. declare module "babylonjs/Offline/database" {
  71213. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71214. /**
  71215. * Class used to enable access to IndexedDB
  71216. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71217. */
  71218. export class Database implements IOfflineProvider {
  71219. private _callbackManifestChecked;
  71220. private _currentSceneUrl;
  71221. private _db;
  71222. private _enableSceneOffline;
  71223. private _enableTexturesOffline;
  71224. private _manifestVersionFound;
  71225. private _mustUpdateRessources;
  71226. private _hasReachedQuota;
  71227. private _isSupported;
  71228. private _idbFactory;
  71229. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71230. private static IsUASupportingBlobStorage;
  71231. /**
  71232. * Gets a boolean indicating if Database storate is enabled (off by default)
  71233. */
  71234. static IDBStorageEnabled: boolean;
  71235. /**
  71236. * Gets a boolean indicating if scene must be saved in the database
  71237. */
  71238. get enableSceneOffline(): boolean;
  71239. /**
  71240. * Gets a boolean indicating if textures must be saved in the database
  71241. */
  71242. get enableTexturesOffline(): boolean;
  71243. /**
  71244. * Creates a new Database
  71245. * @param urlToScene defines the url to load the scene
  71246. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71247. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71248. */
  71249. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71250. private static _ParseURL;
  71251. private static _ReturnFullUrlLocation;
  71252. private _checkManifestFile;
  71253. /**
  71254. * Open the database and make it available
  71255. * @param successCallback defines the callback to call on success
  71256. * @param errorCallback defines the callback to call on error
  71257. */
  71258. open(successCallback: () => void, errorCallback: () => void): void;
  71259. /**
  71260. * Loads an image from the database
  71261. * @param url defines the url to load from
  71262. * @param image defines the target DOM image
  71263. */
  71264. loadImage(url: string, image: HTMLImageElement): void;
  71265. private _loadImageFromDBAsync;
  71266. private _saveImageIntoDBAsync;
  71267. private _checkVersionFromDB;
  71268. private _loadVersionFromDBAsync;
  71269. private _saveVersionIntoDBAsync;
  71270. /**
  71271. * Loads a file from database
  71272. * @param url defines the URL to load from
  71273. * @param sceneLoaded defines a callback to call on success
  71274. * @param progressCallBack defines a callback to call when progress changed
  71275. * @param errorCallback defines a callback to call on error
  71276. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71277. */
  71278. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71279. private _loadFileAsync;
  71280. private _saveFileAsync;
  71281. /**
  71282. * Validates if xhr data is correct
  71283. * @param xhr defines the request to validate
  71284. * @param dataType defines the expected data type
  71285. * @returns true if data is correct
  71286. */
  71287. private static _ValidateXHRData;
  71288. }
  71289. }
  71290. declare module "babylonjs/Offline/index" {
  71291. export * from "babylonjs/Offline/database";
  71292. export * from "babylonjs/Offline/IOfflineProvider";
  71293. }
  71294. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71295. /** @hidden */
  71296. export var gpuUpdateParticlesPixelShader: {
  71297. name: string;
  71298. shader: string;
  71299. };
  71300. }
  71301. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71302. /** @hidden */
  71303. export var gpuUpdateParticlesVertexShader: {
  71304. name: string;
  71305. shader: string;
  71306. };
  71307. }
  71308. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71309. /** @hidden */
  71310. export var clipPlaneFragmentDeclaration2: {
  71311. name: string;
  71312. shader: string;
  71313. };
  71314. }
  71315. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71316. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71317. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71318. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71319. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71320. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71321. /** @hidden */
  71322. export var gpuRenderParticlesPixelShader: {
  71323. name: string;
  71324. shader: string;
  71325. };
  71326. }
  71327. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71328. /** @hidden */
  71329. export var clipPlaneVertexDeclaration2: {
  71330. name: string;
  71331. shader: string;
  71332. };
  71333. }
  71334. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71335. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71336. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71337. /** @hidden */
  71338. export var gpuRenderParticlesVertexShader: {
  71339. name: string;
  71340. shader: string;
  71341. };
  71342. }
  71343. declare module "babylonjs/Particles/gpuParticleSystem" {
  71344. import { Nullable } from "babylonjs/types";
  71345. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71346. import { Observable } from "babylonjs/Misc/observable";
  71347. import { Matrix } from "babylonjs/Maths/math.vector";
  71348. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71349. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71350. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71351. import { IDisposable } from "babylonjs/scene";
  71352. import { Effect } from "babylonjs/Materials/effect";
  71353. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71354. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71355. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71356. import { Scene } from "babylonjs/scene";
  71357. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71358. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71359. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71360. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71361. /**
  71362. * This represents a GPU particle system in Babylon
  71363. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71364. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71365. */
  71366. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71367. /**
  71368. * The layer mask we are rendering the particles through.
  71369. */
  71370. layerMask: number;
  71371. private _capacity;
  71372. private _activeCount;
  71373. private _currentActiveCount;
  71374. private _accumulatedCount;
  71375. private _renderEffect;
  71376. private _updateEffect;
  71377. private _buffer0;
  71378. private _buffer1;
  71379. private _spriteBuffer;
  71380. private _updateVAO;
  71381. private _renderVAO;
  71382. private _targetIndex;
  71383. private _sourceBuffer;
  71384. private _targetBuffer;
  71385. private _currentRenderId;
  71386. private _started;
  71387. private _stopped;
  71388. private _timeDelta;
  71389. private _randomTexture;
  71390. private _randomTexture2;
  71391. private _attributesStrideSize;
  71392. private _updateEffectOptions;
  71393. private _randomTextureSize;
  71394. private _actualFrame;
  71395. private _customEffect;
  71396. private readonly _rawTextureWidth;
  71397. /**
  71398. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71399. */
  71400. static get IsSupported(): boolean;
  71401. /**
  71402. * An event triggered when the system is disposed.
  71403. */
  71404. onDisposeObservable: Observable<IParticleSystem>;
  71405. /**
  71406. * Gets the maximum number of particles active at the same time.
  71407. * @returns The max number of active particles.
  71408. */
  71409. getCapacity(): number;
  71410. /**
  71411. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71412. * to override the particles.
  71413. */
  71414. forceDepthWrite: boolean;
  71415. /**
  71416. * Gets or set the number of active particles
  71417. */
  71418. get activeParticleCount(): number;
  71419. set activeParticleCount(value: number);
  71420. private _preWarmDone;
  71421. /**
  71422. * Specifies if the particles are updated in emitter local space or world space.
  71423. */
  71424. isLocal: boolean;
  71425. /** Gets or sets a matrix to use to compute projection */
  71426. defaultProjectionMatrix: Matrix;
  71427. /**
  71428. * Is this system ready to be used/rendered
  71429. * @return true if the system is ready
  71430. */
  71431. isReady(): boolean;
  71432. /**
  71433. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71434. * @returns True if it has been started, otherwise false.
  71435. */
  71436. isStarted(): boolean;
  71437. /**
  71438. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71439. * @returns True if it has been stopped, otherwise false.
  71440. */
  71441. isStopped(): boolean;
  71442. /**
  71443. * Gets a boolean indicating that the system is stopping
  71444. * @returns true if the system is currently stopping
  71445. */
  71446. isStopping(): boolean;
  71447. /**
  71448. * Gets the number of particles active at the same time.
  71449. * @returns The number of active particles.
  71450. */
  71451. getActiveCount(): number;
  71452. /**
  71453. * Starts the particle system and begins to emit
  71454. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71455. */
  71456. start(delay?: number): void;
  71457. /**
  71458. * Stops the particle system.
  71459. */
  71460. stop(): void;
  71461. /**
  71462. * Remove all active particles
  71463. */
  71464. reset(): void;
  71465. /**
  71466. * Returns the string "GPUParticleSystem"
  71467. * @returns a string containing the class name
  71468. */
  71469. getClassName(): string;
  71470. /**
  71471. * Gets the custom effect used to render the particles
  71472. * @param blendMode Blend mode for which the effect should be retrieved
  71473. * @returns The effect
  71474. */
  71475. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71476. /**
  71477. * Sets the custom effect used to render the particles
  71478. * @param effect The effect to set
  71479. * @param blendMode Blend mode for which the effect should be set
  71480. */
  71481. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71482. /** @hidden */
  71483. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71484. /**
  71485. * Observable that will be called just before the particles are drawn
  71486. */
  71487. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71488. /**
  71489. * Gets the name of the particle vertex shader
  71490. */
  71491. get vertexShaderName(): string;
  71492. private _colorGradientsTexture;
  71493. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71494. /**
  71495. * Adds a new color gradient
  71496. * @param gradient defines the gradient to use (between 0 and 1)
  71497. * @param color1 defines the color to affect to the specified gradient
  71498. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71499. * @returns the current particle system
  71500. */
  71501. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71502. private _refreshColorGradient;
  71503. /** Force the system to rebuild all gradients that need to be resync */
  71504. forceRefreshGradients(): void;
  71505. /**
  71506. * Remove a specific color gradient
  71507. * @param gradient defines the gradient to remove
  71508. * @returns the current particle system
  71509. */
  71510. removeColorGradient(gradient: number): GPUParticleSystem;
  71511. private _angularSpeedGradientsTexture;
  71512. private _sizeGradientsTexture;
  71513. private _velocityGradientsTexture;
  71514. private _limitVelocityGradientsTexture;
  71515. private _dragGradientsTexture;
  71516. private _addFactorGradient;
  71517. /**
  71518. * Adds a new size gradient
  71519. * @param gradient defines the gradient to use (between 0 and 1)
  71520. * @param factor defines the size factor to affect to the specified gradient
  71521. * @returns the current particle system
  71522. */
  71523. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71524. /**
  71525. * Remove a specific size gradient
  71526. * @param gradient defines the gradient to remove
  71527. * @returns the current particle system
  71528. */
  71529. removeSizeGradient(gradient: number): GPUParticleSystem;
  71530. private _refreshFactorGradient;
  71531. /**
  71532. * Adds a new angular speed gradient
  71533. * @param gradient defines the gradient to use (between 0 and 1)
  71534. * @param factor defines the angular speed to affect to the specified gradient
  71535. * @returns the current particle system
  71536. */
  71537. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71538. /**
  71539. * Remove a specific angular speed gradient
  71540. * @param gradient defines the gradient to remove
  71541. * @returns the current particle system
  71542. */
  71543. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71544. /**
  71545. * Adds a new velocity gradient
  71546. * @param gradient defines the gradient to use (between 0 and 1)
  71547. * @param factor defines the velocity to affect to the specified gradient
  71548. * @returns the current particle system
  71549. */
  71550. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71551. /**
  71552. * Remove a specific velocity gradient
  71553. * @param gradient defines the gradient to remove
  71554. * @returns the current particle system
  71555. */
  71556. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71557. /**
  71558. * Adds a new limit velocity gradient
  71559. * @param gradient defines the gradient to use (between 0 and 1)
  71560. * @param factor defines the limit velocity value to affect to the specified gradient
  71561. * @returns the current particle system
  71562. */
  71563. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71564. /**
  71565. * Remove a specific limit velocity gradient
  71566. * @param gradient defines the gradient to remove
  71567. * @returns the current particle system
  71568. */
  71569. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71570. /**
  71571. * Adds a new drag gradient
  71572. * @param gradient defines the gradient to use (between 0 and 1)
  71573. * @param factor defines the drag value to affect to the specified gradient
  71574. * @returns the current particle system
  71575. */
  71576. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71577. /**
  71578. * Remove a specific drag gradient
  71579. * @param gradient defines the gradient to remove
  71580. * @returns the current particle system
  71581. */
  71582. removeDragGradient(gradient: number): GPUParticleSystem;
  71583. /**
  71584. * Not supported by GPUParticleSystem
  71585. * @param gradient defines the gradient to use (between 0 and 1)
  71586. * @param factor defines the emit rate value to affect to the specified gradient
  71587. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71588. * @returns the current particle system
  71589. */
  71590. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71591. /**
  71592. * Not supported by GPUParticleSystem
  71593. * @param gradient defines the gradient to remove
  71594. * @returns the current particle system
  71595. */
  71596. removeEmitRateGradient(gradient: number): IParticleSystem;
  71597. /**
  71598. * Not supported by GPUParticleSystem
  71599. * @param gradient defines the gradient to use (between 0 and 1)
  71600. * @param factor defines the start size value to affect to the specified gradient
  71601. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71602. * @returns the current particle system
  71603. */
  71604. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71605. /**
  71606. * Not supported by GPUParticleSystem
  71607. * @param gradient defines the gradient to remove
  71608. * @returns the current particle system
  71609. */
  71610. removeStartSizeGradient(gradient: number): IParticleSystem;
  71611. /**
  71612. * Not supported by GPUParticleSystem
  71613. * @param gradient defines the gradient to use (between 0 and 1)
  71614. * @param min defines the color remap minimal range
  71615. * @param max defines the color remap maximal range
  71616. * @returns the current particle system
  71617. */
  71618. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71619. /**
  71620. * Not supported by GPUParticleSystem
  71621. * @param gradient defines the gradient to remove
  71622. * @returns the current particle system
  71623. */
  71624. removeColorRemapGradient(): IParticleSystem;
  71625. /**
  71626. * Not supported by GPUParticleSystem
  71627. * @param gradient defines the gradient to use (between 0 and 1)
  71628. * @param min defines the alpha remap minimal range
  71629. * @param max defines the alpha remap maximal range
  71630. * @returns the current particle system
  71631. */
  71632. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71633. /**
  71634. * Not supported by GPUParticleSystem
  71635. * @param gradient defines the gradient to remove
  71636. * @returns the current particle system
  71637. */
  71638. removeAlphaRemapGradient(): IParticleSystem;
  71639. /**
  71640. * Not supported by GPUParticleSystem
  71641. * @param gradient defines the gradient to use (between 0 and 1)
  71642. * @param color defines the color to affect to the specified gradient
  71643. * @returns the current particle system
  71644. */
  71645. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71646. /**
  71647. * Not supported by GPUParticleSystem
  71648. * @param gradient defines the gradient to remove
  71649. * @returns the current particle system
  71650. */
  71651. removeRampGradient(): IParticleSystem;
  71652. /**
  71653. * Not supported by GPUParticleSystem
  71654. * @returns the list of ramp gradients
  71655. */
  71656. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71657. /**
  71658. * Not supported by GPUParticleSystem
  71659. * Gets or sets a boolean indicating that ramp gradients must be used
  71660. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71661. */
  71662. get useRampGradients(): boolean;
  71663. set useRampGradients(value: boolean);
  71664. /**
  71665. * Not supported by GPUParticleSystem
  71666. * @param gradient defines the gradient to use (between 0 and 1)
  71667. * @param factor defines the life time factor to affect to the specified gradient
  71668. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71669. * @returns the current particle system
  71670. */
  71671. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71672. /**
  71673. * Not supported by GPUParticleSystem
  71674. * @param gradient defines the gradient to remove
  71675. * @returns the current particle system
  71676. */
  71677. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71678. /**
  71679. * Instantiates a GPU particle system.
  71680. * 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.
  71681. * @param name The name of the particle system
  71682. * @param options The options used to create the system
  71683. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71684. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71685. * @param customEffect a custom effect used to change the way particles are rendered by default
  71686. */
  71687. constructor(name: string, options: Partial<{
  71688. capacity: number;
  71689. randomTextureSize: number;
  71690. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71691. protected _reset(): void;
  71692. private _createUpdateVAO;
  71693. private _createRenderVAO;
  71694. private _initialize;
  71695. /** @hidden */
  71696. _recreateUpdateEffect(): void;
  71697. private _getEffect;
  71698. /**
  71699. * Fill the defines array according to the current settings of the particle system
  71700. * @param defines Array to be updated
  71701. * @param blendMode blend mode to take into account when updating the array
  71702. */
  71703. fillDefines(defines: Array<string>, blendMode?: number): void;
  71704. /**
  71705. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71706. * @param uniforms Uniforms array to fill
  71707. * @param attributes Attributes array to fill
  71708. * @param samplers Samplers array to fill
  71709. */
  71710. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71711. /** @hidden */
  71712. _recreateRenderEffect(): Effect;
  71713. /**
  71714. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71715. * @param preWarm defines if we are in the pre-warmimg phase
  71716. */
  71717. animate(preWarm?: boolean): void;
  71718. private _createFactorGradientTexture;
  71719. private _createSizeGradientTexture;
  71720. private _createAngularSpeedGradientTexture;
  71721. private _createVelocityGradientTexture;
  71722. private _createLimitVelocityGradientTexture;
  71723. private _createDragGradientTexture;
  71724. private _createColorGradientTexture;
  71725. /**
  71726. * Renders the particle system in its current state
  71727. * @param preWarm defines if the system should only update the particles but not render them
  71728. * @returns the current number of particles
  71729. */
  71730. render(preWarm?: boolean): number;
  71731. /**
  71732. * Rebuilds the particle system
  71733. */
  71734. rebuild(): void;
  71735. private _releaseBuffers;
  71736. private _releaseVAOs;
  71737. /**
  71738. * Disposes the particle system and free the associated resources
  71739. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71740. */
  71741. dispose(disposeTexture?: boolean): void;
  71742. /**
  71743. * Clones the particle system.
  71744. * @param name The name of the cloned object
  71745. * @param newEmitter The new emitter to use
  71746. * @returns the cloned particle system
  71747. */
  71748. clone(name: string, newEmitter: any): GPUParticleSystem;
  71749. /**
  71750. * Serializes the particle system to a JSON object
  71751. * @param serializeTexture defines if the texture must be serialized as well
  71752. * @returns the JSON object
  71753. */
  71754. serialize(serializeTexture?: boolean): any;
  71755. /**
  71756. * Parses a JSON object to create a GPU particle system.
  71757. * @param parsedParticleSystem The JSON object to parse
  71758. * @param sceneOrEngine The scene or the engine to create the particle system in
  71759. * @param rootUrl The root url to use to load external dependencies like texture
  71760. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71761. * @returns the parsed GPU particle system
  71762. */
  71763. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71764. }
  71765. }
  71766. declare module "babylonjs/Particles/particleSystemSet" {
  71767. import { Nullable } from "babylonjs/types";
  71768. import { Color3 } from "babylonjs/Maths/math.color";
  71769. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71771. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71772. import { Scene, IDisposable } from "babylonjs/scene";
  71773. /**
  71774. * Represents a set of particle systems working together to create a specific effect
  71775. */
  71776. export class ParticleSystemSet implements IDisposable {
  71777. /**
  71778. * Gets or sets base Assets URL
  71779. */
  71780. static BaseAssetsUrl: string;
  71781. private _emitterCreationOptions;
  71782. private _emitterNode;
  71783. /**
  71784. * Gets the particle system list
  71785. */
  71786. systems: IParticleSystem[];
  71787. /**
  71788. * Gets the emitter node used with this set
  71789. */
  71790. get emitterNode(): Nullable<TransformNode>;
  71791. /**
  71792. * Creates a new emitter mesh as a sphere
  71793. * @param options defines the options used to create the sphere
  71794. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71795. * @param scene defines the hosting scene
  71796. */
  71797. setEmitterAsSphere(options: {
  71798. diameter: number;
  71799. segments: number;
  71800. color: Color3;
  71801. }, renderingGroupId: number, scene: Scene): void;
  71802. /**
  71803. * Starts all particle systems of the set
  71804. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71805. */
  71806. start(emitter?: AbstractMesh): void;
  71807. /**
  71808. * Release all associated resources
  71809. */
  71810. dispose(): void;
  71811. /**
  71812. * Serialize the set into a JSON compatible object
  71813. * @param serializeTexture defines if the texture must be serialized as well
  71814. * @returns a JSON compatible representation of the set
  71815. */
  71816. serialize(serializeTexture?: boolean): any;
  71817. /**
  71818. * Parse a new ParticleSystemSet from a serialized source
  71819. * @param data defines a JSON compatible representation of the set
  71820. * @param scene defines the hosting scene
  71821. * @param gpu defines if we want GPU particles or CPU particles
  71822. * @returns a new ParticleSystemSet
  71823. */
  71824. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71825. }
  71826. }
  71827. declare module "babylonjs/Particles/particleHelper" {
  71828. import { Nullable } from "babylonjs/types";
  71829. import { Scene } from "babylonjs/scene";
  71830. import { Vector3 } from "babylonjs/Maths/math.vector";
  71831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71832. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71833. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71834. /**
  71835. * This class is made for on one-liner static method to help creating particle system set.
  71836. */
  71837. export class ParticleHelper {
  71838. /**
  71839. * Gets or sets base Assets URL
  71840. */
  71841. static BaseAssetsUrl: string;
  71842. /** Define the Url to load snippets */
  71843. static SnippetUrl: string;
  71844. /**
  71845. * Create a default particle system that you can tweak
  71846. * @param emitter defines the emitter to use
  71847. * @param capacity defines the system capacity (default is 500 particles)
  71848. * @param scene defines the hosting scene
  71849. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71850. * @returns the new Particle system
  71851. */
  71852. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71853. /**
  71854. * This is the main static method (one-liner) of this helper to create different particle systems
  71855. * @param type This string represents the type to the particle system to create
  71856. * @param scene The scene where the particle system should live
  71857. * @param gpu If the system will use gpu
  71858. * @returns the ParticleSystemSet created
  71859. */
  71860. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71861. /**
  71862. * Static function used to export a particle system to a ParticleSystemSet variable.
  71863. * Please note that the emitter shape is not exported
  71864. * @param systems defines the particle systems to export
  71865. * @returns the created particle system set
  71866. */
  71867. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71868. /**
  71869. * Creates a particle system from a snippet saved in a remote file
  71870. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71871. * @param url defines the url to load from
  71872. * @param scene defines the hosting scene
  71873. * @param gpu If the system will use gpu
  71874. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71875. * @returns a promise that will resolve to the new particle system
  71876. */
  71877. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71878. /**
  71879. * Creates a particle system from a snippet saved by the particle system editor
  71880. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71881. * @param scene defines the hosting scene
  71882. * @param gpu If the system will use gpu
  71883. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71884. * @returns a promise that will resolve to the new particle system
  71885. */
  71886. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71887. }
  71888. }
  71889. declare module "babylonjs/Particles/particleSystemComponent" {
  71890. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71891. import { Effect } from "babylonjs/Materials/effect";
  71892. import "babylonjs/Shaders/particles.vertex";
  71893. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71894. module "babylonjs/Engines/engine" {
  71895. interface Engine {
  71896. /**
  71897. * Create an effect to use with particle systems.
  71898. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71899. * the particle system for which you want to create a custom effect in the last parameter
  71900. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71901. * @param uniformsNames defines a list of attribute names
  71902. * @param samplers defines an array of string used to represent textures
  71903. * @param defines defines the string containing the defines to use to compile the shaders
  71904. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71905. * @param onCompiled defines a function to call when the effect creation is successful
  71906. * @param onError defines a function to call when the effect creation has failed
  71907. * @param particleSystem the particle system you want to create the effect for
  71908. * @returns the new Effect
  71909. */
  71910. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71911. }
  71912. }
  71913. module "babylonjs/Meshes/mesh" {
  71914. interface Mesh {
  71915. /**
  71916. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71917. * @returns an array of IParticleSystem
  71918. */
  71919. getEmittedParticleSystems(): IParticleSystem[];
  71920. /**
  71921. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71922. * @returns an array of IParticleSystem
  71923. */
  71924. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71925. }
  71926. }
  71927. }
  71928. declare module "babylonjs/Particles/pointsCloudSystem" {
  71929. import { Color4 } from "babylonjs/Maths/math";
  71930. import { Mesh } from "babylonjs/Meshes/mesh";
  71931. import { Scene, IDisposable } from "babylonjs/scene";
  71932. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71933. /** Defines the 4 color options */
  71934. export enum PointColor {
  71935. /** color value */
  71936. Color = 2,
  71937. /** uv value */
  71938. UV = 1,
  71939. /** random value */
  71940. Random = 0,
  71941. /** stated value */
  71942. Stated = 3
  71943. }
  71944. /**
  71945. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71946. * 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.
  71947. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71948. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71949. *
  71950. * Full documentation here : TO BE ENTERED
  71951. */
  71952. export class PointsCloudSystem implements IDisposable {
  71953. /**
  71954. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71955. * Example : var p = SPS.particles[i];
  71956. */
  71957. particles: CloudPoint[];
  71958. /**
  71959. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71960. */
  71961. nbParticles: number;
  71962. /**
  71963. * This a counter for your own usage. It's not set by any SPS functions.
  71964. */
  71965. counter: number;
  71966. /**
  71967. * The PCS name. This name is also given to the underlying mesh.
  71968. */
  71969. name: string;
  71970. /**
  71971. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71972. */
  71973. mesh: Mesh;
  71974. /**
  71975. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71976. * Please read :
  71977. */
  71978. vars: any;
  71979. /**
  71980. * @hidden
  71981. */
  71982. _size: number;
  71983. private _scene;
  71984. private _promises;
  71985. private _positions;
  71986. private _indices;
  71987. private _normals;
  71988. private _colors;
  71989. private _uvs;
  71990. private _indices32;
  71991. private _positions32;
  71992. private _colors32;
  71993. private _uvs32;
  71994. private _updatable;
  71995. private _isVisibilityBoxLocked;
  71996. private _alwaysVisible;
  71997. private _groups;
  71998. private _groupCounter;
  71999. private _computeParticleColor;
  72000. private _computeParticleTexture;
  72001. private _computeParticleRotation;
  72002. private _computeBoundingBox;
  72003. private _isReady;
  72004. /**
  72005. * Creates a PCS (Points Cloud System) object
  72006. * @param name (String) is the PCS name, this will be the underlying mesh name
  72007. * @param pointSize (number) is the size for each point
  72008. * @param scene (Scene) is the scene in which the PCS is added
  72009. * @param options defines the options of the PCS e.g.
  72010. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72011. */
  72012. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72013. updatable?: boolean;
  72014. });
  72015. /**
  72016. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72017. * If no points were added to the PCS, the returned mesh is just a single point.
  72018. * @returns a promise for the created mesh
  72019. */
  72020. buildMeshAsync(): Promise<Mesh>;
  72021. /**
  72022. * @hidden
  72023. */
  72024. private _buildMesh;
  72025. private _addParticle;
  72026. private _randomUnitVector;
  72027. private _getColorIndicesForCoord;
  72028. private _setPointsColorOrUV;
  72029. private _colorFromTexture;
  72030. private _calculateDensity;
  72031. /**
  72032. * Adds points to the PCS in random positions within a unit sphere
  72033. * @param nb (positive integer) the number of particles to be created from this model
  72034. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72035. * @returns the number of groups in the system
  72036. */
  72037. addPoints(nb: number, pointFunction?: any): number;
  72038. /**
  72039. * Adds points to the PCS from the surface of the model shape
  72040. * @param mesh is any Mesh object that will be used as a surface model for the points
  72041. * @param nb (positive integer) the number of particles to be created from this model
  72042. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72043. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72044. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72045. * @returns the number of groups in the system
  72046. */
  72047. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72048. /**
  72049. * Adds points to the PCS inside the model shape
  72050. * @param mesh is any Mesh object that will be used as a surface model for the points
  72051. * @param nb (positive integer) the number of particles to be created from this model
  72052. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72053. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72054. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72055. * @returns the number of groups in the system
  72056. */
  72057. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72058. /**
  72059. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72060. * This method calls `updateParticle()` for each particle of the SPS.
  72061. * For an animated SPS, it is usually called within the render loop.
  72062. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72063. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72064. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72065. * @returns the PCS.
  72066. */
  72067. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72068. /**
  72069. * Disposes the PCS.
  72070. */
  72071. dispose(): void;
  72072. /**
  72073. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72074. * doc :
  72075. * @returns the PCS.
  72076. */
  72077. refreshVisibleSize(): PointsCloudSystem;
  72078. /**
  72079. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72080. * @param size the size (float) of the visibility box
  72081. * note : this doesn't lock the PCS mesh bounding box.
  72082. * doc :
  72083. */
  72084. setVisibilityBox(size: number): void;
  72085. /**
  72086. * Gets whether the PCS is always visible or not
  72087. * doc :
  72088. */
  72089. get isAlwaysVisible(): boolean;
  72090. /**
  72091. * Sets the PCS as always visible or not
  72092. * doc :
  72093. */
  72094. set isAlwaysVisible(val: boolean);
  72095. /**
  72096. * Tells to `setParticles()` to compute the particle rotations or not
  72097. * Default value : false. The PCS is faster when it's set to false
  72098. * Note : particle rotations are only applied to parent particles
  72099. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72100. */
  72101. set computeParticleRotation(val: boolean);
  72102. /**
  72103. * Tells to `setParticles()` to compute the particle colors or not.
  72104. * Default value : true. The PCS is faster when it's set to false.
  72105. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72106. */
  72107. set computeParticleColor(val: boolean);
  72108. set computeParticleTexture(val: boolean);
  72109. /**
  72110. * Gets if `setParticles()` computes the particle colors or not.
  72111. * Default value : false. The PCS is faster when it's set to false.
  72112. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72113. */
  72114. get computeParticleColor(): boolean;
  72115. /**
  72116. * Gets if `setParticles()` computes the particle textures or not.
  72117. * Default value : false. The PCS is faster when it's set to false.
  72118. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72119. */
  72120. get computeParticleTexture(): boolean;
  72121. /**
  72122. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72123. */
  72124. set computeBoundingBox(val: boolean);
  72125. /**
  72126. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72127. */
  72128. get computeBoundingBox(): boolean;
  72129. /**
  72130. * This function does nothing. It may be overwritten to set all the particle first values.
  72131. * The PCS doesn't call this function, you may have to call it by your own.
  72132. * doc :
  72133. */
  72134. initParticles(): void;
  72135. /**
  72136. * This function does nothing. It may be overwritten to recycle a particle
  72137. * The PCS doesn't call this function, you can to call it
  72138. * doc :
  72139. * @param particle The particle to recycle
  72140. * @returns the recycled particle
  72141. */
  72142. recycleParticle(particle: CloudPoint): CloudPoint;
  72143. /**
  72144. * Updates a particle : this function should be overwritten by the user.
  72145. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72146. * doc :
  72147. * @example : just set a particle position or velocity and recycle conditions
  72148. * @param particle The particle to update
  72149. * @returns the updated particle
  72150. */
  72151. updateParticle(particle: CloudPoint): CloudPoint;
  72152. /**
  72153. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72154. * This does nothing and may be overwritten by the user.
  72155. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72156. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72157. * @param update the boolean update value actually passed to setParticles()
  72158. */
  72159. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72160. /**
  72161. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72162. * This will be passed three parameters.
  72163. * This does nothing and may be overwritten by the user.
  72164. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72165. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72166. * @param update the boolean update value actually passed to setParticles()
  72167. */
  72168. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72169. }
  72170. }
  72171. declare module "babylonjs/Particles/cloudPoint" {
  72172. import { Nullable } from "babylonjs/types";
  72173. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72174. import { Mesh } from "babylonjs/Meshes/mesh";
  72175. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72176. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72177. /**
  72178. * Represents one particle of a points cloud system.
  72179. */
  72180. export class CloudPoint {
  72181. /**
  72182. * particle global index
  72183. */
  72184. idx: number;
  72185. /**
  72186. * The color of the particle
  72187. */
  72188. color: Nullable<Color4>;
  72189. /**
  72190. * The world space position of the particle.
  72191. */
  72192. position: Vector3;
  72193. /**
  72194. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72195. */
  72196. rotation: Vector3;
  72197. /**
  72198. * The world space rotation quaternion of the particle.
  72199. */
  72200. rotationQuaternion: Nullable<Quaternion>;
  72201. /**
  72202. * The uv of the particle.
  72203. */
  72204. uv: Nullable<Vector2>;
  72205. /**
  72206. * The current speed of the particle.
  72207. */
  72208. velocity: Vector3;
  72209. /**
  72210. * The pivot point in the particle local space.
  72211. */
  72212. pivot: Vector3;
  72213. /**
  72214. * Must the particle be translated from its pivot point in its local space ?
  72215. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72216. * Default : false
  72217. */
  72218. translateFromPivot: boolean;
  72219. /**
  72220. * Index of this particle in the global "positions" array (Internal use)
  72221. * @hidden
  72222. */
  72223. _pos: number;
  72224. /**
  72225. * @hidden Index of this particle in the global "indices" array (Internal use)
  72226. */
  72227. _ind: number;
  72228. /**
  72229. * Group this particle belongs to
  72230. */
  72231. _group: PointsGroup;
  72232. /**
  72233. * Group id of this particle
  72234. */
  72235. groupId: number;
  72236. /**
  72237. * Index of the particle in its group id (Internal use)
  72238. */
  72239. idxInGroup: number;
  72240. /**
  72241. * @hidden Particle BoundingInfo object (Internal use)
  72242. */
  72243. _boundingInfo: BoundingInfo;
  72244. /**
  72245. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72246. */
  72247. _pcs: PointsCloudSystem;
  72248. /**
  72249. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72250. */
  72251. _stillInvisible: boolean;
  72252. /**
  72253. * @hidden Last computed particle rotation matrix
  72254. */
  72255. _rotationMatrix: number[];
  72256. /**
  72257. * Parent particle Id, if any.
  72258. * Default null.
  72259. */
  72260. parentId: Nullable<number>;
  72261. /**
  72262. * @hidden Internal global position in the PCS.
  72263. */
  72264. _globalPosition: Vector3;
  72265. /**
  72266. * Creates a Point Cloud object.
  72267. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72268. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72269. * @param group (PointsGroup) is the group the particle belongs to
  72270. * @param groupId (integer) is the group identifier in the PCS.
  72271. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72272. * @param pcs defines the PCS it is associated to
  72273. */
  72274. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72275. /**
  72276. * get point size
  72277. */
  72278. get size(): Vector3;
  72279. /**
  72280. * Set point size
  72281. */
  72282. set size(scale: Vector3);
  72283. /**
  72284. * Legacy support, changed quaternion to rotationQuaternion
  72285. */
  72286. get quaternion(): Nullable<Quaternion>;
  72287. /**
  72288. * Legacy support, changed quaternion to rotationQuaternion
  72289. */
  72290. set quaternion(q: Nullable<Quaternion>);
  72291. /**
  72292. * Returns a boolean. True if the particle intersects a mesh, else false
  72293. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72294. * @param target is the object (point or mesh) what the intersection is computed against
  72295. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72296. * @returns true if it intersects
  72297. */
  72298. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72299. /**
  72300. * get the rotation matrix of the particle
  72301. * @hidden
  72302. */
  72303. getRotationMatrix(m: Matrix): void;
  72304. }
  72305. /**
  72306. * Represents a group of points in a points cloud system
  72307. * * PCS internal tool, don't use it manually.
  72308. */
  72309. export class PointsGroup {
  72310. /**
  72311. * The group id
  72312. * @hidden
  72313. */
  72314. groupID: number;
  72315. /**
  72316. * image data for group (internal use)
  72317. * @hidden
  72318. */
  72319. _groupImageData: Nullable<ArrayBufferView>;
  72320. /**
  72321. * Image Width (internal use)
  72322. * @hidden
  72323. */
  72324. _groupImgWidth: number;
  72325. /**
  72326. * Image Height (internal use)
  72327. * @hidden
  72328. */
  72329. _groupImgHeight: number;
  72330. /**
  72331. * Custom position function (internal use)
  72332. * @hidden
  72333. */
  72334. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72335. /**
  72336. * density per facet for surface points
  72337. * @hidden
  72338. */
  72339. _groupDensity: number[];
  72340. /**
  72341. * Only when points are colored by texture carries pointer to texture list array
  72342. * @hidden
  72343. */
  72344. _textureNb: number;
  72345. /**
  72346. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72347. * PCS internal tool, don't use it manually.
  72348. * @hidden
  72349. */
  72350. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72351. }
  72352. }
  72353. declare module "babylonjs/Particles/index" {
  72354. export * from "babylonjs/Particles/baseParticleSystem";
  72355. export * from "babylonjs/Particles/EmitterTypes/index";
  72356. export * from "babylonjs/Particles/gpuParticleSystem";
  72357. export * from "babylonjs/Particles/IParticleSystem";
  72358. export * from "babylonjs/Particles/particle";
  72359. export * from "babylonjs/Particles/particleHelper";
  72360. export * from "babylonjs/Particles/particleSystem";
  72361. import "babylonjs/Particles/particleSystemComponent";
  72362. export * from "babylonjs/Particles/particleSystemComponent";
  72363. export * from "babylonjs/Particles/particleSystemSet";
  72364. export * from "babylonjs/Particles/solidParticle";
  72365. export * from "babylonjs/Particles/solidParticleSystem";
  72366. export * from "babylonjs/Particles/cloudPoint";
  72367. export * from "babylonjs/Particles/pointsCloudSystem";
  72368. export * from "babylonjs/Particles/subEmitter";
  72369. }
  72370. declare module "babylonjs/Physics/physicsEngineComponent" {
  72371. import { Nullable } from "babylonjs/types";
  72372. import { Observable, Observer } from "babylonjs/Misc/observable";
  72373. import { Vector3 } from "babylonjs/Maths/math.vector";
  72374. import { Mesh } from "babylonjs/Meshes/mesh";
  72375. import { ISceneComponent } from "babylonjs/sceneComponent";
  72376. import { Scene } from "babylonjs/scene";
  72377. import { Node } from "babylonjs/node";
  72378. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72379. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72380. module "babylonjs/scene" {
  72381. interface Scene {
  72382. /** @hidden (Backing field) */
  72383. _physicsEngine: Nullable<IPhysicsEngine>;
  72384. /** @hidden */
  72385. _physicsTimeAccumulator: number;
  72386. /**
  72387. * Gets the current physics engine
  72388. * @returns a IPhysicsEngine or null if none attached
  72389. */
  72390. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72391. /**
  72392. * Enables physics to the current scene
  72393. * @param gravity defines the scene's gravity for the physics engine
  72394. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72395. * @return a boolean indicating if the physics engine was initialized
  72396. */
  72397. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72398. /**
  72399. * Disables and disposes the physics engine associated with the scene
  72400. */
  72401. disablePhysicsEngine(): void;
  72402. /**
  72403. * Gets a boolean indicating if there is an active physics engine
  72404. * @returns a boolean indicating if there is an active physics engine
  72405. */
  72406. isPhysicsEnabled(): boolean;
  72407. /**
  72408. * Deletes a physics compound impostor
  72409. * @param compound defines the compound to delete
  72410. */
  72411. deleteCompoundImpostor(compound: any): void;
  72412. /**
  72413. * An event triggered when physic simulation is about to be run
  72414. */
  72415. onBeforePhysicsObservable: Observable<Scene>;
  72416. /**
  72417. * An event triggered when physic simulation has been done
  72418. */
  72419. onAfterPhysicsObservable: Observable<Scene>;
  72420. }
  72421. }
  72422. module "babylonjs/Meshes/abstractMesh" {
  72423. interface AbstractMesh {
  72424. /** @hidden */
  72425. _physicsImpostor: Nullable<PhysicsImpostor>;
  72426. /**
  72427. * Gets or sets impostor used for physic simulation
  72428. * @see https://doc.babylonjs.com/features/physics_engine
  72429. */
  72430. physicsImpostor: Nullable<PhysicsImpostor>;
  72431. /**
  72432. * Gets the current physics impostor
  72433. * @see https://doc.babylonjs.com/features/physics_engine
  72434. * @returns a physics impostor or null
  72435. */
  72436. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72437. /** Apply a physic impulse to the mesh
  72438. * @param force defines the force to apply
  72439. * @param contactPoint defines where to apply the force
  72440. * @returns the current mesh
  72441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72442. */
  72443. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72444. /**
  72445. * Creates a physic joint between two meshes
  72446. * @param otherMesh defines the other mesh to use
  72447. * @param pivot1 defines the pivot to use on this mesh
  72448. * @param pivot2 defines the pivot to use on the other mesh
  72449. * @param options defines additional options (can be plugin dependent)
  72450. * @returns the current mesh
  72451. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72452. */
  72453. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72454. /** @hidden */
  72455. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72456. }
  72457. }
  72458. /**
  72459. * Defines the physics engine scene component responsible to manage a physics engine
  72460. */
  72461. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72462. /**
  72463. * The component name helpful to identify the component in the list of scene components.
  72464. */
  72465. readonly name: string;
  72466. /**
  72467. * The scene the component belongs to.
  72468. */
  72469. scene: Scene;
  72470. /**
  72471. * Creates a new instance of the component for the given scene
  72472. * @param scene Defines the scene to register the component in
  72473. */
  72474. constructor(scene: Scene);
  72475. /**
  72476. * Registers the component in a given scene
  72477. */
  72478. register(): void;
  72479. /**
  72480. * Rebuilds the elements related to this component in case of
  72481. * context lost for instance.
  72482. */
  72483. rebuild(): void;
  72484. /**
  72485. * Disposes the component and the associated ressources
  72486. */
  72487. dispose(): void;
  72488. }
  72489. }
  72490. declare module "babylonjs/Physics/physicsHelper" {
  72491. import { Nullable } from "babylonjs/types";
  72492. import { Vector3 } from "babylonjs/Maths/math.vector";
  72493. import { Mesh } from "babylonjs/Meshes/mesh";
  72494. import { Scene } from "babylonjs/scene";
  72495. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72496. /**
  72497. * A helper for physics simulations
  72498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72499. */
  72500. export class PhysicsHelper {
  72501. private _scene;
  72502. private _physicsEngine;
  72503. /**
  72504. * Initializes the Physics helper
  72505. * @param scene Babylon.js scene
  72506. */
  72507. constructor(scene: Scene);
  72508. /**
  72509. * Applies a radial explosion impulse
  72510. * @param origin the origin of the explosion
  72511. * @param radiusOrEventOptions the radius or the options of radial explosion
  72512. * @param strength the explosion strength
  72513. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72514. * @returns A physics radial explosion event, or null
  72515. */
  72516. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72517. /**
  72518. * Applies a radial explosion force
  72519. * @param origin the origin of the explosion
  72520. * @param radiusOrEventOptions the radius or the options of radial explosion
  72521. * @param strength the explosion strength
  72522. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72523. * @returns A physics radial explosion event, or null
  72524. */
  72525. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72526. /**
  72527. * Creates a gravitational field
  72528. * @param origin the origin of the explosion
  72529. * @param radiusOrEventOptions the radius or the options of radial explosion
  72530. * @param strength the explosion strength
  72531. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72532. * @returns A physics gravitational field event, or null
  72533. */
  72534. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72535. /**
  72536. * Creates a physics updraft event
  72537. * @param origin the origin of the updraft
  72538. * @param radiusOrEventOptions the radius or the options of the updraft
  72539. * @param strength the strength of the updraft
  72540. * @param height the height of the updraft
  72541. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72542. * @returns A physics updraft event, or null
  72543. */
  72544. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72545. /**
  72546. * Creates a physics vortex event
  72547. * @param origin the of the vortex
  72548. * @param radiusOrEventOptions the radius or the options of the vortex
  72549. * @param strength the strength of the vortex
  72550. * @param height the height of the vortex
  72551. * @returns a Physics vortex event, or null
  72552. * A physics vortex event or null
  72553. */
  72554. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72555. }
  72556. /**
  72557. * Represents a physics radial explosion event
  72558. */
  72559. class PhysicsRadialExplosionEvent {
  72560. private _scene;
  72561. private _options;
  72562. private _sphere;
  72563. private _dataFetched;
  72564. /**
  72565. * Initializes a radial explosioin event
  72566. * @param _scene BabylonJS scene
  72567. * @param _options The options for the vortex event
  72568. */
  72569. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72570. /**
  72571. * Returns the data related to the radial explosion event (sphere).
  72572. * @returns The radial explosion event data
  72573. */
  72574. getData(): PhysicsRadialExplosionEventData;
  72575. /**
  72576. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72577. * @param impostor A physics imposter
  72578. * @param origin the origin of the explosion
  72579. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72580. */
  72581. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72582. /**
  72583. * Triggers affecterd impostors callbacks
  72584. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72585. */
  72586. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72587. /**
  72588. * Disposes the sphere.
  72589. * @param force Specifies if the sphere should be disposed by force
  72590. */
  72591. dispose(force?: boolean): void;
  72592. /*** Helpers ***/
  72593. private _prepareSphere;
  72594. private _intersectsWithSphere;
  72595. }
  72596. /**
  72597. * Represents a gravitational field event
  72598. */
  72599. class PhysicsGravitationalFieldEvent {
  72600. private _physicsHelper;
  72601. private _scene;
  72602. private _origin;
  72603. private _options;
  72604. private _tickCallback;
  72605. private _sphere;
  72606. private _dataFetched;
  72607. /**
  72608. * Initializes the physics gravitational field event
  72609. * @param _physicsHelper A physics helper
  72610. * @param _scene BabylonJS scene
  72611. * @param _origin The origin position of the gravitational field event
  72612. * @param _options The options for the vortex event
  72613. */
  72614. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72615. /**
  72616. * Returns the data related to the gravitational field event (sphere).
  72617. * @returns A gravitational field event
  72618. */
  72619. getData(): PhysicsGravitationalFieldEventData;
  72620. /**
  72621. * Enables the gravitational field.
  72622. */
  72623. enable(): void;
  72624. /**
  72625. * Disables the gravitational field.
  72626. */
  72627. disable(): void;
  72628. /**
  72629. * Disposes the sphere.
  72630. * @param force The force to dispose from the gravitational field event
  72631. */
  72632. dispose(force?: boolean): void;
  72633. private _tick;
  72634. }
  72635. /**
  72636. * Represents a physics updraft event
  72637. */
  72638. class PhysicsUpdraftEvent {
  72639. private _scene;
  72640. private _origin;
  72641. private _options;
  72642. private _physicsEngine;
  72643. private _originTop;
  72644. private _originDirection;
  72645. private _tickCallback;
  72646. private _cylinder;
  72647. private _cylinderPosition;
  72648. private _dataFetched;
  72649. /**
  72650. * Initializes the physics updraft event
  72651. * @param _scene BabylonJS scene
  72652. * @param _origin The origin position of the updraft
  72653. * @param _options The options for the updraft event
  72654. */
  72655. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72656. /**
  72657. * Returns the data related to the updraft event (cylinder).
  72658. * @returns A physics updraft event
  72659. */
  72660. getData(): PhysicsUpdraftEventData;
  72661. /**
  72662. * Enables the updraft.
  72663. */
  72664. enable(): void;
  72665. /**
  72666. * Disables the updraft.
  72667. */
  72668. disable(): void;
  72669. /**
  72670. * Disposes the cylinder.
  72671. * @param force Specifies if the updraft should be disposed by force
  72672. */
  72673. dispose(force?: boolean): void;
  72674. private getImpostorHitData;
  72675. private _tick;
  72676. /*** Helpers ***/
  72677. private _prepareCylinder;
  72678. private _intersectsWithCylinder;
  72679. }
  72680. /**
  72681. * Represents a physics vortex event
  72682. */
  72683. class PhysicsVortexEvent {
  72684. private _scene;
  72685. private _origin;
  72686. private _options;
  72687. private _physicsEngine;
  72688. private _originTop;
  72689. private _tickCallback;
  72690. private _cylinder;
  72691. private _cylinderPosition;
  72692. private _dataFetched;
  72693. /**
  72694. * Initializes the physics vortex event
  72695. * @param _scene The BabylonJS scene
  72696. * @param _origin The origin position of the vortex
  72697. * @param _options The options for the vortex event
  72698. */
  72699. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72700. /**
  72701. * Returns the data related to the vortex event (cylinder).
  72702. * @returns The physics vortex event data
  72703. */
  72704. getData(): PhysicsVortexEventData;
  72705. /**
  72706. * Enables the vortex.
  72707. */
  72708. enable(): void;
  72709. /**
  72710. * Disables the cortex.
  72711. */
  72712. disable(): void;
  72713. /**
  72714. * Disposes the sphere.
  72715. * @param force
  72716. */
  72717. dispose(force?: boolean): void;
  72718. private getImpostorHitData;
  72719. private _tick;
  72720. /*** Helpers ***/
  72721. private _prepareCylinder;
  72722. private _intersectsWithCylinder;
  72723. }
  72724. /**
  72725. * Options fot the radial explosion event
  72726. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72727. */
  72728. export class PhysicsRadialExplosionEventOptions {
  72729. /**
  72730. * The radius of the sphere for the radial explosion.
  72731. */
  72732. radius: number;
  72733. /**
  72734. * The strenth of the explosion.
  72735. */
  72736. strength: number;
  72737. /**
  72738. * The strenght of the force in correspondence to the distance of the affected object
  72739. */
  72740. falloff: PhysicsRadialImpulseFalloff;
  72741. /**
  72742. * Sphere options for the radial explosion.
  72743. */
  72744. sphere: {
  72745. segments: number;
  72746. diameter: number;
  72747. };
  72748. /**
  72749. * Sphere options for the radial explosion.
  72750. */
  72751. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72752. }
  72753. /**
  72754. * Options fot the updraft event
  72755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72756. */
  72757. export class PhysicsUpdraftEventOptions {
  72758. /**
  72759. * The radius of the cylinder for the vortex
  72760. */
  72761. radius: number;
  72762. /**
  72763. * The strenth of the updraft.
  72764. */
  72765. strength: number;
  72766. /**
  72767. * The height of the cylinder for the updraft.
  72768. */
  72769. height: number;
  72770. /**
  72771. * The mode for the the updraft.
  72772. */
  72773. updraftMode: PhysicsUpdraftMode;
  72774. }
  72775. /**
  72776. * Options fot the vortex event
  72777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72778. */
  72779. export class PhysicsVortexEventOptions {
  72780. /**
  72781. * The radius of the cylinder for the vortex
  72782. */
  72783. radius: number;
  72784. /**
  72785. * The strenth of the vortex.
  72786. */
  72787. strength: number;
  72788. /**
  72789. * The height of the cylinder for the vortex.
  72790. */
  72791. height: number;
  72792. /**
  72793. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72794. */
  72795. centripetalForceThreshold: number;
  72796. /**
  72797. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72798. */
  72799. centripetalForceMultiplier: number;
  72800. /**
  72801. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72802. */
  72803. centrifugalForceMultiplier: number;
  72804. /**
  72805. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72806. */
  72807. updraftForceMultiplier: number;
  72808. }
  72809. /**
  72810. * The strenght of the force in correspondence to the distance of the affected object
  72811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72812. */
  72813. export enum PhysicsRadialImpulseFalloff {
  72814. /** Defines that impulse is constant in strength across it's whole radius */
  72815. Constant = 0,
  72816. /** Defines that impulse gets weaker if it's further from the origin */
  72817. Linear = 1
  72818. }
  72819. /**
  72820. * The strength of the force in correspondence to the distance of the affected object
  72821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72822. */
  72823. export enum PhysicsUpdraftMode {
  72824. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72825. Center = 0,
  72826. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72827. Perpendicular = 1
  72828. }
  72829. /**
  72830. * Interface for a physics hit data
  72831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72832. */
  72833. export interface PhysicsHitData {
  72834. /**
  72835. * The force applied at the contact point
  72836. */
  72837. force: Vector3;
  72838. /**
  72839. * The contact point
  72840. */
  72841. contactPoint: Vector3;
  72842. /**
  72843. * The distance from the origin to the contact point
  72844. */
  72845. distanceFromOrigin: number;
  72846. }
  72847. /**
  72848. * Interface for radial explosion event data
  72849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72850. */
  72851. export interface PhysicsRadialExplosionEventData {
  72852. /**
  72853. * A sphere used for the radial explosion event
  72854. */
  72855. sphere: Mesh;
  72856. }
  72857. /**
  72858. * Interface for gravitational field event data
  72859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72860. */
  72861. export interface PhysicsGravitationalFieldEventData {
  72862. /**
  72863. * A sphere mesh used for the gravitational field event
  72864. */
  72865. sphere: Mesh;
  72866. }
  72867. /**
  72868. * Interface for updraft event data
  72869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72870. */
  72871. export interface PhysicsUpdraftEventData {
  72872. /**
  72873. * A cylinder used for the updraft event
  72874. */
  72875. cylinder: Mesh;
  72876. }
  72877. /**
  72878. * Interface for vortex event data
  72879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72880. */
  72881. export interface PhysicsVortexEventData {
  72882. /**
  72883. * A cylinder used for the vortex event
  72884. */
  72885. cylinder: Mesh;
  72886. }
  72887. /**
  72888. * Interface for an affected physics impostor
  72889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72890. */
  72891. export interface PhysicsAffectedImpostorWithData {
  72892. /**
  72893. * The impostor affected by the effect
  72894. */
  72895. impostor: PhysicsImpostor;
  72896. /**
  72897. * The data about the hit/horce from the explosion
  72898. */
  72899. hitData: PhysicsHitData;
  72900. }
  72901. }
  72902. declare module "babylonjs/Physics/Plugins/index" {
  72903. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72904. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72905. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72906. }
  72907. declare module "babylonjs/Physics/index" {
  72908. export * from "babylonjs/Physics/IPhysicsEngine";
  72909. export * from "babylonjs/Physics/physicsEngine";
  72910. export * from "babylonjs/Physics/physicsEngineComponent";
  72911. export * from "babylonjs/Physics/physicsHelper";
  72912. export * from "babylonjs/Physics/physicsImpostor";
  72913. export * from "babylonjs/Physics/physicsJoint";
  72914. export * from "babylonjs/Physics/Plugins/index";
  72915. }
  72916. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72917. /** @hidden */
  72918. export var blackAndWhitePixelShader: {
  72919. name: string;
  72920. shader: string;
  72921. };
  72922. }
  72923. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72924. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72925. import { Camera } from "babylonjs/Cameras/camera";
  72926. import { Engine } from "babylonjs/Engines/engine";
  72927. import "babylonjs/Shaders/blackAndWhite.fragment";
  72928. import { Nullable } from "babylonjs/types";
  72929. import { Scene } from "babylonjs/scene";
  72930. /**
  72931. * Post process used to render in black and white
  72932. */
  72933. export class BlackAndWhitePostProcess extends PostProcess {
  72934. /**
  72935. * Linear about to convert he result to black and white (default: 1)
  72936. */
  72937. degree: number;
  72938. /**
  72939. * Gets a string identifying the name of the class
  72940. * @returns "BlackAndWhitePostProcess" string
  72941. */
  72942. getClassName(): string;
  72943. /**
  72944. * Creates a black and white post process
  72945. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72946. * @param name The name of the effect.
  72947. * @param options The required width/height ratio to downsize to before computing the render pass.
  72948. * @param camera The camera to apply the render pass to.
  72949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72950. * @param engine The engine which the post process will be applied. (default: current engine)
  72951. * @param reusable If the post process can be reused on the same frame. (default: false)
  72952. */
  72953. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72954. /** @hidden */
  72955. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72956. }
  72957. }
  72958. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72959. import { Nullable } from "babylonjs/types";
  72960. import { Camera } from "babylonjs/Cameras/camera";
  72961. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72962. import { Engine } from "babylonjs/Engines/engine";
  72963. /**
  72964. * This represents a set of one or more post processes in Babylon.
  72965. * A post process can be used to apply a shader to a texture after it is rendered.
  72966. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72967. */
  72968. export class PostProcessRenderEffect {
  72969. private _postProcesses;
  72970. private _getPostProcesses;
  72971. private _singleInstance;
  72972. private _cameras;
  72973. private _indicesForCamera;
  72974. /**
  72975. * Name of the effect
  72976. * @hidden
  72977. */
  72978. _name: string;
  72979. /**
  72980. * Instantiates a post process render effect.
  72981. * A post process can be used to apply a shader to a texture after it is rendered.
  72982. * @param engine The engine the effect is tied to
  72983. * @param name The name of the effect
  72984. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72985. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72986. */
  72987. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72988. /**
  72989. * Checks if all the post processes in the effect are supported.
  72990. */
  72991. get isSupported(): boolean;
  72992. /**
  72993. * Updates the current state of the effect
  72994. * @hidden
  72995. */
  72996. _update(): void;
  72997. /**
  72998. * Attaches the effect on cameras
  72999. * @param cameras The camera to attach to.
  73000. * @hidden
  73001. */
  73002. _attachCameras(cameras: Camera): void;
  73003. /**
  73004. * Attaches the effect on cameras
  73005. * @param cameras The camera to attach to.
  73006. * @hidden
  73007. */
  73008. _attachCameras(cameras: Camera[]): void;
  73009. /**
  73010. * Detaches the effect on cameras
  73011. * @param cameras The camera to detatch from.
  73012. * @hidden
  73013. */
  73014. _detachCameras(cameras: Camera): void;
  73015. /**
  73016. * Detatches the effect on cameras
  73017. * @param cameras The camera to detatch from.
  73018. * @hidden
  73019. */
  73020. _detachCameras(cameras: Camera[]): void;
  73021. /**
  73022. * Enables the effect on given cameras
  73023. * @param cameras The camera to enable.
  73024. * @hidden
  73025. */
  73026. _enable(cameras: Camera): void;
  73027. /**
  73028. * Enables the effect on given cameras
  73029. * @param cameras The camera to enable.
  73030. * @hidden
  73031. */
  73032. _enable(cameras: Nullable<Camera[]>): void;
  73033. /**
  73034. * Disables the effect on the given cameras
  73035. * @param cameras The camera to disable.
  73036. * @hidden
  73037. */
  73038. _disable(cameras: Camera): void;
  73039. /**
  73040. * Disables the effect on the given cameras
  73041. * @param cameras The camera to disable.
  73042. * @hidden
  73043. */
  73044. _disable(cameras: Nullable<Camera[]>): void;
  73045. /**
  73046. * Gets a list of the post processes contained in the effect.
  73047. * @param camera The camera to get the post processes on.
  73048. * @returns The list of the post processes in the effect.
  73049. */
  73050. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73051. }
  73052. }
  73053. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73054. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73055. /** @hidden */
  73056. export var extractHighlightsPixelShader: {
  73057. name: string;
  73058. shader: string;
  73059. };
  73060. }
  73061. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73062. import { Nullable } from "babylonjs/types";
  73063. import { Camera } from "babylonjs/Cameras/camera";
  73064. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73065. import { Engine } from "babylonjs/Engines/engine";
  73066. import "babylonjs/Shaders/extractHighlights.fragment";
  73067. /**
  73068. * 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.
  73069. */
  73070. export class ExtractHighlightsPostProcess extends PostProcess {
  73071. /**
  73072. * The luminance threshold, pixels below this value will be set to black.
  73073. */
  73074. threshold: number;
  73075. /** @hidden */
  73076. _exposure: number;
  73077. /**
  73078. * Post process which has the input texture to be used when performing highlight extraction
  73079. * @hidden
  73080. */
  73081. _inputPostProcess: Nullable<PostProcess>;
  73082. /**
  73083. * Gets a string identifying the name of the class
  73084. * @returns "ExtractHighlightsPostProcess" string
  73085. */
  73086. getClassName(): string;
  73087. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73088. }
  73089. }
  73090. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73091. /** @hidden */
  73092. export var bloomMergePixelShader: {
  73093. name: string;
  73094. shader: string;
  73095. };
  73096. }
  73097. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73098. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73099. import { Nullable } from "babylonjs/types";
  73100. import { Engine } from "babylonjs/Engines/engine";
  73101. import { Camera } from "babylonjs/Cameras/camera";
  73102. import "babylonjs/Shaders/bloomMerge.fragment";
  73103. /**
  73104. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73105. */
  73106. export class BloomMergePostProcess extends PostProcess {
  73107. /** Weight of the bloom to be added to the original input. */
  73108. weight: number;
  73109. /**
  73110. * Gets a string identifying the name of the class
  73111. * @returns "BloomMergePostProcess" string
  73112. */
  73113. getClassName(): string;
  73114. /**
  73115. * Creates a new instance of @see BloomMergePostProcess
  73116. * @param name The name of the effect.
  73117. * @param originalFromInput Post process which's input will be used for the merge.
  73118. * @param blurred Blurred highlights post process which's output will be used.
  73119. * @param weight Weight of the bloom to be added to the original input.
  73120. * @param options The required width/height ratio to downsize to before computing the render pass.
  73121. * @param camera The camera to apply the render pass to.
  73122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73123. * @param engine The engine which the post process will be applied. (default: current engine)
  73124. * @param reusable If the post process can be reused on the same frame. (default: false)
  73125. * @param textureType Type of textures used when performing the post process. (default: 0)
  73126. * @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)
  73127. */
  73128. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73129. /** Weight of the bloom to be added to the original input. */
  73130. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73131. }
  73132. }
  73133. declare module "babylonjs/PostProcesses/bloomEffect" {
  73134. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73135. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73136. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73137. import { Camera } from "babylonjs/Cameras/camera";
  73138. import { Scene } from "babylonjs/scene";
  73139. /**
  73140. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73141. */
  73142. export class BloomEffect extends PostProcessRenderEffect {
  73143. private bloomScale;
  73144. /**
  73145. * @hidden Internal
  73146. */
  73147. _effects: Array<PostProcess>;
  73148. /**
  73149. * @hidden Internal
  73150. */
  73151. _downscale: ExtractHighlightsPostProcess;
  73152. private _blurX;
  73153. private _blurY;
  73154. private _merge;
  73155. /**
  73156. * The luminance threshold to find bright areas of the image to bloom.
  73157. */
  73158. get threshold(): number;
  73159. set threshold(value: number);
  73160. /**
  73161. * The strength of the bloom.
  73162. */
  73163. get weight(): number;
  73164. set weight(value: number);
  73165. /**
  73166. * Specifies the size of the bloom blur kernel, relative to the final output size
  73167. */
  73168. get kernel(): number;
  73169. set kernel(value: number);
  73170. /**
  73171. * Creates a new instance of @see BloomEffect
  73172. * @param scene The scene the effect belongs to.
  73173. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73174. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73175. * @param bloomWeight The the strength of bloom.
  73176. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73177. * @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)
  73178. */
  73179. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73180. /**
  73181. * Disposes each of the internal effects for a given camera.
  73182. * @param camera The camera to dispose the effect on.
  73183. */
  73184. disposeEffects(camera: Camera): void;
  73185. /**
  73186. * @hidden Internal
  73187. */
  73188. _updateEffects(): void;
  73189. /**
  73190. * Internal
  73191. * @returns if all the contained post processes are ready.
  73192. * @hidden
  73193. */
  73194. _isReady(): boolean;
  73195. }
  73196. }
  73197. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73198. /** @hidden */
  73199. export var chromaticAberrationPixelShader: {
  73200. name: string;
  73201. shader: string;
  73202. };
  73203. }
  73204. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73205. import { Vector2 } from "babylonjs/Maths/math.vector";
  73206. import { Nullable } from "babylonjs/types";
  73207. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73208. import { Camera } from "babylonjs/Cameras/camera";
  73209. import { Engine } from "babylonjs/Engines/engine";
  73210. import "babylonjs/Shaders/chromaticAberration.fragment";
  73211. import { Scene } from "babylonjs/scene";
  73212. /**
  73213. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73214. */
  73215. export class ChromaticAberrationPostProcess extends PostProcess {
  73216. /**
  73217. * The amount of seperation of rgb channels (default: 30)
  73218. */
  73219. aberrationAmount: number;
  73220. /**
  73221. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73222. */
  73223. radialIntensity: number;
  73224. /**
  73225. * 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))
  73226. */
  73227. direction: Vector2;
  73228. /**
  73229. * 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))
  73230. */
  73231. centerPosition: Vector2;
  73232. /** The width of the screen to apply the effect on */
  73233. screenWidth: number;
  73234. /** The height of the screen to apply the effect on */
  73235. screenHeight: number;
  73236. /**
  73237. * Gets a string identifying the name of the class
  73238. * @returns "ChromaticAberrationPostProcess" string
  73239. */
  73240. getClassName(): string;
  73241. /**
  73242. * Creates a new instance ChromaticAberrationPostProcess
  73243. * @param name The name of the effect.
  73244. * @param screenWidth The width of the screen to apply the effect on.
  73245. * @param screenHeight The height of the screen to apply the effect on.
  73246. * @param options The required width/height ratio to downsize to before computing the render pass.
  73247. * @param camera The camera to apply the render pass to.
  73248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73249. * @param engine The engine which the post process will be applied. (default: current engine)
  73250. * @param reusable If the post process can be reused on the same frame. (default: false)
  73251. * @param textureType Type of textures used when performing the post process. (default: 0)
  73252. * @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)
  73253. */
  73254. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73255. /** @hidden */
  73256. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73257. }
  73258. }
  73259. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73260. /** @hidden */
  73261. export var circleOfConfusionPixelShader: {
  73262. name: string;
  73263. shader: string;
  73264. };
  73265. }
  73266. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73267. import { Nullable } from "babylonjs/types";
  73268. import { Engine } from "babylonjs/Engines/engine";
  73269. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73270. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73271. import { Camera } from "babylonjs/Cameras/camera";
  73272. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73273. /**
  73274. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73275. */
  73276. export class CircleOfConfusionPostProcess extends PostProcess {
  73277. /**
  73278. * 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.
  73279. */
  73280. lensSize: number;
  73281. /**
  73282. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73283. */
  73284. fStop: number;
  73285. /**
  73286. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73287. */
  73288. focusDistance: number;
  73289. /**
  73290. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73291. */
  73292. focalLength: number;
  73293. /**
  73294. * Gets a string identifying the name of the class
  73295. * @returns "CircleOfConfusionPostProcess" string
  73296. */
  73297. getClassName(): string;
  73298. private _depthTexture;
  73299. /**
  73300. * Creates a new instance CircleOfConfusionPostProcess
  73301. * @param name The name of the effect.
  73302. * @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.
  73303. * @param options The required width/height ratio to downsize to before computing the render pass.
  73304. * @param camera The camera to apply the render pass to.
  73305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73306. * @param engine The engine which the post process will be applied. (default: current engine)
  73307. * @param reusable If the post process can be reused on the same frame. (default: false)
  73308. * @param textureType Type of textures used when performing the post process. (default: 0)
  73309. * @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)
  73310. */
  73311. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73312. /**
  73313. * 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.
  73314. */
  73315. set depthTexture(value: RenderTargetTexture);
  73316. }
  73317. }
  73318. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73319. /** @hidden */
  73320. export var colorCorrectionPixelShader: {
  73321. name: string;
  73322. shader: string;
  73323. };
  73324. }
  73325. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73326. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73327. import { Engine } from "babylonjs/Engines/engine";
  73328. import { Camera } from "babylonjs/Cameras/camera";
  73329. import "babylonjs/Shaders/colorCorrection.fragment";
  73330. import { Nullable } from "babylonjs/types";
  73331. import { Scene } from "babylonjs/scene";
  73332. /**
  73333. *
  73334. * This post-process allows the modification of rendered colors by using
  73335. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73336. *
  73337. * The object needs to be provided an url to a texture containing the color
  73338. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73339. * Use an image editing software to tweak the LUT to match your needs.
  73340. *
  73341. * For an example of a color LUT, see here:
  73342. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73343. * For explanations on color grading, see here:
  73344. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73345. *
  73346. */
  73347. export class ColorCorrectionPostProcess extends PostProcess {
  73348. private _colorTableTexture;
  73349. /**
  73350. * Gets the color table url used to create the LUT texture
  73351. */
  73352. colorTableUrl: string;
  73353. /**
  73354. * Gets a string identifying the name of the class
  73355. * @returns "ColorCorrectionPostProcess" string
  73356. */
  73357. getClassName(): string;
  73358. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73359. /** @hidden */
  73360. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73361. }
  73362. }
  73363. declare module "babylonjs/Shaders/convolution.fragment" {
  73364. /** @hidden */
  73365. export var convolutionPixelShader: {
  73366. name: string;
  73367. shader: string;
  73368. };
  73369. }
  73370. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73371. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73372. import { Nullable } from "babylonjs/types";
  73373. import { Camera } from "babylonjs/Cameras/camera";
  73374. import { Engine } from "babylonjs/Engines/engine";
  73375. import "babylonjs/Shaders/convolution.fragment";
  73376. import { Scene } from "babylonjs/scene";
  73377. /**
  73378. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73379. * input texture to perform effects such as edge detection or sharpening
  73380. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73381. */
  73382. export class ConvolutionPostProcess extends PostProcess {
  73383. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73384. kernel: number[];
  73385. /**
  73386. * Gets a string identifying the name of the class
  73387. * @returns "ConvolutionPostProcess" string
  73388. */
  73389. getClassName(): string;
  73390. /**
  73391. * Creates a new instance ConvolutionPostProcess
  73392. * @param name The name of the effect.
  73393. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73394. * @param options The required width/height ratio to downsize to before computing the render pass.
  73395. * @param camera The camera to apply the render pass to.
  73396. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73397. * @param engine The engine which the post process will be applied. (default: current engine)
  73398. * @param reusable If the post process can be reused on the same frame. (default: false)
  73399. * @param textureType Type of textures used when performing the post process. (default: 0)
  73400. */
  73401. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73402. /** @hidden */
  73403. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73404. /**
  73405. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73406. */
  73407. static EdgeDetect0Kernel: number[];
  73408. /**
  73409. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73410. */
  73411. static EdgeDetect1Kernel: number[];
  73412. /**
  73413. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73414. */
  73415. static EdgeDetect2Kernel: number[];
  73416. /**
  73417. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73418. */
  73419. static SharpenKernel: number[];
  73420. /**
  73421. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73422. */
  73423. static EmbossKernel: number[];
  73424. /**
  73425. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73426. */
  73427. static GaussianKernel: number[];
  73428. }
  73429. }
  73430. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73431. import { Nullable } from "babylonjs/types";
  73432. import { Vector2 } from "babylonjs/Maths/math.vector";
  73433. import { Camera } from "babylonjs/Cameras/camera";
  73434. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73435. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73436. import { Engine } from "babylonjs/Engines/engine";
  73437. import { Scene } from "babylonjs/scene";
  73438. /**
  73439. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73440. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73441. * based on samples that have a large difference in distance than the center pixel.
  73442. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73443. */
  73444. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73445. /**
  73446. * The direction the blur should be applied
  73447. */
  73448. direction: Vector2;
  73449. /**
  73450. * Gets a string identifying the name of the class
  73451. * @returns "DepthOfFieldBlurPostProcess" string
  73452. */
  73453. getClassName(): string;
  73454. /**
  73455. * Creates a new instance CircleOfConfusionPostProcess
  73456. * @param name The name of the effect.
  73457. * @param scene The scene the effect belongs to.
  73458. * @param direction The direction the blur should be applied.
  73459. * @param kernel The size of the kernel used to blur.
  73460. * @param options The required width/height ratio to downsize to before computing the render pass.
  73461. * @param camera The camera to apply the render pass to.
  73462. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73463. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73465. * @param engine The engine which the post process will be applied. (default: current engine)
  73466. * @param reusable If the post process can be reused on the same frame. (default: false)
  73467. * @param textureType Type of textures used when performing the post process. (default: 0)
  73468. * @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)
  73469. */
  73470. 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);
  73471. }
  73472. }
  73473. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73474. /** @hidden */
  73475. export var depthOfFieldMergePixelShader: {
  73476. name: string;
  73477. shader: string;
  73478. };
  73479. }
  73480. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73481. import { Nullable } from "babylonjs/types";
  73482. import { Camera } from "babylonjs/Cameras/camera";
  73483. import { Effect } from "babylonjs/Materials/effect";
  73484. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73485. import { Engine } from "babylonjs/Engines/engine";
  73486. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73487. /**
  73488. * Options to be set when merging outputs from the default pipeline.
  73489. */
  73490. export class DepthOfFieldMergePostProcessOptions {
  73491. /**
  73492. * The original image to merge on top of
  73493. */
  73494. originalFromInput: PostProcess;
  73495. /**
  73496. * Parameters to perform the merge of the depth of field effect
  73497. */
  73498. depthOfField?: {
  73499. circleOfConfusion: PostProcess;
  73500. blurSteps: Array<PostProcess>;
  73501. };
  73502. /**
  73503. * Parameters to perform the merge of bloom effect
  73504. */
  73505. bloom?: {
  73506. blurred: PostProcess;
  73507. weight: number;
  73508. };
  73509. }
  73510. /**
  73511. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73512. */
  73513. export class DepthOfFieldMergePostProcess extends PostProcess {
  73514. private blurSteps;
  73515. /**
  73516. * Gets a string identifying the name of the class
  73517. * @returns "DepthOfFieldMergePostProcess" string
  73518. */
  73519. getClassName(): string;
  73520. /**
  73521. * Creates a new instance of DepthOfFieldMergePostProcess
  73522. * @param name The name of the effect.
  73523. * @param originalFromInput Post process which's input will be used for the merge.
  73524. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73525. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73526. * @param options The required width/height ratio to downsize to before computing the render pass.
  73527. * @param camera The camera to apply the render pass to.
  73528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73529. * @param engine The engine which the post process will be applied. (default: current engine)
  73530. * @param reusable If the post process can be reused on the same frame. (default: false)
  73531. * @param textureType Type of textures used when performing the post process. (default: 0)
  73532. * @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)
  73533. */
  73534. 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);
  73535. /**
  73536. * Updates the effect with the current post process compile time values and recompiles the shader.
  73537. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73538. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73539. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73540. * @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
  73541. * @param onCompiled Called when the shader has been compiled.
  73542. * @param onError Called if there is an error when compiling a shader.
  73543. */
  73544. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73545. }
  73546. }
  73547. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73548. import { Nullable } from "babylonjs/types";
  73549. import { Camera } from "babylonjs/Cameras/camera";
  73550. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73551. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73552. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73553. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73554. import { Scene } from "babylonjs/scene";
  73555. /**
  73556. * Specifies the level of max blur that should be applied when using the depth of field effect
  73557. */
  73558. export enum DepthOfFieldEffectBlurLevel {
  73559. /**
  73560. * Subtle blur
  73561. */
  73562. Low = 0,
  73563. /**
  73564. * Medium blur
  73565. */
  73566. Medium = 1,
  73567. /**
  73568. * Large blur
  73569. */
  73570. High = 2
  73571. }
  73572. /**
  73573. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73574. */
  73575. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73576. private _circleOfConfusion;
  73577. /**
  73578. * @hidden Internal, blurs from high to low
  73579. */
  73580. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73581. private _depthOfFieldBlurY;
  73582. private _dofMerge;
  73583. /**
  73584. * @hidden Internal post processes in depth of field effect
  73585. */
  73586. _effects: Array<PostProcess>;
  73587. /**
  73588. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73589. */
  73590. set focalLength(value: number);
  73591. get focalLength(): number;
  73592. /**
  73593. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73594. */
  73595. set fStop(value: number);
  73596. get fStop(): number;
  73597. /**
  73598. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73599. */
  73600. set focusDistance(value: number);
  73601. get focusDistance(): number;
  73602. /**
  73603. * 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.
  73604. */
  73605. set lensSize(value: number);
  73606. get lensSize(): number;
  73607. /**
  73608. * Creates a new instance DepthOfFieldEffect
  73609. * @param scene The scene the effect belongs to.
  73610. * @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.
  73611. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73612. * @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)
  73613. */
  73614. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73615. /**
  73616. * Get the current class name of the current effet
  73617. * @returns "DepthOfFieldEffect"
  73618. */
  73619. getClassName(): string;
  73620. /**
  73621. * 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.
  73622. */
  73623. set depthTexture(value: RenderTargetTexture);
  73624. /**
  73625. * Disposes each of the internal effects for a given camera.
  73626. * @param camera The camera to dispose the effect on.
  73627. */
  73628. disposeEffects(camera: Camera): void;
  73629. /**
  73630. * @hidden Internal
  73631. */
  73632. _updateEffects(): void;
  73633. /**
  73634. * Internal
  73635. * @returns if all the contained post processes are ready.
  73636. * @hidden
  73637. */
  73638. _isReady(): boolean;
  73639. }
  73640. }
  73641. declare module "babylonjs/Shaders/displayPass.fragment" {
  73642. /** @hidden */
  73643. export var displayPassPixelShader: {
  73644. name: string;
  73645. shader: string;
  73646. };
  73647. }
  73648. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73649. import { Nullable } from "babylonjs/types";
  73650. import { Camera } from "babylonjs/Cameras/camera";
  73651. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73652. import { Engine } from "babylonjs/Engines/engine";
  73653. import "babylonjs/Shaders/displayPass.fragment";
  73654. import { Scene } from "babylonjs/scene";
  73655. /**
  73656. * DisplayPassPostProcess which produces an output the same as it's input
  73657. */
  73658. export class DisplayPassPostProcess extends PostProcess {
  73659. /**
  73660. * Gets a string identifying the name of the class
  73661. * @returns "DisplayPassPostProcess" string
  73662. */
  73663. getClassName(): string;
  73664. /**
  73665. * Creates the DisplayPassPostProcess
  73666. * @param name The name of the effect.
  73667. * @param options The required width/height ratio to downsize to before computing the render pass.
  73668. * @param camera The camera to apply the render pass to.
  73669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73670. * @param engine The engine which the post process will be applied. (default: current engine)
  73671. * @param reusable If the post process can be reused on the same frame. (default: false)
  73672. */
  73673. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73674. /** @hidden */
  73675. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73676. }
  73677. }
  73678. declare module "babylonjs/Shaders/filter.fragment" {
  73679. /** @hidden */
  73680. export var filterPixelShader: {
  73681. name: string;
  73682. shader: string;
  73683. };
  73684. }
  73685. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73686. import { Nullable } from "babylonjs/types";
  73687. import { Matrix } from "babylonjs/Maths/math.vector";
  73688. import { Camera } from "babylonjs/Cameras/camera";
  73689. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73690. import { Engine } from "babylonjs/Engines/engine";
  73691. import "babylonjs/Shaders/filter.fragment";
  73692. import { Scene } from "babylonjs/scene";
  73693. /**
  73694. * Applies a kernel filter to the image
  73695. */
  73696. export class FilterPostProcess extends PostProcess {
  73697. /** The matrix to be applied to the image */
  73698. kernelMatrix: Matrix;
  73699. /**
  73700. * Gets a string identifying the name of the class
  73701. * @returns "FilterPostProcess" string
  73702. */
  73703. getClassName(): string;
  73704. /**
  73705. *
  73706. * @param name The name of the effect.
  73707. * @param kernelMatrix The matrix to be applied to the image
  73708. * @param options The required width/height ratio to downsize to before computing the render pass.
  73709. * @param camera The camera to apply the render pass to.
  73710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73711. * @param engine The engine which the post process will be applied. (default: current engine)
  73712. * @param reusable If the post process can be reused on the same frame. (default: false)
  73713. */
  73714. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73715. /** @hidden */
  73716. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73717. }
  73718. }
  73719. declare module "babylonjs/Shaders/fxaa.fragment" {
  73720. /** @hidden */
  73721. export var fxaaPixelShader: {
  73722. name: string;
  73723. shader: string;
  73724. };
  73725. }
  73726. declare module "babylonjs/Shaders/fxaa.vertex" {
  73727. /** @hidden */
  73728. export var fxaaVertexShader: {
  73729. name: string;
  73730. shader: string;
  73731. };
  73732. }
  73733. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73734. import { Nullable } from "babylonjs/types";
  73735. import { Camera } from "babylonjs/Cameras/camera";
  73736. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73737. import { Engine } from "babylonjs/Engines/engine";
  73738. import "babylonjs/Shaders/fxaa.fragment";
  73739. import "babylonjs/Shaders/fxaa.vertex";
  73740. import { Scene } from "babylonjs/scene";
  73741. /**
  73742. * Fxaa post process
  73743. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73744. */
  73745. export class FxaaPostProcess extends PostProcess {
  73746. /**
  73747. * Gets a string identifying the name of the class
  73748. * @returns "FxaaPostProcess" string
  73749. */
  73750. getClassName(): string;
  73751. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73752. private _getDefines;
  73753. /** @hidden */
  73754. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73755. }
  73756. }
  73757. declare module "babylonjs/Shaders/grain.fragment" {
  73758. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73759. /** @hidden */
  73760. export var grainPixelShader: {
  73761. name: string;
  73762. shader: string;
  73763. };
  73764. }
  73765. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73766. import { Nullable } from "babylonjs/types";
  73767. import { Camera } from "babylonjs/Cameras/camera";
  73768. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73769. import { Engine } from "babylonjs/Engines/engine";
  73770. import "babylonjs/Shaders/grain.fragment";
  73771. import { Scene } from "babylonjs/scene";
  73772. /**
  73773. * The GrainPostProcess adds noise to the image at mid luminance levels
  73774. */
  73775. export class GrainPostProcess extends PostProcess {
  73776. /**
  73777. * The intensity of the grain added (default: 30)
  73778. */
  73779. intensity: number;
  73780. /**
  73781. * If the grain should be randomized on every frame
  73782. */
  73783. animated: boolean;
  73784. /**
  73785. * Gets a string identifying the name of the class
  73786. * @returns "GrainPostProcess" string
  73787. */
  73788. getClassName(): string;
  73789. /**
  73790. * Creates a new instance of @see GrainPostProcess
  73791. * @param name The name of the effect.
  73792. * @param options The required width/height ratio to downsize to before computing the render pass.
  73793. * @param camera The camera to apply the render pass to.
  73794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73795. * @param engine The engine which the post process will be applied. (default: current engine)
  73796. * @param reusable If the post process can be reused on the same frame. (default: false)
  73797. * @param textureType Type of textures used when performing the post process. (default: 0)
  73798. * @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)
  73799. */
  73800. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73801. /** @hidden */
  73802. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73803. }
  73804. }
  73805. declare module "babylonjs/Shaders/highlights.fragment" {
  73806. /** @hidden */
  73807. export var highlightsPixelShader: {
  73808. name: string;
  73809. shader: string;
  73810. };
  73811. }
  73812. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73813. import { Nullable } from "babylonjs/types";
  73814. import { Camera } from "babylonjs/Cameras/camera";
  73815. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73816. import { Engine } from "babylonjs/Engines/engine";
  73817. import "babylonjs/Shaders/highlights.fragment";
  73818. /**
  73819. * Extracts highlights from the image
  73820. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73821. */
  73822. export class HighlightsPostProcess extends PostProcess {
  73823. /**
  73824. * Gets a string identifying the name of the class
  73825. * @returns "HighlightsPostProcess" string
  73826. */
  73827. getClassName(): string;
  73828. /**
  73829. * Extracts highlights from the image
  73830. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73831. * @param name The name of the effect.
  73832. * @param options The required width/height ratio to downsize to before computing the render pass.
  73833. * @param camera The camera to apply the render pass to.
  73834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73835. * @param engine The engine which the post process will be applied. (default: current engine)
  73836. * @param reusable If the post process can be reused on the same frame. (default: false)
  73837. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73838. */
  73839. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73840. }
  73841. }
  73842. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73843. /** @hidden */
  73844. export var mrtFragmentDeclaration: {
  73845. name: string;
  73846. shader: string;
  73847. };
  73848. }
  73849. declare module "babylonjs/Shaders/geometry.fragment" {
  73850. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73851. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73852. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73853. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73854. /** @hidden */
  73855. export var geometryPixelShader: {
  73856. name: string;
  73857. shader: string;
  73858. };
  73859. }
  73860. declare module "babylonjs/Shaders/geometry.vertex" {
  73861. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73862. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73863. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73864. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73865. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73866. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73867. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73868. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73869. /** @hidden */
  73870. export var geometryVertexShader: {
  73871. name: string;
  73872. shader: string;
  73873. };
  73874. }
  73875. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73876. import { Matrix } from "babylonjs/Maths/math.vector";
  73877. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73878. import { Mesh } from "babylonjs/Meshes/mesh";
  73879. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73880. import { Effect } from "babylonjs/Materials/effect";
  73881. import { Scene } from "babylonjs/scene";
  73882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73883. import "babylonjs/Shaders/geometry.fragment";
  73884. import "babylonjs/Shaders/geometry.vertex";
  73885. /** @hidden */
  73886. interface ISavedTransformationMatrix {
  73887. world: Matrix;
  73888. viewProjection: Matrix;
  73889. }
  73890. /**
  73891. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73892. */
  73893. export class GeometryBufferRenderer {
  73894. /**
  73895. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73896. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73897. */
  73898. static readonly POSITION_TEXTURE_TYPE: number;
  73899. /**
  73900. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73901. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73902. */
  73903. static readonly VELOCITY_TEXTURE_TYPE: number;
  73904. /**
  73905. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73906. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73907. */
  73908. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73909. /**
  73910. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73911. * in order to compute objects velocities when enableVelocity is set to "true"
  73912. * @hidden
  73913. */
  73914. _previousTransformationMatrices: {
  73915. [index: number]: ISavedTransformationMatrix;
  73916. };
  73917. /**
  73918. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73919. * in order to compute objects velocities when enableVelocity is set to "true"
  73920. * @hidden
  73921. */
  73922. _previousBonesTransformationMatrices: {
  73923. [index: number]: Float32Array;
  73924. };
  73925. /**
  73926. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73927. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73928. */
  73929. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73930. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73931. renderTransparentMeshes: boolean;
  73932. private _scene;
  73933. private _resizeObserver;
  73934. private _multiRenderTarget;
  73935. private _ratio;
  73936. private _enablePosition;
  73937. private _enableVelocity;
  73938. private _enableReflectivity;
  73939. private _positionIndex;
  73940. private _velocityIndex;
  73941. private _reflectivityIndex;
  73942. protected _effect: Effect;
  73943. protected _cachedDefines: string;
  73944. /**
  73945. * Set the render list (meshes to be rendered) used in the G buffer.
  73946. */
  73947. set renderList(meshes: Mesh[]);
  73948. /**
  73949. * Gets wether or not G buffer are supported by the running hardware.
  73950. * This requires draw buffer supports
  73951. */
  73952. get isSupported(): boolean;
  73953. /**
  73954. * Returns the index of the given texture type in the G-Buffer textures array
  73955. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73956. * @returns the index of the given texture type in the G-Buffer textures array
  73957. */
  73958. getTextureIndex(textureType: number): number;
  73959. /**
  73960. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73961. */
  73962. get enablePosition(): boolean;
  73963. /**
  73964. * Sets whether or not objects positions are enabled for the G buffer.
  73965. */
  73966. set enablePosition(enable: boolean);
  73967. /**
  73968. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73969. */
  73970. get enableVelocity(): boolean;
  73971. /**
  73972. * Sets wether or not objects velocities are enabled for the G buffer.
  73973. */
  73974. set enableVelocity(enable: boolean);
  73975. /**
  73976. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73977. */
  73978. get enableReflectivity(): boolean;
  73979. /**
  73980. * Sets wether or not objects roughness are enabled for the G buffer.
  73981. */
  73982. set enableReflectivity(enable: boolean);
  73983. /**
  73984. * Gets the scene associated with the buffer.
  73985. */
  73986. get scene(): Scene;
  73987. /**
  73988. * Gets the ratio used by the buffer during its creation.
  73989. * How big is the buffer related to the main canvas.
  73990. */
  73991. get ratio(): number;
  73992. /** @hidden */
  73993. static _SceneComponentInitialization: (scene: Scene) => void;
  73994. /**
  73995. * Creates a new G Buffer for the scene
  73996. * @param scene The scene the buffer belongs to
  73997. * @param ratio How big is the buffer related to the main canvas.
  73998. */
  73999. constructor(scene: Scene, ratio?: number);
  74000. /**
  74001. * Checks wether everything is ready to render a submesh to the G buffer.
  74002. * @param subMesh the submesh to check readiness for
  74003. * @param useInstances is the mesh drawn using instance or not
  74004. * @returns true if ready otherwise false
  74005. */
  74006. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74007. /**
  74008. * Gets the current underlying G Buffer.
  74009. * @returns the buffer
  74010. */
  74011. getGBuffer(): MultiRenderTarget;
  74012. /**
  74013. * Gets the number of samples used to render the buffer (anti aliasing).
  74014. */
  74015. get samples(): number;
  74016. /**
  74017. * Sets the number of samples used to render the buffer (anti aliasing).
  74018. */
  74019. set samples(value: number);
  74020. /**
  74021. * Disposes the renderer and frees up associated resources.
  74022. */
  74023. dispose(): void;
  74024. protected _createRenderTargets(): void;
  74025. private _copyBonesTransformationMatrices;
  74026. }
  74027. }
  74028. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74029. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74030. /**
  74031. * Contains all parameters needed for the prepass to perform
  74032. * motion blur
  74033. */
  74034. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74035. /**
  74036. * Is motion blur enabled
  74037. */
  74038. enabled: boolean;
  74039. /**
  74040. * Name of the configuration
  74041. */
  74042. name: string;
  74043. /**
  74044. * Textures that should be present in the MRT for this effect to work
  74045. */
  74046. readonly texturesRequired: number[];
  74047. }
  74048. }
  74049. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74050. import { Nullable } from "babylonjs/types";
  74051. import { Scene } from "babylonjs/scene";
  74052. import { ISceneComponent } from "babylonjs/sceneComponent";
  74053. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74054. module "babylonjs/scene" {
  74055. interface Scene {
  74056. /** @hidden (Backing field) */
  74057. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74058. /**
  74059. * Gets or Sets the current geometry buffer associated to the scene.
  74060. */
  74061. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74062. /**
  74063. * Enables a GeometryBufferRender and associates it with the scene
  74064. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74065. * @returns the GeometryBufferRenderer
  74066. */
  74067. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74068. /**
  74069. * Disables the GeometryBufferRender associated with the scene
  74070. */
  74071. disableGeometryBufferRenderer(): void;
  74072. }
  74073. }
  74074. /**
  74075. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74076. * in several rendering techniques.
  74077. */
  74078. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74079. /**
  74080. * The component name helpful to identify the component in the list of scene components.
  74081. */
  74082. readonly name: string;
  74083. /**
  74084. * The scene the component belongs to.
  74085. */
  74086. scene: Scene;
  74087. /**
  74088. * Creates a new instance of the component for the given scene
  74089. * @param scene Defines the scene to register the component in
  74090. */
  74091. constructor(scene: Scene);
  74092. /**
  74093. * Registers the component in a given scene
  74094. */
  74095. register(): void;
  74096. /**
  74097. * Rebuilds the elements related to this component in case of
  74098. * context lost for instance.
  74099. */
  74100. rebuild(): void;
  74101. /**
  74102. * Disposes the component and the associated ressources
  74103. */
  74104. dispose(): void;
  74105. private _gatherRenderTargets;
  74106. }
  74107. }
  74108. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74109. /** @hidden */
  74110. export var motionBlurPixelShader: {
  74111. name: string;
  74112. shader: string;
  74113. };
  74114. }
  74115. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74116. import { Nullable } from "babylonjs/types";
  74117. import { Camera } from "babylonjs/Cameras/camera";
  74118. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74120. import "babylonjs/Animations/animatable";
  74121. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74122. import "babylonjs/Shaders/motionBlur.fragment";
  74123. import { Engine } from "babylonjs/Engines/engine";
  74124. import { Scene } from "babylonjs/scene";
  74125. /**
  74126. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74127. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74128. * As an example, all you have to do is to create the post-process:
  74129. * var mb = new BABYLON.MotionBlurPostProcess(
  74130. * 'mb', // The name of the effect.
  74131. * scene, // The scene containing the objects to blur according to their velocity.
  74132. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74133. * camera // The camera to apply the render pass to.
  74134. * );
  74135. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74136. */
  74137. export class MotionBlurPostProcess extends PostProcess {
  74138. /**
  74139. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74140. */
  74141. motionStrength: number;
  74142. /**
  74143. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74144. */
  74145. get motionBlurSamples(): number;
  74146. /**
  74147. * Sets the number of iterations to be used for motion blur quality
  74148. */
  74149. set motionBlurSamples(samples: number);
  74150. private _motionBlurSamples;
  74151. private _forceGeometryBuffer;
  74152. private _geometryBufferRenderer;
  74153. private _prePassRenderer;
  74154. /**
  74155. * Gets a string identifying the name of the class
  74156. * @returns "MotionBlurPostProcess" string
  74157. */
  74158. getClassName(): string;
  74159. /**
  74160. * Creates a new instance MotionBlurPostProcess
  74161. * @param name The name of the effect.
  74162. * @param scene The scene containing the objects to blur according to their velocity.
  74163. * @param options The required width/height ratio to downsize to before computing the render pass.
  74164. * @param camera The camera to apply the render pass to.
  74165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74166. * @param engine The engine which the post process will be applied. (default: current engine)
  74167. * @param reusable If the post process can be reused on the same frame. (default: false)
  74168. * @param textureType Type of textures used when performing the post process. (default: 0)
  74169. * @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)
  74170. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74171. */
  74172. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74173. /**
  74174. * Excludes the given skinned mesh from computing bones velocities.
  74175. * 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.
  74176. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74177. */
  74178. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74179. /**
  74180. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74181. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74182. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74183. */
  74184. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74185. /**
  74186. * Disposes the post process.
  74187. * @param camera The camera to dispose the post process on.
  74188. */
  74189. dispose(camera?: Camera): void;
  74190. /** @hidden */
  74191. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74192. }
  74193. }
  74194. declare module "babylonjs/Shaders/refraction.fragment" {
  74195. /** @hidden */
  74196. export var refractionPixelShader: {
  74197. name: string;
  74198. shader: string;
  74199. };
  74200. }
  74201. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74202. import { Color3 } from "babylonjs/Maths/math.color";
  74203. import { Camera } from "babylonjs/Cameras/camera";
  74204. import { Texture } from "babylonjs/Materials/Textures/texture";
  74205. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74206. import { Engine } from "babylonjs/Engines/engine";
  74207. import "babylonjs/Shaders/refraction.fragment";
  74208. import { Scene } from "babylonjs/scene";
  74209. /**
  74210. * Post process which applies a refractin texture
  74211. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74212. */
  74213. export class RefractionPostProcess extends PostProcess {
  74214. private _refTexture;
  74215. private _ownRefractionTexture;
  74216. /** the base color of the refraction (used to taint the rendering) */
  74217. color: Color3;
  74218. /** simulated refraction depth */
  74219. depth: number;
  74220. /** the coefficient of the base color (0 to remove base color tainting) */
  74221. colorLevel: number;
  74222. /** Gets the url used to load the refraction texture */
  74223. refractionTextureUrl: string;
  74224. /**
  74225. * Gets or sets the refraction texture
  74226. * Please note that you are responsible for disposing the texture if you set it manually
  74227. */
  74228. get refractionTexture(): Texture;
  74229. set refractionTexture(value: Texture);
  74230. /**
  74231. * Gets a string identifying the name of the class
  74232. * @returns "RefractionPostProcess" string
  74233. */
  74234. getClassName(): string;
  74235. /**
  74236. * Initializes the RefractionPostProcess
  74237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74238. * @param name The name of the effect.
  74239. * @param refractionTextureUrl Url of the refraction texture to use
  74240. * @param color the base color of the refraction (used to taint the rendering)
  74241. * @param depth simulated refraction depth
  74242. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74243. * @param camera The camera to apply the render pass to.
  74244. * @param options The required width/height ratio to downsize to before computing the render pass.
  74245. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74246. * @param engine The engine which the post process will be applied. (default: current engine)
  74247. * @param reusable If the post process can be reused on the same frame. (default: false)
  74248. */
  74249. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74250. /**
  74251. * Disposes of the post process
  74252. * @param camera Camera to dispose post process on
  74253. */
  74254. dispose(camera: Camera): void;
  74255. /** @hidden */
  74256. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74257. }
  74258. }
  74259. declare module "babylonjs/Shaders/sharpen.fragment" {
  74260. /** @hidden */
  74261. export var sharpenPixelShader: {
  74262. name: string;
  74263. shader: string;
  74264. };
  74265. }
  74266. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74267. import { Nullable } from "babylonjs/types";
  74268. import { Camera } from "babylonjs/Cameras/camera";
  74269. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74270. import "babylonjs/Shaders/sharpen.fragment";
  74271. import { Engine } from "babylonjs/Engines/engine";
  74272. import { Scene } from "babylonjs/scene";
  74273. /**
  74274. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74275. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74276. */
  74277. export class SharpenPostProcess extends PostProcess {
  74278. /**
  74279. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74280. */
  74281. colorAmount: number;
  74282. /**
  74283. * How much sharpness should be applied (default: 0.3)
  74284. */
  74285. edgeAmount: number;
  74286. /**
  74287. * Gets a string identifying the name of the class
  74288. * @returns "SharpenPostProcess" string
  74289. */
  74290. getClassName(): string;
  74291. /**
  74292. * Creates a new instance ConvolutionPostProcess
  74293. * @param name The name of the effect.
  74294. * @param options The required width/height ratio to downsize to before computing the render pass.
  74295. * @param camera The camera to apply the render pass to.
  74296. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74297. * @param engine The engine which the post process will be applied. (default: current engine)
  74298. * @param reusable If the post process can be reused on the same frame. (default: false)
  74299. * @param textureType Type of textures used when performing the post process. (default: 0)
  74300. * @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)
  74301. */
  74302. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74303. /** @hidden */
  74304. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74305. }
  74306. }
  74307. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74308. import { Nullable } from "babylonjs/types";
  74309. import { Camera } from "babylonjs/Cameras/camera";
  74310. import { Engine } from "babylonjs/Engines/engine";
  74311. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74312. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74313. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74314. /**
  74315. * PostProcessRenderPipeline
  74316. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74317. */
  74318. export class PostProcessRenderPipeline {
  74319. private engine;
  74320. private _renderEffects;
  74321. private _renderEffectsForIsolatedPass;
  74322. /**
  74323. * List of inspectable custom properties (used by the Inspector)
  74324. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74325. */
  74326. inspectableCustomProperties: IInspectable[];
  74327. /**
  74328. * @hidden
  74329. */
  74330. protected _cameras: Camera[];
  74331. /** @hidden */
  74332. _name: string;
  74333. /**
  74334. * Gets pipeline name
  74335. */
  74336. get name(): string;
  74337. /** Gets the list of attached cameras */
  74338. get cameras(): Camera[];
  74339. /**
  74340. * Initializes a PostProcessRenderPipeline
  74341. * @param engine engine to add the pipeline to
  74342. * @param name name of the pipeline
  74343. */
  74344. constructor(engine: Engine, name: string);
  74345. /**
  74346. * Gets the class name
  74347. * @returns "PostProcessRenderPipeline"
  74348. */
  74349. getClassName(): string;
  74350. /**
  74351. * If all the render effects in the pipeline are supported
  74352. */
  74353. get isSupported(): boolean;
  74354. /**
  74355. * Adds an effect to the pipeline
  74356. * @param renderEffect the effect to add
  74357. */
  74358. addEffect(renderEffect: PostProcessRenderEffect): void;
  74359. /** @hidden */
  74360. _rebuild(): void;
  74361. /** @hidden */
  74362. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74363. /** @hidden */
  74364. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74365. /** @hidden */
  74366. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74367. /** @hidden */
  74368. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74369. /** @hidden */
  74370. _attachCameras(cameras: Camera, unique: boolean): void;
  74371. /** @hidden */
  74372. _attachCameras(cameras: Camera[], unique: boolean): void;
  74373. /** @hidden */
  74374. _detachCameras(cameras: Camera): void;
  74375. /** @hidden */
  74376. _detachCameras(cameras: Nullable<Camera[]>): void;
  74377. /** @hidden */
  74378. _update(): void;
  74379. /** @hidden */
  74380. _reset(): void;
  74381. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74382. /**
  74383. * Sets the required values to the prepass renderer.
  74384. * @param prePassRenderer defines the prepass renderer to setup.
  74385. * @returns true if the pre pass is needed.
  74386. */
  74387. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74388. /**
  74389. * Disposes of the pipeline
  74390. */
  74391. dispose(): void;
  74392. }
  74393. }
  74394. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74395. import { Camera } from "babylonjs/Cameras/camera";
  74396. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74397. /**
  74398. * PostProcessRenderPipelineManager class
  74399. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74400. */
  74401. export class PostProcessRenderPipelineManager {
  74402. private _renderPipelines;
  74403. /**
  74404. * Initializes a PostProcessRenderPipelineManager
  74405. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74406. */
  74407. constructor();
  74408. /**
  74409. * Gets the list of supported render pipelines
  74410. */
  74411. get supportedPipelines(): PostProcessRenderPipeline[];
  74412. /**
  74413. * Adds a pipeline to the manager
  74414. * @param renderPipeline The pipeline to add
  74415. */
  74416. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74417. /**
  74418. * Attaches a camera to the pipeline
  74419. * @param renderPipelineName The name of the pipeline to attach to
  74420. * @param cameras the camera to attach
  74421. * @param unique if the camera can be attached multiple times to the pipeline
  74422. */
  74423. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74424. /**
  74425. * Detaches a camera from the pipeline
  74426. * @param renderPipelineName The name of the pipeline to detach from
  74427. * @param cameras the camera to detach
  74428. */
  74429. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74430. /**
  74431. * Enables an effect by name on a pipeline
  74432. * @param renderPipelineName the name of the pipeline to enable the effect in
  74433. * @param renderEffectName the name of the effect to enable
  74434. * @param cameras the cameras that the effect should be enabled on
  74435. */
  74436. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74437. /**
  74438. * Disables an effect by name on a pipeline
  74439. * @param renderPipelineName the name of the pipeline to disable the effect in
  74440. * @param renderEffectName the name of the effect to disable
  74441. * @param cameras the cameras that the effect should be disabled on
  74442. */
  74443. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74444. /**
  74445. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74446. */
  74447. update(): void;
  74448. /** @hidden */
  74449. _rebuild(): void;
  74450. /**
  74451. * Disposes of the manager and pipelines
  74452. */
  74453. dispose(): void;
  74454. }
  74455. }
  74456. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74457. import { ISceneComponent } from "babylonjs/sceneComponent";
  74458. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74459. import { Scene } from "babylonjs/scene";
  74460. module "babylonjs/scene" {
  74461. interface Scene {
  74462. /** @hidden (Backing field) */
  74463. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74464. /**
  74465. * Gets the postprocess render pipeline manager
  74466. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74467. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74468. */
  74469. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74470. }
  74471. }
  74472. /**
  74473. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74474. */
  74475. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74476. /**
  74477. * The component name helpfull to identify the component in the list of scene components.
  74478. */
  74479. readonly name: string;
  74480. /**
  74481. * The scene the component belongs to.
  74482. */
  74483. scene: Scene;
  74484. /**
  74485. * Creates a new instance of the component for the given scene
  74486. * @param scene Defines the scene to register the component in
  74487. */
  74488. constructor(scene: Scene);
  74489. /**
  74490. * Registers the component in a given scene
  74491. */
  74492. register(): void;
  74493. /**
  74494. * Rebuilds the elements related to this component in case of
  74495. * context lost for instance.
  74496. */
  74497. rebuild(): void;
  74498. /**
  74499. * Disposes the component and the associated ressources
  74500. */
  74501. dispose(): void;
  74502. private _gatherRenderTargets;
  74503. }
  74504. }
  74505. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74506. import { Nullable } from "babylonjs/types";
  74507. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74508. import { Camera } from "babylonjs/Cameras/camera";
  74509. import { IDisposable } from "babylonjs/scene";
  74510. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74511. import { Scene } from "babylonjs/scene";
  74512. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74513. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74514. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74515. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74516. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74517. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74518. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74519. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74520. import { Animation } from "babylonjs/Animations/animation";
  74521. /**
  74522. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74523. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74524. */
  74525. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74526. private _scene;
  74527. private _camerasToBeAttached;
  74528. /**
  74529. * ID of the sharpen post process,
  74530. */
  74531. private readonly SharpenPostProcessId;
  74532. /**
  74533. * @ignore
  74534. * ID of the image processing post process;
  74535. */
  74536. readonly ImageProcessingPostProcessId: string;
  74537. /**
  74538. * @ignore
  74539. * ID of the Fast Approximate Anti-Aliasing post process;
  74540. */
  74541. readonly FxaaPostProcessId: string;
  74542. /**
  74543. * ID of the chromatic aberration post process,
  74544. */
  74545. private readonly ChromaticAberrationPostProcessId;
  74546. /**
  74547. * ID of the grain post process
  74548. */
  74549. private readonly GrainPostProcessId;
  74550. /**
  74551. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74552. */
  74553. sharpen: SharpenPostProcess;
  74554. private _sharpenEffect;
  74555. private bloom;
  74556. /**
  74557. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74558. */
  74559. depthOfField: DepthOfFieldEffect;
  74560. /**
  74561. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74562. */
  74563. fxaa: FxaaPostProcess;
  74564. /**
  74565. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74566. */
  74567. imageProcessing: ImageProcessingPostProcess;
  74568. /**
  74569. * Chromatic aberration post process which will shift rgb colors in the image
  74570. */
  74571. chromaticAberration: ChromaticAberrationPostProcess;
  74572. private _chromaticAberrationEffect;
  74573. /**
  74574. * Grain post process which add noise to the image
  74575. */
  74576. grain: GrainPostProcess;
  74577. private _grainEffect;
  74578. /**
  74579. * Glow post process which adds a glow to emissive areas of the image
  74580. */
  74581. private _glowLayer;
  74582. /**
  74583. * Animations which can be used to tweak settings over a period of time
  74584. */
  74585. animations: Animation[];
  74586. private _imageProcessingConfigurationObserver;
  74587. private _sharpenEnabled;
  74588. private _bloomEnabled;
  74589. private _depthOfFieldEnabled;
  74590. private _depthOfFieldBlurLevel;
  74591. private _fxaaEnabled;
  74592. private _imageProcessingEnabled;
  74593. private _defaultPipelineTextureType;
  74594. private _bloomScale;
  74595. private _chromaticAberrationEnabled;
  74596. private _grainEnabled;
  74597. private _buildAllowed;
  74598. /**
  74599. * Gets active scene
  74600. */
  74601. get scene(): Scene;
  74602. /**
  74603. * Enable or disable the sharpen process from the pipeline
  74604. */
  74605. set sharpenEnabled(enabled: boolean);
  74606. get sharpenEnabled(): boolean;
  74607. private _resizeObserver;
  74608. private _hardwareScaleLevel;
  74609. private _bloomKernel;
  74610. /**
  74611. * Specifies the size of the bloom blur kernel, relative to the final output size
  74612. */
  74613. get bloomKernel(): number;
  74614. set bloomKernel(value: number);
  74615. /**
  74616. * Specifies the weight of the bloom in the final rendering
  74617. */
  74618. private _bloomWeight;
  74619. /**
  74620. * Specifies the luma threshold for the area that will be blurred by the bloom
  74621. */
  74622. private _bloomThreshold;
  74623. private _hdr;
  74624. /**
  74625. * The strength of the bloom.
  74626. */
  74627. set bloomWeight(value: number);
  74628. get bloomWeight(): number;
  74629. /**
  74630. * The strength of the bloom.
  74631. */
  74632. set bloomThreshold(value: number);
  74633. get bloomThreshold(): number;
  74634. /**
  74635. * The scale of the bloom, lower value will provide better performance.
  74636. */
  74637. set bloomScale(value: number);
  74638. get bloomScale(): number;
  74639. /**
  74640. * Enable or disable the bloom from the pipeline
  74641. */
  74642. set bloomEnabled(enabled: boolean);
  74643. get bloomEnabled(): boolean;
  74644. private _rebuildBloom;
  74645. /**
  74646. * If the depth of field is enabled.
  74647. */
  74648. get depthOfFieldEnabled(): boolean;
  74649. set depthOfFieldEnabled(enabled: boolean);
  74650. /**
  74651. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74652. */
  74653. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74654. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74655. /**
  74656. * If the anti aliasing is enabled.
  74657. */
  74658. set fxaaEnabled(enabled: boolean);
  74659. get fxaaEnabled(): boolean;
  74660. private _samples;
  74661. /**
  74662. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74663. */
  74664. set samples(sampleCount: number);
  74665. get samples(): number;
  74666. /**
  74667. * If image processing is enabled.
  74668. */
  74669. set imageProcessingEnabled(enabled: boolean);
  74670. get imageProcessingEnabled(): boolean;
  74671. /**
  74672. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74673. */
  74674. set glowLayerEnabled(enabled: boolean);
  74675. get glowLayerEnabled(): boolean;
  74676. /**
  74677. * Gets the glow layer (or null if not defined)
  74678. */
  74679. get glowLayer(): Nullable<GlowLayer>;
  74680. /**
  74681. * Enable or disable the chromaticAberration process from the pipeline
  74682. */
  74683. set chromaticAberrationEnabled(enabled: boolean);
  74684. get chromaticAberrationEnabled(): boolean;
  74685. /**
  74686. * Enable or disable the grain process from the pipeline
  74687. */
  74688. set grainEnabled(enabled: boolean);
  74689. get grainEnabled(): boolean;
  74690. /**
  74691. * @constructor
  74692. * @param name - The rendering pipeline name (default: "")
  74693. * @param hdr - If high dynamic range textures should be used (default: true)
  74694. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74695. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74696. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74697. */
  74698. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74699. /**
  74700. * Get the class name
  74701. * @returns "DefaultRenderingPipeline"
  74702. */
  74703. getClassName(): string;
  74704. /**
  74705. * Force the compilation of the entire pipeline.
  74706. */
  74707. prepare(): void;
  74708. private _hasCleared;
  74709. private _prevPostProcess;
  74710. private _prevPrevPostProcess;
  74711. private _setAutoClearAndTextureSharing;
  74712. private _depthOfFieldSceneObserver;
  74713. private _buildPipeline;
  74714. private _disposePostProcesses;
  74715. /**
  74716. * Adds a camera to the pipeline
  74717. * @param camera the camera to be added
  74718. */
  74719. addCamera(camera: Camera): void;
  74720. /**
  74721. * Removes a camera from the pipeline
  74722. * @param camera the camera to remove
  74723. */
  74724. removeCamera(camera: Camera): void;
  74725. /**
  74726. * Dispose of the pipeline and stop all post processes
  74727. */
  74728. dispose(): void;
  74729. /**
  74730. * Serialize the rendering pipeline (Used when exporting)
  74731. * @returns the serialized object
  74732. */
  74733. serialize(): any;
  74734. /**
  74735. * Parse the serialized pipeline
  74736. * @param source Source pipeline.
  74737. * @param scene The scene to load the pipeline to.
  74738. * @param rootUrl The URL of the serialized pipeline.
  74739. * @returns An instantiated pipeline from the serialized object.
  74740. */
  74741. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74742. }
  74743. }
  74744. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74745. /** @hidden */
  74746. export var lensHighlightsPixelShader: {
  74747. name: string;
  74748. shader: string;
  74749. };
  74750. }
  74751. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74752. /** @hidden */
  74753. export var depthOfFieldPixelShader: {
  74754. name: string;
  74755. shader: string;
  74756. };
  74757. }
  74758. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74759. import { Camera } from "babylonjs/Cameras/camera";
  74760. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74761. import { Scene } from "babylonjs/scene";
  74762. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74763. import "babylonjs/Shaders/chromaticAberration.fragment";
  74764. import "babylonjs/Shaders/lensHighlights.fragment";
  74765. import "babylonjs/Shaders/depthOfField.fragment";
  74766. /**
  74767. * BABYLON.JS Chromatic Aberration GLSL Shader
  74768. * Author: Olivier Guyot
  74769. * Separates very slightly R, G and B colors on the edges of the screen
  74770. * Inspired by Francois Tarlier & Martins Upitis
  74771. */
  74772. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74773. /**
  74774. * @ignore
  74775. * The chromatic aberration PostProcess id in the pipeline
  74776. */
  74777. LensChromaticAberrationEffect: string;
  74778. /**
  74779. * @ignore
  74780. * The highlights enhancing PostProcess id in the pipeline
  74781. */
  74782. HighlightsEnhancingEffect: string;
  74783. /**
  74784. * @ignore
  74785. * The depth-of-field PostProcess id in the pipeline
  74786. */
  74787. LensDepthOfFieldEffect: string;
  74788. private _scene;
  74789. private _depthTexture;
  74790. private _grainTexture;
  74791. private _chromaticAberrationPostProcess;
  74792. private _highlightsPostProcess;
  74793. private _depthOfFieldPostProcess;
  74794. private _edgeBlur;
  74795. private _grainAmount;
  74796. private _chromaticAberration;
  74797. private _distortion;
  74798. private _highlightsGain;
  74799. private _highlightsThreshold;
  74800. private _dofDistance;
  74801. private _dofAperture;
  74802. private _dofDarken;
  74803. private _dofPentagon;
  74804. private _blurNoise;
  74805. /**
  74806. * @constructor
  74807. *
  74808. * Effect parameters are as follow:
  74809. * {
  74810. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74811. * edge_blur: number; // from 0 to x (1 for realism)
  74812. * distortion: number; // from 0 to x (1 for realism)
  74813. * grain_amount: number; // from 0 to 1
  74814. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74815. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74816. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74817. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74818. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74819. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74820. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74821. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74822. * }
  74823. * Note: if an effect parameter is unset, effect is disabled
  74824. *
  74825. * @param name The rendering pipeline name
  74826. * @param parameters - An object containing all parameters (see above)
  74827. * @param scene The scene linked to this pipeline
  74828. * @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)
  74829. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74830. */
  74831. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74832. /**
  74833. * Get the class name
  74834. * @returns "LensRenderingPipeline"
  74835. */
  74836. getClassName(): string;
  74837. /**
  74838. * Gets associated scene
  74839. */
  74840. get scene(): Scene;
  74841. /**
  74842. * Gets or sets the edge blur
  74843. */
  74844. get edgeBlur(): number;
  74845. set edgeBlur(value: number);
  74846. /**
  74847. * Gets or sets the grain amount
  74848. */
  74849. get grainAmount(): number;
  74850. set grainAmount(value: number);
  74851. /**
  74852. * Gets or sets the chromatic aberration amount
  74853. */
  74854. get chromaticAberration(): number;
  74855. set chromaticAberration(value: number);
  74856. /**
  74857. * Gets or sets the depth of field aperture
  74858. */
  74859. get dofAperture(): number;
  74860. set dofAperture(value: number);
  74861. /**
  74862. * Gets or sets the edge distortion
  74863. */
  74864. get edgeDistortion(): number;
  74865. set edgeDistortion(value: number);
  74866. /**
  74867. * Gets or sets the depth of field distortion
  74868. */
  74869. get dofDistortion(): number;
  74870. set dofDistortion(value: number);
  74871. /**
  74872. * Gets or sets the darken out of focus amount
  74873. */
  74874. get darkenOutOfFocus(): number;
  74875. set darkenOutOfFocus(value: number);
  74876. /**
  74877. * Gets or sets a boolean indicating if blur noise is enabled
  74878. */
  74879. get blurNoise(): boolean;
  74880. set blurNoise(value: boolean);
  74881. /**
  74882. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74883. */
  74884. get pentagonBokeh(): boolean;
  74885. set pentagonBokeh(value: boolean);
  74886. /**
  74887. * Gets or sets the highlight grain amount
  74888. */
  74889. get highlightsGain(): number;
  74890. set highlightsGain(value: number);
  74891. /**
  74892. * Gets or sets the highlight threshold
  74893. */
  74894. get highlightsThreshold(): number;
  74895. set highlightsThreshold(value: number);
  74896. /**
  74897. * Sets the amount of blur at the edges
  74898. * @param amount blur amount
  74899. */
  74900. setEdgeBlur(amount: number): void;
  74901. /**
  74902. * Sets edge blur to 0
  74903. */
  74904. disableEdgeBlur(): void;
  74905. /**
  74906. * Sets the amout of grain
  74907. * @param amount Amount of grain
  74908. */
  74909. setGrainAmount(amount: number): void;
  74910. /**
  74911. * Set grain amount to 0
  74912. */
  74913. disableGrain(): void;
  74914. /**
  74915. * Sets the chromatic aberration amount
  74916. * @param amount amount of chromatic aberration
  74917. */
  74918. setChromaticAberration(amount: number): void;
  74919. /**
  74920. * Sets chromatic aberration amount to 0
  74921. */
  74922. disableChromaticAberration(): void;
  74923. /**
  74924. * Sets the EdgeDistortion amount
  74925. * @param amount amount of EdgeDistortion
  74926. */
  74927. setEdgeDistortion(amount: number): void;
  74928. /**
  74929. * Sets edge distortion to 0
  74930. */
  74931. disableEdgeDistortion(): void;
  74932. /**
  74933. * Sets the FocusDistance amount
  74934. * @param amount amount of FocusDistance
  74935. */
  74936. setFocusDistance(amount: number): void;
  74937. /**
  74938. * Disables depth of field
  74939. */
  74940. disableDepthOfField(): void;
  74941. /**
  74942. * Sets the Aperture amount
  74943. * @param amount amount of Aperture
  74944. */
  74945. setAperture(amount: number): void;
  74946. /**
  74947. * Sets the DarkenOutOfFocus amount
  74948. * @param amount amount of DarkenOutOfFocus
  74949. */
  74950. setDarkenOutOfFocus(amount: number): void;
  74951. private _pentagonBokehIsEnabled;
  74952. /**
  74953. * Creates a pentagon bokeh effect
  74954. */
  74955. enablePentagonBokeh(): void;
  74956. /**
  74957. * Disables the pentagon bokeh effect
  74958. */
  74959. disablePentagonBokeh(): void;
  74960. /**
  74961. * Enables noise blur
  74962. */
  74963. enableNoiseBlur(): void;
  74964. /**
  74965. * Disables noise blur
  74966. */
  74967. disableNoiseBlur(): void;
  74968. /**
  74969. * Sets the HighlightsGain amount
  74970. * @param amount amount of HighlightsGain
  74971. */
  74972. setHighlightsGain(amount: number): void;
  74973. /**
  74974. * Sets the HighlightsThreshold amount
  74975. * @param amount amount of HighlightsThreshold
  74976. */
  74977. setHighlightsThreshold(amount: number): void;
  74978. /**
  74979. * Disables highlights
  74980. */
  74981. disableHighlights(): void;
  74982. /**
  74983. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74984. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74985. */
  74986. dispose(disableDepthRender?: boolean): void;
  74987. private _createChromaticAberrationPostProcess;
  74988. private _createHighlightsPostProcess;
  74989. private _createDepthOfFieldPostProcess;
  74990. private _createGrainTexture;
  74991. }
  74992. }
  74993. declare module "babylonjs/Rendering/ssao2Configuration" {
  74994. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74995. /**
  74996. * Contains all parameters needed for the prepass to perform
  74997. * screen space subsurface scattering
  74998. */
  74999. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75000. /**
  75001. * Is subsurface enabled
  75002. */
  75003. enabled: boolean;
  75004. /**
  75005. * Name of the configuration
  75006. */
  75007. name: string;
  75008. /**
  75009. * Textures that should be present in the MRT for this effect to work
  75010. */
  75011. readonly texturesRequired: number[];
  75012. }
  75013. }
  75014. declare module "babylonjs/Shaders/ssao2.fragment" {
  75015. /** @hidden */
  75016. export var ssao2PixelShader: {
  75017. name: string;
  75018. shader: string;
  75019. };
  75020. }
  75021. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75022. /** @hidden */
  75023. export var ssaoCombinePixelShader: {
  75024. name: string;
  75025. shader: string;
  75026. };
  75027. }
  75028. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75029. import { Camera } from "babylonjs/Cameras/camera";
  75030. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75031. import { Scene } from "babylonjs/scene";
  75032. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75033. import "babylonjs/Shaders/ssao2.fragment";
  75034. import "babylonjs/Shaders/ssaoCombine.fragment";
  75035. /**
  75036. * Render pipeline to produce ssao effect
  75037. */
  75038. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75039. /**
  75040. * @ignore
  75041. * The PassPostProcess id in the pipeline that contains the original scene color
  75042. */
  75043. SSAOOriginalSceneColorEffect: string;
  75044. /**
  75045. * @ignore
  75046. * The SSAO PostProcess id in the pipeline
  75047. */
  75048. SSAORenderEffect: string;
  75049. /**
  75050. * @ignore
  75051. * The horizontal blur PostProcess id in the pipeline
  75052. */
  75053. SSAOBlurHRenderEffect: string;
  75054. /**
  75055. * @ignore
  75056. * The vertical blur PostProcess id in the pipeline
  75057. */
  75058. SSAOBlurVRenderEffect: string;
  75059. /**
  75060. * @ignore
  75061. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75062. */
  75063. SSAOCombineRenderEffect: string;
  75064. /**
  75065. * The output strength of the SSAO post-process. Default value is 1.0.
  75066. */
  75067. totalStrength: number;
  75068. /**
  75069. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75070. */
  75071. maxZ: number;
  75072. /**
  75073. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75074. */
  75075. minZAspect: number;
  75076. private _samples;
  75077. /**
  75078. * Number of samples used for the SSAO calculations. Default value is 8
  75079. */
  75080. set samples(n: number);
  75081. get samples(): number;
  75082. private _textureSamples;
  75083. /**
  75084. * Number of samples to use for antialiasing
  75085. */
  75086. set textureSamples(n: number);
  75087. get textureSamples(): number;
  75088. /**
  75089. * Force rendering the geometry through geometry buffer
  75090. */
  75091. private _forceGeometryBuffer;
  75092. /**
  75093. * Ratio object used for SSAO ratio and blur ratio
  75094. */
  75095. private _ratio;
  75096. /**
  75097. * Dynamically generated sphere sampler.
  75098. */
  75099. private _sampleSphere;
  75100. /**
  75101. * Blur filter offsets
  75102. */
  75103. private _samplerOffsets;
  75104. private _expensiveBlur;
  75105. /**
  75106. * If bilateral blur should be used
  75107. */
  75108. set expensiveBlur(b: boolean);
  75109. get expensiveBlur(): boolean;
  75110. /**
  75111. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75112. */
  75113. radius: number;
  75114. /**
  75115. * The base color of the SSAO post-process
  75116. * The final result is "base + ssao" between [0, 1]
  75117. */
  75118. base: number;
  75119. /**
  75120. * Support test.
  75121. */
  75122. static get IsSupported(): boolean;
  75123. private _scene;
  75124. private _randomTexture;
  75125. private _originalColorPostProcess;
  75126. private _ssaoPostProcess;
  75127. private _blurHPostProcess;
  75128. private _blurVPostProcess;
  75129. private _ssaoCombinePostProcess;
  75130. private _prePassRenderer;
  75131. /**
  75132. * Gets active scene
  75133. */
  75134. get scene(): Scene;
  75135. /**
  75136. * @constructor
  75137. * @param name The rendering pipeline name
  75138. * @param scene The scene linked to this pipeline
  75139. * @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 }
  75140. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75141. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75142. */
  75143. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75144. /**
  75145. * Get the class name
  75146. * @returns "SSAO2RenderingPipeline"
  75147. */
  75148. getClassName(): string;
  75149. /**
  75150. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75151. */
  75152. dispose(disableGeometryBufferRenderer?: boolean): void;
  75153. private _createBlurPostProcess;
  75154. /** @hidden */
  75155. _rebuild(): void;
  75156. private _bits;
  75157. private _radicalInverse_VdC;
  75158. private _hammersley;
  75159. private _hemisphereSample_uniform;
  75160. private _generateHemisphere;
  75161. private _getDefinesForSSAO;
  75162. private _createSSAOPostProcess;
  75163. private _createSSAOCombinePostProcess;
  75164. private _createRandomTexture;
  75165. /**
  75166. * Serialize the rendering pipeline (Used when exporting)
  75167. * @returns the serialized object
  75168. */
  75169. serialize(): any;
  75170. /**
  75171. * Parse the serialized pipeline
  75172. * @param source Source pipeline.
  75173. * @param scene The scene to load the pipeline to.
  75174. * @param rootUrl The URL of the serialized pipeline.
  75175. * @returns An instantiated pipeline from the serialized object.
  75176. */
  75177. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75178. }
  75179. }
  75180. declare module "babylonjs/Shaders/ssao.fragment" {
  75181. /** @hidden */
  75182. export var ssaoPixelShader: {
  75183. name: string;
  75184. shader: string;
  75185. };
  75186. }
  75187. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75188. import { Camera } from "babylonjs/Cameras/camera";
  75189. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75190. import { Scene } from "babylonjs/scene";
  75191. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75192. import "babylonjs/Shaders/ssao.fragment";
  75193. import "babylonjs/Shaders/ssaoCombine.fragment";
  75194. /**
  75195. * Render pipeline to produce ssao effect
  75196. */
  75197. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75198. /**
  75199. * @ignore
  75200. * The PassPostProcess id in the pipeline that contains the original scene color
  75201. */
  75202. SSAOOriginalSceneColorEffect: string;
  75203. /**
  75204. * @ignore
  75205. * The SSAO PostProcess id in the pipeline
  75206. */
  75207. SSAORenderEffect: string;
  75208. /**
  75209. * @ignore
  75210. * The horizontal blur PostProcess id in the pipeline
  75211. */
  75212. SSAOBlurHRenderEffect: string;
  75213. /**
  75214. * @ignore
  75215. * The vertical blur PostProcess id in the pipeline
  75216. */
  75217. SSAOBlurVRenderEffect: string;
  75218. /**
  75219. * @ignore
  75220. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75221. */
  75222. SSAOCombineRenderEffect: string;
  75223. /**
  75224. * The output strength of the SSAO post-process. Default value is 1.0.
  75225. */
  75226. totalStrength: number;
  75227. /**
  75228. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75229. */
  75230. radius: number;
  75231. /**
  75232. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75233. * Must not be equal to fallOff and superior to fallOff.
  75234. * Default value is 0.0075
  75235. */
  75236. area: number;
  75237. /**
  75238. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75239. * Must not be equal to area and inferior to area.
  75240. * Default value is 0.000001
  75241. */
  75242. fallOff: number;
  75243. /**
  75244. * The base color of the SSAO post-process
  75245. * The final result is "base + ssao" between [0, 1]
  75246. */
  75247. base: number;
  75248. private _scene;
  75249. private _depthTexture;
  75250. private _randomTexture;
  75251. private _originalColorPostProcess;
  75252. private _ssaoPostProcess;
  75253. private _blurHPostProcess;
  75254. private _blurVPostProcess;
  75255. private _ssaoCombinePostProcess;
  75256. private _firstUpdate;
  75257. /**
  75258. * Gets active scene
  75259. */
  75260. get scene(): Scene;
  75261. /**
  75262. * @constructor
  75263. * @param name - The rendering pipeline name
  75264. * @param scene - The scene linked to this pipeline
  75265. * @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 }
  75266. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75267. */
  75268. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75269. /**
  75270. * Get the class name
  75271. * @returns "SSAORenderingPipeline"
  75272. */
  75273. getClassName(): string;
  75274. /**
  75275. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75276. */
  75277. dispose(disableDepthRender?: boolean): void;
  75278. private _createBlurPostProcess;
  75279. /** @hidden */
  75280. _rebuild(): void;
  75281. private _createSSAOPostProcess;
  75282. private _createSSAOCombinePostProcess;
  75283. private _createRandomTexture;
  75284. }
  75285. }
  75286. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75287. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75288. /**
  75289. * Contains all parameters needed for the prepass to perform
  75290. * screen space reflections
  75291. */
  75292. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75293. /**
  75294. * Is ssr enabled
  75295. */
  75296. enabled: boolean;
  75297. /**
  75298. * Name of the configuration
  75299. */
  75300. name: string;
  75301. /**
  75302. * Textures that should be present in the MRT for this effect to work
  75303. */
  75304. readonly texturesRequired: number[];
  75305. }
  75306. }
  75307. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75308. /** @hidden */
  75309. export var screenSpaceReflectionPixelShader: {
  75310. name: string;
  75311. shader: string;
  75312. };
  75313. }
  75314. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75315. import { Nullable } from "babylonjs/types";
  75316. import { Camera } from "babylonjs/Cameras/camera";
  75317. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75318. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75319. import { Engine } from "babylonjs/Engines/engine";
  75320. import { Scene } from "babylonjs/scene";
  75321. /**
  75322. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75323. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75324. */
  75325. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75326. /**
  75327. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75328. */
  75329. threshold: number;
  75330. /**
  75331. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75332. */
  75333. strength: number;
  75334. /**
  75335. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75336. */
  75337. reflectionSpecularFalloffExponent: number;
  75338. /**
  75339. * 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]
  75340. */
  75341. step: number;
  75342. /**
  75343. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75344. */
  75345. roughnessFactor: number;
  75346. private _forceGeometryBuffer;
  75347. private _geometryBufferRenderer;
  75348. private _prePassRenderer;
  75349. private _enableSmoothReflections;
  75350. private _reflectionSamples;
  75351. private _smoothSteps;
  75352. /**
  75353. * Gets a string identifying the name of the class
  75354. * @returns "ScreenSpaceReflectionPostProcess" string
  75355. */
  75356. getClassName(): string;
  75357. /**
  75358. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75359. * @param name The name of the effect.
  75360. * @param scene The scene containing the objects to calculate reflections.
  75361. * @param options The required width/height ratio to downsize to before computing the render pass.
  75362. * @param camera The camera to apply the render pass to.
  75363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75364. * @param engine The engine which the post process will be applied. (default: current engine)
  75365. * @param reusable If the post process can be reused on the same frame. (default: false)
  75366. * @param textureType Type of textures used when performing the post process. (default: 0)
  75367. * @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)
  75368. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75369. */
  75370. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75371. /**
  75372. * Gets wether or not smoothing reflections is enabled.
  75373. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75374. */
  75375. get enableSmoothReflections(): boolean;
  75376. /**
  75377. * Sets wether or not smoothing reflections is enabled.
  75378. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75379. */
  75380. set enableSmoothReflections(enabled: boolean);
  75381. /**
  75382. * Gets the number of samples taken while computing reflections. More samples count is high,
  75383. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75384. */
  75385. get reflectionSamples(): number;
  75386. /**
  75387. * Sets the number of samples taken while computing reflections. More samples count is high,
  75388. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75389. */
  75390. set reflectionSamples(samples: number);
  75391. /**
  75392. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75393. * more the post-process will require GPU power and can generate a drop in FPS.
  75394. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75395. */
  75396. get smoothSteps(): number;
  75397. set smoothSteps(steps: number);
  75398. private _updateEffectDefines;
  75399. /** @hidden */
  75400. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75401. }
  75402. }
  75403. declare module "babylonjs/Shaders/standard.fragment" {
  75404. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75405. /** @hidden */
  75406. export var standardPixelShader: {
  75407. name: string;
  75408. shader: string;
  75409. };
  75410. }
  75411. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75412. import { Nullable } from "babylonjs/types";
  75413. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75414. import { Camera } from "babylonjs/Cameras/camera";
  75415. import { Texture } from "babylonjs/Materials/Textures/texture";
  75416. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75417. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75418. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75419. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75420. import { IDisposable } from "babylonjs/scene";
  75421. import { SpotLight } from "babylonjs/Lights/spotLight";
  75422. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75423. import { Scene } from "babylonjs/scene";
  75424. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75425. import { Animation } from "babylonjs/Animations/animation";
  75426. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75427. import "babylonjs/Shaders/standard.fragment";
  75428. /**
  75429. * Standard rendering pipeline
  75430. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75431. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75432. */
  75433. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75434. /**
  75435. * Public members
  75436. */
  75437. /**
  75438. * Post-process which contains the original scene color before the pipeline applies all the effects
  75439. */
  75440. originalPostProcess: Nullable<PostProcess>;
  75441. /**
  75442. * Post-process used to down scale an image x4
  75443. */
  75444. downSampleX4PostProcess: Nullable<PostProcess>;
  75445. /**
  75446. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75447. */
  75448. brightPassPostProcess: Nullable<PostProcess>;
  75449. /**
  75450. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75451. */
  75452. blurHPostProcesses: PostProcess[];
  75453. /**
  75454. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75455. */
  75456. blurVPostProcesses: PostProcess[];
  75457. /**
  75458. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75459. */
  75460. textureAdderPostProcess: Nullable<PostProcess>;
  75461. /**
  75462. * Post-process used to create volumetric lighting effect
  75463. */
  75464. volumetricLightPostProcess: Nullable<PostProcess>;
  75465. /**
  75466. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75467. */
  75468. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75469. /**
  75470. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75471. */
  75472. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75473. /**
  75474. * Post-process used to merge the volumetric light effect and the real scene color
  75475. */
  75476. volumetricLightMergePostProces: Nullable<PostProcess>;
  75477. /**
  75478. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75479. */
  75480. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75481. /**
  75482. * Base post-process used to calculate the average luminance of the final image for HDR
  75483. */
  75484. luminancePostProcess: Nullable<PostProcess>;
  75485. /**
  75486. * Post-processes used to create down sample post-processes in order to get
  75487. * the average luminance of the final image for HDR
  75488. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75489. */
  75490. luminanceDownSamplePostProcesses: PostProcess[];
  75491. /**
  75492. * Post-process used to create a HDR effect (light adaptation)
  75493. */
  75494. hdrPostProcess: Nullable<PostProcess>;
  75495. /**
  75496. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75497. */
  75498. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75499. /**
  75500. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75501. */
  75502. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75503. /**
  75504. * Post-process used to merge the final HDR post-process and the real scene color
  75505. */
  75506. hdrFinalPostProcess: Nullable<PostProcess>;
  75507. /**
  75508. * Post-process used to create a lens flare effect
  75509. */
  75510. lensFlarePostProcess: Nullable<PostProcess>;
  75511. /**
  75512. * Post-process that merges the result of the lens flare post-process and the real scene color
  75513. */
  75514. lensFlareComposePostProcess: Nullable<PostProcess>;
  75515. /**
  75516. * Post-process used to create a motion blur effect
  75517. */
  75518. motionBlurPostProcess: Nullable<PostProcess>;
  75519. /**
  75520. * Post-process used to create a depth of field effect
  75521. */
  75522. depthOfFieldPostProcess: Nullable<PostProcess>;
  75523. /**
  75524. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75525. */
  75526. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75527. /**
  75528. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75529. */
  75530. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75531. /**
  75532. * Represents the brightness threshold in order to configure the illuminated surfaces
  75533. */
  75534. brightThreshold: number;
  75535. /**
  75536. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75537. */
  75538. blurWidth: number;
  75539. /**
  75540. * Sets if the blur for highlighted surfaces must be only horizontal
  75541. */
  75542. horizontalBlur: boolean;
  75543. /**
  75544. * Gets the overall exposure used by the pipeline
  75545. */
  75546. get exposure(): number;
  75547. /**
  75548. * Sets the overall exposure used by the pipeline
  75549. */
  75550. set exposure(value: number);
  75551. /**
  75552. * Texture used typically to simulate "dirty" on camera lens
  75553. */
  75554. lensTexture: Nullable<Texture>;
  75555. /**
  75556. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75557. */
  75558. volumetricLightCoefficient: number;
  75559. /**
  75560. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75561. */
  75562. volumetricLightPower: number;
  75563. /**
  75564. * Used the set the blur intensity to smooth the volumetric lights
  75565. */
  75566. volumetricLightBlurScale: number;
  75567. /**
  75568. * Light (spot or directional) used to generate the volumetric lights rays
  75569. * The source light must have a shadow generate so the pipeline can get its
  75570. * depth map
  75571. */
  75572. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75573. /**
  75574. * For eye adaptation, represents the minimum luminance the eye can see
  75575. */
  75576. hdrMinimumLuminance: number;
  75577. /**
  75578. * For eye adaptation, represents the decrease luminance speed
  75579. */
  75580. hdrDecreaseRate: number;
  75581. /**
  75582. * For eye adaptation, represents the increase luminance speed
  75583. */
  75584. hdrIncreaseRate: number;
  75585. /**
  75586. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75587. */
  75588. get hdrAutoExposure(): boolean;
  75589. /**
  75590. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75591. */
  75592. set hdrAutoExposure(value: boolean);
  75593. /**
  75594. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75595. */
  75596. lensColorTexture: Nullable<Texture>;
  75597. /**
  75598. * The overall strengh for the lens flare effect
  75599. */
  75600. lensFlareStrength: number;
  75601. /**
  75602. * Dispersion coefficient for lens flare ghosts
  75603. */
  75604. lensFlareGhostDispersal: number;
  75605. /**
  75606. * Main lens flare halo width
  75607. */
  75608. lensFlareHaloWidth: number;
  75609. /**
  75610. * Based on the lens distortion effect, defines how much the lens flare result
  75611. * is distorted
  75612. */
  75613. lensFlareDistortionStrength: number;
  75614. /**
  75615. * Configures the blur intensity used for for lens flare (halo)
  75616. */
  75617. lensFlareBlurWidth: number;
  75618. /**
  75619. * Lens star texture must be used to simulate rays on the flares and is available
  75620. * in the documentation
  75621. */
  75622. lensStarTexture: Nullable<Texture>;
  75623. /**
  75624. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75625. * flare effect by taking account of the dirt texture
  75626. */
  75627. lensFlareDirtTexture: Nullable<Texture>;
  75628. /**
  75629. * Represents the focal length for the depth of field effect
  75630. */
  75631. depthOfFieldDistance: number;
  75632. /**
  75633. * Represents the blur intensity for the blurred part of the depth of field effect
  75634. */
  75635. depthOfFieldBlurWidth: number;
  75636. /**
  75637. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75638. */
  75639. get motionStrength(): number;
  75640. /**
  75641. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75642. */
  75643. set motionStrength(strength: number);
  75644. /**
  75645. * Gets wether or not the motion blur post-process is object based or screen based.
  75646. */
  75647. get objectBasedMotionBlur(): boolean;
  75648. /**
  75649. * Sets wether or not the motion blur post-process should be object based or screen based
  75650. */
  75651. set objectBasedMotionBlur(value: boolean);
  75652. /**
  75653. * List of animations for the pipeline (IAnimatable implementation)
  75654. */
  75655. animations: Animation[];
  75656. /**
  75657. * Private members
  75658. */
  75659. private _scene;
  75660. private _currentDepthOfFieldSource;
  75661. private _basePostProcess;
  75662. private _fixedExposure;
  75663. private _currentExposure;
  75664. private _hdrAutoExposure;
  75665. private _hdrCurrentLuminance;
  75666. private _motionStrength;
  75667. private _isObjectBasedMotionBlur;
  75668. private _floatTextureType;
  75669. private _camerasToBeAttached;
  75670. private _ratio;
  75671. private _bloomEnabled;
  75672. private _depthOfFieldEnabled;
  75673. private _vlsEnabled;
  75674. private _lensFlareEnabled;
  75675. private _hdrEnabled;
  75676. private _motionBlurEnabled;
  75677. private _fxaaEnabled;
  75678. private _screenSpaceReflectionsEnabled;
  75679. private _motionBlurSamples;
  75680. private _volumetricLightStepsCount;
  75681. private _samples;
  75682. /**
  75683. * @ignore
  75684. * Specifies if the bloom pipeline is enabled
  75685. */
  75686. get BloomEnabled(): boolean;
  75687. set BloomEnabled(enabled: boolean);
  75688. /**
  75689. * @ignore
  75690. * Specifies if the depth of field pipeline is enabed
  75691. */
  75692. get DepthOfFieldEnabled(): boolean;
  75693. set DepthOfFieldEnabled(enabled: boolean);
  75694. /**
  75695. * @ignore
  75696. * Specifies if the lens flare pipeline is enabed
  75697. */
  75698. get LensFlareEnabled(): boolean;
  75699. set LensFlareEnabled(enabled: boolean);
  75700. /**
  75701. * @ignore
  75702. * Specifies if the HDR pipeline is enabled
  75703. */
  75704. get HDREnabled(): boolean;
  75705. set HDREnabled(enabled: boolean);
  75706. /**
  75707. * @ignore
  75708. * Specifies if the volumetric lights scattering effect is enabled
  75709. */
  75710. get VLSEnabled(): boolean;
  75711. set VLSEnabled(enabled: boolean);
  75712. /**
  75713. * @ignore
  75714. * Specifies if the motion blur effect is enabled
  75715. */
  75716. get MotionBlurEnabled(): boolean;
  75717. set MotionBlurEnabled(enabled: boolean);
  75718. /**
  75719. * Specifies if anti-aliasing is enabled
  75720. */
  75721. get fxaaEnabled(): boolean;
  75722. set fxaaEnabled(enabled: boolean);
  75723. /**
  75724. * Specifies if screen space reflections are enabled.
  75725. */
  75726. get screenSpaceReflectionsEnabled(): boolean;
  75727. set screenSpaceReflectionsEnabled(enabled: boolean);
  75728. /**
  75729. * Specifies the number of steps used to calculate the volumetric lights
  75730. * Typically in interval [50, 200]
  75731. */
  75732. get volumetricLightStepsCount(): number;
  75733. set volumetricLightStepsCount(count: number);
  75734. /**
  75735. * Specifies the number of samples used for the motion blur effect
  75736. * Typically in interval [16, 64]
  75737. */
  75738. get motionBlurSamples(): number;
  75739. set motionBlurSamples(samples: number);
  75740. /**
  75741. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75742. */
  75743. get samples(): number;
  75744. set samples(sampleCount: number);
  75745. /**
  75746. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75747. * @constructor
  75748. * @param name The rendering pipeline name
  75749. * @param scene The scene linked to this pipeline
  75750. * @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)
  75751. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75752. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75753. */
  75754. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75755. private _buildPipeline;
  75756. private _createDownSampleX4PostProcess;
  75757. private _createBrightPassPostProcess;
  75758. private _createBlurPostProcesses;
  75759. private _createTextureAdderPostProcess;
  75760. private _createVolumetricLightPostProcess;
  75761. private _createLuminancePostProcesses;
  75762. private _createHdrPostProcess;
  75763. private _createLensFlarePostProcess;
  75764. private _createDepthOfFieldPostProcess;
  75765. private _createMotionBlurPostProcess;
  75766. private _getDepthTexture;
  75767. private _disposePostProcesses;
  75768. /**
  75769. * Dispose of the pipeline and stop all post processes
  75770. */
  75771. dispose(): void;
  75772. /**
  75773. * Serialize the rendering pipeline (Used when exporting)
  75774. * @returns the serialized object
  75775. */
  75776. serialize(): any;
  75777. /**
  75778. * Parse the serialized pipeline
  75779. * @param source Source pipeline.
  75780. * @param scene The scene to load the pipeline to.
  75781. * @param rootUrl The URL of the serialized pipeline.
  75782. * @returns An instantiated pipeline from the serialized object.
  75783. */
  75784. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75785. /**
  75786. * Luminance steps
  75787. */
  75788. static LuminanceSteps: number;
  75789. }
  75790. }
  75791. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75792. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75793. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75794. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75795. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75796. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75797. }
  75798. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75799. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75800. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75801. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75802. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75803. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75804. }
  75805. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75806. /** @hidden */
  75807. export var stereoscopicInterlacePixelShader: {
  75808. name: string;
  75809. shader: string;
  75810. };
  75811. }
  75812. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75813. import { Camera } from "babylonjs/Cameras/camera";
  75814. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75815. import { Engine } from "babylonjs/Engines/engine";
  75816. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75817. /**
  75818. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75819. */
  75820. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75821. private _stepSize;
  75822. private _passedProcess;
  75823. /**
  75824. * Gets a string identifying the name of the class
  75825. * @returns "StereoscopicInterlacePostProcessI" string
  75826. */
  75827. getClassName(): string;
  75828. /**
  75829. * Initializes a StereoscopicInterlacePostProcessI
  75830. * @param name The name of the effect.
  75831. * @param rigCameras The rig cameras to be appled to the post process
  75832. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75833. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75835. * @param engine The engine which the post process will be applied. (default: current engine)
  75836. * @param reusable If the post process can be reused on the same frame. (default: false)
  75837. */
  75838. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75839. }
  75840. /**
  75841. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75842. */
  75843. export class StereoscopicInterlacePostProcess extends PostProcess {
  75844. private _stepSize;
  75845. private _passedProcess;
  75846. /**
  75847. * Gets a string identifying the name of the class
  75848. * @returns "StereoscopicInterlacePostProcess" string
  75849. */
  75850. getClassName(): string;
  75851. /**
  75852. * Initializes a StereoscopicInterlacePostProcess
  75853. * @param name The name of the effect.
  75854. * @param rigCameras The rig cameras to be appled to the post process
  75855. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75857. * @param engine The engine which the post process will be applied. (default: current engine)
  75858. * @param reusable If the post process can be reused on the same frame. (default: false)
  75859. */
  75860. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75861. }
  75862. }
  75863. declare module "babylonjs/Shaders/tonemap.fragment" {
  75864. /** @hidden */
  75865. export var tonemapPixelShader: {
  75866. name: string;
  75867. shader: string;
  75868. };
  75869. }
  75870. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75871. import { Camera } from "babylonjs/Cameras/camera";
  75872. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75873. import "babylonjs/Shaders/tonemap.fragment";
  75874. import { Engine } from "babylonjs/Engines/engine";
  75875. /** Defines operator used for tonemapping */
  75876. export enum TonemappingOperator {
  75877. /** Hable */
  75878. Hable = 0,
  75879. /** Reinhard */
  75880. Reinhard = 1,
  75881. /** HejiDawson */
  75882. HejiDawson = 2,
  75883. /** Photographic */
  75884. Photographic = 3
  75885. }
  75886. /**
  75887. * Defines a post process to apply tone mapping
  75888. */
  75889. export class TonemapPostProcess extends PostProcess {
  75890. private _operator;
  75891. /** Defines the required exposure adjustement */
  75892. exposureAdjustment: number;
  75893. /**
  75894. * Gets a string identifying the name of the class
  75895. * @returns "TonemapPostProcess" string
  75896. */
  75897. getClassName(): string;
  75898. /**
  75899. * Creates a new TonemapPostProcess
  75900. * @param name defines the name of the postprocess
  75901. * @param _operator defines the operator to use
  75902. * @param exposureAdjustment defines the required exposure adjustement
  75903. * @param camera defines the camera to use (can be null)
  75904. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75905. * @param engine defines the hosting engine (can be ignore if camera is set)
  75906. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75907. */
  75908. constructor(name: string, _operator: TonemappingOperator,
  75909. /** Defines the required exposure adjustement */
  75910. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75911. }
  75912. }
  75913. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75914. /** @hidden */
  75915. export var volumetricLightScatteringPixelShader: {
  75916. name: string;
  75917. shader: string;
  75918. };
  75919. }
  75920. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75921. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75922. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75923. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75924. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75925. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75926. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75927. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75928. /** @hidden */
  75929. export var volumetricLightScatteringPassVertexShader: {
  75930. name: string;
  75931. shader: string;
  75932. };
  75933. }
  75934. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75935. /** @hidden */
  75936. export var volumetricLightScatteringPassPixelShader: {
  75937. name: string;
  75938. shader: string;
  75939. };
  75940. }
  75941. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75942. import { Vector3 } from "babylonjs/Maths/math.vector";
  75943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75944. import { Mesh } from "babylonjs/Meshes/mesh";
  75945. import { Camera } from "babylonjs/Cameras/camera";
  75946. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75947. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75948. import { Scene } from "babylonjs/scene";
  75949. import "babylonjs/Meshes/Builders/planeBuilder";
  75950. import "babylonjs/Shaders/depth.vertex";
  75951. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75952. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75953. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75954. import { Engine } from "babylonjs/Engines/engine";
  75955. /**
  75956. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75957. */
  75958. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75959. private _volumetricLightScatteringPass;
  75960. private _volumetricLightScatteringRTT;
  75961. private _viewPort;
  75962. private _screenCoordinates;
  75963. private _cachedDefines;
  75964. /**
  75965. * If not undefined, the mesh position is computed from the attached node position
  75966. */
  75967. attachedNode: {
  75968. position: Vector3;
  75969. };
  75970. /**
  75971. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75972. */
  75973. customMeshPosition: Vector3;
  75974. /**
  75975. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75976. */
  75977. useCustomMeshPosition: boolean;
  75978. /**
  75979. * If the post-process should inverse the light scattering direction
  75980. */
  75981. invert: boolean;
  75982. /**
  75983. * The internal mesh used by the post-process
  75984. */
  75985. mesh: Mesh;
  75986. /**
  75987. * @hidden
  75988. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75989. */
  75990. get useDiffuseColor(): boolean;
  75991. set useDiffuseColor(useDiffuseColor: boolean);
  75992. /**
  75993. * Array containing the excluded meshes not rendered in the internal pass
  75994. */
  75995. excludedMeshes: AbstractMesh[];
  75996. /**
  75997. * Controls the overall intensity of the post-process
  75998. */
  75999. exposure: number;
  76000. /**
  76001. * Dissipates each sample's contribution in range [0, 1]
  76002. */
  76003. decay: number;
  76004. /**
  76005. * Controls the overall intensity of each sample
  76006. */
  76007. weight: number;
  76008. /**
  76009. * Controls the density of each sample
  76010. */
  76011. density: number;
  76012. /**
  76013. * @constructor
  76014. * @param name The post-process name
  76015. * @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)
  76016. * @param camera The camera that the post-process will be attached to
  76017. * @param mesh The mesh used to create the light scattering
  76018. * @param samples The post-process quality, default 100
  76019. * @param samplingModeThe post-process filtering mode
  76020. * @param engine The babylon engine
  76021. * @param reusable If the post-process is reusable
  76022. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76023. */
  76024. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76025. /**
  76026. * Returns the string "VolumetricLightScatteringPostProcess"
  76027. * @returns "VolumetricLightScatteringPostProcess"
  76028. */
  76029. getClassName(): string;
  76030. private _isReady;
  76031. /**
  76032. * Sets the new light position for light scattering effect
  76033. * @param position The new custom light position
  76034. */
  76035. setCustomMeshPosition(position: Vector3): void;
  76036. /**
  76037. * Returns the light position for light scattering effect
  76038. * @return Vector3 The custom light position
  76039. */
  76040. getCustomMeshPosition(): Vector3;
  76041. /**
  76042. * Disposes the internal assets and detaches the post-process from the camera
  76043. */
  76044. dispose(camera: Camera): void;
  76045. /**
  76046. * Returns the render target texture used by the post-process
  76047. * @return the render target texture used by the post-process
  76048. */
  76049. getPass(): RenderTargetTexture;
  76050. private _meshExcluded;
  76051. private _createPass;
  76052. private _updateMeshScreenCoordinates;
  76053. /**
  76054. * Creates a default mesh for the Volumeric Light Scattering post-process
  76055. * @param name The mesh name
  76056. * @param scene The scene where to create the mesh
  76057. * @return the default mesh
  76058. */
  76059. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76060. }
  76061. }
  76062. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76063. /** @hidden */
  76064. export var screenSpaceCurvaturePixelShader: {
  76065. name: string;
  76066. shader: string;
  76067. };
  76068. }
  76069. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76070. import { Nullable } from "babylonjs/types";
  76071. import { Camera } from "babylonjs/Cameras/camera";
  76072. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76073. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76074. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76075. import { Engine } from "babylonjs/Engines/engine";
  76076. import { Scene } from "babylonjs/scene";
  76077. /**
  76078. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76079. */
  76080. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76081. /**
  76082. * Defines how much ridge the curvature effect displays.
  76083. */
  76084. ridge: number;
  76085. /**
  76086. * Defines how much valley the curvature effect displays.
  76087. */
  76088. valley: number;
  76089. private _geometryBufferRenderer;
  76090. /**
  76091. * Gets a string identifying the name of the class
  76092. * @returns "ScreenSpaceCurvaturePostProcess" string
  76093. */
  76094. getClassName(): string;
  76095. /**
  76096. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76097. * @param name The name of the effect.
  76098. * @param scene The scene containing the objects to blur according to their velocity.
  76099. * @param options The required width/height ratio to downsize to before computing the render pass.
  76100. * @param camera The camera to apply the render pass to.
  76101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76102. * @param engine The engine which the post process will be applied. (default: current engine)
  76103. * @param reusable If the post process can be reused on the same frame. (default: false)
  76104. * @param textureType Type of textures used when performing the post process. (default: 0)
  76105. * @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)
  76106. */
  76107. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76108. /**
  76109. * Support test.
  76110. */
  76111. static get IsSupported(): boolean;
  76112. /** @hidden */
  76113. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76114. }
  76115. }
  76116. declare module "babylonjs/PostProcesses/index" {
  76117. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76118. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76119. export * from "babylonjs/PostProcesses/bloomEffect";
  76120. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76121. export * from "babylonjs/PostProcesses/blurPostProcess";
  76122. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76123. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76124. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76125. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76126. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76127. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76128. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76129. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76130. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76131. export * from "babylonjs/PostProcesses/filterPostProcess";
  76132. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76133. export * from "babylonjs/PostProcesses/grainPostProcess";
  76134. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76135. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76136. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76137. export * from "babylonjs/PostProcesses/passPostProcess";
  76138. export * from "babylonjs/PostProcesses/postProcess";
  76139. export * from "babylonjs/PostProcesses/postProcessManager";
  76140. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76141. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76142. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76143. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76144. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76145. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76146. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76147. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76148. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76149. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76150. }
  76151. declare module "babylonjs/Probes/index" {
  76152. export * from "babylonjs/Probes/reflectionProbe";
  76153. }
  76154. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76155. import { Scene } from "babylonjs/scene";
  76156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76157. import { SmartArray } from "babylonjs/Misc/smartArray";
  76158. import { ISceneComponent } from "babylonjs/sceneComponent";
  76159. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76160. import "babylonjs/Meshes/Builders/boxBuilder";
  76161. import "babylonjs/Shaders/color.fragment";
  76162. import "babylonjs/Shaders/color.vertex";
  76163. import { Color3 } from "babylonjs/Maths/math.color";
  76164. import { Observable } from "babylonjs/Misc/observable";
  76165. module "babylonjs/scene" {
  76166. interface Scene {
  76167. /** @hidden (Backing field) */
  76168. _boundingBoxRenderer: BoundingBoxRenderer;
  76169. /** @hidden (Backing field) */
  76170. _forceShowBoundingBoxes: boolean;
  76171. /**
  76172. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76173. */
  76174. forceShowBoundingBoxes: boolean;
  76175. /**
  76176. * Gets the bounding box renderer associated with the scene
  76177. * @returns a BoundingBoxRenderer
  76178. */
  76179. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76180. }
  76181. }
  76182. module "babylonjs/Meshes/abstractMesh" {
  76183. interface AbstractMesh {
  76184. /** @hidden (Backing field) */
  76185. _showBoundingBox: boolean;
  76186. /**
  76187. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76188. */
  76189. showBoundingBox: boolean;
  76190. }
  76191. }
  76192. /**
  76193. * Component responsible of rendering the bounding box of the meshes in a scene.
  76194. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76195. */
  76196. export class BoundingBoxRenderer implements ISceneComponent {
  76197. /**
  76198. * The component name helpfull to identify the component in the list of scene components.
  76199. */
  76200. readonly name: string;
  76201. /**
  76202. * The scene the component belongs to.
  76203. */
  76204. scene: Scene;
  76205. /**
  76206. * Color of the bounding box lines placed in front of an object
  76207. */
  76208. frontColor: Color3;
  76209. /**
  76210. * Color of the bounding box lines placed behind an object
  76211. */
  76212. backColor: Color3;
  76213. /**
  76214. * Defines if the renderer should show the back lines or not
  76215. */
  76216. showBackLines: boolean;
  76217. /**
  76218. * Observable raised before rendering a bounding box
  76219. */
  76220. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76221. /**
  76222. * Observable raised after rendering a bounding box
  76223. */
  76224. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76225. /**
  76226. * @hidden
  76227. */
  76228. renderList: SmartArray<BoundingBox>;
  76229. private _colorShader;
  76230. private _vertexBuffers;
  76231. private _indexBuffer;
  76232. private _fillIndexBuffer;
  76233. private _fillIndexData;
  76234. /**
  76235. * Instantiates a new bounding box renderer in a scene.
  76236. * @param scene the scene the renderer renders in
  76237. */
  76238. constructor(scene: Scene);
  76239. /**
  76240. * Registers the component in a given scene
  76241. */
  76242. register(): void;
  76243. private _evaluateSubMesh;
  76244. private _activeMesh;
  76245. private _prepareRessources;
  76246. private _createIndexBuffer;
  76247. /**
  76248. * Rebuilds the elements related to this component in case of
  76249. * context lost for instance.
  76250. */
  76251. rebuild(): void;
  76252. /**
  76253. * @hidden
  76254. */
  76255. reset(): void;
  76256. /**
  76257. * Render the bounding boxes of a specific rendering group
  76258. * @param renderingGroupId defines the rendering group to render
  76259. */
  76260. render(renderingGroupId: number): void;
  76261. /**
  76262. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76263. * @param mesh Define the mesh to render the occlusion bounding box for
  76264. */
  76265. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76266. /**
  76267. * Dispose and release the resources attached to this renderer.
  76268. */
  76269. dispose(): void;
  76270. }
  76271. }
  76272. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76273. import { Nullable } from "babylonjs/types";
  76274. import { Scene } from "babylonjs/scene";
  76275. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76276. import { Camera } from "babylonjs/Cameras/camera";
  76277. import { ISceneComponent } from "babylonjs/sceneComponent";
  76278. module "babylonjs/scene" {
  76279. interface Scene {
  76280. /** @hidden (Backing field) */
  76281. _depthRenderer: {
  76282. [id: string]: DepthRenderer;
  76283. };
  76284. /**
  76285. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76286. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76287. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76288. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76289. * @returns the created depth renderer
  76290. */
  76291. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76292. /**
  76293. * Disables a depth renderer for a given camera
  76294. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76295. */
  76296. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76297. }
  76298. }
  76299. /**
  76300. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76301. * in several rendering techniques.
  76302. */
  76303. export class DepthRendererSceneComponent implements ISceneComponent {
  76304. /**
  76305. * The component name helpfull to identify the component in the list of scene components.
  76306. */
  76307. readonly name: string;
  76308. /**
  76309. * The scene the component belongs to.
  76310. */
  76311. scene: Scene;
  76312. /**
  76313. * Creates a new instance of the component for the given scene
  76314. * @param scene Defines the scene to register the component in
  76315. */
  76316. constructor(scene: Scene);
  76317. /**
  76318. * Registers the component in a given scene
  76319. */
  76320. register(): void;
  76321. /**
  76322. * Rebuilds the elements related to this component in case of
  76323. * context lost for instance.
  76324. */
  76325. rebuild(): void;
  76326. /**
  76327. * Disposes the component and the associated ressources
  76328. */
  76329. dispose(): void;
  76330. private _gatherRenderTargets;
  76331. private _gatherActiveCameraRenderTargets;
  76332. }
  76333. }
  76334. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76335. import { Nullable } from "babylonjs/types";
  76336. import { Scene } from "babylonjs/scene";
  76337. import { ISceneComponent } from "babylonjs/sceneComponent";
  76338. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76339. module "babylonjs/abstractScene" {
  76340. interface AbstractScene {
  76341. /** @hidden (Backing field) */
  76342. _prePassRenderer: Nullable<PrePassRenderer>;
  76343. /**
  76344. * Gets or Sets the current prepass renderer associated to the scene.
  76345. */
  76346. prePassRenderer: Nullable<PrePassRenderer>;
  76347. /**
  76348. * Enables the prepass and associates it with the scene
  76349. * @returns the PrePassRenderer
  76350. */
  76351. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76352. /**
  76353. * Disables the prepass associated with the scene
  76354. */
  76355. disablePrePassRenderer(): void;
  76356. }
  76357. }
  76358. /**
  76359. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76360. * in several rendering techniques.
  76361. */
  76362. export class PrePassRendererSceneComponent implements ISceneComponent {
  76363. /**
  76364. * The component name helpful to identify the component in the list of scene components.
  76365. */
  76366. readonly name: string;
  76367. /**
  76368. * The scene the component belongs to.
  76369. */
  76370. scene: Scene;
  76371. /**
  76372. * Creates a new instance of the component for the given scene
  76373. * @param scene Defines the scene to register the component in
  76374. */
  76375. constructor(scene: Scene);
  76376. /**
  76377. * Registers the component in a given scene
  76378. */
  76379. register(): void;
  76380. private _beforeCameraDraw;
  76381. private _afterCameraDraw;
  76382. private _beforeClearStage;
  76383. /**
  76384. * Rebuilds the elements related to this component in case of
  76385. * context lost for instance.
  76386. */
  76387. rebuild(): void;
  76388. /**
  76389. * Disposes the component and the associated ressources
  76390. */
  76391. dispose(): void;
  76392. }
  76393. }
  76394. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76395. /** @hidden */
  76396. export var fibonacci: {
  76397. name: string;
  76398. shader: string;
  76399. };
  76400. }
  76401. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76402. /** @hidden */
  76403. export var diffusionProfile: {
  76404. name: string;
  76405. shader: string;
  76406. };
  76407. }
  76408. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76409. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76410. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76411. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76412. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76413. /** @hidden */
  76414. export var subSurfaceScatteringPixelShader: {
  76415. name: string;
  76416. shader: string;
  76417. };
  76418. }
  76419. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76420. import { Nullable } from "babylonjs/types";
  76421. import { Camera } from "babylonjs/Cameras/camera";
  76422. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76423. import { Engine } from "babylonjs/Engines/engine";
  76424. import { Scene } from "babylonjs/scene";
  76425. import "babylonjs/Shaders/imageProcessing.fragment";
  76426. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76427. import "babylonjs/Shaders/postprocess.vertex";
  76428. /**
  76429. * Sub surface scattering post process
  76430. */
  76431. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76432. /**
  76433. * Gets a string identifying the name of the class
  76434. * @returns "SubSurfaceScatteringPostProcess" string
  76435. */
  76436. getClassName(): string;
  76437. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76438. }
  76439. }
  76440. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76441. import { Scene } from "babylonjs/scene";
  76442. import { Color3 } from "babylonjs/Maths/math.color";
  76443. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76444. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76445. /**
  76446. * Contains all parameters needed for the prepass to perform
  76447. * screen space subsurface scattering
  76448. */
  76449. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76450. /** @hidden */
  76451. static _SceneComponentInitialization: (scene: Scene) => void;
  76452. private _ssDiffusionS;
  76453. private _ssFilterRadii;
  76454. private _ssDiffusionD;
  76455. /**
  76456. * Post process to attach for screen space subsurface scattering
  76457. */
  76458. postProcess: SubSurfaceScatteringPostProcess;
  76459. /**
  76460. * Diffusion profile color for subsurface scattering
  76461. */
  76462. get ssDiffusionS(): number[];
  76463. /**
  76464. * Diffusion profile max color channel value for subsurface scattering
  76465. */
  76466. get ssDiffusionD(): number[];
  76467. /**
  76468. * Diffusion profile filter radius for subsurface scattering
  76469. */
  76470. get ssFilterRadii(): number[];
  76471. /**
  76472. * Is subsurface enabled
  76473. */
  76474. enabled: boolean;
  76475. /**
  76476. * Name of the configuration
  76477. */
  76478. name: string;
  76479. /**
  76480. * Diffusion profile colors for subsurface scattering
  76481. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76482. * See ...
  76483. * Note that you can only store up to 5 of them
  76484. */
  76485. ssDiffusionProfileColors: Color3[];
  76486. /**
  76487. * Defines the ratio real world => scene units.
  76488. * Used for subsurface scattering
  76489. */
  76490. metersPerUnit: number;
  76491. /**
  76492. * Textures that should be present in the MRT for this effect to work
  76493. */
  76494. readonly texturesRequired: number[];
  76495. private _scene;
  76496. /**
  76497. * Builds a subsurface configuration object
  76498. * @param scene The scene
  76499. */
  76500. constructor(scene: Scene);
  76501. /**
  76502. * Adds a new diffusion profile.
  76503. * Useful for more realistic subsurface scattering on diverse materials.
  76504. * @param color The color of the diffusion profile. Should be the average color of the material.
  76505. * @return The index of the diffusion profile for the material subsurface configuration
  76506. */
  76507. addDiffusionProfile(color: Color3): number;
  76508. /**
  76509. * Creates the sss post process
  76510. * @return The created post process
  76511. */
  76512. createPostProcess(): SubSurfaceScatteringPostProcess;
  76513. /**
  76514. * Deletes all diffusion profiles.
  76515. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76516. */
  76517. clearAllDiffusionProfiles(): void;
  76518. /**
  76519. * Disposes this object
  76520. */
  76521. dispose(): void;
  76522. /**
  76523. * @hidden
  76524. * https://zero-radiance.github.io/post/sampling-diffusion/
  76525. *
  76526. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76527. * ------------------------------------------------------------------------------------
  76528. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76529. * PDF[r, phi, s] = r * R[r, phi, s]
  76530. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76531. * ------------------------------------------------------------------------------------
  76532. * We importance sample the color channel with the widest scattering distance.
  76533. */
  76534. getDiffusionProfileParameters(color: Color3): number;
  76535. /**
  76536. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76537. * 'u' is the random number (the value of the CDF): [0, 1).
  76538. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76539. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76540. */
  76541. private _sampleBurleyDiffusionProfile;
  76542. }
  76543. }
  76544. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76545. import { Nullable } from "babylonjs/types";
  76546. import { Scene } from "babylonjs/scene";
  76547. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76548. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76549. import { AbstractScene } from "babylonjs/abstractScene";
  76550. module "babylonjs/abstractScene" {
  76551. interface AbstractScene {
  76552. /** @hidden (Backing field) */
  76553. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76554. /**
  76555. * Gets or Sets the current prepass renderer associated to the scene.
  76556. */
  76557. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76558. /**
  76559. * Enables the subsurface effect for prepass
  76560. * @returns the SubSurfaceConfiguration
  76561. */
  76562. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76563. /**
  76564. * Disables the subsurface effect for prepass
  76565. */
  76566. disableSubSurfaceForPrePass(): void;
  76567. }
  76568. }
  76569. /**
  76570. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76571. * in several rendering techniques.
  76572. */
  76573. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76574. /**
  76575. * The component name helpful to identify the component in the list of scene components.
  76576. */
  76577. readonly name: string;
  76578. /**
  76579. * The scene the component belongs to.
  76580. */
  76581. scene: Scene;
  76582. /**
  76583. * Creates a new instance of the component for the given scene
  76584. * @param scene Defines the scene to register the component in
  76585. */
  76586. constructor(scene: Scene);
  76587. /**
  76588. * Registers the component in a given scene
  76589. */
  76590. register(): void;
  76591. /**
  76592. * Serializes the component data to the specified json object
  76593. * @param serializationObject The object to serialize to
  76594. */
  76595. serialize(serializationObject: any): void;
  76596. /**
  76597. * Adds all the elements from the container to the scene
  76598. * @param container the container holding the elements
  76599. */
  76600. addFromContainer(container: AbstractScene): void;
  76601. /**
  76602. * Removes all the elements in the container from the scene
  76603. * @param container contains the elements to remove
  76604. * @param dispose if the removed element should be disposed (default: false)
  76605. */
  76606. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76607. /**
  76608. * Rebuilds the elements related to this component in case of
  76609. * context lost for instance.
  76610. */
  76611. rebuild(): void;
  76612. /**
  76613. * Disposes the component and the associated ressources
  76614. */
  76615. dispose(): void;
  76616. }
  76617. }
  76618. declare module "babylonjs/Shaders/outline.fragment" {
  76619. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76620. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76621. /** @hidden */
  76622. export var outlinePixelShader: {
  76623. name: string;
  76624. shader: string;
  76625. };
  76626. }
  76627. declare module "babylonjs/Shaders/outline.vertex" {
  76628. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76629. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76630. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76631. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76632. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76633. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76634. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76635. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76636. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76637. /** @hidden */
  76638. export var outlineVertexShader: {
  76639. name: string;
  76640. shader: string;
  76641. };
  76642. }
  76643. declare module "babylonjs/Rendering/outlineRenderer" {
  76644. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76645. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76646. import { Scene } from "babylonjs/scene";
  76647. import { ISceneComponent } from "babylonjs/sceneComponent";
  76648. import "babylonjs/Shaders/outline.fragment";
  76649. import "babylonjs/Shaders/outline.vertex";
  76650. module "babylonjs/scene" {
  76651. interface Scene {
  76652. /** @hidden */
  76653. _outlineRenderer: OutlineRenderer;
  76654. /**
  76655. * Gets the outline renderer associated with the scene
  76656. * @returns a OutlineRenderer
  76657. */
  76658. getOutlineRenderer(): OutlineRenderer;
  76659. }
  76660. }
  76661. module "babylonjs/Meshes/abstractMesh" {
  76662. interface AbstractMesh {
  76663. /** @hidden (Backing field) */
  76664. _renderOutline: boolean;
  76665. /**
  76666. * Gets or sets a boolean indicating if the outline must be rendered as well
  76667. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76668. */
  76669. renderOutline: boolean;
  76670. /** @hidden (Backing field) */
  76671. _renderOverlay: boolean;
  76672. /**
  76673. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76674. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76675. */
  76676. renderOverlay: boolean;
  76677. }
  76678. }
  76679. /**
  76680. * This class is responsible to draw bothe outline/overlay of meshes.
  76681. * It should not be used directly but through the available method on mesh.
  76682. */
  76683. export class OutlineRenderer implements ISceneComponent {
  76684. /**
  76685. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76686. */
  76687. private static _StencilReference;
  76688. /**
  76689. * The name of the component. Each component must have a unique name.
  76690. */
  76691. name: string;
  76692. /**
  76693. * The scene the component belongs to.
  76694. */
  76695. scene: Scene;
  76696. /**
  76697. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76698. */
  76699. zOffset: number;
  76700. private _engine;
  76701. private _effect;
  76702. private _cachedDefines;
  76703. private _savedDepthWrite;
  76704. /**
  76705. * Instantiates a new outline renderer. (There could be only one per scene).
  76706. * @param scene Defines the scene it belongs to
  76707. */
  76708. constructor(scene: Scene);
  76709. /**
  76710. * Register the component to one instance of a scene.
  76711. */
  76712. register(): void;
  76713. /**
  76714. * Rebuilds the elements related to this component in case of
  76715. * context lost for instance.
  76716. */
  76717. rebuild(): void;
  76718. /**
  76719. * Disposes the component and the associated ressources.
  76720. */
  76721. dispose(): void;
  76722. /**
  76723. * Renders the outline in the canvas.
  76724. * @param subMesh Defines the sumesh to render
  76725. * @param batch Defines the batch of meshes in case of instances
  76726. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76727. */
  76728. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76729. /**
  76730. * Returns whether or not the outline renderer is ready for a given submesh.
  76731. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76732. * @param subMesh Defines the submesh to check readyness for
  76733. * @param useInstances Defines wheter wee are trying to render instances or not
  76734. * @returns true if ready otherwise false
  76735. */
  76736. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76737. private _beforeRenderingMesh;
  76738. private _afterRenderingMesh;
  76739. }
  76740. }
  76741. declare module "babylonjs/Rendering/index" {
  76742. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76743. export * from "babylonjs/Rendering/depthRenderer";
  76744. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76745. export * from "babylonjs/Rendering/edgesRenderer";
  76746. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76747. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76748. export * from "babylonjs/Rendering/prePassRenderer";
  76749. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76750. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76751. export * from "babylonjs/Rendering/outlineRenderer";
  76752. export * from "babylonjs/Rendering/renderingGroup";
  76753. export * from "babylonjs/Rendering/renderingManager";
  76754. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76755. }
  76756. declare module "babylonjs/Sprites/ISprites" {
  76757. /**
  76758. * Defines the basic options interface of a Sprite Frame Source Size.
  76759. */
  76760. export interface ISpriteJSONSpriteSourceSize {
  76761. /**
  76762. * number of the original width of the Frame
  76763. */
  76764. w: number;
  76765. /**
  76766. * number of the original height of the Frame
  76767. */
  76768. h: number;
  76769. }
  76770. /**
  76771. * Defines the basic options interface of a Sprite Frame Data.
  76772. */
  76773. export interface ISpriteJSONSpriteFrameData {
  76774. /**
  76775. * number of the x offset of the Frame
  76776. */
  76777. x: number;
  76778. /**
  76779. * number of the y offset of the Frame
  76780. */
  76781. y: number;
  76782. /**
  76783. * number of the width of the Frame
  76784. */
  76785. w: number;
  76786. /**
  76787. * number of the height of the Frame
  76788. */
  76789. h: number;
  76790. }
  76791. /**
  76792. * Defines the basic options interface of a JSON Sprite.
  76793. */
  76794. export interface ISpriteJSONSprite {
  76795. /**
  76796. * string name of the Frame
  76797. */
  76798. filename: string;
  76799. /**
  76800. * ISpriteJSONSpriteFrame basic object of the frame data
  76801. */
  76802. frame: ISpriteJSONSpriteFrameData;
  76803. /**
  76804. * boolean to flag is the frame was rotated.
  76805. */
  76806. rotated: boolean;
  76807. /**
  76808. * boolean to flag is the frame was trimmed.
  76809. */
  76810. trimmed: boolean;
  76811. /**
  76812. * ISpriteJSONSpriteFrame basic object of the source data
  76813. */
  76814. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76815. /**
  76816. * ISpriteJSONSpriteFrame basic object of the source data
  76817. */
  76818. sourceSize: ISpriteJSONSpriteSourceSize;
  76819. }
  76820. /**
  76821. * Defines the basic options interface of a JSON atlas.
  76822. */
  76823. export interface ISpriteJSONAtlas {
  76824. /**
  76825. * Array of objects that contain the frame data.
  76826. */
  76827. frames: Array<ISpriteJSONSprite>;
  76828. /**
  76829. * object basic object containing the sprite meta data.
  76830. */
  76831. meta?: object;
  76832. }
  76833. }
  76834. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76835. /** @hidden */
  76836. export var spriteMapPixelShader: {
  76837. name: string;
  76838. shader: string;
  76839. };
  76840. }
  76841. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76842. /** @hidden */
  76843. export var spriteMapVertexShader: {
  76844. name: string;
  76845. shader: string;
  76846. };
  76847. }
  76848. declare module "babylonjs/Sprites/spriteMap" {
  76849. import { IDisposable, Scene } from "babylonjs/scene";
  76850. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76851. import { Texture } from "babylonjs/Materials/Textures/texture";
  76852. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76853. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76854. import "babylonjs/Meshes/Builders/planeBuilder";
  76855. import "babylonjs/Shaders/spriteMap.fragment";
  76856. import "babylonjs/Shaders/spriteMap.vertex";
  76857. /**
  76858. * Defines the basic options interface of a SpriteMap
  76859. */
  76860. export interface ISpriteMapOptions {
  76861. /**
  76862. * Vector2 of the number of cells in the grid.
  76863. */
  76864. stageSize?: Vector2;
  76865. /**
  76866. * Vector2 of the size of the output plane in World Units.
  76867. */
  76868. outputSize?: Vector2;
  76869. /**
  76870. * Vector3 of the position of the output plane in World Units.
  76871. */
  76872. outputPosition?: Vector3;
  76873. /**
  76874. * Vector3 of the rotation of the output plane.
  76875. */
  76876. outputRotation?: Vector3;
  76877. /**
  76878. * number of layers that the system will reserve in resources.
  76879. */
  76880. layerCount?: number;
  76881. /**
  76882. * number of max animation frames a single cell will reserve in resources.
  76883. */
  76884. maxAnimationFrames?: number;
  76885. /**
  76886. * number cell index of the base tile when the system compiles.
  76887. */
  76888. baseTile?: number;
  76889. /**
  76890. * boolean flip the sprite after its been repositioned by the framing data.
  76891. */
  76892. flipU?: boolean;
  76893. /**
  76894. * Vector3 scalar of the global RGB values of the SpriteMap.
  76895. */
  76896. colorMultiply?: Vector3;
  76897. }
  76898. /**
  76899. * Defines the IDisposable interface in order to be cleanable from resources.
  76900. */
  76901. export interface ISpriteMap extends IDisposable {
  76902. /**
  76903. * String name of the SpriteMap.
  76904. */
  76905. name: string;
  76906. /**
  76907. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76908. */
  76909. atlasJSON: ISpriteJSONAtlas;
  76910. /**
  76911. * Texture of the SpriteMap.
  76912. */
  76913. spriteSheet: Texture;
  76914. /**
  76915. * The parameters to initialize the SpriteMap with.
  76916. */
  76917. options: ISpriteMapOptions;
  76918. }
  76919. /**
  76920. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76921. */
  76922. export class SpriteMap implements ISpriteMap {
  76923. /** The Name of the spriteMap */
  76924. name: string;
  76925. /** The JSON file with the frame and meta data */
  76926. atlasJSON: ISpriteJSONAtlas;
  76927. /** The systems Sprite Sheet Texture */
  76928. spriteSheet: Texture;
  76929. /** Arguments passed with the Constructor */
  76930. options: ISpriteMapOptions;
  76931. /** Public Sprite Storage array, parsed from atlasJSON */
  76932. sprites: Array<ISpriteJSONSprite>;
  76933. /** Returns the Number of Sprites in the System */
  76934. get spriteCount(): number;
  76935. /** Returns the Position of Output Plane*/
  76936. get position(): Vector3;
  76937. /** Returns the Position of Output Plane*/
  76938. set position(v: Vector3);
  76939. /** Returns the Rotation of Output Plane*/
  76940. get rotation(): Vector3;
  76941. /** Returns the Rotation of Output Plane*/
  76942. set rotation(v: Vector3);
  76943. /** Sets the AnimationMap*/
  76944. get animationMap(): RawTexture;
  76945. /** Sets the AnimationMap*/
  76946. set animationMap(v: RawTexture);
  76947. /** Scene that the SpriteMap was created in */
  76948. private _scene;
  76949. /** Texture Buffer of Float32 that holds tile frame data*/
  76950. private _frameMap;
  76951. /** Texture Buffers of Float32 that holds tileMap data*/
  76952. private _tileMaps;
  76953. /** Texture Buffer of Float32 that holds Animation Data*/
  76954. private _animationMap;
  76955. /** Custom ShaderMaterial Central to the System*/
  76956. private _material;
  76957. /** Custom ShaderMaterial Central to the System*/
  76958. private _output;
  76959. /** Systems Time Ticker*/
  76960. private _time;
  76961. /**
  76962. * Creates a new SpriteMap
  76963. * @param name defines the SpriteMaps Name
  76964. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76965. * @param spriteSheet is the Texture that the Sprites are on.
  76966. * @param options a basic deployment configuration
  76967. * @param scene The Scene that the map is deployed on
  76968. */
  76969. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76970. /**
  76971. * Returns tileID location
  76972. * @returns Vector2 the cell position ID
  76973. */
  76974. getTileID(): Vector2;
  76975. /**
  76976. * Gets the UV location of the mouse over the SpriteMap.
  76977. * @returns Vector2 the UV position of the mouse interaction
  76978. */
  76979. getMousePosition(): Vector2;
  76980. /**
  76981. * Creates the "frame" texture Buffer
  76982. * -------------------------------------
  76983. * Structure of frames
  76984. * "filename": "Falling-Water-2.png",
  76985. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76986. * "rotated": true,
  76987. * "trimmed": true,
  76988. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76989. * "sourceSize": {"w":32,"h":32}
  76990. * @returns RawTexture of the frameMap
  76991. */
  76992. private _createFrameBuffer;
  76993. /**
  76994. * Creates the tileMap texture Buffer
  76995. * @param buffer normally and array of numbers, or a false to generate from scratch
  76996. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76997. * @returns RawTexture of the tileMap
  76998. */
  76999. private _createTileBuffer;
  77000. /**
  77001. * Modifies the data of the tileMaps
  77002. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77003. * @param pos is the iVector2 Coordinates of the Tile
  77004. * @param tile The SpriteIndex of the new Tile
  77005. */
  77006. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77007. /**
  77008. * Creates the animationMap texture Buffer
  77009. * @param buffer normally and array of numbers, or a false to generate from scratch
  77010. * @returns RawTexture of the animationMap
  77011. */
  77012. private _createTileAnimationBuffer;
  77013. /**
  77014. * Modifies the data of the animationMap
  77015. * @param cellID is the Index of the Sprite
  77016. * @param _frame is the target Animation frame
  77017. * @param toCell is the Target Index of the next frame of the animation
  77018. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77019. * @param speed is a global scalar of the time variable on the map.
  77020. */
  77021. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77022. /**
  77023. * Exports the .tilemaps file
  77024. */
  77025. saveTileMaps(): void;
  77026. /**
  77027. * Imports the .tilemaps file
  77028. * @param url of the .tilemaps file
  77029. */
  77030. loadTileMaps(url: string): void;
  77031. /**
  77032. * Release associated resources
  77033. */
  77034. dispose(): void;
  77035. }
  77036. }
  77037. declare module "babylonjs/Sprites/spritePackedManager" {
  77038. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77039. import { Scene } from "babylonjs/scene";
  77040. /**
  77041. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77042. * @see https://doc.babylonjs.com/babylon101/sprites
  77043. */
  77044. export class SpritePackedManager extends SpriteManager {
  77045. /** defines the packed manager's name */
  77046. name: string;
  77047. /**
  77048. * Creates a new sprite manager from a packed sprite sheet
  77049. * @param name defines the manager's name
  77050. * @param imgUrl defines the sprite sheet url
  77051. * @param capacity defines the maximum allowed number of sprites
  77052. * @param scene defines the hosting scene
  77053. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77054. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77055. * @param samplingMode defines the smapling mode to use with spritesheet
  77056. * @param fromPacked set to true; do not alter
  77057. */
  77058. constructor(
  77059. /** defines the packed manager's name */
  77060. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77061. }
  77062. }
  77063. declare module "babylonjs/Sprites/index" {
  77064. export * from "babylonjs/Sprites/sprite";
  77065. export * from "babylonjs/Sprites/ISprites";
  77066. export * from "babylonjs/Sprites/spriteManager";
  77067. export * from "babylonjs/Sprites/spriteMap";
  77068. export * from "babylonjs/Sprites/spritePackedManager";
  77069. export * from "babylonjs/Sprites/spriteSceneComponent";
  77070. }
  77071. declare module "babylonjs/States/index" {
  77072. export * from "babylonjs/States/alphaCullingState";
  77073. export * from "babylonjs/States/depthCullingState";
  77074. export * from "babylonjs/States/stencilState";
  77075. }
  77076. declare module "babylonjs/Misc/assetsManager" {
  77077. import { Scene } from "babylonjs/scene";
  77078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77079. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77080. import { Skeleton } from "babylonjs/Bones/skeleton";
  77081. import { Observable } from "babylonjs/Misc/observable";
  77082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77083. import { Texture } from "babylonjs/Materials/Textures/texture";
  77084. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77085. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77086. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77087. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77088. import { AssetContainer } from "babylonjs/assetContainer";
  77089. /**
  77090. * Defines the list of states available for a task inside a AssetsManager
  77091. */
  77092. export enum AssetTaskState {
  77093. /**
  77094. * Initialization
  77095. */
  77096. INIT = 0,
  77097. /**
  77098. * Running
  77099. */
  77100. RUNNING = 1,
  77101. /**
  77102. * Done
  77103. */
  77104. DONE = 2,
  77105. /**
  77106. * Error
  77107. */
  77108. ERROR = 3
  77109. }
  77110. /**
  77111. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77112. */
  77113. export abstract class AbstractAssetTask {
  77114. /**
  77115. * Task name
  77116. */ name: string;
  77117. /**
  77118. * Callback called when the task is successful
  77119. */
  77120. onSuccess: (task: any) => void;
  77121. /**
  77122. * Callback called when the task is not successful
  77123. */
  77124. onError: (task: any, message?: string, exception?: any) => void;
  77125. /**
  77126. * Creates a new AssetsManager
  77127. * @param name defines the name of the task
  77128. */
  77129. constructor(
  77130. /**
  77131. * Task name
  77132. */ name: string);
  77133. private _isCompleted;
  77134. private _taskState;
  77135. private _errorObject;
  77136. /**
  77137. * Get if the task is completed
  77138. */
  77139. get isCompleted(): boolean;
  77140. /**
  77141. * Gets the current state of the task
  77142. */
  77143. get taskState(): AssetTaskState;
  77144. /**
  77145. * Gets the current error object (if task is in error)
  77146. */
  77147. get errorObject(): {
  77148. message?: string;
  77149. exception?: any;
  77150. };
  77151. /**
  77152. * Internal only
  77153. * @hidden
  77154. */
  77155. _setErrorObject(message?: string, exception?: any): void;
  77156. /**
  77157. * Execute the current task
  77158. * @param scene defines the scene where you want your assets to be loaded
  77159. * @param onSuccess is a callback called when the task is successfully executed
  77160. * @param onError is a callback called if an error occurs
  77161. */
  77162. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77163. /**
  77164. * Execute the current task
  77165. * @param scene defines the scene where you want your assets to be loaded
  77166. * @param onSuccess is a callback called when the task is successfully executed
  77167. * @param onError is a callback called if an error occurs
  77168. */
  77169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77170. /**
  77171. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77172. * This can be used with failed tasks that have the reason for failure fixed.
  77173. */
  77174. reset(): void;
  77175. private onErrorCallback;
  77176. private onDoneCallback;
  77177. }
  77178. /**
  77179. * Define the interface used by progress events raised during assets loading
  77180. */
  77181. export interface IAssetsProgressEvent {
  77182. /**
  77183. * Defines the number of remaining tasks to process
  77184. */
  77185. remainingCount: number;
  77186. /**
  77187. * Defines the total number of tasks
  77188. */
  77189. totalCount: number;
  77190. /**
  77191. * Defines the task that was just processed
  77192. */
  77193. task: AbstractAssetTask;
  77194. }
  77195. /**
  77196. * Class used to share progress information about assets loading
  77197. */
  77198. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77199. /**
  77200. * Defines the number of remaining tasks to process
  77201. */
  77202. remainingCount: number;
  77203. /**
  77204. * Defines the total number of tasks
  77205. */
  77206. totalCount: number;
  77207. /**
  77208. * Defines the task that was just processed
  77209. */
  77210. task: AbstractAssetTask;
  77211. /**
  77212. * Creates a AssetsProgressEvent
  77213. * @param remainingCount defines the number of remaining tasks to process
  77214. * @param totalCount defines the total number of tasks
  77215. * @param task defines the task that was just processed
  77216. */
  77217. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77218. }
  77219. /**
  77220. * Define a task used by AssetsManager to load assets into a container
  77221. */
  77222. export class ContainerAssetTask extends AbstractAssetTask {
  77223. /**
  77224. * Defines the name of the task
  77225. */
  77226. name: string;
  77227. /**
  77228. * Defines the list of mesh's names you want to load
  77229. */
  77230. meshesNames: any;
  77231. /**
  77232. * Defines the root url to use as a base to load your meshes and associated resources
  77233. */
  77234. rootUrl: string;
  77235. /**
  77236. * Defines the filename or File of the scene to load from
  77237. */
  77238. sceneFilename: string | File;
  77239. /**
  77240. * Get the loaded asset container
  77241. */
  77242. loadedContainer: AssetContainer;
  77243. /**
  77244. * Gets the list of loaded meshes
  77245. */
  77246. loadedMeshes: Array<AbstractMesh>;
  77247. /**
  77248. * Gets the list of loaded particle systems
  77249. */
  77250. loadedParticleSystems: Array<IParticleSystem>;
  77251. /**
  77252. * Gets the list of loaded skeletons
  77253. */
  77254. loadedSkeletons: Array<Skeleton>;
  77255. /**
  77256. * Gets the list of loaded animation groups
  77257. */
  77258. loadedAnimationGroups: Array<AnimationGroup>;
  77259. /**
  77260. * Callback called when the task is successful
  77261. */
  77262. onSuccess: (task: ContainerAssetTask) => void;
  77263. /**
  77264. * Callback called when the task is successful
  77265. */
  77266. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77267. /**
  77268. * Creates a new ContainerAssetTask
  77269. * @param name defines the name of the task
  77270. * @param meshesNames defines the list of mesh's names you want to load
  77271. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77272. * @param sceneFilename defines the filename or File of the scene to load from
  77273. */
  77274. constructor(
  77275. /**
  77276. * Defines the name of the task
  77277. */
  77278. name: string,
  77279. /**
  77280. * Defines the list of mesh's names you want to load
  77281. */
  77282. meshesNames: any,
  77283. /**
  77284. * Defines the root url to use as a base to load your meshes and associated resources
  77285. */
  77286. rootUrl: string,
  77287. /**
  77288. * Defines the filename or File of the scene to load from
  77289. */
  77290. sceneFilename: string | File);
  77291. /**
  77292. * Execute the current task
  77293. * @param scene defines the scene where you want your assets to be loaded
  77294. * @param onSuccess is a callback called when the task is successfully executed
  77295. * @param onError is a callback called if an error occurs
  77296. */
  77297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77298. }
  77299. /**
  77300. * Define a task used by AssetsManager to load meshes
  77301. */
  77302. export class MeshAssetTask extends AbstractAssetTask {
  77303. /**
  77304. * Defines the name of the task
  77305. */
  77306. name: string;
  77307. /**
  77308. * Defines the list of mesh's names you want to load
  77309. */
  77310. meshesNames: any;
  77311. /**
  77312. * Defines the root url to use as a base to load your meshes and associated resources
  77313. */
  77314. rootUrl: string;
  77315. /**
  77316. * Defines the filename or File of the scene to load from
  77317. */
  77318. sceneFilename: string | File;
  77319. /**
  77320. * Gets the list of loaded meshes
  77321. */
  77322. loadedMeshes: Array<AbstractMesh>;
  77323. /**
  77324. * Gets the list of loaded particle systems
  77325. */
  77326. loadedParticleSystems: Array<IParticleSystem>;
  77327. /**
  77328. * Gets the list of loaded skeletons
  77329. */
  77330. loadedSkeletons: Array<Skeleton>;
  77331. /**
  77332. * Gets the list of loaded animation groups
  77333. */
  77334. loadedAnimationGroups: Array<AnimationGroup>;
  77335. /**
  77336. * Callback called when the task is successful
  77337. */
  77338. onSuccess: (task: MeshAssetTask) => void;
  77339. /**
  77340. * Callback called when the task is successful
  77341. */
  77342. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77343. /**
  77344. * Creates a new MeshAssetTask
  77345. * @param name defines the name of the task
  77346. * @param meshesNames defines the list of mesh's names you want to load
  77347. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77348. * @param sceneFilename defines the filename or File of the scene to load from
  77349. */
  77350. constructor(
  77351. /**
  77352. * Defines the name of the task
  77353. */
  77354. name: string,
  77355. /**
  77356. * Defines the list of mesh's names you want to load
  77357. */
  77358. meshesNames: any,
  77359. /**
  77360. * Defines the root url to use as a base to load your meshes and associated resources
  77361. */
  77362. rootUrl: string,
  77363. /**
  77364. * Defines the filename or File of the scene to load from
  77365. */
  77366. sceneFilename: string | File);
  77367. /**
  77368. * Execute the current task
  77369. * @param scene defines the scene where you want your assets to be loaded
  77370. * @param onSuccess is a callback called when the task is successfully executed
  77371. * @param onError is a callback called if an error occurs
  77372. */
  77373. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77374. }
  77375. /**
  77376. * Define a task used by AssetsManager to load text content
  77377. */
  77378. export class TextFileAssetTask extends AbstractAssetTask {
  77379. /**
  77380. * Defines the name of the task
  77381. */
  77382. name: string;
  77383. /**
  77384. * Defines the location of the file to load
  77385. */
  77386. url: string;
  77387. /**
  77388. * Gets the loaded text string
  77389. */
  77390. text: string;
  77391. /**
  77392. * Callback called when the task is successful
  77393. */
  77394. onSuccess: (task: TextFileAssetTask) => void;
  77395. /**
  77396. * Callback called when the task is successful
  77397. */
  77398. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77399. /**
  77400. * Creates a new TextFileAssetTask object
  77401. * @param name defines the name of the task
  77402. * @param url defines the location of the file to load
  77403. */
  77404. constructor(
  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. * Execute the current task
  77415. * @param scene defines the scene where you want your assets to be loaded
  77416. * @param onSuccess is a callback called when the task is successfully executed
  77417. * @param onError is a callback called if an error occurs
  77418. */
  77419. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77420. }
  77421. /**
  77422. * Define a task used by AssetsManager to load binary data
  77423. */
  77424. export class BinaryFileAssetTask extends AbstractAssetTask {
  77425. /**
  77426. * Defines the name of the task
  77427. */
  77428. name: string;
  77429. /**
  77430. * Defines the location of the file to load
  77431. */
  77432. url: string;
  77433. /**
  77434. * Gets the lodaded data (as an array buffer)
  77435. */
  77436. data: ArrayBuffer;
  77437. /**
  77438. * Callback called when the task is successful
  77439. */
  77440. onSuccess: (task: BinaryFileAssetTask) => void;
  77441. /**
  77442. * Callback called when the task is successful
  77443. */
  77444. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77445. /**
  77446. * Creates a new BinaryFileAssetTask object
  77447. * @param name defines the name of the new task
  77448. * @param url defines the location of the file to load
  77449. */
  77450. constructor(
  77451. /**
  77452. * Defines the name of the task
  77453. */
  77454. name: string,
  77455. /**
  77456. * Defines the location of the file to load
  77457. */
  77458. url: string);
  77459. /**
  77460. * Execute the current task
  77461. * @param scene defines the scene where you want your assets to be loaded
  77462. * @param onSuccess is a callback called when the task is successfully executed
  77463. * @param onError is a callback called if an error occurs
  77464. */
  77465. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77466. }
  77467. /**
  77468. * Define a task used by AssetsManager to load images
  77469. */
  77470. export class ImageAssetTask extends AbstractAssetTask {
  77471. /**
  77472. * Defines the name of the task
  77473. */
  77474. name: string;
  77475. /**
  77476. * Defines the location of the image to load
  77477. */
  77478. url: string;
  77479. /**
  77480. * Gets the loaded images
  77481. */
  77482. image: HTMLImageElement;
  77483. /**
  77484. * Callback called when the task is successful
  77485. */
  77486. onSuccess: (task: ImageAssetTask) => void;
  77487. /**
  77488. * Callback called when the task is successful
  77489. */
  77490. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77491. /**
  77492. * Creates a new ImageAssetTask
  77493. * @param name defines the name of the task
  77494. * @param url defines the location of the image to load
  77495. */
  77496. constructor(
  77497. /**
  77498. * Defines the name of the task
  77499. */
  77500. name: string,
  77501. /**
  77502. * Defines the location of the image to load
  77503. */
  77504. url: string);
  77505. /**
  77506. * Execute the current task
  77507. * @param scene defines the scene where you want your assets to be loaded
  77508. * @param onSuccess is a callback called when the task is successfully executed
  77509. * @param onError is a callback called if an error occurs
  77510. */
  77511. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77512. }
  77513. /**
  77514. * Defines the interface used by texture loading tasks
  77515. */
  77516. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77517. /**
  77518. * Gets the loaded texture
  77519. */
  77520. texture: TEX;
  77521. }
  77522. /**
  77523. * Define a task used by AssetsManager to load 2D textures
  77524. */
  77525. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77526. /**
  77527. * Defines the name of the task
  77528. */
  77529. name: string;
  77530. /**
  77531. * Defines the location of the file to load
  77532. */
  77533. url: string;
  77534. /**
  77535. * Defines if mipmap should not be generated (default is false)
  77536. */
  77537. noMipmap?: boolean | undefined;
  77538. /**
  77539. * Defines if texture must be inverted on Y axis (default is true)
  77540. */
  77541. invertY: boolean;
  77542. /**
  77543. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77544. */
  77545. samplingMode: number;
  77546. /**
  77547. * Gets the loaded texture
  77548. */
  77549. texture: Texture;
  77550. /**
  77551. * Callback called when the task is successful
  77552. */
  77553. onSuccess: (task: TextureAssetTask) => void;
  77554. /**
  77555. * Callback called when the task is successful
  77556. */
  77557. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77558. /**
  77559. * Creates a new TextureAssetTask object
  77560. * @param name defines the name of the task
  77561. * @param url defines the location of the file to load
  77562. * @param noMipmap defines if mipmap should not be generated (default is false)
  77563. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77564. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77565. */
  77566. constructor(
  77567. /**
  77568. * Defines the name of the task
  77569. */
  77570. name: string,
  77571. /**
  77572. * Defines the location of the file to load
  77573. */
  77574. url: string,
  77575. /**
  77576. * Defines if mipmap should not be generated (default is false)
  77577. */
  77578. noMipmap?: boolean | undefined,
  77579. /**
  77580. * Defines if texture must be inverted on Y axis (default is true)
  77581. */
  77582. invertY?: boolean,
  77583. /**
  77584. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77585. */
  77586. samplingMode?: number);
  77587. /**
  77588. * Execute the current task
  77589. * @param scene defines the scene where you want your assets to be loaded
  77590. * @param onSuccess is a callback called when the task is successfully executed
  77591. * @param onError is a callback called if an error occurs
  77592. */
  77593. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77594. }
  77595. /**
  77596. * Define a task used by AssetsManager to load cube textures
  77597. */
  77598. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77599. /**
  77600. * Defines the name of the task
  77601. */
  77602. name: string;
  77603. /**
  77604. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77605. */
  77606. url: string;
  77607. /**
  77608. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77609. */
  77610. extensions?: string[] | undefined;
  77611. /**
  77612. * Defines if mipmaps should not be generated (default is false)
  77613. */
  77614. noMipmap?: boolean | undefined;
  77615. /**
  77616. * Defines the explicit list of files (undefined by default)
  77617. */
  77618. files?: string[] | undefined;
  77619. /**
  77620. * Gets the loaded texture
  77621. */
  77622. texture: CubeTexture;
  77623. /**
  77624. * Callback called when the task is successful
  77625. */
  77626. onSuccess: (task: CubeTextureAssetTask) => void;
  77627. /**
  77628. * Callback called when the task is successful
  77629. */
  77630. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77631. /**
  77632. * Creates a new CubeTextureAssetTask
  77633. * @param name defines the name of the task
  77634. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77635. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77636. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77637. * @param files defines the explicit list of files (undefined by default)
  77638. */
  77639. constructor(
  77640. /**
  77641. * Defines the name of the task
  77642. */
  77643. name: string,
  77644. /**
  77645. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77646. */
  77647. url: string,
  77648. /**
  77649. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77650. */
  77651. extensions?: string[] | undefined,
  77652. /**
  77653. * Defines if mipmaps should not be generated (default is false)
  77654. */
  77655. noMipmap?: boolean | undefined,
  77656. /**
  77657. * Defines the explicit list of files (undefined by default)
  77658. */
  77659. files?: string[] | undefined);
  77660. /**
  77661. * Execute the current task
  77662. * @param scene defines the scene where you want your assets to be loaded
  77663. * @param onSuccess is a callback called when the task is successfully executed
  77664. * @param onError is a callback called if an error occurs
  77665. */
  77666. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77667. }
  77668. /**
  77669. * Define a task used by AssetsManager to load HDR cube textures
  77670. */
  77671. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77672. /**
  77673. * Defines the name of the task
  77674. */
  77675. name: string;
  77676. /**
  77677. * Defines the location of the file to load
  77678. */
  77679. url: string;
  77680. /**
  77681. * Defines the desired size (the more it increases the longer the generation will be)
  77682. */
  77683. size: number;
  77684. /**
  77685. * Defines if mipmaps should not be generated (default is false)
  77686. */
  77687. noMipmap: boolean;
  77688. /**
  77689. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77690. */
  77691. generateHarmonics: boolean;
  77692. /**
  77693. * 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)
  77694. */
  77695. gammaSpace: boolean;
  77696. /**
  77697. * Internal Use Only
  77698. */
  77699. reserved: boolean;
  77700. /**
  77701. * Gets the loaded texture
  77702. */
  77703. texture: HDRCubeTexture;
  77704. /**
  77705. * Callback called when the task is successful
  77706. */
  77707. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77708. /**
  77709. * Callback called when the task is successful
  77710. */
  77711. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77712. /**
  77713. * Creates a new HDRCubeTextureAssetTask object
  77714. * @param name defines the name of the task
  77715. * @param url defines the location of the file to load
  77716. * @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.
  77717. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77718. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77719. * @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)
  77720. * @param reserved Internal use only
  77721. */
  77722. constructor(
  77723. /**
  77724. * Defines the name of the task
  77725. */
  77726. name: string,
  77727. /**
  77728. * Defines the location of the file to load
  77729. */
  77730. url: string,
  77731. /**
  77732. * Defines the desired size (the more it increases the longer the generation will be)
  77733. */
  77734. size: number,
  77735. /**
  77736. * Defines if mipmaps should not be generated (default is false)
  77737. */
  77738. noMipmap?: boolean,
  77739. /**
  77740. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77741. */
  77742. generateHarmonics?: boolean,
  77743. /**
  77744. * 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)
  77745. */
  77746. gammaSpace?: boolean,
  77747. /**
  77748. * Internal Use Only
  77749. */
  77750. reserved?: boolean);
  77751. /**
  77752. * Execute the current task
  77753. * @param scene defines the scene where you want your assets to be loaded
  77754. * @param onSuccess is a callback called when the task is successfully executed
  77755. * @param onError is a callback called if an error occurs
  77756. */
  77757. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77758. }
  77759. /**
  77760. * Define a task used by AssetsManager to load Equirectangular cube textures
  77761. */
  77762. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77763. /**
  77764. * Defines the name of the task
  77765. */
  77766. name: string;
  77767. /**
  77768. * Defines the location of the file to load
  77769. */
  77770. url: string;
  77771. /**
  77772. * Defines the desired size (the more it increases the longer the generation will be)
  77773. */
  77774. size: number;
  77775. /**
  77776. * Defines if mipmaps should not be generated (default is false)
  77777. */
  77778. noMipmap: boolean;
  77779. /**
  77780. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77781. * but the standard material would require them in Gamma space) (default is true)
  77782. */
  77783. gammaSpace: boolean;
  77784. /**
  77785. * Gets the loaded texture
  77786. */
  77787. texture: EquiRectangularCubeTexture;
  77788. /**
  77789. * Callback called when the task is successful
  77790. */
  77791. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77792. /**
  77793. * Callback called when the task is successful
  77794. */
  77795. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77796. /**
  77797. * Creates a new EquiRectangularCubeTextureAssetTask object
  77798. * @param name defines the name of the task
  77799. * @param url defines the location of the file to load
  77800. * @param size defines the desired size (the more it increases the longer the generation will be)
  77801. * If the size is omitted this implies you are using a preprocessed cubemap.
  77802. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77803. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77804. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77805. * (default is true)
  77806. */
  77807. constructor(
  77808. /**
  77809. * Defines the name of the task
  77810. */
  77811. name: string,
  77812. /**
  77813. * Defines the location of the file to load
  77814. */
  77815. url: string,
  77816. /**
  77817. * Defines the desired size (the more it increases the longer the generation will be)
  77818. */
  77819. size: number,
  77820. /**
  77821. * Defines if mipmaps should not be generated (default is false)
  77822. */
  77823. noMipmap?: boolean,
  77824. /**
  77825. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77826. * but the standard material would require them in Gamma space) (default is true)
  77827. */
  77828. gammaSpace?: boolean);
  77829. /**
  77830. * Execute the current task
  77831. * @param scene defines the scene where you want your assets to be loaded
  77832. * @param onSuccess is a callback called when the task is successfully executed
  77833. * @param onError is a callback called if an error occurs
  77834. */
  77835. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77836. }
  77837. /**
  77838. * This class can be used to easily import assets into a scene
  77839. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77840. */
  77841. export class AssetsManager {
  77842. private _scene;
  77843. private _isLoading;
  77844. protected _tasks: AbstractAssetTask[];
  77845. protected _waitingTasksCount: number;
  77846. protected _totalTasksCount: number;
  77847. /**
  77848. * Callback called when all tasks are processed
  77849. */
  77850. onFinish: (tasks: AbstractAssetTask[]) => void;
  77851. /**
  77852. * Callback called when a task is successful
  77853. */
  77854. onTaskSuccess: (task: AbstractAssetTask) => void;
  77855. /**
  77856. * Callback called when a task had an error
  77857. */
  77858. onTaskError: (task: AbstractAssetTask) => void;
  77859. /**
  77860. * Callback called when a task is done (whatever the result is)
  77861. */
  77862. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77863. /**
  77864. * Observable called when all tasks are processed
  77865. */
  77866. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77867. /**
  77868. * Observable called when a task had an error
  77869. */
  77870. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77871. /**
  77872. * Observable called when all tasks were executed
  77873. */
  77874. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77875. /**
  77876. * Observable called when a task is done (whatever the result is)
  77877. */
  77878. onProgressObservable: Observable<IAssetsProgressEvent>;
  77879. /**
  77880. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77881. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77882. */
  77883. useDefaultLoadingScreen: boolean;
  77884. /**
  77885. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77886. * when all assets have been downloaded.
  77887. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77888. */
  77889. autoHideLoadingUI: boolean;
  77890. /**
  77891. * Creates a new AssetsManager
  77892. * @param scene defines the scene to work on
  77893. */
  77894. constructor(scene: Scene);
  77895. /**
  77896. * Add a ContainerAssetTask to the list of active tasks
  77897. * @param taskName defines the name of the new task
  77898. * @param meshesNames defines the name of meshes to load
  77899. * @param rootUrl defines the root url to use to locate files
  77900. * @param sceneFilename defines the filename of the scene file
  77901. * @returns a new ContainerAssetTask object
  77902. */
  77903. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77904. /**
  77905. * Add a MeshAssetTask to the list of active tasks
  77906. * @param taskName defines the name of the new task
  77907. * @param meshesNames defines the name of meshes to load
  77908. * @param rootUrl defines the root url to use to locate files
  77909. * @param sceneFilename defines the filename of the scene file
  77910. * @returns a new MeshAssetTask object
  77911. */
  77912. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77913. /**
  77914. * Add a TextFileAssetTask to the list of active tasks
  77915. * @param taskName defines the name of the new task
  77916. * @param url defines the url of the file to load
  77917. * @returns a new TextFileAssetTask object
  77918. */
  77919. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77920. /**
  77921. * Add a BinaryFileAssetTask to the list of active tasks
  77922. * @param taskName defines the name of the new task
  77923. * @param url defines the url of the file to load
  77924. * @returns a new BinaryFileAssetTask object
  77925. */
  77926. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77927. /**
  77928. * Add a ImageAssetTask to the list of active tasks
  77929. * @param taskName defines the name of the new task
  77930. * @param url defines the url of the file to load
  77931. * @returns a new ImageAssetTask object
  77932. */
  77933. addImageTask(taskName: string, url: string): ImageAssetTask;
  77934. /**
  77935. * Add a TextureAssetTask to the list of active tasks
  77936. * @param taskName defines the name of the new task
  77937. * @param url defines the url of the file to load
  77938. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77939. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77940. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77941. * @returns a new TextureAssetTask object
  77942. */
  77943. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77944. /**
  77945. * Add a CubeTextureAssetTask to the list of active tasks
  77946. * @param taskName defines the name of the new task
  77947. * @param url defines the url of the file to load
  77948. * @param extensions defines the extension to use to load the cube map (can be null)
  77949. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77950. * @param files defines the list of files to load (can be null)
  77951. * @returns a new CubeTextureAssetTask object
  77952. */
  77953. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77954. /**
  77955. *
  77956. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77957. * @param taskName defines the name of the new task
  77958. * @param url defines the url of the file to load
  77959. * @param size defines the size you want for the cubemap (can be null)
  77960. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77961. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77962. * @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)
  77963. * @param reserved Internal use only
  77964. * @returns a new HDRCubeTextureAssetTask object
  77965. */
  77966. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77967. /**
  77968. *
  77969. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77970. * @param taskName defines the name of the new task
  77971. * @param url defines the url of the file to load
  77972. * @param size defines the size you want for the cubemap (can be null)
  77973. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77974. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77975. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77976. * @returns a new EquiRectangularCubeTextureAssetTask object
  77977. */
  77978. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77979. /**
  77980. * Remove a task from the assets manager.
  77981. * @param task the task to remove
  77982. */
  77983. removeTask(task: AbstractAssetTask): void;
  77984. private _decreaseWaitingTasksCount;
  77985. private _runTask;
  77986. /**
  77987. * Reset the AssetsManager and remove all tasks
  77988. * @return the current instance of the AssetsManager
  77989. */
  77990. reset(): AssetsManager;
  77991. /**
  77992. * Start the loading process
  77993. * @return the current instance of the AssetsManager
  77994. */
  77995. load(): AssetsManager;
  77996. /**
  77997. * Start the loading process as an async operation
  77998. * @return a promise returning the list of failed tasks
  77999. */
  78000. loadAsync(): Promise<void>;
  78001. }
  78002. }
  78003. declare module "babylonjs/Misc/deferred" {
  78004. /**
  78005. * Wrapper class for promise with external resolve and reject.
  78006. */
  78007. export class Deferred<T> {
  78008. /**
  78009. * The promise associated with this deferred object.
  78010. */
  78011. readonly promise: Promise<T>;
  78012. private _resolve;
  78013. private _reject;
  78014. /**
  78015. * The resolve method of the promise associated with this deferred object.
  78016. */
  78017. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78018. /**
  78019. * The reject method of the promise associated with this deferred object.
  78020. */
  78021. get reject(): (reason?: any) => void;
  78022. /**
  78023. * Constructor for this deferred object.
  78024. */
  78025. constructor();
  78026. }
  78027. }
  78028. declare module "babylonjs/Misc/meshExploder" {
  78029. import { Mesh } from "babylonjs/Meshes/mesh";
  78030. /**
  78031. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78032. */
  78033. export class MeshExploder {
  78034. private _centerMesh;
  78035. private _meshes;
  78036. private _meshesOrigins;
  78037. private _toCenterVectors;
  78038. private _scaledDirection;
  78039. private _newPosition;
  78040. private _centerPosition;
  78041. /**
  78042. * Explodes meshes from a center mesh.
  78043. * @param meshes The meshes to explode.
  78044. * @param centerMesh The mesh to be center of explosion.
  78045. */
  78046. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78047. private _setCenterMesh;
  78048. /**
  78049. * Get class name
  78050. * @returns "MeshExploder"
  78051. */
  78052. getClassName(): string;
  78053. /**
  78054. * "Exploded meshes"
  78055. * @returns Array of meshes with the centerMesh at index 0.
  78056. */
  78057. getMeshes(): Array<Mesh>;
  78058. /**
  78059. * Explodes meshes giving a specific direction
  78060. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78061. */
  78062. explode(direction?: number): void;
  78063. }
  78064. }
  78065. declare module "babylonjs/Misc/filesInput" {
  78066. import { Engine } from "babylonjs/Engines/engine";
  78067. import { Scene } from "babylonjs/scene";
  78068. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78069. import { Nullable } from "babylonjs/types";
  78070. /**
  78071. * Class used to help managing file picking and drag'n'drop
  78072. */
  78073. export class FilesInput {
  78074. /**
  78075. * List of files ready to be loaded
  78076. */
  78077. static get FilesToLoad(): {
  78078. [key: string]: File;
  78079. };
  78080. /**
  78081. * Callback called when a file is processed
  78082. */
  78083. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78084. private _engine;
  78085. private _currentScene;
  78086. private _sceneLoadedCallback;
  78087. private _progressCallback;
  78088. private _additionalRenderLoopLogicCallback;
  78089. private _textureLoadingCallback;
  78090. private _startingProcessingFilesCallback;
  78091. private _onReloadCallback;
  78092. private _errorCallback;
  78093. private _elementToMonitor;
  78094. private _sceneFileToLoad;
  78095. private _filesToLoad;
  78096. /**
  78097. * Creates a new FilesInput
  78098. * @param engine defines the rendering engine
  78099. * @param scene defines the hosting scene
  78100. * @param sceneLoadedCallback callback called when scene is loaded
  78101. * @param progressCallback callback called to track progress
  78102. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78103. * @param textureLoadingCallback callback called when a texture is loading
  78104. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78105. * @param onReloadCallback callback called when a reload is requested
  78106. * @param errorCallback callback call if an error occurs
  78107. */
  78108. 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>);
  78109. private _dragEnterHandler;
  78110. private _dragOverHandler;
  78111. private _dropHandler;
  78112. /**
  78113. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78114. * @param elementToMonitor defines the DOM element to track
  78115. */
  78116. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78117. /** Gets the current list of files to load */
  78118. get filesToLoad(): File[];
  78119. /**
  78120. * Release all associated resources
  78121. */
  78122. dispose(): void;
  78123. private renderFunction;
  78124. private drag;
  78125. private drop;
  78126. private _traverseFolder;
  78127. private _processFiles;
  78128. /**
  78129. * Load files from a drop event
  78130. * @param event defines the drop event to use as source
  78131. */
  78132. loadFiles(event: any): void;
  78133. private _processReload;
  78134. /**
  78135. * Reload the current scene from the loaded files
  78136. */
  78137. reload(): void;
  78138. }
  78139. }
  78140. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78141. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78142. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78143. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78144. }
  78145. declare module "babylonjs/Misc/sceneOptimizer" {
  78146. import { Scene, IDisposable } from "babylonjs/scene";
  78147. import { Observable } from "babylonjs/Misc/observable";
  78148. /**
  78149. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78150. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78151. */
  78152. export class SceneOptimization {
  78153. /**
  78154. * Defines the priority of this optimization (0 by default which means first in the list)
  78155. */
  78156. priority: number;
  78157. /**
  78158. * Gets a string describing the action executed by the current optimization
  78159. * @returns description string
  78160. */
  78161. getDescription(): string;
  78162. /**
  78163. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78164. * @param scene defines the current scene where to apply this optimization
  78165. * @param optimizer defines the current optimizer
  78166. * @returns true if everything that can be done was applied
  78167. */
  78168. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78169. /**
  78170. * Creates the SceneOptimization object
  78171. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78172. * @param desc defines the description associated with the optimization
  78173. */
  78174. constructor(
  78175. /**
  78176. * Defines the priority of this optimization (0 by default which means first in the list)
  78177. */
  78178. priority?: number);
  78179. }
  78180. /**
  78181. * Defines an optimization used to reduce the size of render target textures
  78182. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78183. */
  78184. export class TextureOptimization extends SceneOptimization {
  78185. /**
  78186. * Defines the priority of this optimization (0 by default which means first in the list)
  78187. */
  78188. priority: number;
  78189. /**
  78190. * 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
  78191. */
  78192. maximumSize: number;
  78193. /**
  78194. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78195. */
  78196. step: number;
  78197. /**
  78198. * Gets a string describing the action executed by the current optimization
  78199. * @returns description string
  78200. */
  78201. getDescription(): string;
  78202. /**
  78203. * Creates the TextureOptimization object
  78204. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78205. * @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
  78206. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78207. */
  78208. constructor(
  78209. /**
  78210. * Defines the priority of this optimization (0 by default which means first in the list)
  78211. */
  78212. priority?: number,
  78213. /**
  78214. * 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
  78215. */
  78216. maximumSize?: number,
  78217. /**
  78218. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78219. */
  78220. step?: number);
  78221. /**
  78222. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78223. * @param scene defines the current scene where to apply this optimization
  78224. * @param optimizer defines the current optimizer
  78225. * @returns true if everything that can be done was applied
  78226. */
  78227. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78228. }
  78229. /**
  78230. * Defines an optimization used to increase or decrease the rendering resolution
  78231. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78232. */
  78233. export class HardwareScalingOptimization extends SceneOptimization {
  78234. /**
  78235. * Defines the priority of this optimization (0 by default which means first in the list)
  78236. */
  78237. priority: number;
  78238. /**
  78239. * Defines the maximum scale to use (2 by default)
  78240. */
  78241. maximumScale: number;
  78242. /**
  78243. * Defines the step to use between two passes (0.5 by default)
  78244. */
  78245. step: number;
  78246. private _currentScale;
  78247. private _directionOffset;
  78248. /**
  78249. * Gets a string describing the action executed by the current optimization
  78250. * @return description string
  78251. */
  78252. getDescription(): string;
  78253. /**
  78254. * Creates the HardwareScalingOptimization object
  78255. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78256. * @param maximumScale defines the maximum scale to use (2 by default)
  78257. * @param step defines the step to use between two passes (0.5 by default)
  78258. */
  78259. constructor(
  78260. /**
  78261. * Defines the priority of this optimization (0 by default which means first in the list)
  78262. */
  78263. priority?: number,
  78264. /**
  78265. * Defines the maximum scale to use (2 by default)
  78266. */
  78267. maximumScale?: number,
  78268. /**
  78269. * Defines the step to use between two passes (0.5 by default)
  78270. */
  78271. step?: number);
  78272. /**
  78273. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78274. * @param scene defines the current scene where to apply this optimization
  78275. * @param optimizer defines the current optimizer
  78276. * @returns true if everything that can be done was applied
  78277. */
  78278. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78279. }
  78280. /**
  78281. * Defines an optimization used to remove shadows
  78282. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78283. */
  78284. export class ShadowsOptimization extends SceneOptimization {
  78285. /**
  78286. * Gets a string describing the action executed by the current optimization
  78287. * @return description string
  78288. */
  78289. getDescription(): string;
  78290. /**
  78291. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78292. * @param scene defines the current scene where to apply this optimization
  78293. * @param optimizer defines the current optimizer
  78294. * @returns true if everything that can be done was applied
  78295. */
  78296. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78297. }
  78298. /**
  78299. * Defines an optimization used to turn post-processes off
  78300. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78301. */
  78302. export class PostProcessesOptimization extends SceneOptimization {
  78303. /**
  78304. * Gets a string describing the action executed by the current optimization
  78305. * @return description string
  78306. */
  78307. getDescription(): string;
  78308. /**
  78309. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78310. * @param scene defines the current scene where to apply this optimization
  78311. * @param optimizer defines the current optimizer
  78312. * @returns true if everything that can be done was applied
  78313. */
  78314. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78315. }
  78316. /**
  78317. * Defines an optimization used to turn lens flares off
  78318. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78319. */
  78320. export class LensFlaresOptimization extends SceneOptimization {
  78321. /**
  78322. * Gets a string describing the action executed by the current optimization
  78323. * @return description string
  78324. */
  78325. getDescription(): string;
  78326. /**
  78327. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78328. * @param scene defines the current scene where to apply this optimization
  78329. * @param optimizer defines the current optimizer
  78330. * @returns true if everything that can be done was applied
  78331. */
  78332. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78333. }
  78334. /**
  78335. * Defines an optimization based on user defined callback.
  78336. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78337. */
  78338. export class CustomOptimization extends SceneOptimization {
  78339. /**
  78340. * Callback called to apply the custom optimization.
  78341. */
  78342. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78343. /**
  78344. * Callback called to get custom description
  78345. */
  78346. onGetDescription: () => string;
  78347. /**
  78348. * Gets a string describing the action executed by the current optimization
  78349. * @returns description string
  78350. */
  78351. getDescription(): string;
  78352. /**
  78353. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78354. * @param scene defines the current scene where to apply this optimization
  78355. * @param optimizer defines the current optimizer
  78356. * @returns true if everything that can be done was applied
  78357. */
  78358. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78359. }
  78360. /**
  78361. * Defines an optimization used to turn particles off
  78362. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78363. */
  78364. export class ParticlesOptimization extends SceneOptimization {
  78365. /**
  78366. * Gets a string describing the action executed by the current optimization
  78367. * @return description string
  78368. */
  78369. getDescription(): string;
  78370. /**
  78371. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78372. * @param scene defines the current scene where to apply this optimization
  78373. * @param optimizer defines the current optimizer
  78374. * @returns true if everything that can be done was applied
  78375. */
  78376. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78377. }
  78378. /**
  78379. * Defines an optimization used to turn render targets off
  78380. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78381. */
  78382. export class RenderTargetsOptimization extends SceneOptimization {
  78383. /**
  78384. * Gets a string describing the action executed by the current optimization
  78385. * @return description string
  78386. */
  78387. getDescription(): string;
  78388. /**
  78389. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78390. * @param scene defines the current scene where to apply this optimization
  78391. * @param optimizer defines the current optimizer
  78392. * @returns true if everything that can be done was applied
  78393. */
  78394. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78395. }
  78396. /**
  78397. * Defines an optimization used to merge meshes with compatible materials
  78398. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78399. */
  78400. export class MergeMeshesOptimization extends SceneOptimization {
  78401. private static _UpdateSelectionTree;
  78402. /**
  78403. * Gets or sets a boolean which defines if optimization octree has to be updated
  78404. */
  78405. static get UpdateSelectionTree(): boolean;
  78406. /**
  78407. * Gets or sets a boolean which defines if optimization octree has to be updated
  78408. */
  78409. static set UpdateSelectionTree(value: boolean);
  78410. /**
  78411. * Gets a string describing the action executed by the current optimization
  78412. * @return description string
  78413. */
  78414. getDescription(): string;
  78415. private _canBeMerged;
  78416. /**
  78417. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78418. * @param scene defines the current scene where to apply this optimization
  78419. * @param optimizer defines the current optimizer
  78420. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78421. * @returns true if everything that can be done was applied
  78422. */
  78423. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78424. }
  78425. /**
  78426. * Defines a list of options used by SceneOptimizer
  78427. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78428. */
  78429. export class SceneOptimizerOptions {
  78430. /**
  78431. * Defines the target frame rate to reach (60 by default)
  78432. */
  78433. targetFrameRate: number;
  78434. /**
  78435. * Defines the interval between two checkes (2000ms by default)
  78436. */
  78437. trackerDuration: number;
  78438. /**
  78439. * Gets the list of optimizations to apply
  78440. */
  78441. optimizations: SceneOptimization[];
  78442. /**
  78443. * Creates a new list of options used by SceneOptimizer
  78444. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78445. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78446. */
  78447. constructor(
  78448. /**
  78449. * Defines the target frame rate to reach (60 by default)
  78450. */
  78451. targetFrameRate?: number,
  78452. /**
  78453. * Defines the interval between two checkes (2000ms by default)
  78454. */
  78455. trackerDuration?: number);
  78456. /**
  78457. * Add a new optimization
  78458. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78459. * @returns the current SceneOptimizerOptions
  78460. */
  78461. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78462. /**
  78463. * Add a new custom optimization
  78464. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78465. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78466. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78467. * @returns the current SceneOptimizerOptions
  78468. */
  78469. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78470. /**
  78471. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78472. * @param targetFrameRate defines the target frame rate (60 by default)
  78473. * @returns a SceneOptimizerOptions object
  78474. */
  78475. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78476. /**
  78477. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78478. * @param targetFrameRate defines the target frame rate (60 by default)
  78479. * @returns a SceneOptimizerOptions object
  78480. */
  78481. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78482. /**
  78483. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78484. * @param targetFrameRate defines the target frame rate (60 by default)
  78485. * @returns a SceneOptimizerOptions object
  78486. */
  78487. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78488. }
  78489. /**
  78490. * Class used to run optimizations in order to reach a target frame rate
  78491. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78492. */
  78493. export class SceneOptimizer implements IDisposable {
  78494. private _isRunning;
  78495. private _options;
  78496. private _scene;
  78497. private _currentPriorityLevel;
  78498. private _targetFrameRate;
  78499. private _trackerDuration;
  78500. private _currentFrameRate;
  78501. private _sceneDisposeObserver;
  78502. private _improvementMode;
  78503. /**
  78504. * Defines an observable called when the optimizer reaches the target frame rate
  78505. */
  78506. onSuccessObservable: Observable<SceneOptimizer>;
  78507. /**
  78508. * Defines an observable called when the optimizer enables an optimization
  78509. */
  78510. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78511. /**
  78512. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78513. */
  78514. onFailureObservable: Observable<SceneOptimizer>;
  78515. /**
  78516. * Gets a boolean indicating if the optimizer is in improvement mode
  78517. */
  78518. get isInImprovementMode(): boolean;
  78519. /**
  78520. * Gets the current priority level (0 at start)
  78521. */
  78522. get currentPriorityLevel(): number;
  78523. /**
  78524. * Gets the current frame rate checked by the SceneOptimizer
  78525. */
  78526. get currentFrameRate(): number;
  78527. /**
  78528. * Gets or sets the current target frame rate (60 by default)
  78529. */
  78530. get targetFrameRate(): number;
  78531. /**
  78532. * Gets or sets the current target frame rate (60 by default)
  78533. */
  78534. set targetFrameRate(value: number);
  78535. /**
  78536. * Gets or sets the current interval between two checks (every 2000ms by default)
  78537. */
  78538. get trackerDuration(): number;
  78539. /**
  78540. * Gets or sets the current interval between two checks (every 2000ms by default)
  78541. */
  78542. set trackerDuration(value: number);
  78543. /**
  78544. * Gets the list of active optimizations
  78545. */
  78546. get optimizations(): SceneOptimization[];
  78547. /**
  78548. * Creates a new SceneOptimizer
  78549. * @param scene defines the scene to work on
  78550. * @param options defines the options to use with the SceneOptimizer
  78551. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78552. * @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)
  78553. */
  78554. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78555. /**
  78556. * Stops the current optimizer
  78557. */
  78558. stop(): void;
  78559. /**
  78560. * Reset the optimizer to initial step (current priority level = 0)
  78561. */
  78562. reset(): void;
  78563. /**
  78564. * Start the optimizer. By default it will try to reach a specific framerate
  78565. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78566. */
  78567. start(): void;
  78568. private _checkCurrentState;
  78569. /**
  78570. * Release all resources
  78571. */
  78572. dispose(): void;
  78573. /**
  78574. * Helper function to create a SceneOptimizer with one single line of code
  78575. * @param scene defines the scene to work on
  78576. * @param options defines the options to use with the SceneOptimizer
  78577. * @param onSuccess defines a callback to call on success
  78578. * @param onFailure defines a callback to call on failure
  78579. * @returns the new SceneOptimizer object
  78580. */
  78581. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78582. }
  78583. }
  78584. declare module "babylonjs/Misc/sceneSerializer" {
  78585. import { Scene } from "babylonjs/scene";
  78586. /**
  78587. * Class used to serialize a scene into a string
  78588. */
  78589. export class SceneSerializer {
  78590. /**
  78591. * Clear cache used by a previous serialization
  78592. */
  78593. static ClearCache(): void;
  78594. /**
  78595. * Serialize a scene into a JSON compatible object
  78596. * @param scene defines the scene to serialize
  78597. * @returns a JSON compatible object
  78598. */
  78599. static Serialize(scene: Scene): any;
  78600. /**
  78601. * Serialize a mesh into a JSON compatible object
  78602. * @param toSerialize defines the mesh to serialize
  78603. * @param withParents defines if parents must be serialized as well
  78604. * @param withChildren defines if children must be serialized as well
  78605. * @returns a JSON compatible object
  78606. */
  78607. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78608. }
  78609. }
  78610. declare module "babylonjs/Misc/textureTools" {
  78611. import { Texture } from "babylonjs/Materials/Textures/texture";
  78612. /**
  78613. * Class used to host texture specific utilities
  78614. */
  78615. export class TextureTools {
  78616. /**
  78617. * Uses the GPU to create a copy texture rescaled at a given size
  78618. * @param texture Texture to copy from
  78619. * @param width defines the desired width
  78620. * @param height defines the desired height
  78621. * @param useBilinearMode defines if bilinear mode has to be used
  78622. * @return the generated texture
  78623. */
  78624. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78625. }
  78626. }
  78627. declare module "babylonjs/Misc/videoRecorder" {
  78628. import { Nullable } from "babylonjs/types";
  78629. import { Engine } from "babylonjs/Engines/engine";
  78630. /**
  78631. * This represents the different options available for the video capture.
  78632. */
  78633. export interface VideoRecorderOptions {
  78634. /** Defines the mime type of the video. */
  78635. mimeType: string;
  78636. /** Defines the FPS the video should be recorded at. */
  78637. fps: number;
  78638. /** Defines the chunk size for the recording data. */
  78639. recordChunckSize: number;
  78640. /** The audio tracks to attach to the recording. */
  78641. audioTracks?: MediaStreamTrack[];
  78642. }
  78643. /**
  78644. * This can help with recording videos from BabylonJS.
  78645. * This is based on the available WebRTC functionalities of the browser.
  78646. *
  78647. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78648. */
  78649. export class VideoRecorder {
  78650. private static readonly _defaultOptions;
  78651. /**
  78652. * Returns whether or not the VideoRecorder is available in your browser.
  78653. * @param engine Defines the Babylon Engine.
  78654. * @returns true if supported otherwise false.
  78655. */
  78656. static IsSupported(engine: Engine): boolean;
  78657. private readonly _options;
  78658. private _canvas;
  78659. private _mediaRecorder;
  78660. private _recordedChunks;
  78661. private _fileName;
  78662. private _resolve;
  78663. private _reject;
  78664. /**
  78665. * True when a recording is already in progress.
  78666. */
  78667. get isRecording(): boolean;
  78668. /**
  78669. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78670. * @param engine Defines the BabylonJS Engine you wish to record.
  78671. * @param options Defines options that can be used to customize the capture.
  78672. */
  78673. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78674. /**
  78675. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78676. */
  78677. stopRecording(): void;
  78678. /**
  78679. * Starts recording the canvas for a max duration specified in parameters.
  78680. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78681. * If null no automatic download will start and you can rely on the promise to get the data back.
  78682. * @param maxDuration Defines the maximum recording time in seconds.
  78683. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78684. * @return A promise callback at the end of the recording with the video data in Blob.
  78685. */
  78686. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78687. /**
  78688. * Releases internal resources used during the recording.
  78689. */
  78690. dispose(): void;
  78691. private _handleDataAvailable;
  78692. private _handleError;
  78693. private _handleStop;
  78694. }
  78695. }
  78696. declare module "babylonjs/Misc/screenshotTools" {
  78697. import { Camera } from "babylonjs/Cameras/camera";
  78698. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78699. import { Engine } from "babylonjs/Engines/engine";
  78700. /**
  78701. * Class containing a set of static utilities functions for screenshots
  78702. */
  78703. export class ScreenshotTools {
  78704. /**
  78705. * Captures a screenshot of the current rendering
  78706. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78707. * @param engine defines the rendering engine
  78708. * @param camera defines the source camera
  78709. * @param size This parameter can be set to a single number or to an object with the
  78710. * following (optional) properties: precision, width, height. If a single number is passed,
  78711. * it will be used for both width and height. If an object is passed, the screenshot size
  78712. * will be derived from the parameters. The precision property is a multiplier allowing
  78713. * rendering at a higher or lower resolution
  78714. * @param successCallback defines the callback receives a single parameter which contains the
  78715. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78716. * src parameter of an <img> to display it
  78717. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78718. * Check your browser for supported MIME types
  78719. */
  78720. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78721. /**
  78722. * Captures a screenshot of the current rendering
  78723. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78724. * @param engine defines the rendering engine
  78725. * @param camera defines the source camera
  78726. * @param size This parameter can be set to a single number or to an object with the
  78727. * following (optional) properties: precision, width, height. If a single number is passed,
  78728. * it will be used for both width and height. If an object is passed, the screenshot size
  78729. * will be derived from the parameters. The precision property is a multiplier allowing
  78730. * rendering at a higher or lower resolution
  78731. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78732. * Check your browser for supported MIME types
  78733. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78734. * to the src parameter of an <img> to display it
  78735. */
  78736. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78737. /**
  78738. * Generates an image screenshot from the specified camera.
  78739. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78740. * @param engine The engine to use for rendering
  78741. * @param camera The camera to use for rendering
  78742. * @param size This parameter can be set to a single number or to an object with the
  78743. * following (optional) properties: precision, width, height. If a single number is passed,
  78744. * it will be used for both width and height. If an object is passed, the screenshot size
  78745. * will be derived from the parameters. The precision property is a multiplier allowing
  78746. * rendering at a higher or lower resolution
  78747. * @param successCallback The callback receives a single parameter which contains the
  78748. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78749. * src parameter of an <img> to display it
  78750. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78751. * Check your browser for supported MIME types
  78752. * @param samples Texture samples (default: 1)
  78753. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78754. * @param fileName A name for for the downloaded file.
  78755. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78756. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78757. */
  78758. 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;
  78759. /**
  78760. * Generates an image screenshot from the specified camera.
  78761. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78762. * @param engine The engine to use for rendering
  78763. * @param camera The camera to use for rendering
  78764. * @param size This parameter can be set to a single number or to an object with the
  78765. * following (optional) properties: precision, width, height. If a single number is passed,
  78766. * it will be used for both width and height. If an object is passed, the screenshot size
  78767. * will be derived from the parameters. The precision property is a multiplier allowing
  78768. * rendering at a higher or lower resolution
  78769. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78770. * Check your browser for supported MIME types
  78771. * @param samples Texture samples (default: 1)
  78772. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78773. * @param fileName A name for for the downloaded file.
  78774. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78775. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78776. * to the src parameter of an <img> to display it
  78777. */
  78778. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78779. /**
  78780. * Gets height and width for screenshot size
  78781. * @private
  78782. */
  78783. private static _getScreenshotSize;
  78784. }
  78785. }
  78786. declare module "babylonjs/Misc/dataReader" {
  78787. /**
  78788. * Interface for a data buffer
  78789. */
  78790. export interface IDataBuffer {
  78791. /**
  78792. * Reads bytes from the data buffer.
  78793. * @param byteOffset The byte offset to read
  78794. * @param byteLength The byte length to read
  78795. * @returns A promise that resolves when the bytes are read
  78796. */
  78797. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78798. /**
  78799. * The byte length of the buffer.
  78800. */
  78801. readonly byteLength: number;
  78802. }
  78803. /**
  78804. * Utility class for reading from a data buffer
  78805. */
  78806. export class DataReader {
  78807. /**
  78808. * The data buffer associated with this data reader.
  78809. */
  78810. readonly buffer: IDataBuffer;
  78811. /**
  78812. * The current byte offset from the beginning of the data buffer.
  78813. */
  78814. byteOffset: number;
  78815. private _dataView;
  78816. private _dataByteOffset;
  78817. /**
  78818. * Constructor
  78819. * @param buffer The buffer to read
  78820. */
  78821. constructor(buffer: IDataBuffer);
  78822. /**
  78823. * Loads the given byte length.
  78824. * @param byteLength The byte length to load
  78825. * @returns A promise that resolves when the load is complete
  78826. */
  78827. loadAsync(byteLength: number): Promise<void>;
  78828. /**
  78829. * Read a unsigned 32-bit integer from the currently loaded data range.
  78830. * @returns The 32-bit integer read
  78831. */
  78832. readUint32(): number;
  78833. /**
  78834. * Read a byte array from the currently loaded data range.
  78835. * @param byteLength The byte length to read
  78836. * @returns The byte array read
  78837. */
  78838. readUint8Array(byteLength: number): Uint8Array;
  78839. /**
  78840. * Read a string from the currently loaded data range.
  78841. * @param byteLength The byte length to read
  78842. * @returns The string read
  78843. */
  78844. readString(byteLength: number): string;
  78845. /**
  78846. * Skips the given byte length the currently loaded data range.
  78847. * @param byteLength The byte length to skip
  78848. */
  78849. skipBytes(byteLength: number): void;
  78850. }
  78851. }
  78852. declare module "babylonjs/Misc/dataStorage" {
  78853. /**
  78854. * Class for storing data to local storage if available or in-memory storage otherwise
  78855. */
  78856. export class DataStorage {
  78857. private static _Storage;
  78858. private static _GetStorage;
  78859. /**
  78860. * Reads a string from the data storage
  78861. * @param key The key to read
  78862. * @param defaultValue The value if the key doesn't exist
  78863. * @returns The string value
  78864. */
  78865. static ReadString(key: string, defaultValue: string): string;
  78866. /**
  78867. * Writes a string to the data storage
  78868. * @param key The key to write
  78869. * @param value The value to write
  78870. */
  78871. static WriteString(key: string, value: string): void;
  78872. /**
  78873. * Reads a boolean from the data storage
  78874. * @param key The key to read
  78875. * @param defaultValue The value if the key doesn't exist
  78876. * @returns The boolean value
  78877. */
  78878. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78879. /**
  78880. * Writes a boolean to the data storage
  78881. * @param key The key to write
  78882. * @param value The value to write
  78883. */
  78884. static WriteBoolean(key: string, value: boolean): void;
  78885. /**
  78886. * Reads a number from the data storage
  78887. * @param key The key to read
  78888. * @param defaultValue The value if the key doesn't exist
  78889. * @returns The number value
  78890. */
  78891. static ReadNumber(key: string, defaultValue: number): number;
  78892. /**
  78893. * Writes a number to the data storage
  78894. * @param key The key to write
  78895. * @param value The value to write
  78896. */
  78897. static WriteNumber(key: string, value: number): void;
  78898. }
  78899. }
  78900. declare module "babylonjs/Misc/sceneRecorder" {
  78901. import { Scene } from "babylonjs/scene";
  78902. /**
  78903. * Class used to record delta files between 2 scene states
  78904. */
  78905. export class SceneRecorder {
  78906. private _trackedScene;
  78907. private _savedJSON;
  78908. /**
  78909. * Track a given scene. This means the current scene state will be considered the original state
  78910. * @param scene defines the scene to track
  78911. */
  78912. track(scene: Scene): void;
  78913. /**
  78914. * Get the delta between current state and original state
  78915. * @returns a string containing the delta
  78916. */
  78917. getDelta(): any;
  78918. private _compareArray;
  78919. private _compareObjects;
  78920. private _compareCollections;
  78921. private static GetShadowGeneratorById;
  78922. /**
  78923. * Apply a given delta to a given scene
  78924. * @param deltaJSON defines the JSON containing the delta
  78925. * @param scene defines the scene to apply the delta to
  78926. */
  78927. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78928. private static _ApplyPropertiesToEntity;
  78929. private static _ApplyDeltaForEntity;
  78930. }
  78931. }
  78932. declare module "babylonjs/Misc/trajectoryClassifier" {
  78933. import { DeepImmutable, Nullable } from "babylonjs/types";
  78934. import { Vector3 } from "babylonjs/Maths/math.vector";
  78935. /**
  78936. * A 3D trajectory consisting of an order list of vectors describing a
  78937. * path of motion through 3D space.
  78938. */
  78939. export class Trajectory {
  78940. private _points;
  78941. private readonly _segmentLength;
  78942. /**
  78943. * Serialize to JSON.
  78944. * @returns serialized JSON string
  78945. */
  78946. serialize(): string;
  78947. /**
  78948. * Deserialize from JSON.
  78949. * @param json serialized JSON string
  78950. * @returns deserialized Trajectory
  78951. */
  78952. static Deserialize(json: string): Trajectory;
  78953. /**
  78954. * Create a new empty Trajectory.
  78955. * @param segmentLength radius of discretization for Trajectory points
  78956. */
  78957. constructor(segmentLength?: number);
  78958. /**
  78959. * Get the length of the Trajectory.
  78960. * @returns length of the Trajectory
  78961. */
  78962. getLength(): number;
  78963. /**
  78964. * Append a new point to the Trajectory.
  78965. * NOTE: This implementation has many allocations.
  78966. * @param point point to append to the Trajectory
  78967. */
  78968. add(point: DeepImmutable<Vector3>): void;
  78969. /**
  78970. * Create a new Trajectory with a segment length chosen to make it
  78971. * probable that the new Trajectory will have a specified number of
  78972. * segments. This operation is imprecise.
  78973. * @param targetResolution number of segments desired
  78974. * @returns new Trajectory with approximately the requested number of segments
  78975. */
  78976. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78977. /**
  78978. * Convert Trajectory segments into tokenized representation. This
  78979. * representation is an array of numbers where each nth number is the
  78980. * index of the token which is most similar to the nth segment of the
  78981. * Trajectory.
  78982. * @param tokens list of vectors which serve as discrete tokens
  78983. * @returns list of indices of most similar token per segment
  78984. */
  78985. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78986. private static _forwardDir;
  78987. private static _inverseFromVec;
  78988. private static _upDir;
  78989. private static _fromToVec;
  78990. private static _lookMatrix;
  78991. /**
  78992. * Transform the rotation (i.e., direction) of a segment to isolate
  78993. * the relative transformation represented by the segment. This operation
  78994. * may or may not succeed due to singularities in the equations that define
  78995. * motion relativity in this context.
  78996. * @param priorVec the origin of the prior segment
  78997. * @param fromVec the origin of the current segment
  78998. * @param toVec the destination of the current segment
  78999. * @param result reference to output variable
  79000. * @returns whether or not transformation was successful
  79001. */
  79002. private static _transformSegmentDirToRef;
  79003. private static _bestMatch;
  79004. private static _score;
  79005. private static _bestScore;
  79006. /**
  79007. * Determine which token vector is most similar to the
  79008. * segment vector.
  79009. * @param segment segment vector
  79010. * @param tokens token vector list
  79011. * @returns index of the most similar token to the segment
  79012. */
  79013. private static _tokenizeSegment;
  79014. }
  79015. /**
  79016. * Class representing a set of known, named trajectories to which Trajectories can be
  79017. * added and using which Trajectories can be recognized.
  79018. */
  79019. export class TrajectoryClassifier {
  79020. private _maximumAllowableMatchCost;
  79021. private _vector3Alphabet;
  79022. private _levenshteinAlphabet;
  79023. private _nameToDescribedTrajectory;
  79024. /**
  79025. * Serialize to JSON.
  79026. * @returns JSON serialization
  79027. */
  79028. serialize(): string;
  79029. /**
  79030. * Deserialize from JSON.
  79031. * @param json JSON serialization
  79032. * @returns deserialized TrajectorySet
  79033. */
  79034. static Deserialize(json: string): TrajectoryClassifier;
  79035. /**
  79036. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79037. * VERY naive, need to be generating these things from known
  79038. * sets. Better version later, probably eliminating this one.
  79039. * @returns auto-generated TrajectorySet
  79040. */
  79041. static Generate(): TrajectoryClassifier;
  79042. private constructor();
  79043. /**
  79044. * Add a new Trajectory to the set with a given name.
  79045. * @param trajectory new Trajectory to be added
  79046. * @param classification name to which to add the Trajectory
  79047. */
  79048. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79049. /**
  79050. * Remove a known named trajectory and all Trajectories associated with it.
  79051. * @param classification name to remove
  79052. * @returns whether anything was removed
  79053. */
  79054. deleteClassification(classification: string): boolean;
  79055. /**
  79056. * Attempt to recognize a Trajectory from among all the classifications
  79057. * already known to the classifier.
  79058. * @param trajectory Trajectory to be recognized
  79059. * @returns classification of Trajectory if recognized, null otherwise
  79060. */
  79061. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79062. }
  79063. }
  79064. declare module "babylonjs/Misc/index" {
  79065. export * from "babylonjs/Misc/andOrNotEvaluator";
  79066. export * from "babylonjs/Misc/assetsManager";
  79067. export * from "babylonjs/Misc/basis";
  79068. export * from "babylonjs/Misc/dds";
  79069. export * from "babylonjs/Misc/decorators";
  79070. export * from "babylonjs/Misc/deferred";
  79071. export * from "babylonjs/Misc/environmentTextureTools";
  79072. export * from "babylonjs/Misc/meshExploder";
  79073. export * from "babylonjs/Misc/filesInput";
  79074. export * from "babylonjs/Misc/HighDynamicRange/index";
  79075. export * from "babylonjs/Misc/khronosTextureContainer";
  79076. export * from "babylonjs/Misc/observable";
  79077. export * from "babylonjs/Misc/performanceMonitor";
  79078. export * from "babylonjs/Misc/promise";
  79079. export * from "babylonjs/Misc/sceneOptimizer";
  79080. export * from "babylonjs/Misc/sceneSerializer";
  79081. export * from "babylonjs/Misc/smartArray";
  79082. export * from "babylonjs/Misc/stringDictionary";
  79083. export * from "babylonjs/Misc/tags";
  79084. export * from "babylonjs/Misc/textureTools";
  79085. export * from "babylonjs/Misc/tga";
  79086. export * from "babylonjs/Misc/tools";
  79087. export * from "babylonjs/Misc/videoRecorder";
  79088. export * from "babylonjs/Misc/virtualJoystick";
  79089. export * from "babylonjs/Misc/workerPool";
  79090. export * from "babylonjs/Misc/logger";
  79091. export * from "babylonjs/Misc/typeStore";
  79092. export * from "babylonjs/Misc/filesInputStore";
  79093. export * from "babylonjs/Misc/deepCopier";
  79094. export * from "babylonjs/Misc/pivotTools";
  79095. export * from "babylonjs/Misc/precisionDate";
  79096. export * from "babylonjs/Misc/screenshotTools";
  79097. export * from "babylonjs/Misc/typeStore";
  79098. export * from "babylonjs/Misc/webRequest";
  79099. export * from "babylonjs/Misc/iInspectable";
  79100. export * from "babylonjs/Misc/brdfTextureTools";
  79101. export * from "babylonjs/Misc/rgbdTextureTools";
  79102. export * from "babylonjs/Misc/gradients";
  79103. export * from "babylonjs/Misc/perfCounter";
  79104. export * from "babylonjs/Misc/fileRequest";
  79105. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79106. export * from "babylonjs/Misc/retryStrategy";
  79107. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79108. export * from "babylonjs/Misc/canvasGenerator";
  79109. export * from "babylonjs/Misc/fileTools";
  79110. export * from "babylonjs/Misc/stringTools";
  79111. export * from "babylonjs/Misc/dataReader";
  79112. export * from "babylonjs/Misc/minMaxReducer";
  79113. export * from "babylonjs/Misc/depthReducer";
  79114. export * from "babylonjs/Misc/dataStorage";
  79115. export * from "babylonjs/Misc/sceneRecorder";
  79116. export * from "babylonjs/Misc/khronosTextureContainer2";
  79117. export * from "babylonjs/Misc/trajectoryClassifier";
  79118. export * from "babylonjs/Misc/timer";
  79119. }
  79120. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79121. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79122. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79123. import { Observable } from "babylonjs/Misc/observable";
  79124. import { Matrix } from "babylonjs/Maths/math.vector";
  79125. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79126. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79127. /**
  79128. * An interface for all Hit test features
  79129. */
  79130. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79131. /**
  79132. * Triggered when new babylon (transformed) hit test results are available
  79133. */
  79134. onHitTestResultObservable: Observable<T[]>;
  79135. }
  79136. /**
  79137. * Options used for hit testing
  79138. */
  79139. export interface IWebXRLegacyHitTestOptions {
  79140. /**
  79141. * Only test when user interacted with the scene. Default - hit test every frame
  79142. */
  79143. testOnPointerDownOnly?: boolean;
  79144. /**
  79145. * The node to use to transform the local results to world coordinates
  79146. */
  79147. worldParentNode?: TransformNode;
  79148. }
  79149. /**
  79150. * Interface defining the babylon result of raycasting/hit-test
  79151. */
  79152. export interface IWebXRLegacyHitResult {
  79153. /**
  79154. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79155. */
  79156. transformationMatrix: Matrix;
  79157. /**
  79158. * The native hit test result
  79159. */
  79160. xrHitResult: XRHitResult | XRHitTestResult;
  79161. }
  79162. /**
  79163. * The currently-working hit-test module.
  79164. * Hit test (or Ray-casting) is used to interact with the real world.
  79165. * For further information read here - https://github.com/immersive-web/hit-test
  79166. */
  79167. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79168. /**
  79169. * options to use when constructing this feature
  79170. */
  79171. readonly options: IWebXRLegacyHitTestOptions;
  79172. private _direction;
  79173. private _mat;
  79174. private _onSelectEnabled;
  79175. private _origin;
  79176. /**
  79177. * The module's name
  79178. */
  79179. static readonly Name: string;
  79180. /**
  79181. * The (Babylon) version of this module.
  79182. * This is an integer representing the implementation version.
  79183. * This number does not correspond to the WebXR specs version
  79184. */
  79185. static readonly Version: number;
  79186. /**
  79187. * Populated with the last native XR Hit Results
  79188. */
  79189. lastNativeXRHitResults: XRHitResult[];
  79190. /**
  79191. * Triggered when new babylon (transformed) hit test results are available
  79192. */
  79193. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79194. /**
  79195. * Creates a new instance of the (legacy version) hit test feature
  79196. * @param _xrSessionManager an instance of WebXRSessionManager
  79197. * @param options options to use when constructing this feature
  79198. */
  79199. constructor(_xrSessionManager: WebXRSessionManager,
  79200. /**
  79201. * options to use when constructing this feature
  79202. */
  79203. options?: IWebXRLegacyHitTestOptions);
  79204. /**
  79205. * execute a hit test with an XR Ray
  79206. *
  79207. * @param xrSession a native xrSession that will execute this hit test
  79208. * @param xrRay the ray (position and direction) to use for ray-casting
  79209. * @param referenceSpace native XR reference space to use for the hit-test
  79210. * @param filter filter function that will filter the results
  79211. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79212. */
  79213. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79214. /**
  79215. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79216. * @param event the (select) event to use to select with
  79217. * @param referenceSpace the reference space to use for this hit test
  79218. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79219. */
  79220. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79221. /**
  79222. * attach this feature
  79223. * Will usually be called by the features manager
  79224. *
  79225. * @returns true if successful.
  79226. */
  79227. attach(): boolean;
  79228. /**
  79229. * detach this feature.
  79230. * Will usually be called by the features manager
  79231. *
  79232. * @returns true if successful.
  79233. */
  79234. detach(): boolean;
  79235. /**
  79236. * Dispose this feature and all of the resources attached
  79237. */
  79238. dispose(): void;
  79239. protected _onXRFrame(frame: XRFrame): void;
  79240. private _onHitTestResults;
  79241. private _onSelect;
  79242. }
  79243. }
  79244. declare module "babylonjs/XR/features/WebXRHitTest" {
  79245. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79246. import { Observable } from "babylonjs/Misc/observable";
  79247. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79248. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79249. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79250. /**
  79251. * Options used for hit testing (version 2)
  79252. */
  79253. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79254. /**
  79255. * Do not create a permanent hit test. Will usually be used when only
  79256. * transient inputs are needed.
  79257. */
  79258. disablePermanentHitTest?: boolean;
  79259. /**
  79260. * Enable transient (for example touch-based) hit test inspections
  79261. */
  79262. enableTransientHitTest?: boolean;
  79263. /**
  79264. * Offset ray for the permanent hit test
  79265. */
  79266. offsetRay?: Vector3;
  79267. /**
  79268. * Offset ray for the transient hit test
  79269. */
  79270. transientOffsetRay?: Vector3;
  79271. /**
  79272. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79273. */
  79274. useReferenceSpace?: boolean;
  79275. /**
  79276. * Override the default entity type(s) of the hit-test result
  79277. */
  79278. entityTypes?: XRHitTestTrackableType[];
  79279. }
  79280. /**
  79281. * Interface defining the babylon result of hit-test
  79282. */
  79283. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79284. /**
  79285. * The input source that generated this hit test (if transient)
  79286. */
  79287. inputSource?: XRInputSource;
  79288. /**
  79289. * Is this a transient hit test
  79290. */
  79291. isTransient?: boolean;
  79292. /**
  79293. * Position of the hit test result
  79294. */
  79295. position: Vector3;
  79296. /**
  79297. * Rotation of the hit test result
  79298. */
  79299. rotationQuaternion: Quaternion;
  79300. /**
  79301. * The native hit test result
  79302. */
  79303. xrHitResult: XRHitTestResult;
  79304. }
  79305. /**
  79306. * The currently-working hit-test module.
  79307. * Hit test (or Ray-casting) is used to interact with the real world.
  79308. * For further information read here - https://github.com/immersive-web/hit-test
  79309. *
  79310. * Tested on chrome (mobile) 80.
  79311. */
  79312. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79313. /**
  79314. * options to use when constructing this feature
  79315. */
  79316. readonly options: IWebXRHitTestOptions;
  79317. private _tmpMat;
  79318. private _tmpPos;
  79319. private _tmpQuat;
  79320. private _transientXrHitTestSource;
  79321. private _xrHitTestSource;
  79322. private initHitTestSource;
  79323. /**
  79324. * The module's name
  79325. */
  79326. static readonly Name: string;
  79327. /**
  79328. * The (Babylon) version of this module.
  79329. * This is an integer representing the implementation version.
  79330. * This number does not correspond to the WebXR specs version
  79331. */
  79332. static readonly Version: number;
  79333. /**
  79334. * When set to true, each hit test will have its own position/rotation objects
  79335. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79336. * the developers will clone them or copy them as they see fit.
  79337. */
  79338. autoCloneTransformation: boolean;
  79339. /**
  79340. * Triggered when new babylon (transformed) hit test results are available
  79341. * Note - this will be called when results come back from the device. It can be an empty array!!
  79342. */
  79343. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79344. /**
  79345. * Use this to temporarily pause hit test checks.
  79346. */
  79347. paused: boolean;
  79348. /**
  79349. * Creates a new instance of the hit test feature
  79350. * @param _xrSessionManager an instance of WebXRSessionManager
  79351. * @param options options to use when constructing this feature
  79352. */
  79353. constructor(_xrSessionManager: WebXRSessionManager,
  79354. /**
  79355. * options to use when constructing this feature
  79356. */
  79357. options?: IWebXRHitTestOptions);
  79358. /**
  79359. * attach this feature
  79360. * Will usually be called by the features manager
  79361. *
  79362. * @returns true if successful.
  79363. */
  79364. attach(): boolean;
  79365. /**
  79366. * detach this feature.
  79367. * Will usually be called by the features manager
  79368. *
  79369. * @returns true if successful.
  79370. */
  79371. detach(): boolean;
  79372. /**
  79373. * Dispose this feature and all of the resources attached
  79374. */
  79375. dispose(): void;
  79376. protected _onXRFrame(frame: XRFrame): void;
  79377. private _processWebXRHitTestResult;
  79378. }
  79379. }
  79380. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79381. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79382. import { Observable } from "babylonjs/Misc/observable";
  79383. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79384. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79385. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79386. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79387. /**
  79388. * Configuration options of the anchor system
  79389. */
  79390. export interface IWebXRAnchorSystemOptions {
  79391. /**
  79392. * a node that will be used to convert local to world coordinates
  79393. */
  79394. worldParentNode?: TransformNode;
  79395. /**
  79396. * If set to true a reference of the created anchors will be kept until the next session starts
  79397. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79398. */
  79399. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79400. }
  79401. /**
  79402. * A babylon container for an XR Anchor
  79403. */
  79404. export interface IWebXRAnchor {
  79405. /**
  79406. * A babylon-assigned ID for this anchor
  79407. */
  79408. id: number;
  79409. /**
  79410. * Transformation matrix to apply to an object attached to this anchor
  79411. */
  79412. transformationMatrix: Matrix;
  79413. /**
  79414. * The native anchor object
  79415. */
  79416. xrAnchor: XRAnchor;
  79417. /**
  79418. * if defined, this object will be constantly updated by the anchor's position and rotation
  79419. */
  79420. attachedNode?: TransformNode;
  79421. }
  79422. /**
  79423. * An implementation of the anchor system for WebXR.
  79424. * For further information see https://github.com/immersive-web/anchors/
  79425. */
  79426. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79427. private _options;
  79428. private _lastFrameDetected;
  79429. private _trackedAnchors;
  79430. private _referenceSpaceForFrameAnchors;
  79431. private _futureAnchors;
  79432. /**
  79433. * The module's name
  79434. */
  79435. static readonly Name: string;
  79436. /**
  79437. * The (Babylon) version of this module.
  79438. * This is an integer representing the implementation version.
  79439. * This number does not correspond to the WebXR specs version
  79440. */
  79441. static readonly Version: number;
  79442. /**
  79443. * Observers registered here will be executed when a new anchor was added to the session
  79444. */
  79445. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79446. /**
  79447. * Observers registered here will be executed when an anchor was removed from the session
  79448. */
  79449. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79450. /**
  79451. * Observers registered here will be executed when an existing anchor updates
  79452. * This can execute N times every frame
  79453. */
  79454. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79455. /**
  79456. * Set the reference space to use for anchor creation, when not using a hit test.
  79457. * Will default to the session's reference space if not defined
  79458. */
  79459. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79460. /**
  79461. * constructs a new anchor system
  79462. * @param _xrSessionManager an instance of WebXRSessionManager
  79463. * @param _options configuration object for this feature
  79464. */
  79465. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79466. private _tmpVector;
  79467. private _tmpQuaternion;
  79468. private _populateTmpTransformation;
  79469. /**
  79470. * Create a new anchor point using a hit test result at a specific point in the scene
  79471. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79472. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79473. *
  79474. * @param hitTestResult The hit test result to use for this anchor creation
  79475. * @param position an optional position offset for this anchor
  79476. * @param rotationQuaternion an optional rotation offset for this anchor
  79477. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79478. */
  79479. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79480. /**
  79481. * Add a new anchor at a specific position and rotation
  79482. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79483. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79484. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79485. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79486. *
  79487. * @param position the position in which to add an anchor
  79488. * @param rotationQuaternion an optional rotation for the anchor transformation
  79489. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79490. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79491. */
  79492. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79493. /**
  79494. * detach this feature.
  79495. * Will usually be called by the features manager
  79496. *
  79497. * @returns true if successful.
  79498. */
  79499. detach(): boolean;
  79500. /**
  79501. * Dispose this feature and all of the resources attached
  79502. */
  79503. dispose(): void;
  79504. protected _onXRFrame(frame: XRFrame): void;
  79505. /**
  79506. * avoiding using Array.find for global support.
  79507. * @param xrAnchor the plane to find in the array
  79508. */
  79509. private _findIndexInAnchorArray;
  79510. private _updateAnchorWithXRFrame;
  79511. private _createAnchorAtTransformation;
  79512. }
  79513. }
  79514. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79515. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79516. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79517. import { Observable } from "babylonjs/Misc/observable";
  79518. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79519. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79520. /**
  79521. * Options used in the plane detector module
  79522. */
  79523. export interface IWebXRPlaneDetectorOptions {
  79524. /**
  79525. * The node to use to transform the local results to world coordinates
  79526. */
  79527. worldParentNode?: TransformNode;
  79528. /**
  79529. * If set to true a reference of the created planes will be kept until the next session starts
  79530. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79531. */
  79532. doNotRemovePlanesOnSessionEnded?: boolean;
  79533. }
  79534. /**
  79535. * A babylon interface for a WebXR plane.
  79536. * A Plane is actually a polygon, built from N points in space
  79537. *
  79538. * Supported in chrome 79, not supported in canary 81 ATM
  79539. */
  79540. export interface IWebXRPlane {
  79541. /**
  79542. * a babylon-assigned ID for this polygon
  79543. */
  79544. id: number;
  79545. /**
  79546. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79547. */
  79548. polygonDefinition: Array<Vector3>;
  79549. /**
  79550. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79551. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79552. */
  79553. transformationMatrix: Matrix;
  79554. /**
  79555. * the native xr-plane object
  79556. */
  79557. xrPlane: XRPlane;
  79558. }
  79559. /**
  79560. * The plane detector is used to detect planes in the real world when in AR
  79561. * For more information see https://github.com/immersive-web/real-world-geometry/
  79562. */
  79563. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79564. private _options;
  79565. private _detectedPlanes;
  79566. private _enabled;
  79567. private _lastFrameDetected;
  79568. /**
  79569. * The module's name
  79570. */
  79571. static readonly Name: string;
  79572. /**
  79573. * The (Babylon) version of this module.
  79574. * This is an integer representing the implementation version.
  79575. * This number does not correspond to the WebXR specs version
  79576. */
  79577. static readonly Version: number;
  79578. /**
  79579. * Observers registered here will be executed when a new plane was added to the session
  79580. */
  79581. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79582. /**
  79583. * Observers registered here will be executed when a plane is no longer detected in the session
  79584. */
  79585. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79586. /**
  79587. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79588. * This can execute N times every frame
  79589. */
  79590. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79591. /**
  79592. * construct a new Plane Detector
  79593. * @param _xrSessionManager an instance of xr Session manager
  79594. * @param _options configuration to use when constructing this feature
  79595. */
  79596. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79597. /**
  79598. * detach this feature.
  79599. * Will usually be called by the features manager
  79600. *
  79601. * @returns true if successful.
  79602. */
  79603. detach(): boolean;
  79604. /**
  79605. * Dispose this feature and all of the resources attached
  79606. */
  79607. dispose(): void;
  79608. protected _onXRFrame(frame: XRFrame): void;
  79609. private _init;
  79610. private _updatePlaneWithXRPlane;
  79611. /**
  79612. * avoiding using Array.find for global support.
  79613. * @param xrPlane the plane to find in the array
  79614. */
  79615. private findIndexInPlaneArray;
  79616. }
  79617. }
  79618. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79619. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79621. import { Observable } from "babylonjs/Misc/observable";
  79622. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79623. /**
  79624. * Options interface for the background remover plugin
  79625. */
  79626. export interface IWebXRBackgroundRemoverOptions {
  79627. /**
  79628. * Further background meshes to disable when entering AR
  79629. */
  79630. backgroundMeshes?: AbstractMesh[];
  79631. /**
  79632. * flags to configure the removal of the environment helper.
  79633. * If not set, the entire background will be removed. If set, flags should be set as well.
  79634. */
  79635. environmentHelperRemovalFlags?: {
  79636. /**
  79637. * Should the skybox be removed (default false)
  79638. */
  79639. skyBox?: boolean;
  79640. /**
  79641. * Should the ground be removed (default false)
  79642. */
  79643. ground?: boolean;
  79644. };
  79645. /**
  79646. * don't disable the environment helper
  79647. */
  79648. ignoreEnvironmentHelper?: boolean;
  79649. }
  79650. /**
  79651. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79652. */
  79653. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79654. /**
  79655. * read-only options to be used in this module
  79656. */
  79657. readonly options: IWebXRBackgroundRemoverOptions;
  79658. /**
  79659. * The module's name
  79660. */
  79661. static readonly Name: string;
  79662. /**
  79663. * The (Babylon) version of this module.
  79664. * This is an integer representing the implementation version.
  79665. * This number does not correspond to the WebXR specs version
  79666. */
  79667. static readonly Version: number;
  79668. /**
  79669. * registered observers will be triggered when the background state changes
  79670. */
  79671. onBackgroundStateChangedObservable: Observable<boolean>;
  79672. /**
  79673. * constructs a new background remover module
  79674. * @param _xrSessionManager the session manager for this module
  79675. * @param options read-only options to be used in this module
  79676. */
  79677. constructor(_xrSessionManager: WebXRSessionManager,
  79678. /**
  79679. * read-only options to be used in this module
  79680. */
  79681. options?: IWebXRBackgroundRemoverOptions);
  79682. /**
  79683. * attach this feature
  79684. * Will usually be called by the features manager
  79685. *
  79686. * @returns true if successful.
  79687. */
  79688. attach(): boolean;
  79689. /**
  79690. * detach this feature.
  79691. * Will usually be called by the features manager
  79692. *
  79693. * @returns true if successful.
  79694. */
  79695. detach(): boolean;
  79696. /**
  79697. * Dispose this feature and all of the resources attached
  79698. */
  79699. dispose(): void;
  79700. protected _onXRFrame(_xrFrame: XRFrame): void;
  79701. private _setBackgroundState;
  79702. }
  79703. }
  79704. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79705. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79706. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79707. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79708. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79709. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79710. import { Nullable } from "babylonjs/types";
  79711. /**
  79712. * Options for the controller physics feature
  79713. */
  79714. export class IWebXRControllerPhysicsOptions {
  79715. /**
  79716. * Should the headset get its own impostor
  79717. */
  79718. enableHeadsetImpostor?: boolean;
  79719. /**
  79720. * Optional parameters for the headset impostor
  79721. */
  79722. headsetImpostorParams?: {
  79723. /**
  79724. * The type of impostor to create. Default is sphere
  79725. */
  79726. impostorType: number;
  79727. /**
  79728. * the size of the impostor. Defaults to 10cm
  79729. */
  79730. impostorSize?: number | {
  79731. width: number;
  79732. height: number;
  79733. depth: number;
  79734. };
  79735. /**
  79736. * Friction definitions
  79737. */
  79738. friction?: number;
  79739. /**
  79740. * Restitution
  79741. */
  79742. restitution?: number;
  79743. };
  79744. /**
  79745. * The physics properties of the future impostors
  79746. */
  79747. physicsProperties?: {
  79748. /**
  79749. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79750. * Note that this requires a physics engine that supports mesh impostors!
  79751. */
  79752. useControllerMesh?: boolean;
  79753. /**
  79754. * The type of impostor to create. Default is sphere
  79755. */
  79756. impostorType?: number;
  79757. /**
  79758. * the size of the impostor. Defaults to 10cm
  79759. */
  79760. impostorSize?: number | {
  79761. width: number;
  79762. height: number;
  79763. depth: number;
  79764. };
  79765. /**
  79766. * Friction definitions
  79767. */
  79768. friction?: number;
  79769. /**
  79770. * Restitution
  79771. */
  79772. restitution?: number;
  79773. };
  79774. /**
  79775. * the xr input to use with this pointer selection
  79776. */
  79777. xrInput: WebXRInput;
  79778. }
  79779. /**
  79780. * Add physics impostor to your webxr controllers,
  79781. * including naive calculation of their linear and angular velocity
  79782. */
  79783. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79784. private readonly _options;
  79785. private _attachController;
  79786. private _controllers;
  79787. private _debugMode;
  79788. private _delta;
  79789. private _headsetImpostor?;
  79790. private _headsetMesh?;
  79791. private _lastTimestamp;
  79792. private _tmpQuaternion;
  79793. private _tmpVector;
  79794. /**
  79795. * The module's name
  79796. */
  79797. static readonly Name: string;
  79798. /**
  79799. * The (Babylon) version of this module.
  79800. * This is an integer representing the implementation version.
  79801. * This number does not correspond to the webxr specs version
  79802. */
  79803. static readonly Version: number;
  79804. /**
  79805. * Construct a new Controller Physics Feature
  79806. * @param _xrSessionManager the corresponding xr session manager
  79807. * @param _options options to create this feature with
  79808. */
  79809. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79810. /**
  79811. * @hidden
  79812. * enable debugging - will show console outputs and the impostor mesh
  79813. */
  79814. _enablePhysicsDebug(): void;
  79815. /**
  79816. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79817. * @param xrController the controller to add
  79818. */
  79819. addController(xrController: WebXRInputSource): void;
  79820. /**
  79821. * attach this feature
  79822. * Will usually be called by the features manager
  79823. *
  79824. * @returns true if successful.
  79825. */
  79826. attach(): boolean;
  79827. /**
  79828. * detach this feature.
  79829. * Will usually be called by the features manager
  79830. *
  79831. * @returns true if successful.
  79832. */
  79833. detach(): boolean;
  79834. /**
  79835. * Get the headset impostor, if enabled
  79836. * @returns the impostor
  79837. */
  79838. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79839. /**
  79840. * Get the physics impostor of a specific controller.
  79841. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79842. * @param controller the controller or the controller id of which to get the impostor
  79843. * @returns the impostor or null
  79844. */
  79845. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79846. /**
  79847. * Update the physics properties provided in the constructor
  79848. * @param newProperties the new properties object
  79849. */
  79850. setPhysicsProperties(newProperties: {
  79851. impostorType?: number;
  79852. impostorSize?: number | {
  79853. width: number;
  79854. height: number;
  79855. depth: number;
  79856. };
  79857. friction?: number;
  79858. restitution?: number;
  79859. }): void;
  79860. protected _onXRFrame(_xrFrame: any): void;
  79861. private _detachController;
  79862. }
  79863. }
  79864. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79865. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79866. import { Observable } from "babylonjs/Misc/observable";
  79867. import { Vector3 } from "babylonjs/Maths/math.vector";
  79868. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79869. /**
  79870. * A babylon interface for a "WebXR" feature point.
  79871. * Represents the position and confidence value of a given feature point.
  79872. */
  79873. export interface IWebXRFeaturePoint {
  79874. /**
  79875. * Represents the position of the feature point in world space.
  79876. */
  79877. position: Vector3;
  79878. /**
  79879. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79880. */
  79881. confidenceValue: number;
  79882. }
  79883. /**
  79884. * The feature point system is used to detect feature points from real world geometry.
  79885. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79886. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79887. */
  79888. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79889. private _enabled;
  79890. private _featurePointCloud;
  79891. /**
  79892. * The module's name
  79893. */
  79894. static readonly Name: string;
  79895. /**
  79896. * The (Babylon) version of this module.
  79897. * This is an integer representing the implementation version.
  79898. * This number does not correspond to the WebXR specs version
  79899. */
  79900. static readonly Version: number;
  79901. /**
  79902. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79903. * Will notify the observers about which feature points have been added.
  79904. */
  79905. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79906. /**
  79907. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79908. * Will notify the observers about which feature points have been updated.
  79909. */
  79910. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79911. /**
  79912. * The current feature point cloud maintained across frames.
  79913. */
  79914. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79915. /**
  79916. * construct the feature point system
  79917. * @param _xrSessionManager an instance of xr Session manager
  79918. */
  79919. constructor(_xrSessionManager: WebXRSessionManager);
  79920. /**
  79921. * Detach this feature.
  79922. * Will usually be called by the features manager
  79923. *
  79924. * @returns true if successful.
  79925. */
  79926. detach(): boolean;
  79927. /**
  79928. * Dispose this feature and all of the resources attached
  79929. */
  79930. dispose(): void;
  79931. /**
  79932. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79933. */
  79934. protected _onXRFrame(frame: XRFrame): void;
  79935. /**
  79936. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79937. */
  79938. private _init;
  79939. }
  79940. }
  79941. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79942. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79943. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79945. import { Mesh } from "babylonjs/Meshes/mesh";
  79946. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79947. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79948. import { Nullable } from "babylonjs/types";
  79949. import { IDisposable } from "babylonjs/scene";
  79950. import { Observable } from "babylonjs/Misc/observable";
  79951. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  79952. /**
  79953. * Configuration interface for the hand tracking feature
  79954. */
  79955. export interface IWebXRHandTrackingOptions {
  79956. /**
  79957. * The xrInput that will be used as source for new hands
  79958. */
  79959. xrInput: WebXRInput;
  79960. /**
  79961. * Configuration object for the joint meshes
  79962. */
  79963. jointMeshes?: {
  79964. /**
  79965. * Should the meshes created be invisible (defaults to false)
  79966. */
  79967. invisible?: boolean;
  79968. /**
  79969. * A source mesh to be used to create instances. Defaults to a sphere.
  79970. * This mesh will be the source for all other (25) meshes.
  79971. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79972. */
  79973. sourceMesh?: Mesh;
  79974. /**
  79975. * This function will be called after a mesh was created for a specific joint.
  79976. * Using this function you can either manipulate the instance or return a new mesh.
  79977. * When returning a new mesh the instance created before will be disposed
  79978. */
  79979. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  79980. /**
  79981. * Should the source mesh stay visible. Defaults to false
  79982. */
  79983. keepOriginalVisible?: boolean;
  79984. /**
  79985. * Scale factor for all instances (defaults to 2)
  79986. */
  79987. scaleFactor?: number;
  79988. /**
  79989. * Should each instance have its own physics impostor
  79990. */
  79991. enablePhysics?: boolean;
  79992. /**
  79993. * If enabled, override default physics properties
  79994. */
  79995. physicsProps?: {
  79996. friction?: number;
  79997. restitution?: number;
  79998. impostorType?: number;
  79999. };
  80000. /**
  80001. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80002. */
  80003. handMesh?: AbstractMesh;
  80004. };
  80005. }
  80006. /**
  80007. * Parts of the hands divided to writs and finger names
  80008. */
  80009. export const enum HandPart {
  80010. /**
  80011. * HandPart - Wrist
  80012. */
  80013. WRIST = "wrist",
  80014. /**
  80015. * HandPart - The THumb
  80016. */
  80017. THUMB = "thumb",
  80018. /**
  80019. * HandPart - Index finger
  80020. */
  80021. INDEX = "index",
  80022. /**
  80023. * HandPart - Middle finger
  80024. */
  80025. MIDDLE = "middle",
  80026. /**
  80027. * HandPart - Ring finger
  80028. */
  80029. RING = "ring",
  80030. /**
  80031. * HandPart - Little finger
  80032. */
  80033. LITTLE = "little"
  80034. }
  80035. /**
  80036. * Representing a single hand (with its corresponding native XRHand object)
  80037. */
  80038. export class WebXRHand implements IDisposable {
  80039. /** the controller to which the hand correlates */
  80040. readonly xrController: WebXRInputSource;
  80041. /** the meshes to be used to track the hand joints */
  80042. readonly trackedMeshes: AbstractMesh[];
  80043. /**
  80044. * Hand-parts definition (key is HandPart)
  80045. */
  80046. handPartsDefinition: {
  80047. [key: string]: number[];
  80048. };
  80049. /**
  80050. * Populate the HandPartsDefinition object.
  80051. * This is called as a side effect since certain browsers don't have XRHand defined.
  80052. */
  80053. private generateHandPartsDefinition;
  80054. /**
  80055. * Construct a new hand object
  80056. * @param xrController the controller to which the hand correlates
  80057. * @param trackedMeshes the meshes to be used to track the hand joints
  80058. */
  80059. constructor(
  80060. /** the controller to which the hand correlates */
  80061. xrController: WebXRInputSource,
  80062. /** the meshes to be used to track the hand joints */
  80063. trackedMeshes: AbstractMesh[]);
  80064. /**
  80065. * Update this hand from the latest xr frame
  80066. * @param xrFrame xrFrame to update from
  80067. * @param referenceSpace The current viewer reference space
  80068. * @param scaleFactor optional scale factor for the meshes
  80069. */
  80070. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80071. /**
  80072. * Get meshes of part of the hand
  80073. * @param part the part of hand to get
  80074. * @returns An array of meshes that correlate to the hand part requested
  80075. */
  80076. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80077. /**
  80078. * Dispose this Hand object
  80079. */
  80080. dispose(): void;
  80081. }
  80082. /**
  80083. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80084. */
  80085. export class WebXRHandTracking extends WebXRAbstractFeature {
  80086. /**
  80087. * options to use when constructing this feature
  80088. */
  80089. readonly options: IWebXRHandTrackingOptions;
  80090. private static _idCounter;
  80091. /**
  80092. * The module's name
  80093. */
  80094. static readonly Name: string;
  80095. /**
  80096. * The (Babylon) version of this module.
  80097. * This is an integer representing the implementation version.
  80098. * This number does not correspond to the WebXR specs version
  80099. */
  80100. static readonly Version: number;
  80101. /**
  80102. * This observable will notify registered observers when a new hand object was added and initialized
  80103. */
  80104. onHandAddedObservable: Observable<WebXRHand>;
  80105. /**
  80106. * This observable will notify its observers right before the hand object is disposed
  80107. */
  80108. onHandRemovedObservable: Observable<WebXRHand>;
  80109. private _hands;
  80110. /**
  80111. * Creates a new instance of the hit test feature
  80112. * @param _xrSessionManager an instance of WebXRSessionManager
  80113. * @param options options to use when constructing this feature
  80114. */
  80115. constructor(_xrSessionManager: WebXRSessionManager,
  80116. /**
  80117. * options to use when constructing this feature
  80118. */
  80119. options: IWebXRHandTrackingOptions);
  80120. /**
  80121. * Check if the needed objects are defined.
  80122. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80123. */
  80124. isCompatible(): boolean;
  80125. /**
  80126. * attach this feature
  80127. * Will usually be called by the features manager
  80128. *
  80129. * @returns true if successful.
  80130. */
  80131. attach(): boolean;
  80132. /**
  80133. * detach this feature.
  80134. * Will usually be called by the features manager
  80135. *
  80136. * @returns true if successful.
  80137. */
  80138. detach(): boolean;
  80139. /**
  80140. * Dispose this feature and all of the resources attached
  80141. */
  80142. dispose(): void;
  80143. /**
  80144. * Get the hand object according to the controller id
  80145. * @param controllerId the controller id to which we want to get the hand
  80146. * @returns null if not found or the WebXRHand object if found
  80147. */
  80148. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80149. /**
  80150. * Get a hand object according to the requested handedness
  80151. * @param handedness the handedness to request
  80152. * @returns null if not found or the WebXRHand object if found
  80153. */
  80154. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80155. protected _onXRFrame(_xrFrame: XRFrame): void;
  80156. private _attachHand;
  80157. private _detachHand;
  80158. }
  80159. }
  80160. declare module "babylonjs/XR/features/index" {
  80161. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80162. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80163. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80164. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80165. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80166. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80167. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80168. export * from "babylonjs/XR/features/WebXRHitTest";
  80169. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80170. export * from "babylonjs/XR/features/WebXRHandTracking";
  80171. }
  80172. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80173. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80175. import { Scene } from "babylonjs/scene";
  80176. /**
  80177. * The motion controller class for all microsoft mixed reality controllers
  80178. */
  80179. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80180. protected readonly _mapping: {
  80181. defaultButton: {
  80182. valueNodeName: string;
  80183. unpressedNodeName: string;
  80184. pressedNodeName: string;
  80185. };
  80186. defaultAxis: {
  80187. valueNodeName: string;
  80188. minNodeName: string;
  80189. maxNodeName: string;
  80190. };
  80191. buttons: {
  80192. "xr-standard-trigger": {
  80193. rootNodeName: string;
  80194. componentProperty: string;
  80195. states: string[];
  80196. };
  80197. "xr-standard-squeeze": {
  80198. rootNodeName: string;
  80199. componentProperty: string;
  80200. states: string[];
  80201. };
  80202. "xr-standard-touchpad": {
  80203. rootNodeName: string;
  80204. labelAnchorNodeName: string;
  80205. touchPointNodeName: string;
  80206. };
  80207. "xr-standard-thumbstick": {
  80208. rootNodeName: string;
  80209. componentProperty: string;
  80210. states: string[];
  80211. };
  80212. };
  80213. axes: {
  80214. "xr-standard-touchpad": {
  80215. "x-axis": {
  80216. rootNodeName: string;
  80217. };
  80218. "y-axis": {
  80219. rootNodeName: string;
  80220. };
  80221. };
  80222. "xr-standard-thumbstick": {
  80223. "x-axis": {
  80224. rootNodeName: string;
  80225. };
  80226. "y-axis": {
  80227. rootNodeName: string;
  80228. };
  80229. };
  80230. };
  80231. };
  80232. /**
  80233. * The base url used to load the left and right controller models
  80234. */
  80235. static MODEL_BASE_URL: string;
  80236. /**
  80237. * The name of the left controller model file
  80238. */
  80239. static MODEL_LEFT_FILENAME: string;
  80240. /**
  80241. * The name of the right controller model file
  80242. */
  80243. static MODEL_RIGHT_FILENAME: string;
  80244. profileId: string;
  80245. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80246. protected _getFilenameAndPath(): {
  80247. filename: string;
  80248. path: string;
  80249. };
  80250. protected _getModelLoadingConstraints(): boolean;
  80251. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80252. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80253. protected _updateModel(): void;
  80254. }
  80255. }
  80256. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80257. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80259. import { Scene } from "babylonjs/scene";
  80260. /**
  80261. * The motion controller class for oculus touch (quest, rift).
  80262. * This class supports legacy mapping as well the standard xr mapping
  80263. */
  80264. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80265. private _forceLegacyControllers;
  80266. private _modelRootNode;
  80267. /**
  80268. * The base url used to load the left and right controller models
  80269. */
  80270. static MODEL_BASE_URL: string;
  80271. /**
  80272. * The name of the left controller model file
  80273. */
  80274. static MODEL_LEFT_FILENAME: string;
  80275. /**
  80276. * The name of the right controller model file
  80277. */
  80278. static MODEL_RIGHT_FILENAME: string;
  80279. /**
  80280. * Base Url for the Quest controller model.
  80281. */
  80282. static QUEST_MODEL_BASE_URL: string;
  80283. profileId: string;
  80284. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80285. protected _getFilenameAndPath(): {
  80286. filename: string;
  80287. path: string;
  80288. };
  80289. protected _getModelLoadingConstraints(): boolean;
  80290. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80291. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80292. protected _updateModel(): void;
  80293. /**
  80294. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80295. * between the touch and touch 2.
  80296. */
  80297. private _isQuest;
  80298. }
  80299. }
  80300. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80301. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80302. import { Scene } from "babylonjs/scene";
  80303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80304. /**
  80305. * The motion controller class for the standard HTC-Vive controllers
  80306. */
  80307. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80308. private _modelRootNode;
  80309. /**
  80310. * The base url used to load the left and right controller models
  80311. */
  80312. static MODEL_BASE_URL: string;
  80313. /**
  80314. * File name for the controller model.
  80315. */
  80316. static MODEL_FILENAME: string;
  80317. profileId: string;
  80318. /**
  80319. * Create a new Vive motion controller object
  80320. * @param scene the scene to use to create this controller
  80321. * @param gamepadObject the corresponding gamepad object
  80322. * @param handedness the handedness of the controller
  80323. */
  80324. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80325. protected _getFilenameAndPath(): {
  80326. filename: string;
  80327. path: string;
  80328. };
  80329. protected _getModelLoadingConstraints(): boolean;
  80330. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80331. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80332. protected _updateModel(): void;
  80333. }
  80334. }
  80335. declare module "babylonjs/XR/motionController/index" {
  80336. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80337. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80338. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80339. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80340. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80341. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80342. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80343. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80344. }
  80345. declare module "babylonjs/XR/index" {
  80346. export * from "babylonjs/XR/webXRCamera";
  80347. export * from "babylonjs/XR/webXREnterExitUI";
  80348. export * from "babylonjs/XR/webXRExperienceHelper";
  80349. export * from "babylonjs/XR/webXRInput";
  80350. export * from "babylonjs/XR/webXRInputSource";
  80351. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80352. export * from "babylonjs/XR/webXRTypes";
  80353. export * from "babylonjs/XR/webXRSessionManager";
  80354. export * from "babylonjs/XR/webXRDefaultExperience";
  80355. export * from "babylonjs/XR/webXRFeaturesManager";
  80356. export * from "babylonjs/XR/features/index";
  80357. export * from "babylonjs/XR/motionController/index";
  80358. }
  80359. declare module "babylonjs/index" {
  80360. export * from "babylonjs/abstractScene";
  80361. export * from "babylonjs/Actions/index";
  80362. export * from "babylonjs/Animations/index";
  80363. export * from "babylonjs/assetContainer";
  80364. export * from "babylonjs/Audio/index";
  80365. export * from "babylonjs/Behaviors/index";
  80366. export * from "babylonjs/Bones/index";
  80367. export * from "babylonjs/Cameras/index";
  80368. export * from "babylonjs/Collisions/index";
  80369. export * from "babylonjs/Culling/index";
  80370. export * from "babylonjs/Debug/index";
  80371. export * from "babylonjs/DeviceInput/index";
  80372. export * from "babylonjs/Engines/index";
  80373. export * from "babylonjs/Events/index";
  80374. export * from "babylonjs/Gamepads/index";
  80375. export * from "babylonjs/Gizmos/index";
  80376. export * from "babylonjs/Helpers/index";
  80377. export * from "babylonjs/Instrumentation/index";
  80378. export * from "babylonjs/Layers/index";
  80379. export * from "babylonjs/LensFlares/index";
  80380. export * from "babylonjs/Lights/index";
  80381. export * from "babylonjs/Loading/index";
  80382. export * from "babylonjs/Materials/index";
  80383. export * from "babylonjs/Maths/index";
  80384. export * from "babylonjs/Meshes/index";
  80385. export * from "babylonjs/Morph/index";
  80386. export * from "babylonjs/Navigation/index";
  80387. export * from "babylonjs/node";
  80388. export * from "babylonjs/Offline/index";
  80389. export * from "babylonjs/Particles/index";
  80390. export * from "babylonjs/Physics/index";
  80391. export * from "babylonjs/PostProcesses/index";
  80392. export * from "babylonjs/Probes/index";
  80393. export * from "babylonjs/Rendering/index";
  80394. export * from "babylonjs/scene";
  80395. export * from "babylonjs/sceneComponent";
  80396. export * from "babylonjs/Sprites/index";
  80397. export * from "babylonjs/States/index";
  80398. export * from "babylonjs/Misc/index";
  80399. export * from "babylonjs/XR/index";
  80400. export * from "babylonjs/types";
  80401. }
  80402. declare module "babylonjs/Animations/pathCursor" {
  80403. import { Vector3 } from "babylonjs/Maths/math.vector";
  80404. import { Path2 } from "babylonjs/Maths/math.path";
  80405. /**
  80406. * A cursor which tracks a point on a path
  80407. */
  80408. export class PathCursor {
  80409. private path;
  80410. /**
  80411. * Stores path cursor callbacks for when an onchange event is triggered
  80412. */
  80413. private _onchange;
  80414. /**
  80415. * The value of the path cursor
  80416. */
  80417. value: number;
  80418. /**
  80419. * The animation array of the path cursor
  80420. */
  80421. animations: Animation[];
  80422. /**
  80423. * Initializes the path cursor
  80424. * @param path The path to track
  80425. */
  80426. constructor(path: Path2);
  80427. /**
  80428. * Gets the cursor point on the path
  80429. * @returns A point on the path cursor at the cursor location
  80430. */
  80431. getPoint(): Vector3;
  80432. /**
  80433. * Moves the cursor ahead by the step amount
  80434. * @param step The amount to move the cursor forward
  80435. * @returns This path cursor
  80436. */
  80437. moveAhead(step?: number): PathCursor;
  80438. /**
  80439. * Moves the cursor behind by the step amount
  80440. * @param step The amount to move the cursor back
  80441. * @returns This path cursor
  80442. */
  80443. moveBack(step?: number): PathCursor;
  80444. /**
  80445. * Moves the cursor by the step amount
  80446. * If the step amount is greater than one, an exception is thrown
  80447. * @param step The amount to move the cursor
  80448. * @returns This path cursor
  80449. */
  80450. move(step: number): PathCursor;
  80451. /**
  80452. * Ensures that the value is limited between zero and one
  80453. * @returns This path cursor
  80454. */
  80455. private ensureLimits;
  80456. /**
  80457. * Runs onchange callbacks on change (used by the animation engine)
  80458. * @returns This path cursor
  80459. */
  80460. private raiseOnChange;
  80461. /**
  80462. * Executes a function on change
  80463. * @param f A path cursor onchange callback
  80464. * @returns This path cursor
  80465. */
  80466. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80467. }
  80468. }
  80469. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80470. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80471. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80472. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80473. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80474. }
  80475. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80476. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80477. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80478. }
  80479. declare module "babylonjs/Engines/Processors/index" {
  80480. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80481. export * from "babylonjs/Engines/Processors/Expressions/index";
  80482. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80483. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80484. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80485. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80486. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80487. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80488. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80489. }
  80490. declare module "babylonjs/Legacy/legacy" {
  80491. import * as Babylon from "babylonjs/index";
  80492. export * from "babylonjs/index";
  80493. }
  80494. declare module "babylonjs/Shaders/blur.fragment" {
  80495. /** @hidden */
  80496. export var blurPixelShader: {
  80497. name: string;
  80498. shader: string;
  80499. };
  80500. }
  80501. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80502. /** @hidden */
  80503. export var pointCloudVertexDeclaration: {
  80504. name: string;
  80505. shader: string;
  80506. };
  80507. }
  80508. declare module "babylonjs" {
  80509. export * from "babylonjs/Legacy/legacy";
  80510. }
  80511. declare module BABYLON {
  80512. /** Alias type for value that can be null */
  80513. export type Nullable<T> = T | null;
  80514. /**
  80515. * Alias type for number that are floats
  80516. * @ignorenaming
  80517. */
  80518. export type float = number;
  80519. /**
  80520. * Alias type for number that are doubles.
  80521. * @ignorenaming
  80522. */
  80523. export type double = number;
  80524. /**
  80525. * Alias type for number that are integer
  80526. * @ignorenaming
  80527. */
  80528. export type int = number;
  80529. /** Alias type for number array or Float32Array */
  80530. export type FloatArray = number[] | Float32Array;
  80531. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80532. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80533. /**
  80534. * Alias for types that can be used by a Buffer or VertexBuffer.
  80535. */
  80536. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80537. /**
  80538. * Alias type for primitive types
  80539. * @ignorenaming
  80540. */
  80541. type Primitive = undefined | null | boolean | string | number | Function;
  80542. /**
  80543. * Type modifier to make all the properties of an object Readonly
  80544. */
  80545. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80546. /**
  80547. * Type modifier to make all the properties of an object Readonly recursively
  80548. */
  80549. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80550. /**
  80551. * Type modifier to make object properties readonly.
  80552. */
  80553. export type DeepImmutableObject<T> = {
  80554. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80555. };
  80556. /** @hidden */
  80557. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80558. }
  80559. }
  80560. declare module BABYLON {
  80561. /**
  80562. * A class serves as a medium between the observable and its observers
  80563. */
  80564. export class EventState {
  80565. /**
  80566. * Create a new EventState
  80567. * @param mask defines the mask associated with this state
  80568. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80569. * @param target defines the original target of the state
  80570. * @param currentTarget defines the current target of the state
  80571. */
  80572. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80573. /**
  80574. * Initialize the current event state
  80575. * @param mask defines the mask associated with this state
  80576. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80577. * @param target defines the original target of the state
  80578. * @param currentTarget defines the current target of the state
  80579. * @returns the current event state
  80580. */
  80581. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80582. /**
  80583. * An Observer can set this property to true to prevent subsequent observers of being notified
  80584. */
  80585. skipNextObservers: boolean;
  80586. /**
  80587. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80588. */
  80589. mask: number;
  80590. /**
  80591. * The object that originally notified the event
  80592. */
  80593. target?: any;
  80594. /**
  80595. * The current object in the bubbling phase
  80596. */
  80597. currentTarget?: any;
  80598. /**
  80599. * This will be populated with the return value of the last function that was executed.
  80600. * If it is the first function in the callback chain it will be the event data.
  80601. */
  80602. lastReturnValue?: any;
  80603. }
  80604. /**
  80605. * Represent an Observer registered to a given Observable object.
  80606. */
  80607. export class Observer<T> {
  80608. /**
  80609. * Defines the callback to call when the observer is notified
  80610. */
  80611. callback: (eventData: T, eventState: EventState) => void;
  80612. /**
  80613. * Defines the mask of the observer (used to filter notifications)
  80614. */
  80615. mask: number;
  80616. /**
  80617. * Defines the current scope used to restore the JS context
  80618. */
  80619. scope: any;
  80620. /** @hidden */
  80621. _willBeUnregistered: boolean;
  80622. /**
  80623. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80624. */
  80625. unregisterOnNextCall: boolean;
  80626. /**
  80627. * Creates a new observer
  80628. * @param callback defines the callback to call when the observer is notified
  80629. * @param mask defines the mask of the observer (used to filter notifications)
  80630. * @param scope defines the current scope used to restore the JS context
  80631. */
  80632. constructor(
  80633. /**
  80634. * Defines the callback to call when the observer is notified
  80635. */
  80636. callback: (eventData: T, eventState: EventState) => void,
  80637. /**
  80638. * Defines the mask of the observer (used to filter notifications)
  80639. */
  80640. mask: number,
  80641. /**
  80642. * Defines the current scope used to restore the JS context
  80643. */
  80644. scope?: any);
  80645. }
  80646. /**
  80647. * Represent a list of observers registered to multiple Observables object.
  80648. */
  80649. export class MultiObserver<T> {
  80650. private _observers;
  80651. private _observables;
  80652. /**
  80653. * Release associated resources
  80654. */
  80655. dispose(): void;
  80656. /**
  80657. * Raise a callback when one of the observable will notify
  80658. * @param observables defines a list of observables to watch
  80659. * @param callback defines the callback to call on notification
  80660. * @param mask defines the mask used to filter notifications
  80661. * @param scope defines the current scope used to restore the JS context
  80662. * @returns the new MultiObserver
  80663. */
  80664. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80665. }
  80666. /**
  80667. * The Observable class is a simple implementation of the Observable pattern.
  80668. *
  80669. * 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.
  80670. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80671. * 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).
  80672. * 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.
  80673. */
  80674. export class Observable<T> {
  80675. private _observers;
  80676. private _eventState;
  80677. private _onObserverAdded;
  80678. /**
  80679. * Gets the list of observers
  80680. */
  80681. get observers(): Array<Observer<T>>;
  80682. /**
  80683. * Creates a new observable
  80684. * @param onObserverAdded defines a callback to call when a new observer is added
  80685. */
  80686. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80687. /**
  80688. * Create a new Observer with the specified callback
  80689. * @param callback the callback that will be executed for that Observer
  80690. * @param mask the mask used to filter observers
  80691. * @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.
  80692. * @param scope optional scope for the callback to be called from
  80693. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80694. * @returns the new observer created for the callback
  80695. */
  80696. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80697. /**
  80698. * Create a new Observer with the specified callback and unregisters after the next notification
  80699. * @param callback the callback that will be executed for that Observer
  80700. * @returns the new observer created for the callback
  80701. */
  80702. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80703. /**
  80704. * Remove an Observer from the Observable object
  80705. * @param observer the instance of the Observer to remove
  80706. * @returns false if it doesn't belong to this Observable
  80707. */
  80708. remove(observer: Nullable<Observer<T>>): boolean;
  80709. /**
  80710. * Remove a callback from the Observable object
  80711. * @param callback the callback to remove
  80712. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80713. * @returns false if it doesn't belong to this Observable
  80714. */
  80715. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80716. private _deferUnregister;
  80717. private _remove;
  80718. /**
  80719. * Moves the observable to the top of the observer list making it get called first when notified
  80720. * @param observer the observer to move
  80721. */
  80722. makeObserverTopPriority(observer: Observer<T>): void;
  80723. /**
  80724. * Moves the observable to the bottom of the observer list making it get called last when notified
  80725. * @param observer the observer to move
  80726. */
  80727. makeObserverBottomPriority(observer: Observer<T>): void;
  80728. /**
  80729. * Notify all Observers by calling their respective callback with the given data
  80730. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80731. * @param eventData defines the data to send to all observers
  80732. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80733. * @param target defines the original target of the state
  80734. * @param currentTarget defines the current target of the state
  80735. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80736. */
  80737. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80738. /**
  80739. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80740. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80741. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80742. * and it is crucial that all callbacks will be executed.
  80743. * The order of the callbacks is kept, callbacks are not executed parallel.
  80744. *
  80745. * @param eventData The data to be sent to each callback
  80746. * @param mask is used to filter observers defaults to -1
  80747. * @param target defines the callback target (see EventState)
  80748. * @param currentTarget defines he current object in the bubbling phase
  80749. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80750. */
  80751. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80752. /**
  80753. * Notify a specific observer
  80754. * @param observer defines the observer to notify
  80755. * @param eventData defines the data to be sent to each callback
  80756. * @param mask is used to filter observers defaults to -1
  80757. */
  80758. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80759. /**
  80760. * Gets a boolean indicating if the observable has at least one observer
  80761. * @returns true is the Observable has at least one Observer registered
  80762. */
  80763. hasObservers(): boolean;
  80764. /**
  80765. * Clear the list of observers
  80766. */
  80767. clear(): void;
  80768. /**
  80769. * Clone the current observable
  80770. * @returns a new observable
  80771. */
  80772. clone(): Observable<T>;
  80773. /**
  80774. * Does this observable handles observer registered with a given mask
  80775. * @param mask defines the mask to be tested
  80776. * @return whether or not one observer registered with the given mask is handeled
  80777. **/
  80778. hasSpecificMask(mask?: number): boolean;
  80779. }
  80780. }
  80781. declare module BABYLON {
  80782. /**
  80783. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80784. * Babylon.js
  80785. */
  80786. export class DomManagement {
  80787. /**
  80788. * Checks if the window object exists
  80789. * @returns true if the window object exists
  80790. */
  80791. static IsWindowObjectExist(): boolean;
  80792. /**
  80793. * Checks if the navigator object exists
  80794. * @returns true if the navigator object exists
  80795. */
  80796. static IsNavigatorAvailable(): boolean;
  80797. /**
  80798. * Check if the document object exists
  80799. * @returns true if the document object exists
  80800. */
  80801. static IsDocumentAvailable(): boolean;
  80802. /**
  80803. * Extracts text content from a DOM element hierarchy
  80804. * @param element defines the root element
  80805. * @returns a string
  80806. */
  80807. static GetDOMTextContent(element: HTMLElement): string;
  80808. }
  80809. }
  80810. declare module BABYLON {
  80811. /**
  80812. * Logger used througouht the application to allow configuration of
  80813. * the log level required for the messages.
  80814. */
  80815. export class Logger {
  80816. /**
  80817. * No log
  80818. */
  80819. static readonly NoneLogLevel: number;
  80820. /**
  80821. * Only message logs
  80822. */
  80823. static readonly MessageLogLevel: number;
  80824. /**
  80825. * Only warning logs
  80826. */
  80827. static readonly WarningLogLevel: number;
  80828. /**
  80829. * Only error logs
  80830. */
  80831. static readonly ErrorLogLevel: number;
  80832. /**
  80833. * All logs
  80834. */
  80835. static readonly AllLogLevel: number;
  80836. private static _LogCache;
  80837. /**
  80838. * Gets a value indicating the number of loading errors
  80839. * @ignorenaming
  80840. */
  80841. static errorsCount: number;
  80842. /**
  80843. * Callback called when a new log is added
  80844. */
  80845. static OnNewCacheEntry: (entry: string) => void;
  80846. private static _AddLogEntry;
  80847. private static _FormatMessage;
  80848. private static _LogDisabled;
  80849. private static _LogEnabled;
  80850. private static _WarnDisabled;
  80851. private static _WarnEnabled;
  80852. private static _ErrorDisabled;
  80853. private static _ErrorEnabled;
  80854. /**
  80855. * Log a message to the console
  80856. */
  80857. static Log: (message: string) => void;
  80858. /**
  80859. * Write a warning message to the console
  80860. */
  80861. static Warn: (message: string) => void;
  80862. /**
  80863. * Write an error message to the console
  80864. */
  80865. static Error: (message: string) => void;
  80866. /**
  80867. * Gets current log cache (list of logs)
  80868. */
  80869. static get LogCache(): string;
  80870. /**
  80871. * Clears the log cache
  80872. */
  80873. static ClearLogCache(): void;
  80874. /**
  80875. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80876. */
  80877. static set LogLevels(level: number);
  80878. }
  80879. }
  80880. declare module BABYLON {
  80881. /** @hidden */
  80882. export class _TypeStore {
  80883. /** @hidden */
  80884. static RegisteredTypes: {
  80885. [key: string]: Object;
  80886. };
  80887. /** @hidden */
  80888. static GetClass(fqdn: string): any;
  80889. }
  80890. }
  80891. declare module BABYLON {
  80892. /**
  80893. * Helper to manipulate strings
  80894. */
  80895. export class StringTools {
  80896. /**
  80897. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80898. * @param str Source string
  80899. * @param suffix Suffix to search for in the source string
  80900. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80901. */
  80902. static EndsWith(str: string, suffix: string): boolean;
  80903. /**
  80904. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80905. * @param str Source string
  80906. * @param suffix Suffix to search for in the source string
  80907. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80908. */
  80909. static StartsWith(str: string, suffix: string): boolean;
  80910. /**
  80911. * Decodes a buffer into a string
  80912. * @param buffer The buffer to decode
  80913. * @returns The decoded string
  80914. */
  80915. static Decode(buffer: Uint8Array | Uint16Array): string;
  80916. /**
  80917. * Encode a buffer to a base64 string
  80918. * @param buffer defines the buffer to encode
  80919. * @returns the encoded string
  80920. */
  80921. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80922. /**
  80923. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80924. * @param num the number to convert and pad
  80925. * @param length the expected length of the string
  80926. * @returns the padded string
  80927. */
  80928. static PadNumber(num: number, length: number): string;
  80929. }
  80930. }
  80931. declare module BABYLON {
  80932. /**
  80933. * Class containing a set of static utilities functions for deep copy.
  80934. */
  80935. export class DeepCopier {
  80936. /**
  80937. * Tries to copy an object by duplicating every property
  80938. * @param source defines the source object
  80939. * @param destination defines the target object
  80940. * @param doNotCopyList defines a list of properties to avoid
  80941. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80942. */
  80943. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80944. }
  80945. }
  80946. declare module BABYLON {
  80947. /**
  80948. * Class containing a set of static utilities functions for precision date
  80949. */
  80950. export class PrecisionDate {
  80951. /**
  80952. * Gets either window.performance.now() if supported or Date.now() else
  80953. */
  80954. static get Now(): number;
  80955. }
  80956. }
  80957. declare module BABYLON {
  80958. /** @hidden */
  80959. export class _DevTools {
  80960. static WarnImport(name: string): string;
  80961. }
  80962. }
  80963. declare module BABYLON {
  80964. /**
  80965. * Interface used to define the mechanism to get data from the network
  80966. */
  80967. export interface IWebRequest {
  80968. /**
  80969. * Returns client's response url
  80970. */
  80971. responseURL: string;
  80972. /**
  80973. * Returns client's status
  80974. */
  80975. status: number;
  80976. /**
  80977. * Returns client's status as a text
  80978. */
  80979. statusText: string;
  80980. }
  80981. }
  80982. declare module BABYLON {
  80983. /**
  80984. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80985. */
  80986. export class WebRequest implements IWebRequest {
  80987. private _xhr;
  80988. /**
  80989. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80990. * i.e. when loading files, where the server/service expects an Authorization header
  80991. */
  80992. static CustomRequestHeaders: {
  80993. [key: string]: string;
  80994. };
  80995. /**
  80996. * Add callback functions in this array to update all the requests before they get sent to the network
  80997. */
  80998. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80999. private _injectCustomRequestHeaders;
  81000. /**
  81001. * Gets or sets a function to be called when loading progress changes
  81002. */
  81003. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81004. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81005. /**
  81006. * Returns client's state
  81007. */
  81008. get readyState(): number;
  81009. /**
  81010. * Returns client's status
  81011. */
  81012. get status(): number;
  81013. /**
  81014. * Returns client's status as a text
  81015. */
  81016. get statusText(): string;
  81017. /**
  81018. * Returns client's response
  81019. */
  81020. get response(): any;
  81021. /**
  81022. * Returns client's response url
  81023. */
  81024. get responseURL(): string;
  81025. /**
  81026. * Returns client's response as text
  81027. */
  81028. get responseText(): string;
  81029. /**
  81030. * Gets or sets the expected response type
  81031. */
  81032. get responseType(): XMLHttpRequestResponseType;
  81033. set responseType(value: XMLHttpRequestResponseType);
  81034. /** @hidden */
  81035. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81036. /** @hidden */
  81037. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81038. /**
  81039. * Cancels any network activity
  81040. */
  81041. abort(): void;
  81042. /**
  81043. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81044. * @param body defines an optional request body
  81045. */
  81046. send(body?: Document | BodyInit | null): void;
  81047. /**
  81048. * Sets the request method, request URL
  81049. * @param method defines the method to use (GET, POST, etc..)
  81050. * @param url defines the url to connect with
  81051. */
  81052. open(method: string, url: string): void;
  81053. /**
  81054. * Sets the value of a request header.
  81055. * @param name The name of the header whose value is to be set
  81056. * @param value The value to set as the body of the header
  81057. */
  81058. setRequestHeader(name: string, value: string): void;
  81059. /**
  81060. * Get the string containing the text of a particular header's value.
  81061. * @param name The name of the header
  81062. * @returns The string containing the text of the given header name
  81063. */
  81064. getResponseHeader(name: string): Nullable<string>;
  81065. }
  81066. }
  81067. declare module BABYLON {
  81068. /**
  81069. * File request interface
  81070. */
  81071. export interface IFileRequest {
  81072. /**
  81073. * Raised when the request is complete (success or error).
  81074. */
  81075. onCompleteObservable: Observable<IFileRequest>;
  81076. /**
  81077. * Aborts the request for a file.
  81078. */
  81079. abort: () => void;
  81080. }
  81081. }
  81082. declare module BABYLON {
  81083. /**
  81084. * Define options used to create a render target texture
  81085. */
  81086. export class RenderTargetCreationOptions {
  81087. /**
  81088. * Specifies is mipmaps must be generated
  81089. */
  81090. generateMipMaps?: boolean;
  81091. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81092. generateDepthBuffer?: boolean;
  81093. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81094. generateStencilBuffer?: boolean;
  81095. /** Defines texture type (int by default) */
  81096. type?: number;
  81097. /** Defines sampling mode (trilinear by default) */
  81098. samplingMode?: number;
  81099. /** Defines format (RGBA by default) */
  81100. format?: number;
  81101. }
  81102. }
  81103. declare module BABYLON {
  81104. /** Defines the cross module used constants to avoid circular dependncies */
  81105. export class Constants {
  81106. /** Defines that alpha blending is disabled */
  81107. static readonly ALPHA_DISABLE: number;
  81108. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81109. static readonly ALPHA_ADD: number;
  81110. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81111. static readonly ALPHA_COMBINE: number;
  81112. /** Defines that alpha blending is DEST - SRC * DEST */
  81113. static readonly ALPHA_SUBTRACT: number;
  81114. /** Defines that alpha blending is SRC * DEST */
  81115. static readonly ALPHA_MULTIPLY: number;
  81116. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81117. static readonly ALPHA_MAXIMIZED: number;
  81118. /** Defines that alpha blending is SRC + DEST */
  81119. static readonly ALPHA_ONEONE: number;
  81120. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81121. static readonly ALPHA_PREMULTIPLIED: number;
  81122. /**
  81123. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81124. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81125. */
  81126. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81127. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81128. static readonly ALPHA_INTERPOLATE: number;
  81129. /**
  81130. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81131. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81132. */
  81133. static readonly ALPHA_SCREENMODE: number;
  81134. /**
  81135. * Defines that alpha blending is SRC + DST
  81136. * Alpha will be set to SRC ALPHA + DST ALPHA
  81137. */
  81138. static readonly ALPHA_ONEONE_ONEONE: number;
  81139. /**
  81140. * Defines that alpha blending is SRC * DST ALPHA + DST
  81141. * Alpha will be set to 0
  81142. */
  81143. static readonly ALPHA_ALPHATOCOLOR: number;
  81144. /**
  81145. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81146. */
  81147. static readonly ALPHA_REVERSEONEMINUS: number;
  81148. /**
  81149. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81150. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81151. */
  81152. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81153. /**
  81154. * Defines that alpha blending is SRC + DST
  81155. * Alpha will be set to SRC ALPHA
  81156. */
  81157. static readonly ALPHA_ONEONE_ONEZERO: number;
  81158. /**
  81159. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81160. * Alpha will be set to DST ALPHA
  81161. */
  81162. static readonly ALPHA_EXCLUSION: number;
  81163. /** Defines that alpha blending equation a SUM */
  81164. static readonly ALPHA_EQUATION_ADD: number;
  81165. /** Defines that alpha blending equation a SUBSTRACTION */
  81166. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81167. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81168. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81169. /** Defines that alpha blending equation a MAX operation */
  81170. static readonly ALPHA_EQUATION_MAX: number;
  81171. /** Defines that alpha blending equation a MIN operation */
  81172. static readonly ALPHA_EQUATION_MIN: number;
  81173. /**
  81174. * Defines that alpha blending equation a DARKEN operation:
  81175. * It takes the min of the src and sums the alpha channels.
  81176. */
  81177. static readonly ALPHA_EQUATION_DARKEN: number;
  81178. /** Defines that the ressource is not delayed*/
  81179. static readonly DELAYLOADSTATE_NONE: number;
  81180. /** Defines that the ressource was successfully delay loaded */
  81181. static readonly DELAYLOADSTATE_LOADED: number;
  81182. /** Defines that the ressource is currently delay loading */
  81183. static readonly DELAYLOADSTATE_LOADING: number;
  81184. /** Defines that the ressource is delayed and has not started loading */
  81185. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81186. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81187. static readonly NEVER: number;
  81188. /** 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 */
  81189. static readonly ALWAYS: number;
  81190. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81191. static readonly LESS: number;
  81192. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81193. static readonly EQUAL: number;
  81194. /** 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 */
  81195. static readonly LEQUAL: number;
  81196. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81197. static readonly GREATER: number;
  81198. /** 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 */
  81199. static readonly GEQUAL: number;
  81200. /** 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 */
  81201. static readonly NOTEQUAL: number;
  81202. /** Passed to stencilOperation to specify that stencil value must be kept */
  81203. static readonly KEEP: number;
  81204. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81205. static readonly REPLACE: number;
  81206. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81207. static readonly INCR: number;
  81208. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81209. static readonly DECR: number;
  81210. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81211. static readonly INVERT: number;
  81212. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81213. static readonly INCR_WRAP: number;
  81214. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81215. static readonly DECR_WRAP: number;
  81216. /** Texture is not repeating outside of 0..1 UVs */
  81217. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81218. /** Texture is repeating outside of 0..1 UVs */
  81219. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81220. /** Texture is repeating and mirrored */
  81221. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81222. /** ALPHA */
  81223. static readonly TEXTUREFORMAT_ALPHA: number;
  81224. /** LUMINANCE */
  81225. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81226. /** LUMINANCE_ALPHA */
  81227. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81228. /** RGB */
  81229. static readonly TEXTUREFORMAT_RGB: number;
  81230. /** RGBA */
  81231. static readonly TEXTUREFORMAT_RGBA: number;
  81232. /** RED */
  81233. static readonly TEXTUREFORMAT_RED: number;
  81234. /** RED (2nd reference) */
  81235. static readonly TEXTUREFORMAT_R: number;
  81236. /** RG */
  81237. static readonly TEXTUREFORMAT_RG: number;
  81238. /** RED_INTEGER */
  81239. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81240. /** RED_INTEGER (2nd reference) */
  81241. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81242. /** RG_INTEGER */
  81243. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81244. /** RGB_INTEGER */
  81245. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81246. /** RGBA_INTEGER */
  81247. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81248. /** UNSIGNED_BYTE */
  81249. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81250. /** UNSIGNED_BYTE (2nd reference) */
  81251. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81252. /** FLOAT */
  81253. static readonly TEXTURETYPE_FLOAT: number;
  81254. /** HALF_FLOAT */
  81255. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81256. /** BYTE */
  81257. static readonly TEXTURETYPE_BYTE: number;
  81258. /** SHORT */
  81259. static readonly TEXTURETYPE_SHORT: number;
  81260. /** UNSIGNED_SHORT */
  81261. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81262. /** INT */
  81263. static readonly TEXTURETYPE_INT: number;
  81264. /** UNSIGNED_INT */
  81265. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81266. /** UNSIGNED_SHORT_4_4_4_4 */
  81267. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81268. /** UNSIGNED_SHORT_5_5_5_1 */
  81269. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81270. /** UNSIGNED_SHORT_5_6_5 */
  81271. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81272. /** UNSIGNED_INT_2_10_10_10_REV */
  81273. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81274. /** UNSIGNED_INT_24_8 */
  81275. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81276. /** UNSIGNED_INT_10F_11F_11F_REV */
  81277. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81278. /** UNSIGNED_INT_5_9_9_9_REV */
  81279. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81280. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81281. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81282. /** nearest is mag = nearest and min = nearest and no mip */
  81283. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81284. /** mag = nearest and min = nearest and mip = none */
  81285. static readonly TEXTURE_NEAREST_NEAREST: number;
  81286. /** Bilinear is mag = linear and min = linear and no mip */
  81287. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81288. /** mag = linear and min = linear and mip = none */
  81289. static readonly TEXTURE_LINEAR_LINEAR: number;
  81290. /** Trilinear is mag = linear and min = linear and mip = linear */
  81291. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81292. /** Trilinear is mag = linear and min = linear and mip = linear */
  81293. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81294. /** mag = nearest and min = nearest and mip = nearest */
  81295. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81296. /** mag = nearest and min = linear and mip = nearest */
  81297. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81298. /** mag = nearest and min = linear and mip = linear */
  81299. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81300. /** mag = nearest and min = linear and mip = none */
  81301. static readonly TEXTURE_NEAREST_LINEAR: number;
  81302. /** nearest is mag = nearest and min = nearest and mip = linear */
  81303. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81304. /** mag = linear and min = nearest and mip = nearest */
  81305. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81306. /** mag = linear and min = nearest and mip = linear */
  81307. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81308. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81309. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81310. /** mag = linear and min = nearest and mip = none */
  81311. static readonly TEXTURE_LINEAR_NEAREST: number;
  81312. /** Explicit coordinates mode */
  81313. static readonly TEXTURE_EXPLICIT_MODE: number;
  81314. /** Spherical coordinates mode */
  81315. static readonly TEXTURE_SPHERICAL_MODE: number;
  81316. /** Planar coordinates mode */
  81317. static readonly TEXTURE_PLANAR_MODE: number;
  81318. /** Cubic coordinates mode */
  81319. static readonly TEXTURE_CUBIC_MODE: number;
  81320. /** Projection coordinates mode */
  81321. static readonly TEXTURE_PROJECTION_MODE: number;
  81322. /** Skybox coordinates mode */
  81323. static readonly TEXTURE_SKYBOX_MODE: number;
  81324. /** Inverse Cubic coordinates mode */
  81325. static readonly TEXTURE_INVCUBIC_MODE: number;
  81326. /** Equirectangular coordinates mode */
  81327. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81328. /** Equirectangular Fixed coordinates mode */
  81329. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81330. /** Equirectangular Fixed Mirrored coordinates mode */
  81331. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81332. /** Offline (baking) quality for texture filtering */
  81333. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81334. /** High quality for texture filtering */
  81335. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81336. /** Medium quality for texture filtering */
  81337. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81338. /** Low quality for texture filtering */
  81339. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81340. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81341. static readonly SCALEMODE_FLOOR: number;
  81342. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81343. static readonly SCALEMODE_NEAREST: number;
  81344. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81345. static readonly SCALEMODE_CEILING: number;
  81346. /**
  81347. * The dirty texture flag value
  81348. */
  81349. static readonly MATERIAL_TextureDirtyFlag: number;
  81350. /**
  81351. * The dirty light flag value
  81352. */
  81353. static readonly MATERIAL_LightDirtyFlag: number;
  81354. /**
  81355. * The dirty fresnel flag value
  81356. */
  81357. static readonly MATERIAL_FresnelDirtyFlag: number;
  81358. /**
  81359. * The dirty attribute flag value
  81360. */
  81361. static readonly MATERIAL_AttributesDirtyFlag: number;
  81362. /**
  81363. * The dirty misc flag value
  81364. */
  81365. static readonly MATERIAL_MiscDirtyFlag: number;
  81366. /**
  81367. * The dirty prepass flag value
  81368. */
  81369. static readonly MATERIAL_PrePassDirtyFlag: number;
  81370. /**
  81371. * The all dirty flag value
  81372. */
  81373. static readonly MATERIAL_AllDirtyFlag: number;
  81374. /**
  81375. * Returns the triangle fill mode
  81376. */
  81377. static readonly MATERIAL_TriangleFillMode: number;
  81378. /**
  81379. * Returns the wireframe mode
  81380. */
  81381. static readonly MATERIAL_WireFrameFillMode: number;
  81382. /**
  81383. * Returns the point fill mode
  81384. */
  81385. static readonly MATERIAL_PointFillMode: number;
  81386. /**
  81387. * Returns the point list draw mode
  81388. */
  81389. static readonly MATERIAL_PointListDrawMode: number;
  81390. /**
  81391. * Returns the line list draw mode
  81392. */
  81393. static readonly MATERIAL_LineListDrawMode: number;
  81394. /**
  81395. * Returns the line loop draw mode
  81396. */
  81397. static readonly MATERIAL_LineLoopDrawMode: number;
  81398. /**
  81399. * Returns the line strip draw mode
  81400. */
  81401. static readonly MATERIAL_LineStripDrawMode: number;
  81402. /**
  81403. * Returns the triangle strip draw mode
  81404. */
  81405. static readonly MATERIAL_TriangleStripDrawMode: number;
  81406. /**
  81407. * Returns the triangle fan draw mode
  81408. */
  81409. static readonly MATERIAL_TriangleFanDrawMode: number;
  81410. /**
  81411. * Stores the clock-wise side orientation
  81412. */
  81413. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81414. /**
  81415. * Stores the counter clock-wise side orientation
  81416. */
  81417. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81418. /**
  81419. * Nothing
  81420. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81421. */
  81422. static readonly ACTION_NothingTrigger: number;
  81423. /**
  81424. * On pick
  81425. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81426. */
  81427. static readonly ACTION_OnPickTrigger: number;
  81428. /**
  81429. * On left pick
  81430. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81431. */
  81432. static readonly ACTION_OnLeftPickTrigger: number;
  81433. /**
  81434. * On right pick
  81435. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81436. */
  81437. static readonly ACTION_OnRightPickTrigger: number;
  81438. /**
  81439. * On center pick
  81440. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81441. */
  81442. static readonly ACTION_OnCenterPickTrigger: number;
  81443. /**
  81444. * On pick down
  81445. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81446. */
  81447. static readonly ACTION_OnPickDownTrigger: number;
  81448. /**
  81449. * On double pick
  81450. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81451. */
  81452. static readonly ACTION_OnDoublePickTrigger: number;
  81453. /**
  81454. * On pick up
  81455. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81456. */
  81457. static readonly ACTION_OnPickUpTrigger: number;
  81458. /**
  81459. * On pick out.
  81460. * This trigger will only be raised if you also declared a OnPickDown
  81461. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81462. */
  81463. static readonly ACTION_OnPickOutTrigger: number;
  81464. /**
  81465. * On long press
  81466. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81467. */
  81468. static readonly ACTION_OnLongPressTrigger: number;
  81469. /**
  81470. * On pointer over
  81471. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81472. */
  81473. static readonly ACTION_OnPointerOverTrigger: number;
  81474. /**
  81475. * On pointer out
  81476. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81477. */
  81478. static readonly ACTION_OnPointerOutTrigger: number;
  81479. /**
  81480. * On every frame
  81481. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81482. */
  81483. static readonly ACTION_OnEveryFrameTrigger: number;
  81484. /**
  81485. * On intersection enter
  81486. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81487. */
  81488. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81489. /**
  81490. * On intersection exit
  81491. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81492. */
  81493. static readonly ACTION_OnIntersectionExitTrigger: number;
  81494. /**
  81495. * On key down
  81496. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81497. */
  81498. static readonly ACTION_OnKeyDownTrigger: number;
  81499. /**
  81500. * On key up
  81501. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81502. */
  81503. static readonly ACTION_OnKeyUpTrigger: number;
  81504. /**
  81505. * Billboard mode will only apply to Y axis
  81506. */
  81507. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81508. /**
  81509. * Billboard mode will apply to all axes
  81510. */
  81511. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81512. /**
  81513. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81514. */
  81515. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81516. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81517. * Test order :
  81518. * Is the bounding sphere outside the frustum ?
  81519. * If not, are the bounding box vertices outside the frustum ?
  81520. * It not, then the cullable object is in the frustum.
  81521. */
  81522. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81523. /** Culling strategy : Bounding Sphere Only.
  81524. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81525. * It's also less accurate than the standard because some not visible objects can still be selected.
  81526. * Test : is the bounding sphere outside the frustum ?
  81527. * If not, then the cullable object is in the frustum.
  81528. */
  81529. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81530. /** Culling strategy : Optimistic Inclusion.
  81531. * This in an inclusion test first, then the standard exclusion test.
  81532. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81533. * 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.
  81534. * Anyway, it's as accurate as the standard strategy.
  81535. * Test :
  81536. * Is the cullable object bounding sphere center in the frustum ?
  81537. * If not, apply the default culling strategy.
  81538. */
  81539. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81540. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81541. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81542. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81543. * 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.
  81544. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81545. * Test :
  81546. * Is the cullable object bounding sphere center in the frustum ?
  81547. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81548. */
  81549. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81550. /**
  81551. * No logging while loading
  81552. */
  81553. static readonly SCENELOADER_NO_LOGGING: number;
  81554. /**
  81555. * Minimal logging while loading
  81556. */
  81557. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81558. /**
  81559. * Summary logging while loading
  81560. */
  81561. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81562. /**
  81563. * Detailled logging while loading
  81564. */
  81565. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81566. /**
  81567. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81568. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81569. */
  81570. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81571. /**
  81572. * Constant used to retrieve the position texture index in the textures array in the prepass
  81573. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81574. */
  81575. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81576. /**
  81577. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81578. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81579. */
  81580. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81581. /**
  81582. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81583. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81584. */
  81585. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81586. /**
  81587. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81588. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81589. */
  81590. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81591. /**
  81592. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81593. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81594. */
  81595. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81596. /**
  81597. * Constant used to retrieve albedo index in the textures array in the prepass
  81598. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81599. */
  81600. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81601. }
  81602. }
  81603. declare module BABYLON {
  81604. /**
  81605. * This represents the required contract to create a new type of texture loader.
  81606. */
  81607. export interface IInternalTextureLoader {
  81608. /**
  81609. * Defines wether the loader supports cascade loading the different faces.
  81610. */
  81611. supportCascades: boolean;
  81612. /**
  81613. * This returns if the loader support the current file information.
  81614. * @param extension defines the file extension of the file being loaded
  81615. * @param mimeType defines the optional mime type of the file being loaded
  81616. * @returns true if the loader can load the specified file
  81617. */
  81618. canLoad(extension: string, mimeType?: string): boolean;
  81619. /**
  81620. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81621. * @param data contains the texture data
  81622. * @param texture defines the BabylonJS internal texture
  81623. * @param createPolynomials will be true if polynomials have been requested
  81624. * @param onLoad defines the callback to trigger once the texture is ready
  81625. * @param onError defines the callback to trigger in case of error
  81626. */
  81627. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81628. /**
  81629. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81630. * @param data contains the texture data
  81631. * @param texture defines the BabylonJS internal texture
  81632. * @param callback defines the method to call once ready to upload
  81633. */
  81634. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81635. }
  81636. }
  81637. declare module BABYLON {
  81638. /**
  81639. * Class used to store and describe the pipeline context associated with an effect
  81640. */
  81641. export interface IPipelineContext {
  81642. /**
  81643. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81644. */
  81645. isAsync: boolean;
  81646. /**
  81647. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81648. */
  81649. isReady: boolean;
  81650. /** @hidden */
  81651. _getVertexShaderCode(): string | null;
  81652. /** @hidden */
  81653. _getFragmentShaderCode(): string | null;
  81654. /** @hidden */
  81655. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81656. }
  81657. }
  81658. declare module BABYLON {
  81659. /**
  81660. * Class used to store gfx data (like WebGLBuffer)
  81661. */
  81662. export class DataBuffer {
  81663. /**
  81664. * Gets or sets the number of objects referencing this buffer
  81665. */
  81666. references: number;
  81667. /** Gets or sets the size of the underlying buffer */
  81668. capacity: number;
  81669. /**
  81670. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81671. */
  81672. is32Bits: boolean;
  81673. /**
  81674. * Gets the underlying buffer
  81675. */
  81676. get underlyingResource(): any;
  81677. }
  81678. }
  81679. declare module BABYLON {
  81680. /** @hidden */
  81681. export interface IShaderProcessor {
  81682. attributeProcessor?: (attribute: string) => string;
  81683. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81684. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81685. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81686. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81687. lineProcessor?: (line: string, isFragment: boolean) => string;
  81688. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81689. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81690. }
  81691. }
  81692. declare module BABYLON {
  81693. /** @hidden */
  81694. export interface ProcessingOptions {
  81695. defines: string[];
  81696. indexParameters: any;
  81697. isFragment: boolean;
  81698. shouldUseHighPrecisionShader: boolean;
  81699. supportsUniformBuffers: boolean;
  81700. shadersRepository: string;
  81701. includesShadersStore: {
  81702. [key: string]: string;
  81703. };
  81704. processor?: IShaderProcessor;
  81705. version: string;
  81706. platformName: string;
  81707. lookForClosingBracketForUniformBuffer?: boolean;
  81708. }
  81709. }
  81710. declare module BABYLON {
  81711. /** @hidden */
  81712. export class ShaderCodeNode {
  81713. line: string;
  81714. children: ShaderCodeNode[];
  81715. additionalDefineKey?: string;
  81716. additionalDefineValue?: string;
  81717. isValid(preprocessors: {
  81718. [key: string]: string;
  81719. }): boolean;
  81720. process(preprocessors: {
  81721. [key: string]: string;
  81722. }, options: ProcessingOptions): string;
  81723. }
  81724. }
  81725. declare module BABYLON {
  81726. /** @hidden */
  81727. export class ShaderCodeCursor {
  81728. private _lines;
  81729. lineIndex: number;
  81730. get currentLine(): string;
  81731. get canRead(): boolean;
  81732. set lines(value: string[]);
  81733. }
  81734. }
  81735. declare module BABYLON {
  81736. /** @hidden */
  81737. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81738. process(preprocessors: {
  81739. [key: string]: string;
  81740. }, options: ProcessingOptions): string;
  81741. }
  81742. }
  81743. declare module BABYLON {
  81744. /** @hidden */
  81745. export class ShaderDefineExpression {
  81746. isTrue(preprocessors: {
  81747. [key: string]: string;
  81748. }): boolean;
  81749. private static _OperatorPriority;
  81750. private static _Stack;
  81751. static postfixToInfix(postfix: string[]): string;
  81752. static infixToPostfix(infix: string): string[];
  81753. }
  81754. }
  81755. declare module BABYLON {
  81756. /** @hidden */
  81757. export class ShaderCodeTestNode extends ShaderCodeNode {
  81758. testExpression: ShaderDefineExpression;
  81759. isValid(preprocessors: {
  81760. [key: string]: string;
  81761. }): boolean;
  81762. }
  81763. }
  81764. declare module BABYLON {
  81765. /** @hidden */
  81766. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81767. define: string;
  81768. not: boolean;
  81769. constructor(define: string, not?: boolean);
  81770. isTrue(preprocessors: {
  81771. [key: string]: string;
  81772. }): boolean;
  81773. }
  81774. }
  81775. declare module BABYLON {
  81776. /** @hidden */
  81777. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81778. leftOperand: ShaderDefineExpression;
  81779. rightOperand: ShaderDefineExpression;
  81780. isTrue(preprocessors: {
  81781. [key: string]: string;
  81782. }): boolean;
  81783. }
  81784. }
  81785. declare module BABYLON {
  81786. /** @hidden */
  81787. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81788. leftOperand: ShaderDefineExpression;
  81789. rightOperand: ShaderDefineExpression;
  81790. isTrue(preprocessors: {
  81791. [key: string]: string;
  81792. }): boolean;
  81793. }
  81794. }
  81795. declare module BABYLON {
  81796. /** @hidden */
  81797. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81798. define: string;
  81799. operand: string;
  81800. testValue: string;
  81801. constructor(define: string, operand: string, testValue: string);
  81802. isTrue(preprocessors: {
  81803. [key: string]: string;
  81804. }): boolean;
  81805. }
  81806. }
  81807. declare module BABYLON {
  81808. /**
  81809. * Class used to enable access to offline support
  81810. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81811. */
  81812. export interface IOfflineProvider {
  81813. /**
  81814. * Gets a boolean indicating if scene must be saved in the database
  81815. */
  81816. enableSceneOffline: boolean;
  81817. /**
  81818. * Gets a boolean indicating if textures must be saved in the database
  81819. */
  81820. enableTexturesOffline: boolean;
  81821. /**
  81822. * Open the offline support and make it available
  81823. * @param successCallback defines the callback to call on success
  81824. * @param errorCallback defines the callback to call on error
  81825. */
  81826. open(successCallback: () => void, errorCallback: () => void): void;
  81827. /**
  81828. * Loads an image from the offline support
  81829. * @param url defines the url to load from
  81830. * @param image defines the target DOM image
  81831. */
  81832. loadImage(url: string, image: HTMLImageElement): void;
  81833. /**
  81834. * Loads a file from offline support
  81835. * @param url defines the URL to load from
  81836. * @param sceneLoaded defines a callback to call on success
  81837. * @param progressCallBack defines a callback to call when progress changed
  81838. * @param errorCallback defines a callback to call on error
  81839. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81840. */
  81841. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81842. }
  81843. }
  81844. declare module BABYLON {
  81845. /**
  81846. * Class used to help managing file picking and drag'n'drop
  81847. * File Storage
  81848. */
  81849. export class FilesInputStore {
  81850. /**
  81851. * List of files ready to be loaded
  81852. */
  81853. static FilesToLoad: {
  81854. [key: string]: File;
  81855. };
  81856. }
  81857. }
  81858. declare module BABYLON {
  81859. /**
  81860. * Class used to define a retry strategy when error happens while loading assets
  81861. */
  81862. export class RetryStrategy {
  81863. /**
  81864. * Function used to defines an exponential back off strategy
  81865. * @param maxRetries defines the maximum number of retries (3 by default)
  81866. * @param baseInterval defines the interval between retries
  81867. * @returns the strategy function to use
  81868. */
  81869. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81870. }
  81871. }
  81872. declare module BABYLON {
  81873. /**
  81874. * @ignore
  81875. * Application error to support additional information when loading a file
  81876. */
  81877. export abstract class BaseError extends Error {
  81878. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81879. }
  81880. }
  81881. declare module BABYLON {
  81882. /** @ignore */
  81883. export class LoadFileError extends BaseError {
  81884. request?: WebRequest;
  81885. file?: File;
  81886. /**
  81887. * Creates a new LoadFileError
  81888. * @param message defines the message of the error
  81889. * @param request defines the optional web request
  81890. * @param file defines the optional file
  81891. */
  81892. constructor(message: string, object?: WebRequest | File);
  81893. }
  81894. /** @ignore */
  81895. export class RequestFileError extends BaseError {
  81896. request: WebRequest;
  81897. /**
  81898. * Creates a new LoadFileError
  81899. * @param message defines the message of the error
  81900. * @param request defines the optional web request
  81901. */
  81902. constructor(message: string, request: WebRequest);
  81903. }
  81904. /** @ignore */
  81905. export class ReadFileError extends BaseError {
  81906. file: File;
  81907. /**
  81908. * Creates a new ReadFileError
  81909. * @param message defines the message of the error
  81910. * @param file defines the optional file
  81911. */
  81912. constructor(message: string, file: File);
  81913. }
  81914. /**
  81915. * @hidden
  81916. */
  81917. export class FileTools {
  81918. /**
  81919. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81920. */
  81921. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81922. /**
  81923. * Gets or sets the base URL to use to load assets
  81924. */
  81925. static BaseUrl: string;
  81926. /**
  81927. * Default behaviour for cors in the application.
  81928. * It can be a string if the expected behavior is identical in the entire app.
  81929. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81930. */
  81931. static CorsBehavior: string | ((url: string | string[]) => string);
  81932. /**
  81933. * Gets or sets a function used to pre-process url before using them to load assets
  81934. */
  81935. static PreprocessUrl: (url: string) => string;
  81936. /**
  81937. * Removes unwanted characters from an url
  81938. * @param url defines the url to clean
  81939. * @returns the cleaned url
  81940. */
  81941. private static _CleanUrl;
  81942. /**
  81943. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81944. * @param url define the url we are trying
  81945. * @param element define the dom element where to configure the cors policy
  81946. */
  81947. static SetCorsBehavior(url: string | string[], element: {
  81948. crossOrigin: string | null;
  81949. }): void;
  81950. /**
  81951. * Loads an image as an HTMLImageElement.
  81952. * @param input url string, ArrayBuffer, or Blob to load
  81953. * @param onLoad callback called when the image successfully loads
  81954. * @param onError callback called when the image fails to load
  81955. * @param offlineProvider offline provider for caching
  81956. * @param mimeType optional mime type
  81957. * @returns the HTMLImageElement of the loaded image
  81958. */
  81959. 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>;
  81960. /**
  81961. * Reads a file from a File object
  81962. * @param file defines the file to load
  81963. * @param onSuccess defines the callback to call when data is loaded
  81964. * @param onProgress defines the callback to call during loading process
  81965. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81966. * @param onError defines the callback to call when an error occurs
  81967. * @returns a file request object
  81968. */
  81969. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81970. /**
  81971. * Loads a file from a url
  81972. * @param url url to load
  81973. * @param onSuccess callback called when the file successfully loads
  81974. * @param onProgress callback called while file is loading (if the server supports this mode)
  81975. * @param offlineProvider defines the offline provider for caching
  81976. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81977. * @param onError callback called when the file fails to load
  81978. * @returns a file request object
  81979. */
  81980. 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;
  81981. /**
  81982. * Loads a file
  81983. * @param url url to load
  81984. * @param onSuccess callback called when the file successfully loads
  81985. * @param onProgress callback called while file is loading (if the server supports this mode)
  81986. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81987. * @param onError callback called when the file fails to load
  81988. * @param onOpened callback called when the web request is opened
  81989. * @returns a file request object
  81990. */
  81991. 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;
  81992. /**
  81993. * Checks if the loaded document was accessed via `file:`-Protocol.
  81994. * @returns boolean
  81995. */
  81996. static IsFileURL(): boolean;
  81997. }
  81998. }
  81999. declare module BABYLON {
  82000. /** @hidden */
  82001. export class ShaderProcessor {
  82002. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  82003. private static _ProcessPrecision;
  82004. private static _ExtractOperation;
  82005. private static _BuildSubExpression;
  82006. private static _BuildExpression;
  82007. private static _MoveCursorWithinIf;
  82008. private static _MoveCursor;
  82009. private static _EvaluatePreProcessors;
  82010. private static _PreparePreProcessors;
  82011. private static _ProcessShaderConversion;
  82012. private static _ProcessIncludes;
  82013. /**
  82014. * Loads a file from a url
  82015. * @param url url to load
  82016. * @param onSuccess callback called when the file successfully loads
  82017. * @param onProgress callback called while file is loading (if the server supports this mode)
  82018. * @param offlineProvider defines the offline provider for caching
  82019. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82020. * @param onError callback called when the file fails to load
  82021. * @returns a file request object
  82022. * @hidden
  82023. */
  82024. 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;
  82025. }
  82026. }
  82027. declare module BABYLON {
  82028. /**
  82029. * @hidden
  82030. */
  82031. export interface IColor4Like {
  82032. r: float;
  82033. g: float;
  82034. b: float;
  82035. a: float;
  82036. }
  82037. /**
  82038. * @hidden
  82039. */
  82040. export interface IColor3Like {
  82041. r: float;
  82042. g: float;
  82043. b: float;
  82044. }
  82045. /**
  82046. * @hidden
  82047. */
  82048. export interface IVector4Like {
  82049. x: float;
  82050. y: float;
  82051. z: float;
  82052. w: float;
  82053. }
  82054. /**
  82055. * @hidden
  82056. */
  82057. export interface IVector3Like {
  82058. x: float;
  82059. y: float;
  82060. z: float;
  82061. }
  82062. /**
  82063. * @hidden
  82064. */
  82065. export interface IVector2Like {
  82066. x: float;
  82067. y: float;
  82068. }
  82069. /**
  82070. * @hidden
  82071. */
  82072. export interface IMatrixLike {
  82073. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82074. updateFlag: int;
  82075. }
  82076. /**
  82077. * @hidden
  82078. */
  82079. export interface IViewportLike {
  82080. x: float;
  82081. y: float;
  82082. width: float;
  82083. height: float;
  82084. }
  82085. /**
  82086. * @hidden
  82087. */
  82088. export interface IPlaneLike {
  82089. normal: IVector3Like;
  82090. d: float;
  82091. normalize(): void;
  82092. }
  82093. }
  82094. declare module BABYLON {
  82095. /**
  82096. * Interface used to define common properties for effect fallbacks
  82097. */
  82098. export interface IEffectFallbacks {
  82099. /**
  82100. * Removes the defines that should be removed when falling back.
  82101. * @param currentDefines defines the current define statements for the shader.
  82102. * @param effect defines the current effect we try to compile
  82103. * @returns The resulting defines with defines of the current rank removed.
  82104. */
  82105. reduce(currentDefines: string, effect: Effect): string;
  82106. /**
  82107. * Removes the fallback from the bound mesh.
  82108. */
  82109. unBindMesh(): void;
  82110. /**
  82111. * Checks to see if more fallbacks are still availible.
  82112. */
  82113. hasMoreFallbacks: boolean;
  82114. }
  82115. }
  82116. declare module BABYLON {
  82117. /**
  82118. * Class used to evalaute queries containing `and` and `or` operators
  82119. */
  82120. export class AndOrNotEvaluator {
  82121. /**
  82122. * Evaluate a query
  82123. * @param query defines the query to evaluate
  82124. * @param evaluateCallback defines the callback used to filter result
  82125. * @returns true if the query matches
  82126. */
  82127. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82128. private static _HandleParenthesisContent;
  82129. private static _SimplifyNegation;
  82130. }
  82131. }
  82132. declare module BABYLON {
  82133. /**
  82134. * Class used to store custom tags
  82135. */
  82136. export class Tags {
  82137. /**
  82138. * Adds support for tags on the given object
  82139. * @param obj defines the object to use
  82140. */
  82141. static EnableFor(obj: any): void;
  82142. /**
  82143. * Removes tags support
  82144. * @param obj defines the object to use
  82145. */
  82146. static DisableFor(obj: any): void;
  82147. /**
  82148. * Gets a boolean indicating if the given object has tags
  82149. * @param obj defines the object to use
  82150. * @returns a boolean
  82151. */
  82152. static HasTags(obj: any): boolean;
  82153. /**
  82154. * Gets the tags available on a given object
  82155. * @param obj defines the object to use
  82156. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82157. * @returns the tags
  82158. */
  82159. static GetTags(obj: any, asString?: boolean): any;
  82160. /**
  82161. * Adds tags to an object
  82162. * @param obj defines the object to use
  82163. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82164. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82165. */
  82166. static AddTagsTo(obj: any, tagsString: string): void;
  82167. /**
  82168. * @hidden
  82169. */
  82170. static _AddTagTo(obj: any, tag: string): void;
  82171. /**
  82172. * Removes specific tags from a specific object
  82173. * @param obj defines the object to use
  82174. * @param tagsString defines the tags to remove
  82175. */
  82176. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82177. /**
  82178. * @hidden
  82179. */
  82180. static _RemoveTagFrom(obj: any, tag: string): void;
  82181. /**
  82182. * Defines if tags hosted on an object match a given query
  82183. * @param obj defines the object to use
  82184. * @param tagsQuery defines the tag query
  82185. * @returns a boolean
  82186. */
  82187. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82188. }
  82189. }
  82190. declare module BABYLON {
  82191. /**
  82192. * Scalar computation library
  82193. */
  82194. export class Scalar {
  82195. /**
  82196. * Two pi constants convenient for computation.
  82197. */
  82198. static TwoPi: number;
  82199. /**
  82200. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82201. * @param a number
  82202. * @param b number
  82203. * @param epsilon (default = 1.401298E-45)
  82204. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82205. */
  82206. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82207. /**
  82208. * Returns a string : the upper case translation of the number i to hexadecimal.
  82209. * @param i number
  82210. * @returns the upper case translation of the number i to hexadecimal.
  82211. */
  82212. static ToHex(i: number): string;
  82213. /**
  82214. * Returns -1 if value is negative and +1 is value is positive.
  82215. * @param value the value
  82216. * @returns the value itself if it's equal to zero.
  82217. */
  82218. static Sign(value: number): number;
  82219. /**
  82220. * Returns the value itself if it's between min and max.
  82221. * Returns min if the value is lower than min.
  82222. * Returns max if the value is greater than max.
  82223. * @param value the value to clmap
  82224. * @param min the min value to clamp to (default: 0)
  82225. * @param max the max value to clamp to (default: 1)
  82226. * @returns the clamped value
  82227. */
  82228. static Clamp(value: number, min?: number, max?: number): number;
  82229. /**
  82230. * the log2 of value.
  82231. * @param value the value to compute log2 of
  82232. * @returns the log2 of value.
  82233. */
  82234. static Log2(value: number): number;
  82235. /**
  82236. * Loops the value, so that it is never larger than length and never smaller than 0.
  82237. *
  82238. * This is similar to the modulo operator but it works with floating point numbers.
  82239. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82240. * With t = 5 and length = 2.5, the result would be 0.0.
  82241. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82242. * @param value the value
  82243. * @param length the length
  82244. * @returns the looped value
  82245. */
  82246. static Repeat(value: number, length: number): number;
  82247. /**
  82248. * Normalize the value between 0.0 and 1.0 using min and max values
  82249. * @param value value to normalize
  82250. * @param min max to normalize between
  82251. * @param max min to normalize between
  82252. * @returns the normalized value
  82253. */
  82254. static Normalize(value: number, min: number, max: number): number;
  82255. /**
  82256. * Denormalize the value from 0.0 and 1.0 using min and max values
  82257. * @param normalized value to denormalize
  82258. * @param min max to denormalize between
  82259. * @param max min to denormalize between
  82260. * @returns the denormalized value
  82261. */
  82262. static Denormalize(normalized: number, min: number, max: number): number;
  82263. /**
  82264. * Calculates the shortest difference between two given angles given in degrees.
  82265. * @param current current angle in degrees
  82266. * @param target target angle in degrees
  82267. * @returns the delta
  82268. */
  82269. static DeltaAngle(current: number, target: number): number;
  82270. /**
  82271. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82272. * @param tx value
  82273. * @param length length
  82274. * @returns The returned value will move back and forth between 0 and length
  82275. */
  82276. static PingPong(tx: number, length: number): number;
  82277. /**
  82278. * Interpolates between min and max with smoothing at the limits.
  82279. *
  82280. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82281. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82282. * @param from from
  82283. * @param to to
  82284. * @param tx value
  82285. * @returns the smooth stepped value
  82286. */
  82287. static SmoothStep(from: number, to: number, tx: number): number;
  82288. /**
  82289. * Moves a value current towards target.
  82290. *
  82291. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82292. * Negative values of maxDelta pushes the value away from target.
  82293. * @param current current value
  82294. * @param target target value
  82295. * @param maxDelta max distance to move
  82296. * @returns resulting value
  82297. */
  82298. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82299. /**
  82300. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82301. *
  82302. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82303. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82304. * @param current current value
  82305. * @param target target value
  82306. * @param maxDelta max distance to move
  82307. * @returns resulting angle
  82308. */
  82309. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82310. /**
  82311. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82312. * @param start start value
  82313. * @param end target value
  82314. * @param amount amount to lerp between
  82315. * @returns the lerped value
  82316. */
  82317. static Lerp(start: number, end: number, amount: number): number;
  82318. /**
  82319. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82320. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82321. * @param start start value
  82322. * @param end target value
  82323. * @param amount amount to lerp between
  82324. * @returns the lerped value
  82325. */
  82326. static LerpAngle(start: number, end: number, amount: number): number;
  82327. /**
  82328. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82329. * @param a start value
  82330. * @param b target value
  82331. * @param value value between a and b
  82332. * @returns the inverseLerp value
  82333. */
  82334. static InverseLerp(a: number, b: number, value: number): number;
  82335. /**
  82336. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82337. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82338. * @param value1 spline value
  82339. * @param tangent1 spline value
  82340. * @param value2 spline value
  82341. * @param tangent2 spline value
  82342. * @param amount input value
  82343. * @returns hermite result
  82344. */
  82345. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82346. /**
  82347. * Returns a random float number between and min and max values
  82348. * @param min min value of random
  82349. * @param max max value of random
  82350. * @returns random value
  82351. */
  82352. static RandomRange(min: number, max: number): number;
  82353. /**
  82354. * This function returns percentage of a number in a given range.
  82355. *
  82356. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82357. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82358. * @param number to convert to percentage
  82359. * @param min min range
  82360. * @param max max range
  82361. * @returns the percentage
  82362. */
  82363. static RangeToPercent(number: number, min: number, max: number): number;
  82364. /**
  82365. * This function returns number that corresponds to the percentage in a given range.
  82366. *
  82367. * PercentToRange(0.34,0,100) will return 34.
  82368. * @param percent to convert to number
  82369. * @param min min range
  82370. * @param max max range
  82371. * @returns the number
  82372. */
  82373. static PercentToRange(percent: number, min: number, max: number): number;
  82374. /**
  82375. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82376. * @param angle The angle to normalize in radian.
  82377. * @return The converted angle.
  82378. */
  82379. static NormalizeRadians(angle: number): number;
  82380. }
  82381. }
  82382. declare module BABYLON {
  82383. /**
  82384. * Constant used to convert a value to gamma space
  82385. * @ignorenaming
  82386. */
  82387. export const ToGammaSpace: number;
  82388. /**
  82389. * Constant used to convert a value to linear space
  82390. * @ignorenaming
  82391. */
  82392. export const ToLinearSpace = 2.2;
  82393. /**
  82394. * Constant used to define the minimal number value in Babylon.js
  82395. * @ignorenaming
  82396. */
  82397. let Epsilon: number;
  82398. }
  82399. declare module BABYLON {
  82400. /**
  82401. * Class used to represent a viewport on screen
  82402. */
  82403. export class Viewport {
  82404. /** viewport left coordinate */
  82405. x: number;
  82406. /** viewport top coordinate */
  82407. y: number;
  82408. /**viewport width */
  82409. width: number;
  82410. /** viewport height */
  82411. height: number;
  82412. /**
  82413. * Creates a Viewport object located at (x, y) and sized (width, height)
  82414. * @param x defines viewport left coordinate
  82415. * @param y defines viewport top coordinate
  82416. * @param width defines the viewport width
  82417. * @param height defines the viewport height
  82418. */
  82419. constructor(
  82420. /** viewport left coordinate */
  82421. x: number,
  82422. /** viewport top coordinate */
  82423. y: number,
  82424. /**viewport width */
  82425. width: number,
  82426. /** viewport height */
  82427. height: number);
  82428. /**
  82429. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82430. * @param renderWidth defines the rendering width
  82431. * @param renderHeight defines the rendering height
  82432. * @returns a new Viewport
  82433. */
  82434. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82435. /**
  82436. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82437. * @param renderWidth defines the rendering width
  82438. * @param renderHeight defines the rendering height
  82439. * @param ref defines the target viewport
  82440. * @returns the current viewport
  82441. */
  82442. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82443. /**
  82444. * Returns a new Viewport copied from the current one
  82445. * @returns a new Viewport
  82446. */
  82447. clone(): Viewport;
  82448. }
  82449. }
  82450. declare module BABYLON {
  82451. /**
  82452. * Class containing a set of static utilities functions for arrays.
  82453. */
  82454. export class ArrayTools {
  82455. /**
  82456. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82457. * @param size the number of element to construct and put in the array
  82458. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82459. * @returns a new array filled with new objects
  82460. */
  82461. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82462. }
  82463. }
  82464. declare module BABYLON {
  82465. /**
  82466. * Represents a plane by the equation ax + by + cz + d = 0
  82467. */
  82468. export class Plane {
  82469. private static _TmpMatrix;
  82470. /**
  82471. * Normal of the plane (a,b,c)
  82472. */
  82473. normal: Vector3;
  82474. /**
  82475. * d component of the plane
  82476. */
  82477. d: number;
  82478. /**
  82479. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82480. * @param a a component of the plane
  82481. * @param b b component of the plane
  82482. * @param c c component of the plane
  82483. * @param d d component of the plane
  82484. */
  82485. constructor(a: number, b: number, c: number, d: number);
  82486. /**
  82487. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82488. */
  82489. asArray(): number[];
  82490. /**
  82491. * @returns a new plane copied from the current Plane.
  82492. */
  82493. clone(): Plane;
  82494. /**
  82495. * @returns the string "Plane".
  82496. */
  82497. getClassName(): string;
  82498. /**
  82499. * @returns the Plane hash code.
  82500. */
  82501. getHashCode(): number;
  82502. /**
  82503. * Normalize the current Plane in place.
  82504. * @returns the updated Plane.
  82505. */
  82506. normalize(): Plane;
  82507. /**
  82508. * Applies a transformation the plane and returns the result
  82509. * @param transformation the transformation matrix to be applied to the plane
  82510. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82511. */
  82512. transform(transformation: DeepImmutable<Matrix>): Plane;
  82513. /**
  82514. * Compute the dot product between the point and the plane normal
  82515. * @param point point to calculate the dot product with
  82516. * @returns the dot product (float) of the point coordinates and the plane normal.
  82517. */
  82518. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82519. /**
  82520. * Updates the current Plane from the plane defined by the three given points.
  82521. * @param point1 one of the points used to contruct the plane
  82522. * @param point2 one of the points used to contruct the plane
  82523. * @param point3 one of the points used to contruct the plane
  82524. * @returns the updated Plane.
  82525. */
  82526. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82527. /**
  82528. * Checks if the plane is facing a given direction
  82529. * @param direction the direction to check if the plane is facing
  82530. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82531. * @returns True is the vector "direction" is the same side than the plane normal.
  82532. */
  82533. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82534. /**
  82535. * Calculates the distance to a point
  82536. * @param point point to calculate distance to
  82537. * @returns the signed distance (float) from the given point to the Plane.
  82538. */
  82539. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82540. /**
  82541. * Creates a plane from an array
  82542. * @param array the array to create a plane from
  82543. * @returns a new Plane from the given array.
  82544. */
  82545. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82546. /**
  82547. * Creates a plane from three points
  82548. * @param point1 point used to create the plane
  82549. * @param point2 point used to create the plane
  82550. * @param point3 point used to create the plane
  82551. * @returns a new Plane defined by the three given points.
  82552. */
  82553. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82554. /**
  82555. * Creates a plane from an origin point and a normal
  82556. * @param origin origin of the plane to be constructed
  82557. * @param normal normal of the plane to be constructed
  82558. * @returns a new Plane the normal vector to this plane at the given origin point.
  82559. * Note : the vector "normal" is updated because normalized.
  82560. */
  82561. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82562. /**
  82563. * Calculates the distance from a plane and a point
  82564. * @param origin origin of the plane to be constructed
  82565. * @param normal normal of the plane to be constructed
  82566. * @param point point to calculate distance to
  82567. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82568. */
  82569. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82570. }
  82571. }
  82572. declare module BABYLON {
  82573. /** @hidden */
  82574. export class PerformanceConfigurator {
  82575. /** @hidden */
  82576. static MatrixUse64Bits: boolean;
  82577. /** @hidden */
  82578. static MatrixTrackPrecisionChange: boolean;
  82579. /** @hidden */
  82580. static MatrixCurrentType: any;
  82581. /** @hidden */
  82582. static MatrixTrackedMatrices: Array<any> | null;
  82583. /** @hidden */
  82584. static SetMatrixPrecision(use64bits: boolean): void;
  82585. }
  82586. }
  82587. declare module BABYLON {
  82588. /**
  82589. * Class representing a vector containing 2 coordinates
  82590. */
  82591. export class Vector2 {
  82592. /** defines the first coordinate */
  82593. x: number;
  82594. /** defines the second coordinate */
  82595. y: number;
  82596. /**
  82597. * Creates a new Vector2 from the given x and y coordinates
  82598. * @param x defines the first coordinate
  82599. * @param y defines the second coordinate
  82600. */
  82601. constructor(
  82602. /** defines the first coordinate */
  82603. x?: number,
  82604. /** defines the second coordinate */
  82605. y?: number);
  82606. /**
  82607. * Gets a string with the Vector2 coordinates
  82608. * @returns a string with the Vector2 coordinates
  82609. */
  82610. toString(): string;
  82611. /**
  82612. * Gets class name
  82613. * @returns the string "Vector2"
  82614. */
  82615. getClassName(): string;
  82616. /**
  82617. * Gets current vector hash code
  82618. * @returns the Vector2 hash code as a number
  82619. */
  82620. getHashCode(): number;
  82621. /**
  82622. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82623. * @param array defines the source array
  82624. * @param index defines the offset in source array
  82625. * @returns the current Vector2
  82626. */
  82627. toArray(array: FloatArray, index?: number): Vector2;
  82628. /**
  82629. * Update the current vector from an array
  82630. * @param array defines the destination array
  82631. * @param index defines the offset in the destination array
  82632. * @returns the current Vector3
  82633. */
  82634. fromArray(array: FloatArray, index?: number): Vector2;
  82635. /**
  82636. * Copy the current vector to an array
  82637. * @returns a new array with 2 elements: the Vector2 coordinates.
  82638. */
  82639. asArray(): number[];
  82640. /**
  82641. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82642. * @param source defines the source Vector2
  82643. * @returns the current updated Vector2
  82644. */
  82645. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82646. /**
  82647. * Sets the Vector2 coordinates with the given floats
  82648. * @param x defines the first coordinate
  82649. * @param y defines the second coordinate
  82650. * @returns the current updated Vector2
  82651. */
  82652. copyFromFloats(x: number, y: number): Vector2;
  82653. /**
  82654. * Sets the Vector2 coordinates with the given floats
  82655. * @param x defines the first coordinate
  82656. * @param y defines the second coordinate
  82657. * @returns the current updated Vector2
  82658. */
  82659. set(x: number, y: number): Vector2;
  82660. /**
  82661. * Add another vector with the current one
  82662. * @param otherVector defines the other vector
  82663. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82664. */
  82665. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82666. /**
  82667. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82668. * @param otherVector defines the other vector
  82669. * @param result defines the target vector
  82670. * @returns the unmodified current Vector2
  82671. */
  82672. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82673. /**
  82674. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82675. * @param otherVector defines the other vector
  82676. * @returns the current updated Vector2
  82677. */
  82678. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82679. /**
  82680. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82681. * @param otherVector defines the other vector
  82682. * @returns a new Vector2
  82683. */
  82684. addVector3(otherVector: Vector3): Vector2;
  82685. /**
  82686. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82687. * @param otherVector defines the other vector
  82688. * @returns a new Vector2
  82689. */
  82690. subtract(otherVector: Vector2): Vector2;
  82691. /**
  82692. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82693. * @param otherVector defines the other vector
  82694. * @param result defines the target vector
  82695. * @returns the unmodified current Vector2
  82696. */
  82697. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82698. /**
  82699. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82700. * @param otherVector defines the other vector
  82701. * @returns the current updated Vector2
  82702. */
  82703. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82704. /**
  82705. * Multiplies in place the current Vector2 coordinates by the given ones
  82706. * @param otherVector defines the other vector
  82707. * @returns the current updated Vector2
  82708. */
  82709. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82710. /**
  82711. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82712. * @param otherVector defines the other vector
  82713. * @returns a new Vector2
  82714. */
  82715. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82716. /**
  82717. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82718. * @param otherVector defines the other vector
  82719. * @param result defines the target vector
  82720. * @returns the unmodified current Vector2
  82721. */
  82722. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82723. /**
  82724. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82725. * @param x defines the first coordinate
  82726. * @param y defines the second coordinate
  82727. * @returns a new Vector2
  82728. */
  82729. multiplyByFloats(x: number, y: number): Vector2;
  82730. /**
  82731. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82732. * @param otherVector defines the other vector
  82733. * @returns a new Vector2
  82734. */
  82735. divide(otherVector: Vector2): Vector2;
  82736. /**
  82737. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82738. * @param otherVector defines the other vector
  82739. * @param result defines the target vector
  82740. * @returns the unmodified current Vector2
  82741. */
  82742. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82743. /**
  82744. * Divides the current Vector2 coordinates by the given ones
  82745. * @param otherVector defines the other vector
  82746. * @returns the current updated Vector2
  82747. */
  82748. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82749. /**
  82750. * Gets a new Vector2 with current Vector2 negated coordinates
  82751. * @returns a new Vector2
  82752. */
  82753. negate(): Vector2;
  82754. /**
  82755. * Negate this vector in place
  82756. * @returns this
  82757. */
  82758. negateInPlace(): Vector2;
  82759. /**
  82760. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82761. * @param result defines the Vector3 object where to store the result
  82762. * @returns the current Vector2
  82763. */
  82764. negateToRef(result: Vector2): Vector2;
  82765. /**
  82766. * Multiply the Vector2 coordinates by scale
  82767. * @param scale defines the scaling factor
  82768. * @returns the current updated Vector2
  82769. */
  82770. scaleInPlace(scale: number): Vector2;
  82771. /**
  82772. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82773. * @param scale defines the scaling factor
  82774. * @returns a new Vector2
  82775. */
  82776. scale(scale: number): Vector2;
  82777. /**
  82778. * Scale the current Vector2 values by a factor to a given Vector2
  82779. * @param scale defines the scale factor
  82780. * @param result defines the Vector2 object where to store the result
  82781. * @returns the unmodified current Vector2
  82782. */
  82783. scaleToRef(scale: number, result: Vector2): Vector2;
  82784. /**
  82785. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82786. * @param scale defines the scale factor
  82787. * @param result defines the Vector2 object where to store the result
  82788. * @returns the unmodified current Vector2
  82789. */
  82790. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82791. /**
  82792. * Gets a boolean if two vectors are equals
  82793. * @param otherVector defines the other vector
  82794. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82795. */
  82796. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82797. /**
  82798. * Gets a boolean if two vectors are equals (using an epsilon value)
  82799. * @param otherVector defines the other vector
  82800. * @param epsilon defines the minimal distance to consider equality
  82801. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82802. */
  82803. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82804. /**
  82805. * Gets a new Vector2 from current Vector2 floored values
  82806. * @returns a new Vector2
  82807. */
  82808. floor(): Vector2;
  82809. /**
  82810. * Gets a new Vector2 from current Vector2 floored values
  82811. * @returns a new Vector2
  82812. */
  82813. fract(): Vector2;
  82814. /**
  82815. * Gets the length of the vector
  82816. * @returns the vector length (float)
  82817. */
  82818. length(): number;
  82819. /**
  82820. * Gets the vector squared length
  82821. * @returns the vector squared length (float)
  82822. */
  82823. lengthSquared(): number;
  82824. /**
  82825. * Normalize the vector
  82826. * @returns the current updated Vector2
  82827. */
  82828. normalize(): Vector2;
  82829. /**
  82830. * Gets a new Vector2 copied from the Vector2
  82831. * @returns a new Vector2
  82832. */
  82833. clone(): Vector2;
  82834. /**
  82835. * Gets a new Vector2(0, 0)
  82836. * @returns a new Vector2
  82837. */
  82838. static Zero(): Vector2;
  82839. /**
  82840. * Gets a new Vector2(1, 1)
  82841. * @returns a new Vector2
  82842. */
  82843. static One(): Vector2;
  82844. /**
  82845. * Gets a new Vector2 set from the given index element of the given array
  82846. * @param array defines the data source
  82847. * @param offset defines the offset in the data source
  82848. * @returns a new Vector2
  82849. */
  82850. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82851. /**
  82852. * Sets "result" from the given index element of the given array
  82853. * @param array defines the data source
  82854. * @param offset defines the offset in the data source
  82855. * @param result defines the target vector
  82856. */
  82857. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82858. /**
  82859. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82860. * @param value1 defines 1st point of control
  82861. * @param value2 defines 2nd point of control
  82862. * @param value3 defines 3rd point of control
  82863. * @param value4 defines 4th point of control
  82864. * @param amount defines the interpolation factor
  82865. * @returns a new Vector2
  82866. */
  82867. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82868. /**
  82869. * 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".
  82870. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82871. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82872. * @param value defines the value to clamp
  82873. * @param min defines the lower limit
  82874. * @param max defines the upper limit
  82875. * @returns a new Vector2
  82876. */
  82877. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82878. /**
  82879. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82880. * @param value1 defines the 1st control point
  82881. * @param tangent1 defines the outgoing tangent
  82882. * @param value2 defines the 2nd control point
  82883. * @param tangent2 defines the incoming tangent
  82884. * @param amount defines the interpolation factor
  82885. * @returns a new Vector2
  82886. */
  82887. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82888. /**
  82889. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82890. * @param start defines the start vector
  82891. * @param end defines the end vector
  82892. * @param amount defines the interpolation factor
  82893. * @returns a new Vector2
  82894. */
  82895. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82896. /**
  82897. * Gets the dot product of the vector "left" and the vector "right"
  82898. * @param left defines first vector
  82899. * @param right defines second vector
  82900. * @returns the dot product (float)
  82901. */
  82902. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82903. /**
  82904. * Returns a new Vector2 equal to the normalized given vector
  82905. * @param vector defines the vector to normalize
  82906. * @returns a new Vector2
  82907. */
  82908. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82909. /**
  82910. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82911. * @param left defines 1st vector
  82912. * @param right defines 2nd vector
  82913. * @returns a new Vector2
  82914. */
  82915. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82916. /**
  82917. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82918. * @param left defines 1st vector
  82919. * @param right defines 2nd vector
  82920. * @returns a new Vector2
  82921. */
  82922. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82923. /**
  82924. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82925. * @param vector defines the vector to transform
  82926. * @param transformation defines the matrix to apply
  82927. * @returns a new Vector2
  82928. */
  82929. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82930. /**
  82931. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82932. * @param vector defines the vector to transform
  82933. * @param transformation defines the matrix to apply
  82934. * @param result defines the target vector
  82935. */
  82936. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82937. /**
  82938. * Determines if a given vector is included in a triangle
  82939. * @param p defines the vector to test
  82940. * @param p0 defines 1st triangle point
  82941. * @param p1 defines 2nd triangle point
  82942. * @param p2 defines 3rd triangle point
  82943. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82944. */
  82945. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82946. /**
  82947. * Gets the distance between the vectors "value1" and "value2"
  82948. * @param value1 defines first vector
  82949. * @param value2 defines second vector
  82950. * @returns the distance between vectors
  82951. */
  82952. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82953. /**
  82954. * Returns the squared distance between the vectors "value1" and "value2"
  82955. * @param value1 defines first vector
  82956. * @param value2 defines second vector
  82957. * @returns the squared distance between vectors
  82958. */
  82959. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82960. /**
  82961. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82962. * @param value1 defines first vector
  82963. * @param value2 defines second vector
  82964. * @returns a new Vector2
  82965. */
  82966. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82967. /**
  82968. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82969. * @param p defines the middle point
  82970. * @param segA defines one point of the segment
  82971. * @param segB defines the other point of the segment
  82972. * @returns the shortest distance
  82973. */
  82974. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82975. }
  82976. /**
  82977. * Class used to store (x,y,z) vector representation
  82978. * A Vector3 is the main object used in 3D geometry
  82979. * It can represent etiher the coordinates of a point the space, either a direction
  82980. * Reminder: js uses a left handed forward facing system
  82981. */
  82982. export class Vector3 {
  82983. private static _UpReadOnly;
  82984. private static _ZeroReadOnly;
  82985. /** @hidden */
  82986. _x: number;
  82987. /** @hidden */
  82988. _y: number;
  82989. /** @hidden */
  82990. _z: number;
  82991. /** @hidden */
  82992. _isDirty: boolean;
  82993. /** Gets or sets the x coordinate */
  82994. get x(): number;
  82995. set x(value: number);
  82996. /** Gets or sets the y coordinate */
  82997. get y(): number;
  82998. set y(value: number);
  82999. /** Gets or sets the z coordinate */
  83000. get z(): number;
  83001. set z(value: number);
  83002. /**
  83003. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83004. * @param x defines the first coordinates (on X axis)
  83005. * @param y defines the second coordinates (on Y axis)
  83006. * @param z defines the third coordinates (on Z axis)
  83007. */
  83008. constructor(x?: number, y?: number, z?: number);
  83009. /**
  83010. * Creates a string representation of the Vector3
  83011. * @returns a string with the Vector3 coordinates.
  83012. */
  83013. toString(): string;
  83014. /**
  83015. * Gets the class name
  83016. * @returns the string "Vector3"
  83017. */
  83018. getClassName(): string;
  83019. /**
  83020. * Creates the Vector3 hash code
  83021. * @returns a number which tends to be unique between Vector3 instances
  83022. */
  83023. getHashCode(): number;
  83024. /**
  83025. * Creates an array containing three elements : the coordinates of the Vector3
  83026. * @returns a new array of numbers
  83027. */
  83028. asArray(): number[];
  83029. /**
  83030. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83031. * @param array defines the destination array
  83032. * @param index defines the offset in the destination array
  83033. * @returns the current Vector3
  83034. */
  83035. toArray(array: FloatArray, index?: number): Vector3;
  83036. /**
  83037. * Update the current vector from an array
  83038. * @param array defines the destination array
  83039. * @param index defines the offset in the destination array
  83040. * @returns the current Vector3
  83041. */
  83042. fromArray(array: FloatArray, index?: number): Vector3;
  83043. /**
  83044. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83045. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83046. */
  83047. toQuaternion(): Quaternion;
  83048. /**
  83049. * Adds the given vector to the current Vector3
  83050. * @param otherVector defines the second operand
  83051. * @returns the current updated Vector3
  83052. */
  83053. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83054. /**
  83055. * Adds the given coordinates to the current Vector3
  83056. * @param x defines the x coordinate of the operand
  83057. * @param y defines the y coordinate of the operand
  83058. * @param z defines the z coordinate of the operand
  83059. * @returns the current updated Vector3
  83060. */
  83061. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83062. /**
  83063. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83064. * @param otherVector defines the second operand
  83065. * @returns the resulting Vector3
  83066. */
  83067. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83068. /**
  83069. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83070. * @param otherVector defines the second operand
  83071. * @param result defines the Vector3 object where to store the result
  83072. * @returns the current Vector3
  83073. */
  83074. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83075. /**
  83076. * Subtract the given vector from the current Vector3
  83077. * @param otherVector defines the second operand
  83078. * @returns the current updated Vector3
  83079. */
  83080. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83081. /**
  83082. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83083. * @param otherVector defines the second operand
  83084. * @returns the resulting Vector3
  83085. */
  83086. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83087. /**
  83088. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83089. * @param otherVector defines the second operand
  83090. * @param result defines the Vector3 object where to store the result
  83091. * @returns the current Vector3
  83092. */
  83093. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83094. /**
  83095. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83096. * @param x defines the x coordinate of the operand
  83097. * @param y defines the y coordinate of the operand
  83098. * @param z defines the z coordinate of the operand
  83099. * @returns the resulting Vector3
  83100. */
  83101. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83102. /**
  83103. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83104. * @param x defines the x coordinate of the operand
  83105. * @param y defines the y coordinate of the operand
  83106. * @param z defines the z coordinate of the operand
  83107. * @param result defines the Vector3 object where to store the result
  83108. * @returns the current Vector3
  83109. */
  83110. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83111. /**
  83112. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83113. * @returns a new Vector3
  83114. */
  83115. negate(): Vector3;
  83116. /**
  83117. * Negate this vector in place
  83118. * @returns this
  83119. */
  83120. negateInPlace(): Vector3;
  83121. /**
  83122. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83123. * @param result defines the Vector3 object where to store the result
  83124. * @returns the current Vector3
  83125. */
  83126. negateToRef(result: Vector3): Vector3;
  83127. /**
  83128. * Multiplies the Vector3 coordinates by the float "scale"
  83129. * @param scale defines the multiplier factor
  83130. * @returns the current updated Vector3
  83131. */
  83132. scaleInPlace(scale: number): Vector3;
  83133. /**
  83134. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83135. * @param scale defines the multiplier factor
  83136. * @returns a new Vector3
  83137. */
  83138. scale(scale: number): Vector3;
  83139. /**
  83140. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83141. * @param scale defines the multiplier factor
  83142. * @param result defines the Vector3 object where to store the result
  83143. * @returns the current Vector3
  83144. */
  83145. scaleToRef(scale: number, result: Vector3): Vector3;
  83146. /**
  83147. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83148. * @param scale defines the scale factor
  83149. * @param result defines the Vector3 object where to store the result
  83150. * @returns the unmodified current Vector3
  83151. */
  83152. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83153. /**
  83154. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83155. * @param origin defines the origin of the projection ray
  83156. * @param plane defines the plane to project to
  83157. * @returns the projected vector3
  83158. */
  83159. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83160. /**
  83161. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83162. * @param origin defines the origin of the projection ray
  83163. * @param plane defines the plane to project to
  83164. * @param result defines the Vector3 where to store the result
  83165. */
  83166. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83167. /**
  83168. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83169. * @param otherVector defines the second operand
  83170. * @returns true if both vectors are equals
  83171. */
  83172. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83173. /**
  83174. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83175. * @param otherVector defines the second operand
  83176. * @param epsilon defines the minimal distance to define values as equals
  83177. * @returns true if both vectors are distant less than epsilon
  83178. */
  83179. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83180. /**
  83181. * Returns true if the current Vector3 coordinates equals the given floats
  83182. * @param x defines the x coordinate of the operand
  83183. * @param y defines the y coordinate of the operand
  83184. * @param z defines the z coordinate of the operand
  83185. * @returns true if both vectors are equals
  83186. */
  83187. equalsToFloats(x: number, y: number, z: number): boolean;
  83188. /**
  83189. * Multiplies the current Vector3 coordinates by the given ones
  83190. * @param otherVector defines the second operand
  83191. * @returns the current updated Vector3
  83192. */
  83193. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83194. /**
  83195. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83196. * @param otherVector defines the second operand
  83197. * @returns the new Vector3
  83198. */
  83199. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83200. /**
  83201. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83202. * @param otherVector defines the second operand
  83203. * @param result defines the Vector3 object where to store the result
  83204. * @returns the current Vector3
  83205. */
  83206. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83207. /**
  83208. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83209. * @param x defines the x coordinate of the operand
  83210. * @param y defines the y coordinate of the operand
  83211. * @param z defines the z coordinate of the operand
  83212. * @returns the new Vector3
  83213. */
  83214. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83215. /**
  83216. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83217. * @param otherVector defines the second operand
  83218. * @returns the new Vector3
  83219. */
  83220. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83221. /**
  83222. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83223. * @param otherVector defines the second operand
  83224. * @param result defines the Vector3 object where to store the result
  83225. * @returns the current Vector3
  83226. */
  83227. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83228. /**
  83229. * Divides the current Vector3 coordinates by the given ones.
  83230. * @param otherVector defines the second operand
  83231. * @returns the current updated Vector3
  83232. */
  83233. divideInPlace(otherVector: Vector3): Vector3;
  83234. /**
  83235. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83236. * @param other defines the second operand
  83237. * @returns the current updated Vector3
  83238. */
  83239. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83240. /**
  83241. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83242. * @param other defines the second operand
  83243. * @returns the current updated Vector3
  83244. */
  83245. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83246. /**
  83247. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83248. * @param x defines the x coordinate of the operand
  83249. * @param y defines the y coordinate of the operand
  83250. * @param z defines the z coordinate of the operand
  83251. * @returns the current updated Vector3
  83252. */
  83253. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83254. /**
  83255. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83256. * @param x defines the x coordinate of the operand
  83257. * @param y defines the y coordinate of the operand
  83258. * @param z defines the z coordinate of the operand
  83259. * @returns the current updated Vector3
  83260. */
  83261. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83262. /**
  83263. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83264. * Check if is non uniform within a certain amount of decimal places to account for this
  83265. * @param epsilon the amount the values can differ
  83266. * @returns if the the vector is non uniform to a certain number of decimal places
  83267. */
  83268. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83269. /**
  83270. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83271. */
  83272. get isNonUniform(): boolean;
  83273. /**
  83274. * Gets a new Vector3 from current Vector3 floored values
  83275. * @returns a new Vector3
  83276. */
  83277. floor(): Vector3;
  83278. /**
  83279. * Gets a new Vector3 from current Vector3 floored values
  83280. * @returns a new Vector3
  83281. */
  83282. fract(): Vector3;
  83283. /**
  83284. * Gets the length of the Vector3
  83285. * @returns the length of the Vector3
  83286. */
  83287. length(): number;
  83288. /**
  83289. * Gets the squared length of the Vector3
  83290. * @returns squared length of the Vector3
  83291. */
  83292. lengthSquared(): number;
  83293. /**
  83294. * Normalize the current Vector3.
  83295. * Please note that this is an in place operation.
  83296. * @returns the current updated Vector3
  83297. */
  83298. normalize(): Vector3;
  83299. /**
  83300. * Reorders the x y z properties of the vector in place
  83301. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83302. * @returns the current updated vector
  83303. */
  83304. reorderInPlace(order: string): this;
  83305. /**
  83306. * Rotates the vector around 0,0,0 by a quaternion
  83307. * @param quaternion the rotation quaternion
  83308. * @param result vector to store the result
  83309. * @returns the resulting vector
  83310. */
  83311. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83312. /**
  83313. * Rotates a vector around a given point
  83314. * @param quaternion the rotation quaternion
  83315. * @param point the point to rotate around
  83316. * @param result vector to store the result
  83317. * @returns the resulting vector
  83318. */
  83319. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83320. /**
  83321. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83322. * The cross product is then orthogonal to both current and "other"
  83323. * @param other defines the right operand
  83324. * @returns the cross product
  83325. */
  83326. cross(other: Vector3): Vector3;
  83327. /**
  83328. * Normalize the current Vector3 with the given input length.
  83329. * Please note that this is an in place operation.
  83330. * @param len the length of the vector
  83331. * @returns the current updated Vector3
  83332. */
  83333. normalizeFromLength(len: number): Vector3;
  83334. /**
  83335. * Normalize the current Vector3 to a new vector
  83336. * @returns the new Vector3
  83337. */
  83338. normalizeToNew(): Vector3;
  83339. /**
  83340. * Normalize the current Vector3 to the reference
  83341. * @param reference define the Vector3 to update
  83342. * @returns the updated Vector3
  83343. */
  83344. normalizeToRef(reference: Vector3): Vector3;
  83345. /**
  83346. * Creates a new Vector3 copied from the current Vector3
  83347. * @returns the new Vector3
  83348. */
  83349. clone(): Vector3;
  83350. /**
  83351. * Copies the given vector coordinates to the current Vector3 ones
  83352. * @param source defines the source Vector3
  83353. * @returns the current updated Vector3
  83354. */
  83355. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83356. /**
  83357. * Copies the given floats to the current Vector3 coordinates
  83358. * @param x defines the x coordinate of the operand
  83359. * @param y defines the y coordinate of the operand
  83360. * @param z defines the z coordinate of the operand
  83361. * @returns the current updated Vector3
  83362. */
  83363. copyFromFloats(x: number, y: number, z: number): Vector3;
  83364. /**
  83365. * Copies the given floats to the current Vector3 coordinates
  83366. * @param x defines the x coordinate of the operand
  83367. * @param y defines the y coordinate of the operand
  83368. * @param z defines the z coordinate of the operand
  83369. * @returns the current updated Vector3
  83370. */
  83371. set(x: number, y: number, z: number): Vector3;
  83372. /**
  83373. * Copies the given float to the current Vector3 coordinates
  83374. * @param v defines the x, y and z coordinates of the operand
  83375. * @returns the current updated Vector3
  83376. */
  83377. setAll(v: number): Vector3;
  83378. /**
  83379. * Get the clip factor between two vectors
  83380. * @param vector0 defines the first operand
  83381. * @param vector1 defines the second operand
  83382. * @param axis defines the axis to use
  83383. * @param size defines the size along the axis
  83384. * @returns the clip factor
  83385. */
  83386. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83387. /**
  83388. * Get angle between two vectors
  83389. * @param vector0 angle between vector0 and vector1
  83390. * @param vector1 angle between vector0 and vector1
  83391. * @param normal direction of the normal
  83392. * @return the angle between vector0 and vector1
  83393. */
  83394. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83395. /**
  83396. * Returns a new Vector3 set from the index "offset" of the given array
  83397. * @param array defines the source array
  83398. * @param offset defines the offset in the source array
  83399. * @returns the new Vector3
  83400. */
  83401. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83402. /**
  83403. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83404. * @param array defines the source array
  83405. * @param offset defines the offset in the source array
  83406. * @returns the new Vector3
  83407. * @deprecated Please use FromArray instead.
  83408. */
  83409. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83410. /**
  83411. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83412. * @param array defines the source array
  83413. * @param offset defines the offset in the source array
  83414. * @param result defines the Vector3 where to store the result
  83415. */
  83416. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83417. /**
  83418. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83419. * @param array defines the source array
  83420. * @param offset defines the offset in the source array
  83421. * @param result defines the Vector3 where to store the result
  83422. * @deprecated Please use FromArrayToRef instead.
  83423. */
  83424. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83425. /**
  83426. * Sets the given vector "result" with the given floats.
  83427. * @param x defines the x coordinate of the source
  83428. * @param y defines the y coordinate of the source
  83429. * @param z defines the z coordinate of the source
  83430. * @param result defines the Vector3 where to store the result
  83431. */
  83432. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83433. /**
  83434. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83435. * @returns a new empty Vector3
  83436. */
  83437. static Zero(): Vector3;
  83438. /**
  83439. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83440. * @returns a new unit Vector3
  83441. */
  83442. static One(): Vector3;
  83443. /**
  83444. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83445. * @returns a new up Vector3
  83446. */
  83447. static Up(): Vector3;
  83448. /**
  83449. * Gets a up Vector3 that must not be updated
  83450. */
  83451. static get UpReadOnly(): DeepImmutable<Vector3>;
  83452. /**
  83453. * Gets a zero Vector3 that must not be updated
  83454. */
  83455. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83456. /**
  83457. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83458. * @returns a new down Vector3
  83459. */
  83460. static Down(): Vector3;
  83461. /**
  83462. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83463. * @param rightHandedSystem is the scene right-handed (negative z)
  83464. * @returns a new forward Vector3
  83465. */
  83466. static Forward(rightHandedSystem?: boolean): Vector3;
  83467. /**
  83468. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83469. * @param rightHandedSystem is the scene right-handed (negative-z)
  83470. * @returns a new forward Vector3
  83471. */
  83472. static Backward(rightHandedSystem?: boolean): Vector3;
  83473. /**
  83474. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83475. * @returns a new right Vector3
  83476. */
  83477. static Right(): Vector3;
  83478. /**
  83479. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83480. * @returns a new left Vector3
  83481. */
  83482. static Left(): Vector3;
  83483. /**
  83484. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83485. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83486. * @param vector defines the Vector3 to transform
  83487. * @param transformation defines the transformation matrix
  83488. * @returns the transformed Vector3
  83489. */
  83490. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83491. /**
  83492. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83493. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83494. * @param vector defines the Vector3 to transform
  83495. * @param transformation defines the transformation matrix
  83496. * @param result defines the Vector3 where to store the result
  83497. */
  83498. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83499. /**
  83500. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83501. * This method computes tranformed coordinates only, not transformed direction vectors
  83502. * @param x define the x coordinate of the source vector
  83503. * @param y define the y coordinate of the source vector
  83504. * @param z define the z coordinate of the source vector
  83505. * @param transformation defines the transformation matrix
  83506. * @param result defines the Vector3 where to store the result
  83507. */
  83508. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83509. /**
  83510. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83511. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83512. * @param vector defines the Vector3 to transform
  83513. * @param transformation defines the transformation matrix
  83514. * @returns the new Vector3
  83515. */
  83516. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83517. /**
  83518. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83519. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83520. * @param vector defines the Vector3 to transform
  83521. * @param transformation defines the transformation matrix
  83522. * @param result defines the Vector3 where to store the result
  83523. */
  83524. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83525. /**
  83526. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83527. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83528. * @param x define the x coordinate of the source vector
  83529. * @param y define the y coordinate of the source vector
  83530. * @param z define the z coordinate of the source vector
  83531. * @param transformation defines the transformation matrix
  83532. * @param result defines the Vector3 where to store the result
  83533. */
  83534. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83535. /**
  83536. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83537. * @param value1 defines the first control point
  83538. * @param value2 defines the second control point
  83539. * @param value3 defines the third control point
  83540. * @param value4 defines the fourth control point
  83541. * @param amount defines the amount on the spline to use
  83542. * @returns the new Vector3
  83543. */
  83544. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83545. /**
  83546. * 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"
  83547. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83548. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83549. * @param value defines the current value
  83550. * @param min defines the lower range value
  83551. * @param max defines the upper range value
  83552. * @returns the new Vector3
  83553. */
  83554. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83555. /**
  83556. * 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"
  83557. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83558. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83559. * @param value defines the current value
  83560. * @param min defines the lower range value
  83561. * @param max defines the upper range value
  83562. * @param result defines the Vector3 where to store the result
  83563. */
  83564. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83565. /**
  83566. * Checks if a given vector is inside a specific range
  83567. * @param v defines the vector to test
  83568. * @param min defines the minimum range
  83569. * @param max defines the maximum range
  83570. */
  83571. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83572. /**
  83573. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83574. * @param value1 defines the first control point
  83575. * @param tangent1 defines the first tangent vector
  83576. * @param value2 defines the second control point
  83577. * @param tangent2 defines the second tangent vector
  83578. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83579. * @returns the new Vector3
  83580. */
  83581. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83582. /**
  83583. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83584. * @param start defines the start value
  83585. * @param end defines the end value
  83586. * @param amount max defines amount between both (between 0 and 1)
  83587. * @returns the new Vector3
  83588. */
  83589. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83590. /**
  83591. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83592. * @param start defines the start value
  83593. * @param end defines the end value
  83594. * @param amount max defines amount between both (between 0 and 1)
  83595. * @param result defines the Vector3 where to store the result
  83596. */
  83597. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83598. /**
  83599. * Returns the dot product (float) between the vectors "left" and "right"
  83600. * @param left defines the left operand
  83601. * @param right defines the right operand
  83602. * @returns the dot product
  83603. */
  83604. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83605. /**
  83606. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83607. * The cross product is then orthogonal to both "left" and "right"
  83608. * @param left defines the left operand
  83609. * @param right defines the right operand
  83610. * @returns the cross product
  83611. */
  83612. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83613. /**
  83614. * Sets the given vector "result" with the cross product of "left" and "right"
  83615. * The cross product is then orthogonal to both "left" and "right"
  83616. * @param left defines the left operand
  83617. * @param right defines the right operand
  83618. * @param result defines the Vector3 where to store the result
  83619. */
  83620. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83621. /**
  83622. * Returns a new Vector3 as the normalization of the given vector
  83623. * @param vector defines the Vector3 to normalize
  83624. * @returns the new Vector3
  83625. */
  83626. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83627. /**
  83628. * Sets the given vector "result" with the normalization of the given first vector
  83629. * @param vector defines the Vector3 to normalize
  83630. * @param result defines the Vector3 where to store the result
  83631. */
  83632. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83633. /**
  83634. * Project a Vector3 onto screen space
  83635. * @param vector defines the Vector3 to project
  83636. * @param world defines the world matrix to use
  83637. * @param transform defines the transform (view x projection) matrix to use
  83638. * @param viewport defines the screen viewport to use
  83639. * @returns the new Vector3
  83640. */
  83641. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83642. /** @hidden */
  83643. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83644. /**
  83645. * Unproject from screen space to object space
  83646. * @param source defines the screen space Vector3 to use
  83647. * @param viewportWidth defines the current width of the viewport
  83648. * @param viewportHeight defines the current height of the viewport
  83649. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83650. * @param transform defines the transform (view x projection) matrix to use
  83651. * @returns the new Vector3
  83652. */
  83653. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83654. /**
  83655. * Unproject from screen space to object space
  83656. * @param source defines the screen space Vector3 to use
  83657. * @param viewportWidth defines the current width of the viewport
  83658. * @param viewportHeight defines the current height of the viewport
  83659. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83660. * @param view defines the view matrix to use
  83661. * @param projection defines the projection matrix to use
  83662. * @returns the new Vector3
  83663. */
  83664. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83665. /**
  83666. * Unproject from screen space to object space
  83667. * @param source defines the screen space Vector3 to use
  83668. * @param viewportWidth defines the current width of the viewport
  83669. * @param viewportHeight defines the current height of the viewport
  83670. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83671. * @param view defines the view matrix to use
  83672. * @param projection defines the projection matrix to use
  83673. * @param result defines the Vector3 where to store the result
  83674. */
  83675. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83676. /**
  83677. * Unproject from screen space to object space
  83678. * @param sourceX defines the screen space x coordinate to use
  83679. * @param sourceY defines the screen space y coordinate to use
  83680. * @param sourceZ defines the screen space z coordinate to use
  83681. * @param viewportWidth defines the current width of the viewport
  83682. * @param viewportHeight defines the current height of the viewport
  83683. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83684. * @param view defines the view matrix to use
  83685. * @param projection defines the projection matrix to use
  83686. * @param result defines the Vector3 where to store the result
  83687. */
  83688. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83689. /**
  83690. * Gets the minimal coordinate values between two Vector3
  83691. * @param left defines the first operand
  83692. * @param right defines the second operand
  83693. * @returns the new Vector3
  83694. */
  83695. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83696. /**
  83697. * Gets the maximal coordinate values between two Vector3
  83698. * @param left defines the first operand
  83699. * @param right defines the second operand
  83700. * @returns the new Vector3
  83701. */
  83702. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83703. /**
  83704. * Returns the distance between the vectors "value1" and "value2"
  83705. * @param value1 defines the first operand
  83706. * @param value2 defines the second operand
  83707. * @returns the distance
  83708. */
  83709. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83710. /**
  83711. * Returns the squared distance between the vectors "value1" and "value2"
  83712. * @param value1 defines the first operand
  83713. * @param value2 defines the second operand
  83714. * @returns the squared distance
  83715. */
  83716. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83717. /**
  83718. * Returns a new Vector3 located at the center between "value1" and "value2"
  83719. * @param value1 defines the first operand
  83720. * @param value2 defines the second operand
  83721. * @returns the new Vector3
  83722. */
  83723. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83724. /**
  83725. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83726. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83727. * to something in order to rotate it from its local system to the given target system
  83728. * Note: axis1, axis2 and axis3 are normalized during this operation
  83729. * @param axis1 defines the first axis
  83730. * @param axis2 defines the second axis
  83731. * @param axis3 defines the third axis
  83732. * @returns a new Vector3
  83733. */
  83734. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83735. /**
  83736. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83737. * @param axis1 defines the first axis
  83738. * @param axis2 defines the second axis
  83739. * @param axis3 defines the third axis
  83740. * @param ref defines the Vector3 where to store the result
  83741. */
  83742. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83743. }
  83744. /**
  83745. * Vector4 class created for EulerAngle class conversion to Quaternion
  83746. */
  83747. export class Vector4 {
  83748. /** x value of the vector */
  83749. x: number;
  83750. /** y value of the vector */
  83751. y: number;
  83752. /** z value of the vector */
  83753. z: number;
  83754. /** w value of the vector */
  83755. w: number;
  83756. /**
  83757. * Creates a Vector4 object from the given floats.
  83758. * @param x x value of the vector
  83759. * @param y y value of the vector
  83760. * @param z z value of the vector
  83761. * @param w w value of the vector
  83762. */
  83763. constructor(
  83764. /** x value of the vector */
  83765. x: number,
  83766. /** y value of the vector */
  83767. y: number,
  83768. /** z value of the vector */
  83769. z: number,
  83770. /** w value of the vector */
  83771. w: number);
  83772. /**
  83773. * Returns the string with the Vector4 coordinates.
  83774. * @returns a string containing all the vector values
  83775. */
  83776. toString(): string;
  83777. /**
  83778. * Returns the string "Vector4".
  83779. * @returns "Vector4"
  83780. */
  83781. getClassName(): string;
  83782. /**
  83783. * Returns the Vector4 hash code.
  83784. * @returns a unique hash code
  83785. */
  83786. getHashCode(): number;
  83787. /**
  83788. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83789. * @returns the resulting array
  83790. */
  83791. asArray(): number[];
  83792. /**
  83793. * Populates the given array from the given index with the Vector4 coordinates.
  83794. * @param array array to populate
  83795. * @param index index of the array to start at (default: 0)
  83796. * @returns the Vector4.
  83797. */
  83798. toArray(array: FloatArray, index?: number): Vector4;
  83799. /**
  83800. * Update the current vector from an array
  83801. * @param array defines the destination array
  83802. * @param index defines the offset in the destination array
  83803. * @returns the current Vector3
  83804. */
  83805. fromArray(array: FloatArray, index?: number): Vector4;
  83806. /**
  83807. * Adds the given vector to the current Vector4.
  83808. * @param otherVector the vector to add
  83809. * @returns the updated Vector4.
  83810. */
  83811. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83812. /**
  83813. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83814. * @param otherVector the vector to add
  83815. * @returns the resulting vector
  83816. */
  83817. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83818. /**
  83819. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83820. * @param otherVector the vector to add
  83821. * @param result the vector to store the result
  83822. * @returns the current Vector4.
  83823. */
  83824. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83825. /**
  83826. * Subtract in place the given vector from the current Vector4.
  83827. * @param otherVector the vector to subtract
  83828. * @returns the updated Vector4.
  83829. */
  83830. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83831. /**
  83832. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83833. * @param otherVector the vector to add
  83834. * @returns the new vector with the result
  83835. */
  83836. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83837. /**
  83838. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83839. * @param otherVector the vector to subtract
  83840. * @param result the vector to store the result
  83841. * @returns the current Vector4.
  83842. */
  83843. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83844. /**
  83845. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83846. */
  83847. /**
  83848. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83849. * @param x value to subtract
  83850. * @param y value to subtract
  83851. * @param z value to subtract
  83852. * @param w value to subtract
  83853. * @returns new vector containing the result
  83854. */
  83855. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83856. /**
  83857. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83858. * @param x value to subtract
  83859. * @param y value to subtract
  83860. * @param z value to subtract
  83861. * @param w value to subtract
  83862. * @param result the vector to store the result in
  83863. * @returns the current Vector4.
  83864. */
  83865. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83866. /**
  83867. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83868. * @returns a new vector with the negated values
  83869. */
  83870. negate(): Vector4;
  83871. /**
  83872. * Negate this vector in place
  83873. * @returns this
  83874. */
  83875. negateInPlace(): Vector4;
  83876. /**
  83877. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83878. * @param result defines the Vector3 object where to store the result
  83879. * @returns the current Vector4
  83880. */
  83881. negateToRef(result: Vector4): Vector4;
  83882. /**
  83883. * Multiplies the current Vector4 coordinates by scale (float).
  83884. * @param scale the number to scale with
  83885. * @returns the updated Vector4.
  83886. */
  83887. scaleInPlace(scale: number): Vector4;
  83888. /**
  83889. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83890. * @param scale the number to scale with
  83891. * @returns a new vector with the result
  83892. */
  83893. scale(scale: number): Vector4;
  83894. /**
  83895. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83896. * @param scale the number to scale with
  83897. * @param result a vector to store the result in
  83898. * @returns the current Vector4.
  83899. */
  83900. scaleToRef(scale: number, result: Vector4): Vector4;
  83901. /**
  83902. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83903. * @param scale defines the scale factor
  83904. * @param result defines the Vector4 object where to store the result
  83905. * @returns the unmodified current Vector4
  83906. */
  83907. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83908. /**
  83909. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83910. * @param otherVector the vector to compare against
  83911. * @returns true if they are equal
  83912. */
  83913. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83914. /**
  83915. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83916. * @param otherVector vector to compare against
  83917. * @param epsilon (Default: very small number)
  83918. * @returns true if they are equal
  83919. */
  83920. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83921. /**
  83922. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83923. * @param x x value to compare against
  83924. * @param y y value to compare against
  83925. * @param z z value to compare against
  83926. * @param w w value to compare against
  83927. * @returns true if equal
  83928. */
  83929. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83930. /**
  83931. * Multiplies in place the current Vector4 by the given one.
  83932. * @param otherVector vector to multiple with
  83933. * @returns the updated Vector4.
  83934. */
  83935. multiplyInPlace(otherVector: Vector4): Vector4;
  83936. /**
  83937. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83938. * @param otherVector vector to multiple with
  83939. * @returns resulting new vector
  83940. */
  83941. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83942. /**
  83943. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83944. * @param otherVector vector to multiple with
  83945. * @param result vector to store the result
  83946. * @returns the current Vector4.
  83947. */
  83948. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83949. /**
  83950. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83951. * @param x x value multiply with
  83952. * @param y y value multiply with
  83953. * @param z z value multiply with
  83954. * @param w w value multiply with
  83955. * @returns resulting new vector
  83956. */
  83957. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83958. /**
  83959. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83960. * @param otherVector vector to devide with
  83961. * @returns resulting new vector
  83962. */
  83963. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83964. /**
  83965. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83966. * @param otherVector vector to devide with
  83967. * @param result vector to store the result
  83968. * @returns the current Vector4.
  83969. */
  83970. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83971. /**
  83972. * Divides the current Vector3 coordinates by the given ones.
  83973. * @param otherVector vector to devide with
  83974. * @returns the updated Vector3.
  83975. */
  83976. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83977. /**
  83978. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83979. * @param other defines the second operand
  83980. * @returns the current updated Vector4
  83981. */
  83982. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83983. /**
  83984. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83985. * @param other defines the second operand
  83986. * @returns the current updated Vector4
  83987. */
  83988. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83989. /**
  83990. * Gets a new Vector4 from current Vector4 floored values
  83991. * @returns a new Vector4
  83992. */
  83993. floor(): Vector4;
  83994. /**
  83995. * Gets a new Vector4 from current Vector3 floored values
  83996. * @returns a new Vector4
  83997. */
  83998. fract(): Vector4;
  83999. /**
  84000. * Returns the Vector4 length (float).
  84001. * @returns the length
  84002. */
  84003. length(): number;
  84004. /**
  84005. * Returns the Vector4 squared length (float).
  84006. * @returns the length squared
  84007. */
  84008. lengthSquared(): number;
  84009. /**
  84010. * Normalizes in place the Vector4.
  84011. * @returns the updated Vector4.
  84012. */
  84013. normalize(): Vector4;
  84014. /**
  84015. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84016. * @returns this converted to a new vector3
  84017. */
  84018. toVector3(): Vector3;
  84019. /**
  84020. * Returns a new Vector4 copied from the current one.
  84021. * @returns the new cloned vector
  84022. */
  84023. clone(): Vector4;
  84024. /**
  84025. * Updates the current Vector4 with the given one coordinates.
  84026. * @param source the source vector to copy from
  84027. * @returns the updated Vector4.
  84028. */
  84029. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84030. /**
  84031. * Updates the current Vector4 coordinates with the given floats.
  84032. * @param x float to copy from
  84033. * @param y float to copy from
  84034. * @param z float to copy from
  84035. * @param w float to copy from
  84036. * @returns the updated Vector4.
  84037. */
  84038. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84039. /**
  84040. * Updates the current Vector4 coordinates with the given floats.
  84041. * @param x float to set from
  84042. * @param y float to set from
  84043. * @param z float to set from
  84044. * @param w float to set from
  84045. * @returns the updated Vector4.
  84046. */
  84047. set(x: number, y: number, z: number, w: number): Vector4;
  84048. /**
  84049. * Copies the given float to the current Vector3 coordinates
  84050. * @param v defines the x, y, z and w coordinates of the operand
  84051. * @returns the current updated Vector3
  84052. */
  84053. setAll(v: number): Vector4;
  84054. /**
  84055. * Returns a new Vector4 set from the starting index of the given array.
  84056. * @param array the array to pull values from
  84057. * @param offset the offset into the array to start at
  84058. * @returns the new vector
  84059. */
  84060. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84061. /**
  84062. * Updates the given vector "result" from the starting index of the given array.
  84063. * @param array the array to pull values from
  84064. * @param offset the offset into the array to start at
  84065. * @param result the vector to store the result in
  84066. */
  84067. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84068. /**
  84069. * Updates the given vector "result" from the starting index of the given Float32Array.
  84070. * @param array the array to pull values from
  84071. * @param offset the offset into the array to start at
  84072. * @param result the vector to store the result in
  84073. */
  84074. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84075. /**
  84076. * Updates the given vector "result" coordinates from the given floats.
  84077. * @param x float to set from
  84078. * @param y float to set from
  84079. * @param z float to set from
  84080. * @param w float to set from
  84081. * @param result the vector to the floats in
  84082. */
  84083. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84084. /**
  84085. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84086. * @returns the new vector
  84087. */
  84088. static Zero(): Vector4;
  84089. /**
  84090. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84091. * @returns the new vector
  84092. */
  84093. static One(): Vector4;
  84094. /**
  84095. * Returns a new normalized Vector4 from the given one.
  84096. * @param vector the vector to normalize
  84097. * @returns the vector
  84098. */
  84099. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84100. /**
  84101. * Updates the given vector "result" from the normalization of the given one.
  84102. * @param vector the vector to normalize
  84103. * @param result the vector to store the result in
  84104. */
  84105. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84106. /**
  84107. * Returns a vector with the minimum values from the left and right vectors
  84108. * @param left left vector to minimize
  84109. * @param right right vector to minimize
  84110. * @returns a new vector with the minimum of the left and right vector values
  84111. */
  84112. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84113. /**
  84114. * Returns a vector with the maximum values from the left and right vectors
  84115. * @param left left vector to maximize
  84116. * @param right right vector to maximize
  84117. * @returns a new vector with the maximum of the left and right vector values
  84118. */
  84119. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84120. /**
  84121. * Returns the distance (float) between the vectors "value1" and "value2".
  84122. * @param value1 value to calulate the distance between
  84123. * @param value2 value to calulate the distance between
  84124. * @return the distance between the two vectors
  84125. */
  84126. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84127. /**
  84128. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84129. * @param value1 value to calulate the distance between
  84130. * @param value2 value to calulate the distance between
  84131. * @return the distance between the two vectors squared
  84132. */
  84133. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84134. /**
  84135. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84136. * @param value1 value to calulate the center between
  84137. * @param value2 value to calulate the center between
  84138. * @return the center between the two vectors
  84139. */
  84140. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84141. /**
  84142. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84143. * This methods computes transformed normalized direction vectors only.
  84144. * @param vector the vector to transform
  84145. * @param transformation the transformation matrix to apply
  84146. * @returns the new vector
  84147. */
  84148. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84149. /**
  84150. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84151. * This methods computes transformed normalized direction vectors only.
  84152. * @param vector the vector to transform
  84153. * @param transformation the transformation matrix to apply
  84154. * @param result the vector to store the result in
  84155. */
  84156. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84157. /**
  84158. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84159. * This methods computes transformed normalized direction vectors only.
  84160. * @param x value to transform
  84161. * @param y value to transform
  84162. * @param z value to transform
  84163. * @param w value to transform
  84164. * @param transformation the transformation matrix to apply
  84165. * @param result the vector to store the results in
  84166. */
  84167. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84168. /**
  84169. * Creates a new Vector4 from a Vector3
  84170. * @param source defines the source data
  84171. * @param w defines the 4th component (default is 0)
  84172. * @returns a new Vector4
  84173. */
  84174. static FromVector3(source: Vector3, w?: number): Vector4;
  84175. }
  84176. /**
  84177. * Class used to store quaternion data
  84178. * @see https://en.wikipedia.org/wiki/Quaternion
  84179. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84180. */
  84181. export class Quaternion {
  84182. /** @hidden */
  84183. _x: number;
  84184. /** @hidden */
  84185. _y: number;
  84186. /** @hidden */
  84187. _z: number;
  84188. /** @hidden */
  84189. _w: number;
  84190. /** @hidden */
  84191. _isDirty: boolean;
  84192. /** Gets or sets the x coordinate */
  84193. get x(): number;
  84194. set x(value: number);
  84195. /** Gets or sets the y coordinate */
  84196. get y(): number;
  84197. set y(value: number);
  84198. /** Gets or sets the z coordinate */
  84199. get z(): number;
  84200. set z(value: number);
  84201. /** Gets or sets the w coordinate */
  84202. get w(): number;
  84203. set w(value: number);
  84204. /**
  84205. * Creates a new Quaternion from the given floats
  84206. * @param x defines the first component (0 by default)
  84207. * @param y defines the second component (0 by default)
  84208. * @param z defines the third component (0 by default)
  84209. * @param w defines the fourth component (1.0 by default)
  84210. */
  84211. constructor(x?: number, y?: number, z?: number, w?: number);
  84212. /**
  84213. * Gets a string representation for the current quaternion
  84214. * @returns a string with the Quaternion coordinates
  84215. */
  84216. toString(): string;
  84217. /**
  84218. * Gets the class name of the quaternion
  84219. * @returns the string "Quaternion"
  84220. */
  84221. getClassName(): string;
  84222. /**
  84223. * Gets a hash code for this quaternion
  84224. * @returns the quaternion hash code
  84225. */
  84226. getHashCode(): number;
  84227. /**
  84228. * Copy the quaternion to an array
  84229. * @returns a new array populated with 4 elements from the quaternion coordinates
  84230. */
  84231. asArray(): number[];
  84232. /**
  84233. * Check if two quaternions are equals
  84234. * @param otherQuaternion defines the second operand
  84235. * @return true if the current quaternion and the given one coordinates are strictly equals
  84236. */
  84237. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84238. /**
  84239. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84240. * @param otherQuaternion defines the other quaternion
  84241. * @param epsilon defines the minimal distance to consider equality
  84242. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84243. */
  84244. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84245. /**
  84246. * Clone the current quaternion
  84247. * @returns a new quaternion copied from the current one
  84248. */
  84249. clone(): Quaternion;
  84250. /**
  84251. * Copy a quaternion to the current one
  84252. * @param other defines the other quaternion
  84253. * @returns the updated current quaternion
  84254. */
  84255. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84256. /**
  84257. * Updates the current quaternion with the given float coordinates
  84258. * @param x defines the x coordinate
  84259. * @param y defines the y coordinate
  84260. * @param z defines the z coordinate
  84261. * @param w defines the w coordinate
  84262. * @returns the updated current quaternion
  84263. */
  84264. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84265. /**
  84266. * Updates the current quaternion from the given float coordinates
  84267. * @param x defines the x coordinate
  84268. * @param y defines the y coordinate
  84269. * @param z defines the z coordinate
  84270. * @param w defines the w coordinate
  84271. * @returns the updated current quaternion
  84272. */
  84273. set(x: number, y: number, z: number, w: number): Quaternion;
  84274. /**
  84275. * Adds two quaternions
  84276. * @param other defines the second operand
  84277. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84278. */
  84279. add(other: DeepImmutable<Quaternion>): Quaternion;
  84280. /**
  84281. * Add a quaternion to the current one
  84282. * @param other defines the quaternion to add
  84283. * @returns the current quaternion
  84284. */
  84285. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84286. /**
  84287. * Subtract two quaternions
  84288. * @param other defines the second operand
  84289. * @returns a new quaternion as the subtraction result of the given one from the current one
  84290. */
  84291. subtract(other: Quaternion): Quaternion;
  84292. /**
  84293. * Multiplies the current quaternion by a scale factor
  84294. * @param value defines the scale factor
  84295. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84296. */
  84297. scale(value: number): Quaternion;
  84298. /**
  84299. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84300. * @param scale defines the scale factor
  84301. * @param result defines the Quaternion object where to store the result
  84302. * @returns the unmodified current quaternion
  84303. */
  84304. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84305. /**
  84306. * Multiplies in place the current quaternion by a scale factor
  84307. * @param value defines the scale factor
  84308. * @returns the current modified quaternion
  84309. */
  84310. scaleInPlace(value: number): Quaternion;
  84311. /**
  84312. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84313. * @param scale defines the scale factor
  84314. * @param result defines the Quaternion object where to store the result
  84315. * @returns the unmodified current quaternion
  84316. */
  84317. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84318. /**
  84319. * Multiplies two quaternions
  84320. * @param q1 defines the second operand
  84321. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84322. */
  84323. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84324. /**
  84325. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84326. * @param q1 defines the second operand
  84327. * @param result defines the target quaternion
  84328. * @returns the current quaternion
  84329. */
  84330. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84331. /**
  84332. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84333. * @param q1 defines the second operand
  84334. * @returns the currentupdated quaternion
  84335. */
  84336. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84337. /**
  84338. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84339. * @param ref defines the target quaternion
  84340. * @returns the current quaternion
  84341. */
  84342. conjugateToRef(ref: Quaternion): Quaternion;
  84343. /**
  84344. * Conjugates in place (1-q) the current quaternion
  84345. * @returns the current updated quaternion
  84346. */
  84347. conjugateInPlace(): Quaternion;
  84348. /**
  84349. * Conjugates in place (1-q) the current quaternion
  84350. * @returns a new quaternion
  84351. */
  84352. conjugate(): Quaternion;
  84353. /**
  84354. * Gets length of current quaternion
  84355. * @returns the quaternion length (float)
  84356. */
  84357. length(): number;
  84358. /**
  84359. * Normalize in place the current quaternion
  84360. * @returns the current updated quaternion
  84361. */
  84362. normalize(): Quaternion;
  84363. /**
  84364. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84365. * @param order is a reserved parameter and is ignored for now
  84366. * @returns a new Vector3 containing the Euler angles
  84367. */
  84368. toEulerAngles(order?: string): Vector3;
  84369. /**
  84370. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84371. * @param result defines the vector which will be filled with the Euler angles
  84372. * @returns the current unchanged quaternion
  84373. */
  84374. toEulerAnglesToRef(result: Vector3): Quaternion;
  84375. /**
  84376. * Updates the given rotation matrix with the current quaternion values
  84377. * @param result defines the target matrix
  84378. * @returns the current unchanged quaternion
  84379. */
  84380. toRotationMatrix(result: Matrix): Quaternion;
  84381. /**
  84382. * Updates the current quaternion from the given rotation matrix values
  84383. * @param matrix defines the source matrix
  84384. * @returns the current updated quaternion
  84385. */
  84386. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84387. /**
  84388. * Creates a new quaternion from a rotation matrix
  84389. * @param matrix defines the source matrix
  84390. * @returns a new quaternion created from the given rotation matrix values
  84391. */
  84392. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84393. /**
  84394. * Updates the given quaternion with the given rotation matrix values
  84395. * @param matrix defines the source matrix
  84396. * @param result defines the target quaternion
  84397. */
  84398. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84399. /**
  84400. * Returns the dot product (float) between the quaternions "left" and "right"
  84401. * @param left defines the left operand
  84402. * @param right defines the right operand
  84403. * @returns the dot product
  84404. */
  84405. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84406. /**
  84407. * Checks if the two quaternions are close to each other
  84408. * @param quat0 defines the first quaternion to check
  84409. * @param quat1 defines the second quaternion to check
  84410. * @returns true if the two quaternions are close to each other
  84411. */
  84412. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84413. /**
  84414. * Creates an empty quaternion
  84415. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84416. */
  84417. static Zero(): Quaternion;
  84418. /**
  84419. * Inverse a given quaternion
  84420. * @param q defines the source quaternion
  84421. * @returns a new quaternion as the inverted current quaternion
  84422. */
  84423. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84424. /**
  84425. * Inverse a given quaternion
  84426. * @param q defines the source quaternion
  84427. * @param result the quaternion the result will be stored in
  84428. * @returns the result quaternion
  84429. */
  84430. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84431. /**
  84432. * Creates an identity quaternion
  84433. * @returns the identity quaternion
  84434. */
  84435. static Identity(): Quaternion;
  84436. /**
  84437. * Gets a boolean indicating if the given quaternion is identity
  84438. * @param quaternion defines the quaternion to check
  84439. * @returns true if the quaternion is identity
  84440. */
  84441. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84442. /**
  84443. * Creates a quaternion from a rotation around an axis
  84444. * @param axis defines the axis to use
  84445. * @param angle defines the angle to use
  84446. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84447. */
  84448. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84449. /**
  84450. * Creates a rotation around an axis and stores it into the given quaternion
  84451. * @param axis defines the axis to use
  84452. * @param angle defines the angle to use
  84453. * @param result defines the target quaternion
  84454. * @returns the target quaternion
  84455. */
  84456. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84457. /**
  84458. * Creates a new quaternion from data stored into an array
  84459. * @param array defines the data source
  84460. * @param offset defines the offset in the source array where the data starts
  84461. * @returns a new quaternion
  84462. */
  84463. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84464. /**
  84465. * Updates the given quaternion "result" from the starting index of the given array.
  84466. * @param array the array to pull values from
  84467. * @param offset the offset into the array to start at
  84468. * @param result the quaternion to store the result in
  84469. */
  84470. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84471. /**
  84472. * Create a quaternion from Euler rotation angles
  84473. * @param x Pitch
  84474. * @param y Yaw
  84475. * @param z Roll
  84476. * @returns the new Quaternion
  84477. */
  84478. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84479. /**
  84480. * Updates a quaternion from Euler rotation angles
  84481. * @param x Pitch
  84482. * @param y Yaw
  84483. * @param z Roll
  84484. * @param result the quaternion to store the result
  84485. * @returns the updated quaternion
  84486. */
  84487. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84488. /**
  84489. * Create a quaternion from Euler rotation vector
  84490. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84491. * @returns the new Quaternion
  84492. */
  84493. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84494. /**
  84495. * Updates a quaternion from Euler rotation vector
  84496. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84497. * @param result the quaternion to store the result
  84498. * @returns the updated quaternion
  84499. */
  84500. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84501. /**
  84502. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84503. * @param yaw defines the rotation around Y axis
  84504. * @param pitch defines the rotation around X axis
  84505. * @param roll defines the rotation around Z axis
  84506. * @returns the new quaternion
  84507. */
  84508. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84509. /**
  84510. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84511. * @param yaw defines the rotation around Y axis
  84512. * @param pitch defines the rotation around X axis
  84513. * @param roll defines the rotation around Z axis
  84514. * @param result defines the target quaternion
  84515. */
  84516. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84517. /**
  84518. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84519. * @param alpha defines the rotation around first axis
  84520. * @param beta defines the rotation around second axis
  84521. * @param gamma defines the rotation around third axis
  84522. * @returns the new quaternion
  84523. */
  84524. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84525. /**
  84526. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84527. * @param alpha defines the rotation around first axis
  84528. * @param beta defines the rotation around second axis
  84529. * @param gamma defines the rotation around third axis
  84530. * @param result defines the target quaternion
  84531. */
  84532. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84533. /**
  84534. * 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)
  84535. * @param axis1 defines the first axis
  84536. * @param axis2 defines the second axis
  84537. * @param axis3 defines the third axis
  84538. * @returns the new quaternion
  84539. */
  84540. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84541. /**
  84542. * 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
  84543. * @param axis1 defines the first axis
  84544. * @param axis2 defines the second axis
  84545. * @param axis3 defines the third axis
  84546. * @param ref defines the target quaternion
  84547. */
  84548. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84549. /**
  84550. * Interpolates between two quaternions
  84551. * @param left defines first quaternion
  84552. * @param right defines second quaternion
  84553. * @param amount defines the gradient to use
  84554. * @returns the new interpolated quaternion
  84555. */
  84556. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84557. /**
  84558. * Interpolates between two quaternions and stores it into a target quaternion
  84559. * @param left defines first quaternion
  84560. * @param right defines second quaternion
  84561. * @param amount defines the gradient to use
  84562. * @param result defines the target quaternion
  84563. */
  84564. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84565. /**
  84566. * Interpolate between two quaternions using Hermite interpolation
  84567. * @param value1 defines first quaternion
  84568. * @param tangent1 defines the incoming tangent
  84569. * @param value2 defines second quaternion
  84570. * @param tangent2 defines the outgoing tangent
  84571. * @param amount defines the target quaternion
  84572. * @returns the new interpolated quaternion
  84573. */
  84574. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84575. }
  84576. /**
  84577. * Class used to store matrix data (4x4)
  84578. */
  84579. export class Matrix {
  84580. /**
  84581. * Gets the precision of matrix computations
  84582. */
  84583. static get Use64Bits(): boolean;
  84584. private static _updateFlagSeed;
  84585. private static _identityReadOnly;
  84586. private _isIdentity;
  84587. private _isIdentityDirty;
  84588. private _isIdentity3x2;
  84589. private _isIdentity3x2Dirty;
  84590. /**
  84591. * Gets the update flag of the matrix which is an unique number for the matrix.
  84592. * It will be incremented every time the matrix data change.
  84593. * You can use it to speed the comparison between two versions of the same matrix.
  84594. */
  84595. updateFlag: number;
  84596. private readonly _m;
  84597. /**
  84598. * Gets the internal data of the matrix
  84599. */
  84600. get m(): DeepImmutable<Float32Array | Array<number>>;
  84601. /** @hidden */
  84602. _markAsUpdated(): void;
  84603. /** @hidden */
  84604. private _updateIdentityStatus;
  84605. /**
  84606. * Creates an empty matrix (filled with zeros)
  84607. */
  84608. constructor();
  84609. /**
  84610. * Check if the current matrix is identity
  84611. * @returns true is the matrix is the identity matrix
  84612. */
  84613. isIdentity(): boolean;
  84614. /**
  84615. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84616. * @returns true is the matrix is the identity matrix
  84617. */
  84618. isIdentityAs3x2(): boolean;
  84619. /**
  84620. * Gets the determinant of the matrix
  84621. * @returns the matrix determinant
  84622. */
  84623. determinant(): number;
  84624. /**
  84625. * Returns the matrix as a Float32Array or Array<number>
  84626. * @returns the matrix underlying array
  84627. */
  84628. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84629. /**
  84630. * Returns the matrix as a Float32Array or Array<number>
  84631. * @returns the matrix underlying array.
  84632. */
  84633. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84634. /**
  84635. * Inverts the current matrix in place
  84636. * @returns the current inverted matrix
  84637. */
  84638. invert(): Matrix;
  84639. /**
  84640. * Sets all the matrix elements to zero
  84641. * @returns the current matrix
  84642. */
  84643. reset(): Matrix;
  84644. /**
  84645. * Adds the current matrix with a second one
  84646. * @param other defines the matrix to add
  84647. * @returns a new matrix as the addition of the current matrix and the given one
  84648. */
  84649. add(other: DeepImmutable<Matrix>): Matrix;
  84650. /**
  84651. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84652. * @param other defines the matrix to add
  84653. * @param result defines the target matrix
  84654. * @returns the current matrix
  84655. */
  84656. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84657. /**
  84658. * Adds in place the given matrix to the current matrix
  84659. * @param other defines the second operand
  84660. * @returns the current updated matrix
  84661. */
  84662. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84663. /**
  84664. * Sets the given matrix to the current inverted Matrix
  84665. * @param other defines the target matrix
  84666. * @returns the unmodified current matrix
  84667. */
  84668. invertToRef(other: Matrix): Matrix;
  84669. /**
  84670. * add a value at the specified position in the current Matrix
  84671. * @param index the index of the value within the matrix. between 0 and 15.
  84672. * @param value the value to be added
  84673. * @returns the current updated matrix
  84674. */
  84675. addAtIndex(index: number, value: number): Matrix;
  84676. /**
  84677. * mutiply the specified position in the current Matrix by a value
  84678. * @param index the index of the value within the matrix. between 0 and 15.
  84679. * @param value the value to be added
  84680. * @returns the current updated matrix
  84681. */
  84682. multiplyAtIndex(index: number, value: number): Matrix;
  84683. /**
  84684. * Inserts the translation vector (using 3 floats) in the current matrix
  84685. * @param x defines the 1st component of the translation
  84686. * @param y defines the 2nd component of the translation
  84687. * @param z defines the 3rd component of the translation
  84688. * @returns the current updated matrix
  84689. */
  84690. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84691. /**
  84692. * Adds the translation vector (using 3 floats) in the current matrix
  84693. * @param x defines the 1st component of the translation
  84694. * @param y defines the 2nd component of the translation
  84695. * @param z defines the 3rd component of the translation
  84696. * @returns the current updated matrix
  84697. */
  84698. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84699. /**
  84700. * Inserts the translation vector in the current matrix
  84701. * @param vector3 defines the translation to insert
  84702. * @returns the current updated matrix
  84703. */
  84704. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84705. /**
  84706. * Gets the translation value of the current matrix
  84707. * @returns a new Vector3 as the extracted translation from the matrix
  84708. */
  84709. getTranslation(): Vector3;
  84710. /**
  84711. * Fill a Vector3 with the extracted translation from the matrix
  84712. * @param result defines the Vector3 where to store the translation
  84713. * @returns the current matrix
  84714. */
  84715. getTranslationToRef(result: Vector3): Matrix;
  84716. /**
  84717. * Remove rotation and scaling part from the matrix
  84718. * @returns the updated matrix
  84719. */
  84720. removeRotationAndScaling(): Matrix;
  84721. /**
  84722. * Multiply two matrices
  84723. * @param other defines the second operand
  84724. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84725. */
  84726. multiply(other: DeepImmutable<Matrix>): Matrix;
  84727. /**
  84728. * Copy the current matrix from the given one
  84729. * @param other defines the source matrix
  84730. * @returns the current updated matrix
  84731. */
  84732. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84733. /**
  84734. * Populates the given array from the starting index with the current matrix values
  84735. * @param array defines the target array
  84736. * @param offset defines the offset in the target array where to start storing values
  84737. * @returns the current matrix
  84738. */
  84739. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84740. /**
  84741. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84742. * @param other defines the second operand
  84743. * @param result defines the matrix where to store the multiplication
  84744. * @returns the current matrix
  84745. */
  84746. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84747. /**
  84748. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84749. * @param other defines the second operand
  84750. * @param result defines the array where to store the multiplication
  84751. * @param offset defines the offset in the target array where to start storing values
  84752. * @returns the current matrix
  84753. */
  84754. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84755. /**
  84756. * Check equality between this matrix and a second one
  84757. * @param value defines the second matrix to compare
  84758. * @returns true is the current matrix and the given one values are strictly equal
  84759. */
  84760. equals(value: DeepImmutable<Matrix>): boolean;
  84761. /**
  84762. * Clone the current matrix
  84763. * @returns a new matrix from the current matrix
  84764. */
  84765. clone(): Matrix;
  84766. /**
  84767. * Returns the name of the current matrix class
  84768. * @returns the string "Matrix"
  84769. */
  84770. getClassName(): string;
  84771. /**
  84772. * Gets the hash code of the current matrix
  84773. * @returns the hash code
  84774. */
  84775. getHashCode(): number;
  84776. /**
  84777. * Decomposes the current Matrix into a translation, rotation and scaling components
  84778. * @param scale defines the scale vector3 given as a reference to update
  84779. * @param rotation defines the rotation quaternion given as a reference to update
  84780. * @param translation defines the translation vector3 given as a reference to update
  84781. * @returns true if operation was successful
  84782. */
  84783. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84784. /**
  84785. * Gets specific row of the matrix
  84786. * @param index defines the number of the row to get
  84787. * @returns the index-th row of the current matrix as a new Vector4
  84788. */
  84789. getRow(index: number): Nullable<Vector4>;
  84790. /**
  84791. * Sets the index-th row of the current matrix to the vector4 values
  84792. * @param index defines the number of the row to set
  84793. * @param row defines the target vector4
  84794. * @returns the updated current matrix
  84795. */
  84796. setRow(index: number, row: Vector4): Matrix;
  84797. /**
  84798. * Compute the transpose of the matrix
  84799. * @returns the new transposed matrix
  84800. */
  84801. transpose(): Matrix;
  84802. /**
  84803. * Compute the transpose of the matrix and store it in a given matrix
  84804. * @param result defines the target matrix
  84805. * @returns the current matrix
  84806. */
  84807. transposeToRef(result: Matrix): Matrix;
  84808. /**
  84809. * Sets the index-th row of the current matrix with the given 4 x float values
  84810. * @param index defines the row index
  84811. * @param x defines the x component to set
  84812. * @param y defines the y component to set
  84813. * @param z defines the z component to set
  84814. * @param w defines the w component to set
  84815. * @returns the updated current matrix
  84816. */
  84817. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84818. /**
  84819. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84820. * @param scale defines the scale factor
  84821. * @returns a new matrix
  84822. */
  84823. scale(scale: number): Matrix;
  84824. /**
  84825. * Scale the current matrix values by a factor to a given result matrix
  84826. * @param scale defines the scale factor
  84827. * @param result defines the matrix to store the result
  84828. * @returns the current matrix
  84829. */
  84830. scaleToRef(scale: number, result: Matrix): Matrix;
  84831. /**
  84832. * Scale the current matrix values by a factor and add the result to a given matrix
  84833. * @param scale defines the scale factor
  84834. * @param result defines the Matrix to store the result
  84835. * @returns the current matrix
  84836. */
  84837. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84838. /**
  84839. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84840. * @param ref matrix to store the result
  84841. */
  84842. toNormalMatrix(ref: Matrix): void;
  84843. /**
  84844. * Gets only rotation part of the current matrix
  84845. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84846. */
  84847. getRotationMatrix(): Matrix;
  84848. /**
  84849. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84850. * @param result defines the target matrix to store data to
  84851. * @returns the current matrix
  84852. */
  84853. getRotationMatrixToRef(result: Matrix): Matrix;
  84854. /**
  84855. * Toggles model matrix from being right handed to left handed in place and vice versa
  84856. */
  84857. toggleModelMatrixHandInPlace(): void;
  84858. /**
  84859. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84860. */
  84861. toggleProjectionMatrixHandInPlace(): void;
  84862. /**
  84863. * Creates a matrix from an array
  84864. * @param array defines the source array
  84865. * @param offset defines an offset in the source array
  84866. * @returns a new Matrix set from the starting index of the given array
  84867. */
  84868. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84869. /**
  84870. * Copy the content of an array into a given matrix
  84871. * @param array defines the source array
  84872. * @param offset defines an offset in the source array
  84873. * @param result defines the target matrix
  84874. */
  84875. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84876. /**
  84877. * Stores an array into a matrix after having multiplied each component by a given factor
  84878. * @param array defines the source array
  84879. * @param offset defines the offset in the source array
  84880. * @param scale defines the scaling factor
  84881. * @param result defines the target matrix
  84882. */
  84883. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84884. /**
  84885. * Gets an identity matrix that must not be updated
  84886. */
  84887. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84888. /**
  84889. * Stores a list of values (16) inside a given matrix
  84890. * @param initialM11 defines 1st value of 1st row
  84891. * @param initialM12 defines 2nd value of 1st row
  84892. * @param initialM13 defines 3rd value of 1st row
  84893. * @param initialM14 defines 4th value of 1st row
  84894. * @param initialM21 defines 1st value of 2nd row
  84895. * @param initialM22 defines 2nd value of 2nd row
  84896. * @param initialM23 defines 3rd value of 2nd row
  84897. * @param initialM24 defines 4th value of 2nd row
  84898. * @param initialM31 defines 1st value of 3rd row
  84899. * @param initialM32 defines 2nd value of 3rd row
  84900. * @param initialM33 defines 3rd value of 3rd row
  84901. * @param initialM34 defines 4th value of 3rd row
  84902. * @param initialM41 defines 1st value of 4th row
  84903. * @param initialM42 defines 2nd value of 4th row
  84904. * @param initialM43 defines 3rd value of 4th row
  84905. * @param initialM44 defines 4th value of 4th row
  84906. * @param result defines the target matrix
  84907. */
  84908. 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;
  84909. /**
  84910. * Creates new matrix from a list of values (16)
  84911. * @param initialM11 defines 1st value of 1st row
  84912. * @param initialM12 defines 2nd value of 1st row
  84913. * @param initialM13 defines 3rd value of 1st row
  84914. * @param initialM14 defines 4th value of 1st row
  84915. * @param initialM21 defines 1st value of 2nd row
  84916. * @param initialM22 defines 2nd value of 2nd row
  84917. * @param initialM23 defines 3rd value of 2nd row
  84918. * @param initialM24 defines 4th value of 2nd row
  84919. * @param initialM31 defines 1st value of 3rd row
  84920. * @param initialM32 defines 2nd value of 3rd row
  84921. * @param initialM33 defines 3rd value of 3rd row
  84922. * @param initialM34 defines 4th value of 3rd row
  84923. * @param initialM41 defines 1st value of 4th row
  84924. * @param initialM42 defines 2nd value of 4th row
  84925. * @param initialM43 defines 3rd value of 4th row
  84926. * @param initialM44 defines 4th value of 4th row
  84927. * @returns the new matrix
  84928. */
  84929. 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;
  84930. /**
  84931. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84932. * @param scale defines the scale vector3
  84933. * @param rotation defines the rotation quaternion
  84934. * @param translation defines the translation vector3
  84935. * @returns a new matrix
  84936. */
  84937. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84938. /**
  84939. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84940. * @param scale defines the scale vector3
  84941. * @param rotation defines the rotation quaternion
  84942. * @param translation defines the translation vector3
  84943. * @param result defines the target matrix
  84944. */
  84945. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84946. /**
  84947. * Creates a new identity matrix
  84948. * @returns a new identity matrix
  84949. */
  84950. static Identity(): Matrix;
  84951. /**
  84952. * Creates a new identity matrix and stores the result in a given matrix
  84953. * @param result defines the target matrix
  84954. */
  84955. static IdentityToRef(result: Matrix): void;
  84956. /**
  84957. * Creates a new zero matrix
  84958. * @returns a new zero matrix
  84959. */
  84960. static Zero(): Matrix;
  84961. /**
  84962. * Creates a new rotation matrix for "angle" radians around the X axis
  84963. * @param angle defines the angle (in radians) to use
  84964. * @return the new matrix
  84965. */
  84966. static RotationX(angle: number): Matrix;
  84967. /**
  84968. * Creates a new matrix as the invert of a given matrix
  84969. * @param source defines the source matrix
  84970. * @returns the new matrix
  84971. */
  84972. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84973. /**
  84974. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84975. * @param angle defines the angle (in radians) to use
  84976. * @param result defines the target matrix
  84977. */
  84978. static RotationXToRef(angle: number, result: Matrix): void;
  84979. /**
  84980. * Creates a new rotation matrix for "angle" radians around the Y axis
  84981. * @param angle defines the angle (in radians) to use
  84982. * @return the new matrix
  84983. */
  84984. static RotationY(angle: number): Matrix;
  84985. /**
  84986. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84987. * @param angle defines the angle (in radians) to use
  84988. * @param result defines the target matrix
  84989. */
  84990. static RotationYToRef(angle: number, result: Matrix): void;
  84991. /**
  84992. * Creates a new rotation matrix for "angle" radians around the Z axis
  84993. * @param angle defines the angle (in radians) to use
  84994. * @return the new matrix
  84995. */
  84996. static RotationZ(angle: number): Matrix;
  84997. /**
  84998. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84999. * @param angle defines the angle (in radians) to use
  85000. * @param result defines the target matrix
  85001. */
  85002. static RotationZToRef(angle: number, result: Matrix): void;
  85003. /**
  85004. * Creates a new rotation matrix for "angle" radians around the given axis
  85005. * @param axis defines the axis to use
  85006. * @param angle defines the angle (in radians) to use
  85007. * @return the new matrix
  85008. */
  85009. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  85010. /**
  85011. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  85012. * @param axis defines the axis to use
  85013. * @param angle defines the angle (in radians) to use
  85014. * @param result defines the target matrix
  85015. */
  85016. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  85017. /**
  85018. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  85019. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  85020. * @param from defines the vector to align
  85021. * @param to defines the vector to align to
  85022. * @param result defines the target matrix
  85023. */
  85024. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  85025. /**
  85026. * Creates a rotation matrix
  85027. * @param yaw defines the yaw angle in radians (Y axis)
  85028. * @param pitch defines the pitch angle in radians (X axis)
  85029. * @param roll defines the roll angle in radians (Z axis)
  85030. * @returns the new rotation matrix
  85031. */
  85032. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85033. /**
  85034. * Creates a rotation matrix and stores it in a given matrix
  85035. * @param yaw defines the yaw angle in radians (Y axis)
  85036. * @param pitch defines the pitch angle in radians (X axis)
  85037. * @param roll defines the roll angle in radians (Z axis)
  85038. * @param result defines the target matrix
  85039. */
  85040. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85041. /**
  85042. * Creates a scaling matrix
  85043. * @param x defines the scale factor on X axis
  85044. * @param y defines the scale factor on Y axis
  85045. * @param z defines the scale factor on Z axis
  85046. * @returns the new matrix
  85047. */
  85048. static Scaling(x: number, y: number, z: number): Matrix;
  85049. /**
  85050. * Creates a scaling matrix and stores it in a given matrix
  85051. * @param x defines the scale factor on X axis
  85052. * @param y defines the scale factor on Y axis
  85053. * @param z defines the scale factor on Z axis
  85054. * @param result defines the target matrix
  85055. */
  85056. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85057. /**
  85058. * Creates a translation matrix
  85059. * @param x defines the translation on X axis
  85060. * @param y defines the translation on Y axis
  85061. * @param z defines the translationon Z axis
  85062. * @returns the new matrix
  85063. */
  85064. static Translation(x: number, y: number, z: number): Matrix;
  85065. /**
  85066. * Creates a translation matrix and stores it in a given matrix
  85067. * @param x defines the translation on X axis
  85068. * @param y defines the translation on Y axis
  85069. * @param z defines the translationon Z axis
  85070. * @param result defines the target matrix
  85071. */
  85072. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85073. /**
  85074. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85075. * @param startValue defines the start value
  85076. * @param endValue defines the end value
  85077. * @param gradient defines the gradient factor
  85078. * @returns the new matrix
  85079. */
  85080. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85081. /**
  85082. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85083. * @param startValue defines the start value
  85084. * @param endValue defines the end value
  85085. * @param gradient defines the gradient factor
  85086. * @param result defines the Matrix object where to store data
  85087. */
  85088. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85089. /**
  85090. * Builds a new matrix whose values are computed by:
  85091. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85092. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85093. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85094. * @param startValue defines the first matrix
  85095. * @param endValue defines the second matrix
  85096. * @param gradient defines the gradient between the two matrices
  85097. * @returns the new matrix
  85098. */
  85099. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85100. /**
  85101. * Update a matrix to values which are computed by:
  85102. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85103. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85104. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85105. * @param startValue defines the first matrix
  85106. * @param endValue defines the second matrix
  85107. * @param gradient defines the gradient between the two matrices
  85108. * @param result defines the target matrix
  85109. */
  85110. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85111. /**
  85112. * 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"
  85113. * This function works in left handed mode
  85114. * @param eye defines the final position of the entity
  85115. * @param target defines where the entity should look at
  85116. * @param up defines the up vector for the entity
  85117. * @returns the new matrix
  85118. */
  85119. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85120. /**
  85121. * 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".
  85122. * This function works in left handed mode
  85123. * @param eye defines the final position of the entity
  85124. * @param target defines where the entity should look at
  85125. * @param up defines the up vector for the entity
  85126. * @param result defines the target matrix
  85127. */
  85128. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85129. /**
  85130. * 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"
  85131. * This function works in right handed mode
  85132. * @param eye defines the final position of the entity
  85133. * @param target defines where the entity should look at
  85134. * @param up defines the up vector for the entity
  85135. * @returns the new matrix
  85136. */
  85137. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85138. /**
  85139. * 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".
  85140. * This function works in right handed mode
  85141. * @param eye defines the final position of the entity
  85142. * @param target defines where the entity should look at
  85143. * @param up defines the up vector for the entity
  85144. * @param result defines the target matrix
  85145. */
  85146. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85147. /**
  85148. * Create a left-handed orthographic projection matrix
  85149. * @param width defines the viewport width
  85150. * @param height defines the viewport height
  85151. * @param znear defines the near clip plane
  85152. * @param zfar defines the far clip plane
  85153. * @returns a new matrix as a left-handed orthographic projection matrix
  85154. */
  85155. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85156. /**
  85157. * Store a left-handed orthographic projection to a given matrix
  85158. * @param width defines the viewport width
  85159. * @param height defines the viewport height
  85160. * @param znear defines the near clip plane
  85161. * @param zfar defines the far clip plane
  85162. * @param result defines the target matrix
  85163. */
  85164. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85165. /**
  85166. * Create a left-handed orthographic projection matrix
  85167. * @param left defines the viewport left coordinate
  85168. * @param right defines the viewport right coordinate
  85169. * @param bottom defines the viewport bottom coordinate
  85170. * @param top defines the viewport top coordinate
  85171. * @param znear defines the near clip plane
  85172. * @param zfar defines the far clip plane
  85173. * @returns a new matrix as a left-handed orthographic projection matrix
  85174. */
  85175. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85176. /**
  85177. * Stores a left-handed orthographic projection into a given matrix
  85178. * @param left defines the viewport left coordinate
  85179. * @param right defines the viewport right coordinate
  85180. * @param bottom defines the viewport bottom coordinate
  85181. * @param top defines the viewport top coordinate
  85182. * @param znear defines the near clip plane
  85183. * @param zfar defines the far clip plane
  85184. * @param result defines the target matrix
  85185. */
  85186. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85187. /**
  85188. * Creates a right-handed orthographic projection matrix
  85189. * @param left defines the viewport left coordinate
  85190. * @param right defines the viewport right coordinate
  85191. * @param bottom defines the viewport bottom coordinate
  85192. * @param top defines the viewport top coordinate
  85193. * @param znear defines the near clip plane
  85194. * @param zfar defines the far clip plane
  85195. * @returns a new matrix as a right-handed orthographic projection matrix
  85196. */
  85197. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85198. /**
  85199. * Stores a right-handed orthographic projection into a given matrix
  85200. * @param left defines the viewport left coordinate
  85201. * @param right defines the viewport right coordinate
  85202. * @param bottom defines the viewport bottom coordinate
  85203. * @param top defines the viewport top coordinate
  85204. * @param znear defines the near clip plane
  85205. * @param zfar defines the far clip plane
  85206. * @param result defines the target matrix
  85207. */
  85208. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85209. /**
  85210. * Creates a left-handed perspective projection matrix
  85211. * @param width defines the viewport width
  85212. * @param height defines the viewport height
  85213. * @param znear defines the near clip plane
  85214. * @param zfar defines the far clip plane
  85215. * @returns a new matrix as a left-handed perspective projection matrix
  85216. */
  85217. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85218. /**
  85219. * Creates a left-handed perspective projection matrix
  85220. * @param fov defines the horizontal field of view
  85221. * @param aspect defines the aspect ratio
  85222. * @param znear defines the near clip plane
  85223. * @param zfar defines the far clip plane
  85224. * @returns a new matrix as a left-handed perspective projection matrix
  85225. */
  85226. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85227. /**
  85228. * Stores a left-handed perspective projection into a given matrix
  85229. * @param fov defines the horizontal field of view
  85230. * @param aspect defines the aspect ratio
  85231. * @param znear defines the near clip plane
  85232. * @param zfar defines the far clip plane
  85233. * @param result defines the target matrix
  85234. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85235. */
  85236. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85237. /**
  85238. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85239. * @param fov defines the horizontal field of view
  85240. * @param aspect defines the aspect ratio
  85241. * @param znear defines the near clip plane
  85242. * @param zfar not used as infinity is used as far clip
  85243. * @param result defines the target matrix
  85244. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85245. */
  85246. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85247. /**
  85248. * Creates a right-handed perspective projection matrix
  85249. * @param fov defines the horizontal field of view
  85250. * @param aspect defines the aspect ratio
  85251. * @param znear defines the near clip plane
  85252. * @param zfar defines the far clip plane
  85253. * @returns a new matrix as a right-handed perspective projection matrix
  85254. */
  85255. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85256. /**
  85257. * Stores a right-handed perspective projection into a given matrix
  85258. * @param fov defines the horizontal field of view
  85259. * @param aspect defines the aspect ratio
  85260. * @param znear defines the near clip plane
  85261. * @param zfar defines the far clip plane
  85262. * @param result defines the target matrix
  85263. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85264. */
  85265. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85266. /**
  85267. * Stores a right-handed perspective projection into a given matrix
  85268. * @param fov defines the horizontal field of view
  85269. * @param aspect defines the aspect ratio
  85270. * @param znear defines the near clip plane
  85271. * @param zfar not used as infinity is used as far clip
  85272. * @param result defines the target matrix
  85273. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85274. */
  85275. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85276. /**
  85277. * Stores a perspective projection for WebVR info a given matrix
  85278. * @param fov defines the field of view
  85279. * @param znear defines the near clip plane
  85280. * @param zfar defines the far clip plane
  85281. * @param result defines the target matrix
  85282. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85283. */
  85284. static PerspectiveFovWebVRToRef(fov: {
  85285. upDegrees: number;
  85286. downDegrees: number;
  85287. leftDegrees: number;
  85288. rightDegrees: number;
  85289. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85290. /**
  85291. * Computes a complete transformation matrix
  85292. * @param viewport defines the viewport to use
  85293. * @param world defines the world matrix
  85294. * @param view defines the view matrix
  85295. * @param projection defines the projection matrix
  85296. * @param zmin defines the near clip plane
  85297. * @param zmax defines the far clip plane
  85298. * @returns the transformation matrix
  85299. */
  85300. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85301. /**
  85302. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85303. * @param matrix defines the matrix to use
  85304. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85305. */
  85306. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85307. /**
  85308. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85309. * @param matrix defines the matrix to use
  85310. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85311. */
  85312. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85313. /**
  85314. * Compute the transpose of a given matrix
  85315. * @param matrix defines the matrix to transpose
  85316. * @returns the new matrix
  85317. */
  85318. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85319. /**
  85320. * Compute the transpose of a matrix and store it in a target matrix
  85321. * @param matrix defines the matrix to transpose
  85322. * @param result defines the target matrix
  85323. */
  85324. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85325. /**
  85326. * Computes a reflection matrix from a plane
  85327. * @param plane defines the reflection plane
  85328. * @returns a new matrix
  85329. */
  85330. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85331. /**
  85332. * Computes a reflection matrix from a plane
  85333. * @param plane defines the reflection plane
  85334. * @param result defines the target matrix
  85335. */
  85336. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85337. /**
  85338. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85339. * @param xaxis defines the value of the 1st axis
  85340. * @param yaxis defines the value of the 2nd axis
  85341. * @param zaxis defines the value of the 3rd axis
  85342. * @param result defines the target matrix
  85343. */
  85344. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85345. /**
  85346. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85347. * @param quat defines the quaternion to use
  85348. * @param result defines the target matrix
  85349. */
  85350. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85351. }
  85352. /**
  85353. * @hidden
  85354. */
  85355. export class TmpVectors {
  85356. static Vector2: Vector2[];
  85357. static Vector3: Vector3[];
  85358. static Vector4: Vector4[];
  85359. static Quaternion: Quaternion[];
  85360. static Matrix: Matrix[];
  85361. }
  85362. }
  85363. declare module BABYLON {
  85364. /**
  85365. * Defines potential orientation for back face culling
  85366. */
  85367. export enum Orientation {
  85368. /**
  85369. * Clockwise
  85370. */
  85371. CW = 0,
  85372. /** Counter clockwise */
  85373. CCW = 1
  85374. }
  85375. /** Class used to represent a Bezier curve */
  85376. export class BezierCurve {
  85377. /**
  85378. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85379. * @param t defines the time
  85380. * @param x1 defines the left coordinate on X axis
  85381. * @param y1 defines the left coordinate on Y axis
  85382. * @param x2 defines the right coordinate on X axis
  85383. * @param y2 defines the right coordinate on Y axis
  85384. * @returns the interpolated value
  85385. */
  85386. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85387. }
  85388. /**
  85389. * Defines angle representation
  85390. */
  85391. export class Angle {
  85392. private _radians;
  85393. /**
  85394. * Creates an Angle object of "radians" radians (float).
  85395. * @param radians the angle in radians
  85396. */
  85397. constructor(radians: number);
  85398. /**
  85399. * Get value in degrees
  85400. * @returns the Angle value in degrees (float)
  85401. */
  85402. degrees(): number;
  85403. /**
  85404. * Get value in radians
  85405. * @returns the Angle value in radians (float)
  85406. */
  85407. radians(): number;
  85408. /**
  85409. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85410. * @param a defines first point as the origin
  85411. * @param b defines point
  85412. * @returns a new Angle
  85413. */
  85414. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85415. /**
  85416. * Gets a new Angle object from the given float in radians
  85417. * @param radians defines the angle value in radians
  85418. * @returns a new Angle
  85419. */
  85420. static FromRadians(radians: number): Angle;
  85421. /**
  85422. * Gets a new Angle object from the given float in degrees
  85423. * @param degrees defines the angle value in degrees
  85424. * @returns a new Angle
  85425. */
  85426. static FromDegrees(degrees: number): Angle;
  85427. }
  85428. /**
  85429. * This represents an arc in a 2d space.
  85430. */
  85431. export class Arc2 {
  85432. /** Defines the start point of the arc */
  85433. startPoint: Vector2;
  85434. /** Defines the mid point of the arc */
  85435. midPoint: Vector2;
  85436. /** Defines the end point of the arc */
  85437. endPoint: Vector2;
  85438. /**
  85439. * Defines the center point of the arc.
  85440. */
  85441. centerPoint: Vector2;
  85442. /**
  85443. * Defines the radius of the arc.
  85444. */
  85445. radius: number;
  85446. /**
  85447. * Defines the angle of the arc (from mid point to end point).
  85448. */
  85449. angle: Angle;
  85450. /**
  85451. * Defines the start angle of the arc (from start point to middle point).
  85452. */
  85453. startAngle: Angle;
  85454. /**
  85455. * Defines the orientation of the arc (clock wise/counter clock wise).
  85456. */
  85457. orientation: Orientation;
  85458. /**
  85459. * Creates an Arc object from the three given points : start, middle and end.
  85460. * @param startPoint Defines the start point of the arc
  85461. * @param midPoint Defines the midlle point of the arc
  85462. * @param endPoint Defines the end point of the arc
  85463. */
  85464. constructor(
  85465. /** Defines the start point of the arc */
  85466. startPoint: Vector2,
  85467. /** Defines the mid point of the arc */
  85468. midPoint: Vector2,
  85469. /** Defines the end point of the arc */
  85470. endPoint: Vector2);
  85471. }
  85472. /**
  85473. * Represents a 2D path made up of multiple 2D points
  85474. */
  85475. export class Path2 {
  85476. private _points;
  85477. private _length;
  85478. /**
  85479. * If the path start and end point are the same
  85480. */
  85481. closed: boolean;
  85482. /**
  85483. * Creates a Path2 object from the starting 2D coordinates x and y.
  85484. * @param x the starting points x value
  85485. * @param y the starting points y value
  85486. */
  85487. constructor(x: number, y: number);
  85488. /**
  85489. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85490. * @param x the added points x value
  85491. * @param y the added points y value
  85492. * @returns the updated Path2.
  85493. */
  85494. addLineTo(x: number, y: number): Path2;
  85495. /**
  85496. * 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.
  85497. * @param midX middle point x value
  85498. * @param midY middle point y value
  85499. * @param endX end point x value
  85500. * @param endY end point y value
  85501. * @param numberOfSegments (default: 36)
  85502. * @returns the updated Path2.
  85503. */
  85504. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85505. /**
  85506. * Closes the Path2.
  85507. * @returns the Path2.
  85508. */
  85509. close(): Path2;
  85510. /**
  85511. * Gets the sum of the distance between each sequential point in the path
  85512. * @returns the Path2 total length (float).
  85513. */
  85514. length(): number;
  85515. /**
  85516. * Gets the points which construct the path
  85517. * @returns the Path2 internal array of points.
  85518. */
  85519. getPoints(): Vector2[];
  85520. /**
  85521. * Retreives the point at the distance aways from the starting point
  85522. * @param normalizedLengthPosition the length along the path to retreive the point from
  85523. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85524. */
  85525. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85526. /**
  85527. * Creates a new path starting from an x and y position
  85528. * @param x starting x value
  85529. * @param y starting y value
  85530. * @returns a new Path2 starting at the coordinates (x, y).
  85531. */
  85532. static StartingAt(x: number, y: number): Path2;
  85533. }
  85534. /**
  85535. * Represents a 3D path made up of multiple 3D points
  85536. */
  85537. export class Path3D {
  85538. /**
  85539. * an array of Vector3, the curve axis of the Path3D
  85540. */
  85541. path: Vector3[];
  85542. private _curve;
  85543. private _distances;
  85544. private _tangents;
  85545. private _normals;
  85546. private _binormals;
  85547. private _raw;
  85548. private _alignTangentsWithPath;
  85549. private readonly _pointAtData;
  85550. /**
  85551. * new Path3D(path, normal, raw)
  85552. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85553. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85554. * @param path an array of Vector3, the curve axis of the Path3D
  85555. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85556. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85557. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85558. */
  85559. constructor(
  85560. /**
  85561. * an array of Vector3, the curve axis of the Path3D
  85562. */
  85563. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85564. /**
  85565. * Returns the Path3D array of successive Vector3 designing its curve.
  85566. * @returns the Path3D array of successive Vector3 designing its curve.
  85567. */
  85568. getCurve(): Vector3[];
  85569. /**
  85570. * Returns the Path3D array of successive Vector3 designing its curve.
  85571. * @returns the Path3D array of successive Vector3 designing its curve.
  85572. */
  85573. getPoints(): Vector3[];
  85574. /**
  85575. * @returns the computed length (float) of the path.
  85576. */
  85577. length(): number;
  85578. /**
  85579. * Returns an array populated with tangent vectors on each Path3D curve point.
  85580. * @returns an array populated with tangent vectors on each Path3D curve point.
  85581. */
  85582. getTangents(): Vector3[];
  85583. /**
  85584. * Returns an array populated with normal vectors on each Path3D curve point.
  85585. * @returns an array populated with normal vectors on each Path3D curve point.
  85586. */
  85587. getNormals(): Vector3[];
  85588. /**
  85589. * Returns an array populated with binormal vectors on each Path3D curve point.
  85590. * @returns an array populated with binormal vectors on each Path3D curve point.
  85591. */
  85592. getBinormals(): Vector3[];
  85593. /**
  85594. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85595. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85596. */
  85597. getDistances(): number[];
  85598. /**
  85599. * Returns an interpolated point along this path
  85600. * @param position the position of the point along this path, from 0.0 to 1.0
  85601. * @returns a new Vector3 as the point
  85602. */
  85603. getPointAt(position: number): Vector3;
  85604. /**
  85605. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85606. * @param position the position of the point along this path, from 0.0 to 1.0
  85607. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85608. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85609. */
  85610. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85611. /**
  85612. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85613. * @param position the position of the point along this path, from 0.0 to 1.0
  85614. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85615. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85616. */
  85617. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85618. /**
  85619. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85620. * @param position the position of the point along this path, from 0.0 to 1.0
  85621. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85622. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85623. */
  85624. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85625. /**
  85626. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85627. * @param position the position of the point along this path, from 0.0 to 1.0
  85628. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85629. */
  85630. getDistanceAt(position: number): number;
  85631. /**
  85632. * Returns the array index of the previous point of an interpolated point along this path
  85633. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85634. * @returns the array index
  85635. */
  85636. getPreviousPointIndexAt(position: number): number;
  85637. /**
  85638. * 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)
  85639. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85640. * @returns the sub position
  85641. */
  85642. getSubPositionAt(position: number): number;
  85643. /**
  85644. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85645. * @param target the vector of which to get the closest position to
  85646. * @returns the position of the closest virtual point on this path to the target vector
  85647. */
  85648. getClosestPositionTo(target: Vector3): number;
  85649. /**
  85650. * Returns a sub path (slice) of this path
  85651. * @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
  85652. * @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
  85653. * @returns a sub path (slice) of this path
  85654. */
  85655. slice(start?: number, end?: number): Path3D;
  85656. /**
  85657. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85658. * @param path path which all values are copied into the curves points
  85659. * @param firstNormal which should be projected onto the curve
  85660. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85661. * @returns the same object updated.
  85662. */
  85663. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85664. private _compute;
  85665. private _getFirstNonNullVector;
  85666. private _getLastNonNullVector;
  85667. private _normalVector;
  85668. /**
  85669. * Updates the point at data for an interpolated point along this curve
  85670. * @param position the position of the point along this curve, from 0.0 to 1.0
  85671. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85672. * @returns the (updated) point at data
  85673. */
  85674. private _updatePointAtData;
  85675. /**
  85676. * Updates the point at data from the specified parameters
  85677. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85678. * @param point the interpolated point
  85679. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85680. */
  85681. private _setPointAtData;
  85682. /**
  85683. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85684. */
  85685. private _updateInterpolationMatrix;
  85686. }
  85687. /**
  85688. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85689. * A Curve3 is designed from a series of successive Vector3.
  85690. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85691. */
  85692. export class Curve3 {
  85693. private _points;
  85694. private _length;
  85695. /**
  85696. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85697. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85698. * @param v1 (Vector3) the control point
  85699. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85700. * @param nbPoints (integer) the wanted number of points in the curve
  85701. * @returns the created Curve3
  85702. */
  85703. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85704. /**
  85705. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85706. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85707. * @param v1 (Vector3) the first control point
  85708. * @param v2 (Vector3) the second control point
  85709. * @param v3 (Vector3) the end point of the Cubic Bezier
  85710. * @param nbPoints (integer) the wanted number of points in the curve
  85711. * @returns the created Curve3
  85712. */
  85713. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85714. /**
  85715. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85716. * @param p1 (Vector3) the origin point of the Hermite Spline
  85717. * @param t1 (Vector3) the tangent vector at the origin point
  85718. * @param p2 (Vector3) the end point of the Hermite Spline
  85719. * @param t2 (Vector3) the tangent vector at the end point
  85720. * @param nbPoints (integer) the wanted number of points in the curve
  85721. * @returns the created Curve3
  85722. */
  85723. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85724. /**
  85725. * Returns a Curve3 object along a CatmullRom Spline curve :
  85726. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85727. * @param nbPoints (integer) the wanted number of points between each curve control points
  85728. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85729. * @returns the created Curve3
  85730. */
  85731. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85732. /**
  85733. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85734. * A Curve3 is designed from a series of successive Vector3.
  85735. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85736. * @param points points which make up the curve
  85737. */
  85738. constructor(points: Vector3[]);
  85739. /**
  85740. * @returns the Curve3 stored array of successive Vector3
  85741. */
  85742. getPoints(): Vector3[];
  85743. /**
  85744. * @returns the computed length (float) of the curve.
  85745. */
  85746. length(): number;
  85747. /**
  85748. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85749. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85750. * curveA and curveB keep unchanged.
  85751. * @param curve the curve to continue from this curve
  85752. * @returns the newly constructed curve
  85753. */
  85754. continue(curve: DeepImmutable<Curve3>): Curve3;
  85755. private _computeLength;
  85756. }
  85757. }
  85758. declare module BABYLON {
  85759. /**
  85760. * This represents the main contract an easing function should follow.
  85761. * Easing functions are used throughout the animation system.
  85762. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85763. */
  85764. export interface IEasingFunction {
  85765. /**
  85766. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85767. * of the easing function.
  85768. * The link below provides some of the most common examples of easing functions.
  85769. * @see https://easings.net/
  85770. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85771. * @returns the corresponding value on the curve defined by the easing function
  85772. */
  85773. ease(gradient: number): number;
  85774. }
  85775. /**
  85776. * Base class used for every default easing function.
  85777. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85778. */
  85779. export class EasingFunction implements IEasingFunction {
  85780. /**
  85781. * Interpolation follows the mathematical formula associated with the easing function.
  85782. */
  85783. static readonly EASINGMODE_EASEIN: number;
  85784. /**
  85785. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85786. */
  85787. static readonly EASINGMODE_EASEOUT: number;
  85788. /**
  85789. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85790. */
  85791. static readonly EASINGMODE_EASEINOUT: number;
  85792. private _easingMode;
  85793. /**
  85794. * Sets the easing mode of the current function.
  85795. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85796. */
  85797. setEasingMode(easingMode: number): void;
  85798. /**
  85799. * Gets the current easing mode.
  85800. * @returns the easing mode
  85801. */
  85802. getEasingMode(): number;
  85803. /**
  85804. * @hidden
  85805. */
  85806. easeInCore(gradient: number): number;
  85807. /**
  85808. * Given an input gradient between 0 and 1, this returns the corresponding value
  85809. * of the easing function.
  85810. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85811. * @returns the corresponding value on the curve defined by the easing function
  85812. */
  85813. ease(gradient: number): number;
  85814. }
  85815. /**
  85816. * Easing function with a circle shape (see link below).
  85817. * @see https://easings.net/#easeInCirc
  85818. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85819. */
  85820. export class CircleEase extends EasingFunction implements IEasingFunction {
  85821. /** @hidden */
  85822. easeInCore(gradient: number): number;
  85823. }
  85824. /**
  85825. * Easing function with a ease back shape (see link below).
  85826. * @see https://easings.net/#easeInBack
  85827. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85828. */
  85829. export class BackEase extends EasingFunction implements IEasingFunction {
  85830. /** Defines the amplitude of the function */
  85831. amplitude: number;
  85832. /**
  85833. * Instantiates a back ease easing
  85834. * @see https://easings.net/#easeInBack
  85835. * @param amplitude Defines the amplitude of the function
  85836. */
  85837. constructor(
  85838. /** Defines the amplitude of the function */
  85839. amplitude?: number);
  85840. /** @hidden */
  85841. easeInCore(gradient: number): number;
  85842. }
  85843. /**
  85844. * Easing function with a bouncing shape (see link below).
  85845. * @see https://easings.net/#easeInBounce
  85846. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85847. */
  85848. export class BounceEase extends EasingFunction implements IEasingFunction {
  85849. /** Defines the number of bounces */
  85850. bounces: number;
  85851. /** Defines the amplitude of the bounce */
  85852. bounciness: number;
  85853. /**
  85854. * Instantiates a bounce easing
  85855. * @see https://easings.net/#easeInBounce
  85856. * @param bounces Defines the number of bounces
  85857. * @param bounciness Defines the amplitude of the bounce
  85858. */
  85859. constructor(
  85860. /** Defines the number of bounces */
  85861. bounces?: number,
  85862. /** Defines the amplitude of the bounce */
  85863. bounciness?: number);
  85864. /** @hidden */
  85865. easeInCore(gradient: number): number;
  85866. }
  85867. /**
  85868. * Easing function with a power of 3 shape (see link below).
  85869. * @see https://easings.net/#easeInCubic
  85870. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85871. */
  85872. export class CubicEase extends EasingFunction implements IEasingFunction {
  85873. /** @hidden */
  85874. easeInCore(gradient: number): number;
  85875. }
  85876. /**
  85877. * Easing function with an elastic shape (see link below).
  85878. * @see https://easings.net/#easeInElastic
  85879. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85880. */
  85881. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85882. /** Defines the number of oscillations*/
  85883. oscillations: number;
  85884. /** Defines the amplitude of the oscillations*/
  85885. springiness: number;
  85886. /**
  85887. * Instantiates an elastic easing function
  85888. * @see https://easings.net/#easeInElastic
  85889. * @param oscillations Defines the number of oscillations
  85890. * @param springiness Defines the amplitude of the oscillations
  85891. */
  85892. constructor(
  85893. /** Defines the number of oscillations*/
  85894. oscillations?: number,
  85895. /** Defines the amplitude of the oscillations*/
  85896. springiness?: number);
  85897. /** @hidden */
  85898. easeInCore(gradient: number): number;
  85899. }
  85900. /**
  85901. * Easing function with an exponential shape (see link below).
  85902. * @see https://easings.net/#easeInExpo
  85903. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85904. */
  85905. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85906. /** Defines the exponent of the function */
  85907. exponent: number;
  85908. /**
  85909. * Instantiates an exponential easing function
  85910. * @see https://easings.net/#easeInExpo
  85911. * @param exponent Defines the exponent of the function
  85912. */
  85913. constructor(
  85914. /** Defines the exponent of the function */
  85915. exponent?: number);
  85916. /** @hidden */
  85917. easeInCore(gradient: number): number;
  85918. }
  85919. /**
  85920. * Easing function with a power shape (see link below).
  85921. * @see https://easings.net/#easeInQuad
  85922. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85923. */
  85924. export class PowerEase extends EasingFunction implements IEasingFunction {
  85925. /** Defines the power of the function */
  85926. power: number;
  85927. /**
  85928. * Instantiates an power base easing function
  85929. * @see https://easings.net/#easeInQuad
  85930. * @param power Defines the power of the function
  85931. */
  85932. constructor(
  85933. /** Defines the power of the function */
  85934. power?: number);
  85935. /** @hidden */
  85936. easeInCore(gradient: number): number;
  85937. }
  85938. /**
  85939. * Easing function with a power of 2 shape (see link below).
  85940. * @see https://easings.net/#easeInQuad
  85941. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85942. */
  85943. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85944. /** @hidden */
  85945. easeInCore(gradient: number): number;
  85946. }
  85947. /**
  85948. * Easing function with a power of 4 shape (see link below).
  85949. * @see https://easings.net/#easeInQuart
  85950. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85951. */
  85952. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85953. /** @hidden */
  85954. easeInCore(gradient: number): number;
  85955. }
  85956. /**
  85957. * Easing function with a power of 5 shape (see link below).
  85958. * @see https://easings.net/#easeInQuint
  85959. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85960. */
  85961. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85962. /** @hidden */
  85963. easeInCore(gradient: number): number;
  85964. }
  85965. /**
  85966. * Easing function with a sin shape (see link below).
  85967. * @see https://easings.net/#easeInSine
  85968. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85969. */
  85970. export class SineEase extends EasingFunction implements IEasingFunction {
  85971. /** @hidden */
  85972. easeInCore(gradient: number): number;
  85973. }
  85974. /**
  85975. * Easing function with a bezier shape (see link below).
  85976. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85977. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85978. */
  85979. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85980. /** Defines the x component of the start tangent in the bezier curve */
  85981. x1: number;
  85982. /** Defines the y component of the start tangent in the bezier curve */
  85983. y1: number;
  85984. /** Defines the x component of the end tangent in the bezier curve */
  85985. x2: number;
  85986. /** Defines the y component of the end tangent in the bezier curve */
  85987. y2: number;
  85988. /**
  85989. * Instantiates a bezier function
  85990. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85991. * @param x1 Defines the x component of the start tangent in the bezier curve
  85992. * @param y1 Defines the y component of the start tangent in the bezier curve
  85993. * @param x2 Defines the x component of the end tangent in the bezier curve
  85994. * @param y2 Defines the y component of the end tangent in the bezier curve
  85995. */
  85996. constructor(
  85997. /** Defines the x component of the start tangent in the bezier curve */
  85998. x1?: number,
  85999. /** Defines the y component of the start tangent in the bezier curve */
  86000. y1?: number,
  86001. /** Defines the x component of the end tangent in the bezier curve */
  86002. x2?: number,
  86003. /** Defines the y component of the end tangent in the bezier curve */
  86004. y2?: number);
  86005. /** @hidden */
  86006. easeInCore(gradient: number): number;
  86007. }
  86008. }
  86009. declare module BABYLON {
  86010. /**
  86011. * Class used to hold a RBG color
  86012. */
  86013. export class Color3 {
  86014. /**
  86015. * Defines the red component (between 0 and 1, default is 0)
  86016. */
  86017. r: number;
  86018. /**
  86019. * Defines the green component (between 0 and 1, default is 0)
  86020. */
  86021. g: number;
  86022. /**
  86023. * Defines the blue component (between 0 and 1, default is 0)
  86024. */
  86025. b: number;
  86026. /**
  86027. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86028. * @param r defines the red component (between 0 and 1, default is 0)
  86029. * @param g defines the green component (between 0 and 1, default is 0)
  86030. * @param b defines the blue component (between 0 and 1, default is 0)
  86031. */
  86032. constructor(
  86033. /**
  86034. * Defines the red component (between 0 and 1, default is 0)
  86035. */
  86036. r?: number,
  86037. /**
  86038. * Defines the green component (between 0 and 1, default is 0)
  86039. */
  86040. g?: number,
  86041. /**
  86042. * Defines the blue component (between 0 and 1, default is 0)
  86043. */
  86044. b?: number);
  86045. /**
  86046. * Creates a string with the Color3 current values
  86047. * @returns the string representation of the Color3 object
  86048. */
  86049. toString(): string;
  86050. /**
  86051. * Returns the string "Color3"
  86052. * @returns "Color3"
  86053. */
  86054. getClassName(): string;
  86055. /**
  86056. * Compute the Color3 hash code
  86057. * @returns an unique number that can be used to hash Color3 objects
  86058. */
  86059. getHashCode(): number;
  86060. /**
  86061. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86062. * @param array defines the array where to store the r,g,b components
  86063. * @param index defines an optional index in the target array to define where to start storing values
  86064. * @returns the current Color3 object
  86065. */
  86066. toArray(array: FloatArray, index?: number): Color3;
  86067. /**
  86068. * Update the current color with values stored in an array from the starting index of the given array
  86069. * @param array defines the source array
  86070. * @param offset defines an offset in the source array
  86071. * @returns the current Color3 object
  86072. */
  86073. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86074. /**
  86075. * Returns a new Color4 object from the current Color3 and the given alpha
  86076. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86077. * @returns a new Color4 object
  86078. */
  86079. toColor4(alpha?: number): Color4;
  86080. /**
  86081. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86082. * @returns the new array
  86083. */
  86084. asArray(): number[];
  86085. /**
  86086. * Returns the luminance value
  86087. * @returns a float value
  86088. */
  86089. toLuminance(): number;
  86090. /**
  86091. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86092. * @param otherColor defines the second operand
  86093. * @returns the new Color3 object
  86094. */
  86095. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86096. /**
  86097. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86098. * @param otherColor defines the second operand
  86099. * @param result defines the Color3 object where to store the result
  86100. * @returns the current Color3
  86101. */
  86102. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86103. /**
  86104. * Determines equality between Color3 objects
  86105. * @param otherColor defines the second operand
  86106. * @returns true if the rgb values are equal to the given ones
  86107. */
  86108. equals(otherColor: DeepImmutable<Color3>): boolean;
  86109. /**
  86110. * Determines equality between the current Color3 object and a set of r,b,g values
  86111. * @param r defines the red component to check
  86112. * @param g defines the green component to check
  86113. * @param b defines the blue component to check
  86114. * @returns true if the rgb values are equal to the given ones
  86115. */
  86116. equalsFloats(r: number, g: number, b: number): boolean;
  86117. /**
  86118. * Multiplies in place each rgb value by scale
  86119. * @param scale defines the scaling factor
  86120. * @returns the updated Color3
  86121. */
  86122. scale(scale: number): Color3;
  86123. /**
  86124. * Multiplies the rgb values by scale and stores the result into "result"
  86125. * @param scale defines the scaling factor
  86126. * @param result defines the Color3 object where to store the result
  86127. * @returns the unmodified current Color3
  86128. */
  86129. scaleToRef(scale: number, result: Color3): Color3;
  86130. /**
  86131. * Scale the current Color3 values by a factor and add the result to a given Color3
  86132. * @param scale defines the scale factor
  86133. * @param result defines color to store the result into
  86134. * @returns the unmodified current Color3
  86135. */
  86136. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86137. /**
  86138. * Clamps the rgb values by the min and max values and stores the result into "result"
  86139. * @param min defines minimum clamping value (default is 0)
  86140. * @param max defines maximum clamping value (default is 1)
  86141. * @param result defines color to store the result into
  86142. * @returns the original Color3
  86143. */
  86144. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86145. /**
  86146. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86147. * @param otherColor defines the second operand
  86148. * @returns the new Color3
  86149. */
  86150. add(otherColor: DeepImmutable<Color3>): Color3;
  86151. /**
  86152. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86153. * @param otherColor defines the second operand
  86154. * @param result defines Color3 object to store the result into
  86155. * @returns the unmodified current Color3
  86156. */
  86157. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86158. /**
  86159. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86160. * @param otherColor defines the second operand
  86161. * @returns the new Color3
  86162. */
  86163. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86164. /**
  86165. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86166. * @param otherColor defines the second operand
  86167. * @param result defines Color3 object to store the result into
  86168. * @returns the unmodified current Color3
  86169. */
  86170. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86171. /**
  86172. * Copy the current object
  86173. * @returns a new Color3 copied the current one
  86174. */
  86175. clone(): Color3;
  86176. /**
  86177. * Copies the rgb values from the source in the current Color3
  86178. * @param source defines the source Color3 object
  86179. * @returns the updated Color3 object
  86180. */
  86181. copyFrom(source: DeepImmutable<Color3>): Color3;
  86182. /**
  86183. * Updates the Color3 rgb values from the given floats
  86184. * @param r defines the red component to read from
  86185. * @param g defines the green component to read from
  86186. * @param b defines the blue component to read from
  86187. * @returns the current Color3 object
  86188. */
  86189. copyFromFloats(r: number, g: number, b: number): Color3;
  86190. /**
  86191. * Updates the Color3 rgb values from the given floats
  86192. * @param r defines the red component to read from
  86193. * @param g defines the green component to read from
  86194. * @param b defines the blue component to read from
  86195. * @returns the current Color3 object
  86196. */
  86197. set(r: number, g: number, b: number): Color3;
  86198. /**
  86199. * Compute the Color3 hexadecimal code as a string
  86200. * @returns a string containing the hexadecimal representation of the Color3 object
  86201. */
  86202. toHexString(): string;
  86203. /**
  86204. * Computes a new Color3 converted from the current one to linear space
  86205. * @returns a new Color3 object
  86206. */
  86207. toLinearSpace(): Color3;
  86208. /**
  86209. * Converts current color in rgb space to HSV values
  86210. * @returns a new color3 representing the HSV values
  86211. */
  86212. toHSV(): Color3;
  86213. /**
  86214. * Converts current color in rgb space to HSV values
  86215. * @param result defines the Color3 where to store the HSV values
  86216. */
  86217. toHSVToRef(result: Color3): void;
  86218. /**
  86219. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86220. * @param convertedColor defines the Color3 object where to store the linear space version
  86221. * @returns the unmodified Color3
  86222. */
  86223. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86224. /**
  86225. * Computes a new Color3 converted from the current one to gamma space
  86226. * @returns a new Color3 object
  86227. */
  86228. toGammaSpace(): Color3;
  86229. /**
  86230. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86231. * @param convertedColor defines the Color3 object where to store the gamma space version
  86232. * @returns the unmodified Color3
  86233. */
  86234. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86235. private static _BlackReadOnly;
  86236. /**
  86237. * Convert Hue, saturation and value to a Color3 (RGB)
  86238. * @param hue defines the hue
  86239. * @param saturation defines the saturation
  86240. * @param value defines the value
  86241. * @param result defines the Color3 where to store the RGB values
  86242. */
  86243. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86244. /**
  86245. * Creates a new Color3 from the string containing valid hexadecimal values
  86246. * @param hex defines a string containing valid hexadecimal values
  86247. * @returns a new Color3 object
  86248. */
  86249. static FromHexString(hex: string): Color3;
  86250. /**
  86251. * Creates a new Color3 from the starting index of the given array
  86252. * @param array defines the source array
  86253. * @param offset defines an offset in the source array
  86254. * @returns a new Color3 object
  86255. */
  86256. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86257. /**
  86258. * Creates a new Color3 from the starting index element of the given array
  86259. * @param array defines the source array to read from
  86260. * @param offset defines the offset in the source array
  86261. * @param result defines the target Color3 object
  86262. */
  86263. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86264. /**
  86265. * Creates a new Color3 from integer values (< 256)
  86266. * @param r defines the red component to read from (value between 0 and 255)
  86267. * @param g defines the green component to read from (value between 0 and 255)
  86268. * @param b defines the blue component to read from (value between 0 and 255)
  86269. * @returns a new Color3 object
  86270. */
  86271. static FromInts(r: number, g: number, b: number): Color3;
  86272. /**
  86273. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86274. * @param start defines the start Color3 value
  86275. * @param end defines the end Color3 value
  86276. * @param amount defines the gradient value between start and end
  86277. * @returns a new Color3 object
  86278. */
  86279. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86280. /**
  86281. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86282. * @param left defines the start value
  86283. * @param right defines the end value
  86284. * @param amount defines the gradient factor
  86285. * @param result defines the Color3 object where to store the result
  86286. */
  86287. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86288. /**
  86289. * Returns a Color3 value containing a red color
  86290. * @returns a new Color3 object
  86291. */
  86292. static Red(): Color3;
  86293. /**
  86294. * Returns a Color3 value containing a green color
  86295. * @returns a new Color3 object
  86296. */
  86297. static Green(): Color3;
  86298. /**
  86299. * Returns a Color3 value containing a blue color
  86300. * @returns a new Color3 object
  86301. */
  86302. static Blue(): Color3;
  86303. /**
  86304. * Returns a Color3 value containing a black color
  86305. * @returns a new Color3 object
  86306. */
  86307. static Black(): Color3;
  86308. /**
  86309. * Gets a Color3 value containing a black color that must not be updated
  86310. */
  86311. static get BlackReadOnly(): DeepImmutable<Color3>;
  86312. /**
  86313. * Returns a Color3 value containing a white color
  86314. * @returns a new Color3 object
  86315. */
  86316. static White(): Color3;
  86317. /**
  86318. * Returns a Color3 value containing a purple color
  86319. * @returns a new Color3 object
  86320. */
  86321. static Purple(): Color3;
  86322. /**
  86323. * Returns a Color3 value containing a magenta color
  86324. * @returns a new Color3 object
  86325. */
  86326. static Magenta(): Color3;
  86327. /**
  86328. * Returns a Color3 value containing a yellow color
  86329. * @returns a new Color3 object
  86330. */
  86331. static Yellow(): Color3;
  86332. /**
  86333. * Returns a Color3 value containing a gray color
  86334. * @returns a new Color3 object
  86335. */
  86336. static Gray(): Color3;
  86337. /**
  86338. * Returns a Color3 value containing a teal color
  86339. * @returns a new Color3 object
  86340. */
  86341. static Teal(): Color3;
  86342. /**
  86343. * Returns a Color3 value containing a random color
  86344. * @returns a new Color3 object
  86345. */
  86346. static Random(): Color3;
  86347. }
  86348. /**
  86349. * Class used to hold a RBGA color
  86350. */
  86351. export class Color4 {
  86352. /**
  86353. * Defines the red component (between 0 and 1, default is 0)
  86354. */
  86355. r: number;
  86356. /**
  86357. * Defines the green component (between 0 and 1, default is 0)
  86358. */
  86359. g: number;
  86360. /**
  86361. * Defines the blue component (between 0 and 1, default is 0)
  86362. */
  86363. b: number;
  86364. /**
  86365. * Defines the alpha component (between 0 and 1, default is 1)
  86366. */
  86367. a: number;
  86368. /**
  86369. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86370. * @param r defines the red component (between 0 and 1, default is 0)
  86371. * @param g defines the green component (between 0 and 1, default is 0)
  86372. * @param b defines the blue component (between 0 and 1, default is 0)
  86373. * @param a defines the alpha component (between 0 and 1, default is 1)
  86374. */
  86375. constructor(
  86376. /**
  86377. * Defines the red component (between 0 and 1, default is 0)
  86378. */
  86379. r?: number,
  86380. /**
  86381. * Defines the green component (between 0 and 1, default is 0)
  86382. */
  86383. g?: number,
  86384. /**
  86385. * Defines the blue component (between 0 and 1, default is 0)
  86386. */
  86387. b?: number,
  86388. /**
  86389. * Defines the alpha component (between 0 and 1, default is 1)
  86390. */
  86391. a?: number);
  86392. /**
  86393. * Adds in place the given Color4 values to the current Color4 object
  86394. * @param right defines the second operand
  86395. * @returns the current updated Color4 object
  86396. */
  86397. addInPlace(right: DeepImmutable<Color4>): Color4;
  86398. /**
  86399. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86400. * @returns the new array
  86401. */
  86402. asArray(): number[];
  86403. /**
  86404. * Stores from the starting index in the given array the Color4 successive values
  86405. * @param array defines the array where to store the r,g,b components
  86406. * @param index defines an optional index in the target array to define where to start storing values
  86407. * @returns the current Color4 object
  86408. */
  86409. toArray(array: number[], index?: number): Color4;
  86410. /**
  86411. * Update the current color with values stored in an array from the starting index of the given array
  86412. * @param array defines the source array
  86413. * @param offset defines an offset in the source array
  86414. * @returns the current Color4 object
  86415. */
  86416. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86417. /**
  86418. * Determines equality between Color4 objects
  86419. * @param otherColor defines the second operand
  86420. * @returns true if the rgba values are equal to the given ones
  86421. */
  86422. equals(otherColor: DeepImmutable<Color4>): boolean;
  86423. /**
  86424. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86425. * @param right defines the second operand
  86426. * @returns a new Color4 object
  86427. */
  86428. add(right: DeepImmutable<Color4>): Color4;
  86429. /**
  86430. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86431. * @param right defines the second operand
  86432. * @returns a new Color4 object
  86433. */
  86434. subtract(right: DeepImmutable<Color4>): Color4;
  86435. /**
  86436. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86437. * @param right defines the second operand
  86438. * @param result defines the Color4 object where to store the result
  86439. * @returns the current Color4 object
  86440. */
  86441. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86442. /**
  86443. * Creates a new Color4 with the current Color4 values multiplied by scale
  86444. * @param scale defines the scaling factor to apply
  86445. * @returns a new Color4 object
  86446. */
  86447. scale(scale: number): Color4;
  86448. /**
  86449. * Multiplies the current Color4 values by scale and stores the result in "result"
  86450. * @param scale defines the scaling factor to apply
  86451. * @param result defines the Color4 object where to store the result
  86452. * @returns the current unmodified Color4
  86453. */
  86454. scaleToRef(scale: number, result: Color4): Color4;
  86455. /**
  86456. * Scale the current Color4 values by a factor and add the result to a given Color4
  86457. * @param scale defines the scale factor
  86458. * @param result defines the Color4 object where to store the result
  86459. * @returns the unmodified current Color4
  86460. */
  86461. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86462. /**
  86463. * Clamps the rgb values by the min and max values and stores the result into "result"
  86464. * @param min defines minimum clamping value (default is 0)
  86465. * @param max defines maximum clamping value (default is 1)
  86466. * @param result defines color to store the result into.
  86467. * @returns the cuurent Color4
  86468. */
  86469. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86470. /**
  86471. * Multipy an Color4 value by another and return a new Color4 object
  86472. * @param color defines the Color4 value to multiply by
  86473. * @returns a new Color4 object
  86474. */
  86475. multiply(color: Color4): Color4;
  86476. /**
  86477. * Multipy a Color4 value by another and push the result in a reference value
  86478. * @param color defines the Color4 value to multiply by
  86479. * @param result defines the Color4 to fill the result in
  86480. * @returns the result Color4
  86481. */
  86482. multiplyToRef(color: Color4, result: Color4): Color4;
  86483. /**
  86484. * Creates a string with the Color4 current values
  86485. * @returns the string representation of the Color4 object
  86486. */
  86487. toString(): string;
  86488. /**
  86489. * Returns the string "Color4"
  86490. * @returns "Color4"
  86491. */
  86492. getClassName(): string;
  86493. /**
  86494. * Compute the Color4 hash code
  86495. * @returns an unique number that can be used to hash Color4 objects
  86496. */
  86497. getHashCode(): number;
  86498. /**
  86499. * Creates a new Color4 copied from the current one
  86500. * @returns a new Color4 object
  86501. */
  86502. clone(): Color4;
  86503. /**
  86504. * Copies the given Color4 values into the current one
  86505. * @param source defines the source Color4 object
  86506. * @returns the current updated Color4 object
  86507. */
  86508. copyFrom(source: Color4): Color4;
  86509. /**
  86510. * Copies the given float values into the current one
  86511. * @param r defines the red component to read from
  86512. * @param g defines the green component to read from
  86513. * @param b defines the blue component to read from
  86514. * @param a defines the alpha component to read from
  86515. * @returns the current updated Color4 object
  86516. */
  86517. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86518. /**
  86519. * Copies the given float values into the current one
  86520. * @param r defines the red component to read from
  86521. * @param g defines the green component to read from
  86522. * @param b defines the blue component to read from
  86523. * @param a defines the alpha component to read from
  86524. * @returns the current updated Color4 object
  86525. */
  86526. set(r: number, g: number, b: number, a: number): Color4;
  86527. /**
  86528. * Compute the Color4 hexadecimal code as a string
  86529. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86530. * @returns a string containing the hexadecimal representation of the Color4 object
  86531. */
  86532. toHexString(returnAsColor3?: boolean): string;
  86533. /**
  86534. * Computes a new Color4 converted from the current one to linear space
  86535. * @returns a new Color4 object
  86536. */
  86537. toLinearSpace(): Color4;
  86538. /**
  86539. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86540. * @param convertedColor defines the Color4 object where to store the linear space version
  86541. * @returns the unmodified Color4
  86542. */
  86543. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86544. /**
  86545. * Computes a new Color4 converted from the current one to gamma space
  86546. * @returns a new Color4 object
  86547. */
  86548. toGammaSpace(): Color4;
  86549. /**
  86550. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86551. * @param convertedColor defines the Color4 object where to store the gamma space version
  86552. * @returns the unmodified Color4
  86553. */
  86554. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86555. /**
  86556. * Creates a new Color4 from the string containing valid hexadecimal values
  86557. * @param hex defines a string containing valid hexadecimal values
  86558. * @returns a new Color4 object
  86559. */
  86560. static FromHexString(hex: string): Color4;
  86561. /**
  86562. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86563. * @param left defines the start value
  86564. * @param right defines the end value
  86565. * @param amount defines the gradient factor
  86566. * @returns a new Color4 object
  86567. */
  86568. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86569. /**
  86570. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86571. * @param left defines the start value
  86572. * @param right defines the end value
  86573. * @param amount defines the gradient factor
  86574. * @param result defines the Color4 object where to store data
  86575. */
  86576. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86577. /**
  86578. * Creates a new Color4 from a Color3 and an alpha value
  86579. * @param color3 defines the source Color3 to read from
  86580. * @param alpha defines the alpha component (1.0 by default)
  86581. * @returns a new Color4 object
  86582. */
  86583. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86584. /**
  86585. * Creates a new Color4 from the starting index element of the given array
  86586. * @param array defines the source array to read from
  86587. * @param offset defines the offset in the source array
  86588. * @returns a new Color4 object
  86589. */
  86590. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86591. /**
  86592. * Creates a new Color4 from the starting index element of the given array
  86593. * @param array defines the source array to read from
  86594. * @param offset defines the offset in the source array
  86595. * @param result defines the target Color4 object
  86596. */
  86597. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86598. /**
  86599. * Creates a new Color3 from integer values (< 256)
  86600. * @param r defines the red component to read from (value between 0 and 255)
  86601. * @param g defines the green component to read from (value between 0 and 255)
  86602. * @param b defines the blue component to read from (value between 0 and 255)
  86603. * @param a defines the alpha component to read from (value between 0 and 255)
  86604. * @returns a new Color3 object
  86605. */
  86606. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86607. /**
  86608. * Check the content of a given array and convert it to an array containing RGBA data
  86609. * If the original array was already containing count * 4 values then it is returned directly
  86610. * @param colors defines the array to check
  86611. * @param count defines the number of RGBA data to expect
  86612. * @returns an array containing count * 4 values (RGBA)
  86613. */
  86614. static CheckColors4(colors: number[], count: number): number[];
  86615. }
  86616. /**
  86617. * @hidden
  86618. */
  86619. export class TmpColors {
  86620. static Color3: Color3[];
  86621. static Color4: Color4[];
  86622. }
  86623. }
  86624. declare module BABYLON {
  86625. /**
  86626. * Defines an interface which represents an animation key frame
  86627. */
  86628. export interface IAnimationKey {
  86629. /**
  86630. * Frame of the key frame
  86631. */
  86632. frame: number;
  86633. /**
  86634. * Value at the specifies key frame
  86635. */
  86636. value: any;
  86637. /**
  86638. * The input tangent for the cubic hermite spline
  86639. */
  86640. inTangent?: any;
  86641. /**
  86642. * The output tangent for the cubic hermite spline
  86643. */
  86644. outTangent?: any;
  86645. /**
  86646. * The animation interpolation type
  86647. */
  86648. interpolation?: AnimationKeyInterpolation;
  86649. }
  86650. /**
  86651. * Enum for the animation key frame interpolation type
  86652. */
  86653. export enum AnimationKeyInterpolation {
  86654. /**
  86655. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86656. */
  86657. STEP = 1
  86658. }
  86659. }
  86660. declare module BABYLON {
  86661. /**
  86662. * Represents the range of an animation
  86663. */
  86664. export class AnimationRange {
  86665. /**The name of the animation range**/
  86666. name: string;
  86667. /**The starting frame of the animation */
  86668. from: number;
  86669. /**The ending frame of the animation*/
  86670. to: number;
  86671. /**
  86672. * Initializes the range of an animation
  86673. * @param name The name of the animation range
  86674. * @param from The starting frame of the animation
  86675. * @param to The ending frame of the animation
  86676. */
  86677. constructor(
  86678. /**The name of the animation range**/
  86679. name: string,
  86680. /**The starting frame of the animation */
  86681. from: number,
  86682. /**The ending frame of the animation*/
  86683. to: number);
  86684. /**
  86685. * Makes a copy of the animation range
  86686. * @returns A copy of the animation range
  86687. */
  86688. clone(): AnimationRange;
  86689. }
  86690. }
  86691. declare module BABYLON {
  86692. /**
  86693. * Composed of a frame, and an action function
  86694. */
  86695. export class AnimationEvent {
  86696. /** The frame for which the event is triggered **/
  86697. frame: number;
  86698. /** The event to perform when triggered **/
  86699. action: (currentFrame: number) => void;
  86700. /** Specifies if the event should be triggered only once**/
  86701. onlyOnce?: boolean | undefined;
  86702. /**
  86703. * Specifies if the animation event is done
  86704. */
  86705. isDone: boolean;
  86706. /**
  86707. * Initializes the animation event
  86708. * @param frame The frame for which the event is triggered
  86709. * @param action The event to perform when triggered
  86710. * @param onlyOnce Specifies if the event should be triggered only once
  86711. */
  86712. constructor(
  86713. /** The frame for which the event is triggered **/
  86714. frame: number,
  86715. /** The event to perform when triggered **/
  86716. action: (currentFrame: number) => void,
  86717. /** Specifies if the event should be triggered only once**/
  86718. onlyOnce?: boolean | undefined);
  86719. /** @hidden */
  86720. _clone(): AnimationEvent;
  86721. }
  86722. }
  86723. declare module BABYLON {
  86724. /**
  86725. * Interface used to define a behavior
  86726. */
  86727. export interface Behavior<T> {
  86728. /** gets or sets behavior's name */
  86729. name: string;
  86730. /**
  86731. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86732. */
  86733. init(): void;
  86734. /**
  86735. * Called when the behavior is attached to a target
  86736. * @param target defines the target where the behavior is attached to
  86737. */
  86738. attach(target: T): void;
  86739. /**
  86740. * Called when the behavior is detached from its target
  86741. */
  86742. detach(): void;
  86743. }
  86744. /**
  86745. * Interface implemented by classes supporting behaviors
  86746. */
  86747. export interface IBehaviorAware<T> {
  86748. /**
  86749. * Attach a behavior
  86750. * @param behavior defines the behavior to attach
  86751. * @returns the current host
  86752. */
  86753. addBehavior(behavior: Behavior<T>): T;
  86754. /**
  86755. * Remove a behavior from the current object
  86756. * @param behavior defines the behavior to detach
  86757. * @returns the current host
  86758. */
  86759. removeBehavior(behavior: Behavior<T>): T;
  86760. /**
  86761. * Gets a behavior using its name to search
  86762. * @param name defines the name to search
  86763. * @returns the behavior or null if not found
  86764. */
  86765. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86766. }
  86767. }
  86768. declare module BABYLON {
  86769. /**
  86770. * Defines an array and its length.
  86771. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86772. */
  86773. export interface ISmartArrayLike<T> {
  86774. /**
  86775. * The data of the array.
  86776. */
  86777. data: Array<T>;
  86778. /**
  86779. * The active length of the array.
  86780. */
  86781. length: number;
  86782. }
  86783. /**
  86784. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86785. */
  86786. export class SmartArray<T> implements ISmartArrayLike<T> {
  86787. /**
  86788. * The full set of data from the array.
  86789. */
  86790. data: Array<T>;
  86791. /**
  86792. * The active length of the array.
  86793. */
  86794. length: number;
  86795. protected _id: number;
  86796. /**
  86797. * Instantiates a Smart Array.
  86798. * @param capacity defines the default capacity of the array.
  86799. */
  86800. constructor(capacity: number);
  86801. /**
  86802. * Pushes a value at the end of the active data.
  86803. * @param value defines the object to push in the array.
  86804. */
  86805. push(value: T): void;
  86806. /**
  86807. * Iterates over the active data and apply the lambda to them.
  86808. * @param func defines the action to apply on each value.
  86809. */
  86810. forEach(func: (content: T) => void): void;
  86811. /**
  86812. * Sorts the full sets of data.
  86813. * @param compareFn defines the comparison function to apply.
  86814. */
  86815. sort(compareFn: (a: T, b: T) => number): void;
  86816. /**
  86817. * Resets the active data to an empty array.
  86818. */
  86819. reset(): void;
  86820. /**
  86821. * Releases all the data from the array as well as the array.
  86822. */
  86823. dispose(): void;
  86824. /**
  86825. * Concats the active data with a given array.
  86826. * @param array defines the data to concatenate with.
  86827. */
  86828. concat(array: any): void;
  86829. /**
  86830. * Returns the position of a value in the active data.
  86831. * @param value defines the value to find the index for
  86832. * @returns the index if found in the active data otherwise -1
  86833. */
  86834. indexOf(value: T): number;
  86835. /**
  86836. * Returns whether an element is part of the active data.
  86837. * @param value defines the value to look for
  86838. * @returns true if found in the active data otherwise false
  86839. */
  86840. contains(value: T): boolean;
  86841. private static _GlobalId;
  86842. }
  86843. /**
  86844. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86845. * The data in this array can only be present once
  86846. */
  86847. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86848. private _duplicateId;
  86849. /**
  86850. * Pushes a value at the end of the active data.
  86851. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86852. * @param value defines the object to push in the array.
  86853. */
  86854. push(value: T): void;
  86855. /**
  86856. * Pushes a value at the end of the active data.
  86857. * If the data is already present, it won t be added again
  86858. * @param value defines the object to push in the array.
  86859. * @returns true if added false if it was already present
  86860. */
  86861. pushNoDuplicate(value: T): boolean;
  86862. /**
  86863. * Resets the active data to an empty array.
  86864. */
  86865. reset(): void;
  86866. /**
  86867. * Concats the active data with a given array.
  86868. * This ensures no dupplicate will be present in the result.
  86869. * @param array defines the data to concatenate with.
  86870. */
  86871. concatWithNoDuplicate(array: any): void;
  86872. }
  86873. }
  86874. declare module BABYLON {
  86875. /**
  86876. * @ignore
  86877. * This is a list of all the different input types that are available in the application.
  86878. * Fo instance: ArcRotateCameraGamepadInput...
  86879. */
  86880. export var CameraInputTypes: {};
  86881. /**
  86882. * This is the contract to implement in order to create a new input class.
  86883. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86884. */
  86885. export interface ICameraInput<TCamera extends Camera> {
  86886. /**
  86887. * Defines the camera the input is attached to.
  86888. */
  86889. camera: Nullable<TCamera>;
  86890. /**
  86891. * Gets the class name of the current intput.
  86892. * @returns the class name
  86893. */
  86894. getClassName(): string;
  86895. /**
  86896. * Get the friendly name associated with the input class.
  86897. * @returns the input friendly name
  86898. */
  86899. getSimpleName(): string;
  86900. /**
  86901. * Attach the input controls to a specific dom element to get the input from.
  86902. * @param element Defines the element the controls should be listened from
  86903. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86904. */
  86905. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86906. /**
  86907. * Detach the current controls from the specified dom element.
  86908. * @param element Defines the element to stop listening the inputs from
  86909. */
  86910. detachControl(element: Nullable<HTMLElement>): void;
  86911. /**
  86912. * Update the current camera state depending on the inputs that have been used this frame.
  86913. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86914. */
  86915. checkInputs?: () => void;
  86916. }
  86917. /**
  86918. * Represents a map of input types to input instance or input index to input instance.
  86919. */
  86920. export interface CameraInputsMap<TCamera extends Camera> {
  86921. /**
  86922. * Accessor to the input by input type.
  86923. */
  86924. [name: string]: ICameraInput<TCamera>;
  86925. /**
  86926. * Accessor to the input by input index.
  86927. */
  86928. [idx: number]: ICameraInput<TCamera>;
  86929. }
  86930. /**
  86931. * This represents the input manager used within a camera.
  86932. * It helps dealing with all the different kind of input attached to a camera.
  86933. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86934. */
  86935. export class CameraInputsManager<TCamera extends Camera> {
  86936. /**
  86937. * Defines the list of inputs attahed to the camera.
  86938. */
  86939. attached: CameraInputsMap<TCamera>;
  86940. /**
  86941. * Defines the dom element the camera is collecting inputs from.
  86942. * This is null if the controls have not been attached.
  86943. */
  86944. attachedElement: Nullable<HTMLElement>;
  86945. /**
  86946. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86947. */
  86948. noPreventDefault: boolean;
  86949. /**
  86950. * Defined the camera the input manager belongs to.
  86951. */
  86952. camera: TCamera;
  86953. /**
  86954. * Update the current camera state depending on the inputs that have been used this frame.
  86955. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86956. */
  86957. checkInputs: () => void;
  86958. /**
  86959. * Instantiate a new Camera Input Manager.
  86960. * @param camera Defines the camera the input manager blongs to
  86961. */
  86962. constructor(camera: TCamera);
  86963. /**
  86964. * Add an input method to a camera
  86965. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86966. * @param input camera input method
  86967. */
  86968. add(input: ICameraInput<TCamera>): void;
  86969. /**
  86970. * Remove a specific input method from a camera
  86971. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86972. * @param inputToRemove camera input method
  86973. */
  86974. remove(inputToRemove: ICameraInput<TCamera>): void;
  86975. /**
  86976. * Remove a specific input type from a camera
  86977. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86978. * @param inputType the type of the input to remove
  86979. */
  86980. removeByType(inputType: string): void;
  86981. private _addCheckInputs;
  86982. /**
  86983. * Attach the input controls to the currently attached dom element to listen the events from.
  86984. * @param input Defines the input to attach
  86985. */
  86986. attachInput(input: ICameraInput<TCamera>): void;
  86987. /**
  86988. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86989. * @param element Defines the dom element to collect the events from
  86990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86991. */
  86992. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86993. /**
  86994. * Detach the current manager inputs controls from a specific dom element.
  86995. * @param element Defines the dom element to collect the events from
  86996. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86997. */
  86998. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86999. /**
  87000. * Rebuild the dynamic inputCheck function from the current list of
  87001. * defined inputs in the manager.
  87002. */
  87003. rebuildInputCheck(): void;
  87004. /**
  87005. * Remove all attached input methods from a camera
  87006. */
  87007. clear(): void;
  87008. /**
  87009. * Serialize the current input manager attached to a camera.
  87010. * This ensures than once parsed,
  87011. * the input associated to the camera will be identical to the current ones
  87012. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  87013. */
  87014. serialize(serializedCamera: any): void;
  87015. /**
  87016. * Parses an input manager serialized JSON to restore the previous list of inputs
  87017. * and states associated to a camera.
  87018. * @param parsedCamera Defines the JSON to parse
  87019. */
  87020. parse(parsedCamera: any): void;
  87021. }
  87022. }
  87023. declare module BABYLON {
  87024. /**
  87025. * Class used to store data that will be store in GPU memory
  87026. */
  87027. export class Buffer {
  87028. private _engine;
  87029. private _buffer;
  87030. /** @hidden */
  87031. _data: Nullable<DataArray>;
  87032. private _updatable;
  87033. private _instanced;
  87034. private _divisor;
  87035. /**
  87036. * Gets the byte stride.
  87037. */
  87038. readonly byteStride: number;
  87039. /**
  87040. * Constructor
  87041. * @param engine the engine
  87042. * @param data the data to use for this buffer
  87043. * @param updatable whether the data is updatable
  87044. * @param stride the stride (optional)
  87045. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87046. * @param instanced whether the buffer is instanced (optional)
  87047. * @param useBytes set to true if the stride in in bytes (optional)
  87048. * @param divisor sets an optional divisor for instances (1 by default)
  87049. */
  87050. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87051. /**
  87052. * Create a new VertexBuffer based on the current buffer
  87053. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87054. * @param offset defines offset in the buffer (0 by default)
  87055. * @param size defines the size in floats of attributes (position is 3 for instance)
  87056. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87057. * @param instanced defines if the vertex buffer contains indexed data
  87058. * @param useBytes defines if the offset and stride are in bytes *
  87059. * @param divisor sets an optional divisor for instances (1 by default)
  87060. * @returns the new vertex buffer
  87061. */
  87062. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87063. /**
  87064. * Gets a boolean indicating if the Buffer is updatable?
  87065. * @returns true if the buffer is updatable
  87066. */
  87067. isUpdatable(): boolean;
  87068. /**
  87069. * Gets current buffer's data
  87070. * @returns a DataArray or null
  87071. */
  87072. getData(): Nullable<DataArray>;
  87073. /**
  87074. * Gets underlying native buffer
  87075. * @returns underlying native buffer
  87076. */
  87077. getBuffer(): Nullable<DataBuffer>;
  87078. /**
  87079. * Gets the stride in float32 units (i.e. byte stride / 4).
  87080. * May not be an integer if the byte stride is not divisible by 4.
  87081. * @returns the stride in float32 units
  87082. * @deprecated Please use byteStride instead.
  87083. */
  87084. getStrideSize(): number;
  87085. /**
  87086. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87087. * @param data defines the data to store
  87088. */
  87089. create(data?: Nullable<DataArray>): void;
  87090. /** @hidden */
  87091. _rebuild(): void;
  87092. /**
  87093. * Update current buffer data
  87094. * @param data defines the data to store
  87095. */
  87096. update(data: DataArray): void;
  87097. /**
  87098. * Updates the data directly.
  87099. * @param data the new data
  87100. * @param offset the new offset
  87101. * @param vertexCount the vertex count (optional)
  87102. * @param useBytes set to true if the offset is in bytes
  87103. */
  87104. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87105. /**
  87106. * Release all resources
  87107. */
  87108. dispose(): void;
  87109. }
  87110. /**
  87111. * Specialized buffer used to store vertex data
  87112. */
  87113. export class VertexBuffer {
  87114. /** @hidden */
  87115. _buffer: Buffer;
  87116. private _kind;
  87117. private _size;
  87118. private _ownsBuffer;
  87119. private _instanced;
  87120. private _instanceDivisor;
  87121. /**
  87122. * The byte type.
  87123. */
  87124. static readonly BYTE: number;
  87125. /**
  87126. * The unsigned byte type.
  87127. */
  87128. static readonly UNSIGNED_BYTE: number;
  87129. /**
  87130. * The short type.
  87131. */
  87132. static readonly SHORT: number;
  87133. /**
  87134. * The unsigned short type.
  87135. */
  87136. static readonly UNSIGNED_SHORT: number;
  87137. /**
  87138. * The integer type.
  87139. */
  87140. static readonly INT: number;
  87141. /**
  87142. * The unsigned integer type.
  87143. */
  87144. static readonly UNSIGNED_INT: number;
  87145. /**
  87146. * The float type.
  87147. */
  87148. static readonly FLOAT: number;
  87149. /**
  87150. * Gets or sets the instance divisor when in instanced mode
  87151. */
  87152. get instanceDivisor(): number;
  87153. set instanceDivisor(value: number);
  87154. /**
  87155. * Gets the byte stride.
  87156. */
  87157. readonly byteStride: number;
  87158. /**
  87159. * Gets the byte offset.
  87160. */
  87161. readonly byteOffset: number;
  87162. /**
  87163. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87164. */
  87165. readonly normalized: boolean;
  87166. /**
  87167. * Gets the data type of each component in the array.
  87168. */
  87169. readonly type: number;
  87170. /**
  87171. * Constructor
  87172. * @param engine the engine
  87173. * @param data the data to use for this vertex buffer
  87174. * @param kind the vertex buffer kind
  87175. * @param updatable whether the data is updatable
  87176. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87177. * @param stride the stride (optional)
  87178. * @param instanced whether the buffer is instanced (optional)
  87179. * @param offset the offset of the data (optional)
  87180. * @param size the number of components (optional)
  87181. * @param type the type of the component (optional)
  87182. * @param normalized whether the data contains normalized data (optional)
  87183. * @param useBytes set to true if stride and offset are in bytes (optional)
  87184. * @param divisor defines the instance divisor to use (1 by default)
  87185. */
  87186. 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);
  87187. /** @hidden */
  87188. _rebuild(): void;
  87189. /**
  87190. * Returns the kind of the VertexBuffer (string)
  87191. * @returns a string
  87192. */
  87193. getKind(): string;
  87194. /**
  87195. * Gets a boolean indicating if the VertexBuffer is updatable?
  87196. * @returns true if the buffer is updatable
  87197. */
  87198. isUpdatable(): boolean;
  87199. /**
  87200. * Gets current buffer's data
  87201. * @returns a DataArray or null
  87202. */
  87203. getData(): Nullable<DataArray>;
  87204. /**
  87205. * Gets underlying native buffer
  87206. * @returns underlying native buffer
  87207. */
  87208. getBuffer(): Nullable<DataBuffer>;
  87209. /**
  87210. * Gets the stride in float32 units (i.e. byte stride / 4).
  87211. * May not be an integer if the byte stride is not divisible by 4.
  87212. * @returns the stride in float32 units
  87213. * @deprecated Please use byteStride instead.
  87214. */
  87215. getStrideSize(): number;
  87216. /**
  87217. * Returns the offset as a multiple of the type byte length.
  87218. * @returns the offset in bytes
  87219. * @deprecated Please use byteOffset instead.
  87220. */
  87221. getOffset(): number;
  87222. /**
  87223. * Returns the number of components per vertex attribute (integer)
  87224. * @returns the size in float
  87225. */
  87226. getSize(): number;
  87227. /**
  87228. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87229. * @returns true if this buffer is instanced
  87230. */
  87231. getIsInstanced(): boolean;
  87232. /**
  87233. * Returns the instancing divisor, zero for non-instanced (integer).
  87234. * @returns a number
  87235. */
  87236. getInstanceDivisor(): number;
  87237. /**
  87238. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87239. * @param data defines the data to store
  87240. */
  87241. create(data?: DataArray): void;
  87242. /**
  87243. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87244. * This function will create a new buffer if the current one is not updatable
  87245. * @param data defines the data to store
  87246. */
  87247. update(data: DataArray): void;
  87248. /**
  87249. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87250. * Returns the directly updated WebGLBuffer.
  87251. * @param data the new data
  87252. * @param offset the new offset
  87253. * @param useBytes set to true if the offset is in bytes
  87254. */
  87255. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87256. /**
  87257. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87258. */
  87259. dispose(): void;
  87260. /**
  87261. * Enumerates each value of this vertex buffer as numbers.
  87262. * @param count the number of values to enumerate
  87263. * @param callback the callback function called for each value
  87264. */
  87265. forEach(count: number, callback: (value: number, index: number) => void): void;
  87266. /**
  87267. * Positions
  87268. */
  87269. static readonly PositionKind: string;
  87270. /**
  87271. * Normals
  87272. */
  87273. static readonly NormalKind: string;
  87274. /**
  87275. * Tangents
  87276. */
  87277. static readonly TangentKind: string;
  87278. /**
  87279. * Texture coordinates
  87280. */
  87281. static readonly UVKind: string;
  87282. /**
  87283. * Texture coordinates 2
  87284. */
  87285. static readonly UV2Kind: string;
  87286. /**
  87287. * Texture coordinates 3
  87288. */
  87289. static readonly UV3Kind: string;
  87290. /**
  87291. * Texture coordinates 4
  87292. */
  87293. static readonly UV4Kind: string;
  87294. /**
  87295. * Texture coordinates 5
  87296. */
  87297. static readonly UV5Kind: string;
  87298. /**
  87299. * Texture coordinates 6
  87300. */
  87301. static readonly UV6Kind: string;
  87302. /**
  87303. * Colors
  87304. */
  87305. static readonly ColorKind: string;
  87306. /**
  87307. * Matrix indices (for bones)
  87308. */
  87309. static readonly MatricesIndicesKind: string;
  87310. /**
  87311. * Matrix weights (for bones)
  87312. */
  87313. static readonly MatricesWeightsKind: string;
  87314. /**
  87315. * Additional matrix indices (for bones)
  87316. */
  87317. static readonly MatricesIndicesExtraKind: string;
  87318. /**
  87319. * Additional matrix weights (for bones)
  87320. */
  87321. static readonly MatricesWeightsExtraKind: string;
  87322. /**
  87323. * Deduces the stride given a kind.
  87324. * @param kind The kind string to deduce
  87325. * @returns The deduced stride
  87326. */
  87327. static DeduceStride(kind: string): number;
  87328. /**
  87329. * Gets the byte length of the given type.
  87330. * @param type the type
  87331. * @returns the number of bytes
  87332. */
  87333. static GetTypeByteLength(type: number): number;
  87334. /**
  87335. * Enumerates each value of the given parameters as numbers.
  87336. * @param data the data to enumerate
  87337. * @param byteOffset the byte offset of the data
  87338. * @param byteStride the byte stride of the data
  87339. * @param componentCount the number of components per element
  87340. * @param componentType the type of the component
  87341. * @param count the number of values to enumerate
  87342. * @param normalized whether the data is normalized
  87343. * @param callback the callback function called for each value
  87344. */
  87345. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87346. private static _GetFloatValue;
  87347. }
  87348. }
  87349. declare module BABYLON {
  87350. /**
  87351. * The options Interface for creating a Capsule Mesh
  87352. */
  87353. export interface ICreateCapsuleOptions {
  87354. /** The Orientation of the capsule. Default : Vector3.Up() */
  87355. orientation?: Vector3;
  87356. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87357. subdivisions: number;
  87358. /** Number of cylindrical segments on the capsule. */
  87359. tessellation: number;
  87360. /** Height or Length of the capsule. */
  87361. height: number;
  87362. /** Radius of the capsule. */
  87363. radius: number;
  87364. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87365. capSubdivisions: number;
  87366. /** Overwrite for the top radius. */
  87367. radiusTop?: number;
  87368. /** Overwrite for the bottom radius. */
  87369. radiusBottom?: number;
  87370. /** Overwrite for the top capSubdivisions. */
  87371. topCapSubdivisions?: number;
  87372. /** Overwrite for the bottom capSubdivisions. */
  87373. bottomCapSubdivisions?: number;
  87374. }
  87375. /**
  87376. * Class containing static functions to help procedurally build meshes
  87377. */
  87378. export class CapsuleBuilder {
  87379. /**
  87380. * Creates a capsule or a pill mesh
  87381. * @param name defines the name of the mesh
  87382. * @param options The constructors options.
  87383. * @param scene The scene the mesh is scoped to.
  87384. * @returns Capsule Mesh
  87385. */
  87386. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87387. }
  87388. }
  87389. declare module BABYLON {
  87390. /**
  87391. * @hidden
  87392. */
  87393. export class IntersectionInfo {
  87394. bu: Nullable<number>;
  87395. bv: Nullable<number>;
  87396. distance: number;
  87397. faceId: number;
  87398. subMeshId: number;
  87399. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87400. }
  87401. }
  87402. declare module BABYLON {
  87403. /**
  87404. * Class used to store bounding sphere information
  87405. */
  87406. export class BoundingSphere {
  87407. /**
  87408. * Gets the center of the bounding sphere in local space
  87409. */
  87410. readonly center: Vector3;
  87411. /**
  87412. * Radius of the bounding sphere in local space
  87413. */
  87414. radius: number;
  87415. /**
  87416. * Gets the center of the bounding sphere in world space
  87417. */
  87418. readonly centerWorld: Vector3;
  87419. /**
  87420. * Radius of the bounding sphere in world space
  87421. */
  87422. radiusWorld: number;
  87423. /**
  87424. * Gets the minimum vector in local space
  87425. */
  87426. readonly minimum: Vector3;
  87427. /**
  87428. * Gets the maximum vector in local space
  87429. */
  87430. readonly maximum: Vector3;
  87431. private _worldMatrix;
  87432. private static readonly TmpVector3;
  87433. /**
  87434. * Creates a new bounding sphere
  87435. * @param min defines the minimum vector (in local space)
  87436. * @param max defines the maximum vector (in local space)
  87437. * @param worldMatrix defines the new world matrix
  87438. */
  87439. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87440. /**
  87441. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87442. * @param min defines the new minimum vector (in local space)
  87443. * @param max defines the new maximum vector (in local space)
  87444. * @param worldMatrix defines the new world matrix
  87445. */
  87446. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87447. /**
  87448. * Scale the current bounding sphere by applying a scale factor
  87449. * @param factor defines the scale factor to apply
  87450. * @returns the current bounding box
  87451. */
  87452. scale(factor: number): BoundingSphere;
  87453. /**
  87454. * Gets the world matrix of the bounding box
  87455. * @returns a matrix
  87456. */
  87457. getWorldMatrix(): DeepImmutable<Matrix>;
  87458. /** @hidden */
  87459. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87460. /**
  87461. * Tests if the bounding sphere is intersecting the frustum planes
  87462. * @param frustumPlanes defines the frustum planes to test
  87463. * @returns true if there is an intersection
  87464. */
  87465. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87466. /**
  87467. * Tests if the bounding sphere center is in between the frustum planes.
  87468. * Used for optimistic fast inclusion.
  87469. * @param frustumPlanes defines the frustum planes to test
  87470. * @returns true if the sphere center is in between the frustum planes
  87471. */
  87472. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87473. /**
  87474. * Tests if a point is inside the bounding sphere
  87475. * @param point defines the point to test
  87476. * @returns true if the point is inside the bounding sphere
  87477. */
  87478. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87479. /**
  87480. * Checks if two sphere intersct
  87481. * @param sphere0 sphere 0
  87482. * @param sphere1 sphere 1
  87483. * @returns true if the speres intersect
  87484. */
  87485. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87486. }
  87487. }
  87488. declare module BABYLON {
  87489. /**
  87490. * Class used to store bounding box information
  87491. */
  87492. export class BoundingBox implements ICullable {
  87493. /**
  87494. * Gets the 8 vectors representing the bounding box in local space
  87495. */
  87496. readonly vectors: Vector3[];
  87497. /**
  87498. * Gets the center of the bounding box in local space
  87499. */
  87500. readonly center: Vector3;
  87501. /**
  87502. * Gets the center of the bounding box in world space
  87503. */
  87504. readonly centerWorld: Vector3;
  87505. /**
  87506. * Gets the extend size in local space
  87507. */
  87508. readonly extendSize: Vector3;
  87509. /**
  87510. * Gets the extend size in world space
  87511. */
  87512. readonly extendSizeWorld: Vector3;
  87513. /**
  87514. * Gets the OBB (object bounding box) directions
  87515. */
  87516. readonly directions: Vector3[];
  87517. /**
  87518. * Gets the 8 vectors representing the bounding box in world space
  87519. */
  87520. readonly vectorsWorld: Vector3[];
  87521. /**
  87522. * Gets the minimum vector in world space
  87523. */
  87524. readonly minimumWorld: Vector3;
  87525. /**
  87526. * Gets the maximum vector in world space
  87527. */
  87528. readonly maximumWorld: Vector3;
  87529. /**
  87530. * Gets the minimum vector in local space
  87531. */
  87532. readonly minimum: Vector3;
  87533. /**
  87534. * Gets the maximum vector in local space
  87535. */
  87536. readonly maximum: Vector3;
  87537. private _worldMatrix;
  87538. private static readonly TmpVector3;
  87539. /**
  87540. * @hidden
  87541. */
  87542. _tag: number;
  87543. /**
  87544. * Creates a new bounding box
  87545. * @param min defines the minimum vector (in local space)
  87546. * @param max defines the maximum vector (in local space)
  87547. * @param worldMatrix defines the new world matrix
  87548. */
  87549. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87550. /**
  87551. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87552. * @param min defines the new minimum vector (in local space)
  87553. * @param max defines the new maximum vector (in local space)
  87554. * @param worldMatrix defines the new world matrix
  87555. */
  87556. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87557. /**
  87558. * Scale the current bounding box by applying a scale factor
  87559. * @param factor defines the scale factor to apply
  87560. * @returns the current bounding box
  87561. */
  87562. scale(factor: number): BoundingBox;
  87563. /**
  87564. * Gets the world matrix of the bounding box
  87565. * @returns a matrix
  87566. */
  87567. getWorldMatrix(): DeepImmutable<Matrix>;
  87568. /** @hidden */
  87569. _update(world: DeepImmutable<Matrix>): void;
  87570. /**
  87571. * Tests if the bounding box is intersecting the frustum planes
  87572. * @param frustumPlanes defines the frustum planes to test
  87573. * @returns true if there is an intersection
  87574. */
  87575. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87576. /**
  87577. * Tests if the bounding box is entirely inside the frustum planes
  87578. * @param frustumPlanes defines the frustum planes to test
  87579. * @returns true if there is an inclusion
  87580. */
  87581. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87582. /**
  87583. * Tests if a point is inside the bounding box
  87584. * @param point defines the point to test
  87585. * @returns true if the point is inside the bounding box
  87586. */
  87587. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87588. /**
  87589. * Tests if the bounding box intersects with a bounding sphere
  87590. * @param sphere defines the sphere to test
  87591. * @returns true if there is an intersection
  87592. */
  87593. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87594. /**
  87595. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87596. * @param min defines the min vector to use
  87597. * @param max defines the max vector to use
  87598. * @returns true if there is an intersection
  87599. */
  87600. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87601. /**
  87602. * Tests if two bounding boxes are intersections
  87603. * @param box0 defines the first box to test
  87604. * @param box1 defines the second box to test
  87605. * @returns true if there is an intersection
  87606. */
  87607. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87608. /**
  87609. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87610. * @param minPoint defines the minimum vector of the bounding box
  87611. * @param maxPoint defines the maximum vector of the bounding box
  87612. * @param sphereCenter defines the sphere center
  87613. * @param sphereRadius defines the sphere radius
  87614. * @returns true if there is an intersection
  87615. */
  87616. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87617. /**
  87618. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87619. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87620. * @param frustumPlanes defines the frustum planes to test
  87621. * @return true if there is an inclusion
  87622. */
  87623. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87624. /**
  87625. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87626. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87627. * @param frustumPlanes defines the frustum planes to test
  87628. * @return true if there is an intersection
  87629. */
  87630. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87631. }
  87632. }
  87633. declare module BABYLON {
  87634. /** @hidden */
  87635. export class Collider {
  87636. /** Define if a collision was found */
  87637. collisionFound: boolean;
  87638. /**
  87639. * Define last intersection point in local space
  87640. */
  87641. intersectionPoint: Vector3;
  87642. /**
  87643. * Define last collided mesh
  87644. */
  87645. collidedMesh: Nullable<AbstractMesh>;
  87646. private _collisionPoint;
  87647. private _planeIntersectionPoint;
  87648. private _tempVector;
  87649. private _tempVector2;
  87650. private _tempVector3;
  87651. private _tempVector4;
  87652. private _edge;
  87653. private _baseToVertex;
  87654. private _destinationPoint;
  87655. private _slidePlaneNormal;
  87656. private _displacementVector;
  87657. /** @hidden */
  87658. _radius: Vector3;
  87659. /** @hidden */
  87660. _retry: number;
  87661. private _velocity;
  87662. private _basePoint;
  87663. private _epsilon;
  87664. /** @hidden */
  87665. _velocityWorldLength: number;
  87666. /** @hidden */
  87667. _basePointWorld: Vector3;
  87668. private _velocityWorld;
  87669. private _normalizedVelocity;
  87670. /** @hidden */
  87671. _initialVelocity: Vector3;
  87672. /** @hidden */
  87673. _initialPosition: Vector3;
  87674. private _nearestDistance;
  87675. private _collisionMask;
  87676. get collisionMask(): number;
  87677. set collisionMask(mask: number);
  87678. /**
  87679. * Gets the plane normal used to compute the sliding response (in local space)
  87680. */
  87681. get slidePlaneNormal(): Vector3;
  87682. /** @hidden */
  87683. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87684. /** @hidden */
  87685. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87686. /** @hidden */
  87687. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87688. /** @hidden */
  87689. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87690. /** @hidden */
  87691. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87692. /** @hidden */
  87693. _getResponse(pos: Vector3, vel: Vector3): void;
  87694. }
  87695. }
  87696. declare module BABYLON {
  87697. /**
  87698. * Interface for cullable objects
  87699. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87700. */
  87701. export interface ICullable {
  87702. /**
  87703. * Checks if the object or part of the object is in the frustum
  87704. * @param frustumPlanes Camera near/planes
  87705. * @returns true if the object is in frustum otherwise false
  87706. */
  87707. isInFrustum(frustumPlanes: Plane[]): boolean;
  87708. /**
  87709. * Checks if a cullable object (mesh...) is in the camera frustum
  87710. * Unlike isInFrustum this cheks the full bounding box
  87711. * @param frustumPlanes Camera near/planes
  87712. * @returns true if the object is in frustum otherwise false
  87713. */
  87714. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87715. }
  87716. /**
  87717. * Info for a bounding data of a mesh
  87718. */
  87719. export class BoundingInfo implements ICullable {
  87720. /**
  87721. * Bounding box for the mesh
  87722. */
  87723. readonly boundingBox: BoundingBox;
  87724. /**
  87725. * Bounding sphere for the mesh
  87726. */
  87727. readonly boundingSphere: BoundingSphere;
  87728. private _isLocked;
  87729. private static readonly TmpVector3;
  87730. /**
  87731. * Constructs bounding info
  87732. * @param minimum min vector of the bounding box/sphere
  87733. * @param maximum max vector of the bounding box/sphere
  87734. * @param worldMatrix defines the new world matrix
  87735. */
  87736. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87737. /**
  87738. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87739. * @param min defines the new minimum vector (in local space)
  87740. * @param max defines the new maximum vector (in local space)
  87741. * @param worldMatrix defines the new world matrix
  87742. */
  87743. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87744. /**
  87745. * min vector of the bounding box/sphere
  87746. */
  87747. get minimum(): Vector3;
  87748. /**
  87749. * max vector of the bounding box/sphere
  87750. */
  87751. get maximum(): Vector3;
  87752. /**
  87753. * If the info is locked and won't be updated to avoid perf overhead
  87754. */
  87755. get isLocked(): boolean;
  87756. set isLocked(value: boolean);
  87757. /**
  87758. * Updates the bounding sphere and box
  87759. * @param world world matrix to be used to update
  87760. */
  87761. update(world: DeepImmutable<Matrix>): void;
  87762. /**
  87763. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87764. * @param center New center of the bounding info
  87765. * @param extend New extend of the bounding info
  87766. * @returns the current bounding info
  87767. */
  87768. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87769. /**
  87770. * Scale the current bounding info by applying a scale factor
  87771. * @param factor defines the scale factor to apply
  87772. * @returns the current bounding info
  87773. */
  87774. scale(factor: number): BoundingInfo;
  87775. /**
  87776. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87777. * @param frustumPlanes defines the frustum to test
  87778. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87779. * @returns true if the bounding info is in the frustum planes
  87780. */
  87781. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87782. /**
  87783. * Gets the world distance between the min and max points of the bounding box
  87784. */
  87785. get diagonalLength(): number;
  87786. /**
  87787. * Checks if a cullable object (mesh...) is in the camera frustum
  87788. * Unlike isInFrustum this cheks the full bounding box
  87789. * @param frustumPlanes Camera near/planes
  87790. * @returns true if the object is in frustum otherwise false
  87791. */
  87792. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87793. /** @hidden */
  87794. _checkCollision(collider: Collider): boolean;
  87795. /**
  87796. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87797. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87798. * @param point the point to check intersection with
  87799. * @returns if the point intersects
  87800. */
  87801. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87802. /**
  87803. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87804. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87805. * @param boundingInfo the bounding info to check intersection with
  87806. * @param precise if the intersection should be done using OBB
  87807. * @returns if the bounding info intersects
  87808. */
  87809. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87810. }
  87811. }
  87812. declare module BABYLON {
  87813. /**
  87814. * Extracts minimum and maximum values from a list of indexed positions
  87815. * @param positions defines the positions to use
  87816. * @param indices defines the indices to the positions
  87817. * @param indexStart defines the start index
  87818. * @param indexCount defines the end index
  87819. * @param bias defines bias value to add to the result
  87820. * @return minimum and maximum values
  87821. */
  87822. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87823. minimum: Vector3;
  87824. maximum: Vector3;
  87825. };
  87826. /**
  87827. * Extracts minimum and maximum values from a list of positions
  87828. * @param positions defines the positions to use
  87829. * @param start defines the start index in the positions array
  87830. * @param count defines the number of positions to handle
  87831. * @param bias defines bias value to add to the result
  87832. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87833. * @return minimum and maximum values
  87834. */
  87835. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87836. minimum: Vector3;
  87837. maximum: Vector3;
  87838. };
  87839. }
  87840. declare module BABYLON {
  87841. /** @hidden */
  87842. export class WebGLDataBuffer extends DataBuffer {
  87843. private _buffer;
  87844. constructor(resource: WebGLBuffer);
  87845. get underlyingResource(): any;
  87846. }
  87847. }
  87848. declare module BABYLON {
  87849. /** @hidden */
  87850. export class WebGLPipelineContext implements IPipelineContext {
  87851. engine: ThinEngine;
  87852. program: Nullable<WebGLProgram>;
  87853. context?: WebGLRenderingContext;
  87854. vertexShader?: WebGLShader;
  87855. fragmentShader?: WebGLShader;
  87856. isParallelCompiled: boolean;
  87857. onCompiled?: () => void;
  87858. transformFeedback?: WebGLTransformFeedback | null;
  87859. vertexCompilationError: Nullable<string>;
  87860. fragmentCompilationError: Nullable<string>;
  87861. programLinkError: Nullable<string>;
  87862. programValidationError: Nullable<string>;
  87863. get isAsync(): boolean;
  87864. get isReady(): boolean;
  87865. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87866. _getVertexShaderCode(): string | null;
  87867. _getFragmentShaderCode(): string | null;
  87868. }
  87869. }
  87870. declare module BABYLON {
  87871. interface ThinEngine {
  87872. /**
  87873. * Create an uniform buffer
  87874. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87875. * @param elements defines the content of the uniform buffer
  87876. * @returns the webGL uniform buffer
  87877. */
  87878. createUniformBuffer(elements: FloatArray): DataBuffer;
  87879. /**
  87880. * Create a dynamic uniform buffer
  87881. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87882. * @param elements defines the content of the uniform buffer
  87883. * @returns the webGL uniform buffer
  87884. */
  87885. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87886. /**
  87887. * Update an existing uniform buffer
  87888. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87889. * @param uniformBuffer defines the target uniform buffer
  87890. * @param elements defines the content to update
  87891. * @param offset defines the offset in the uniform buffer where update should start
  87892. * @param count defines the size of the data to update
  87893. */
  87894. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87895. /**
  87896. * Bind an uniform buffer to the current webGL context
  87897. * @param buffer defines the buffer to bind
  87898. */
  87899. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87900. /**
  87901. * Bind a buffer to the current webGL context at a given location
  87902. * @param buffer defines the buffer to bind
  87903. * @param location defines the index where to bind the buffer
  87904. */
  87905. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87906. /**
  87907. * Bind a specific block at a given index in a specific shader program
  87908. * @param pipelineContext defines the pipeline context to use
  87909. * @param blockName defines the block name
  87910. * @param index defines the index where to bind the block
  87911. */
  87912. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87913. }
  87914. }
  87915. declare module BABYLON {
  87916. /**
  87917. * Uniform buffer objects.
  87918. *
  87919. * Handles blocks of uniform on the GPU.
  87920. *
  87921. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87922. *
  87923. * For more information, please refer to :
  87924. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87925. */
  87926. export class UniformBuffer {
  87927. private _engine;
  87928. private _buffer;
  87929. private _data;
  87930. private _bufferData;
  87931. private _dynamic?;
  87932. private _uniformLocations;
  87933. private _uniformSizes;
  87934. private _uniformLocationPointer;
  87935. private _needSync;
  87936. private _noUBO;
  87937. private _currentEffect;
  87938. /** @hidden */
  87939. _alreadyBound: boolean;
  87940. private static _MAX_UNIFORM_SIZE;
  87941. private static _tempBuffer;
  87942. /**
  87943. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87944. * This is dynamic to allow compat with webgl 1 and 2.
  87945. * You will need to pass the name of the uniform as well as the value.
  87946. */
  87947. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87948. /**
  87949. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87950. * This is dynamic to allow compat with webgl 1 and 2.
  87951. * You will need to pass the name of the uniform as well as the value.
  87952. */
  87953. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87954. /**
  87955. * Lambda to Update a single float in a uniform buffer.
  87956. * This is dynamic to allow compat with webgl 1 and 2.
  87957. * You will need to pass the name of the uniform as well as the value.
  87958. */
  87959. updateFloat: (name: string, x: number) => void;
  87960. /**
  87961. * Lambda to Update a vec2 of float in a uniform buffer.
  87962. * This is dynamic to allow compat with webgl 1 and 2.
  87963. * You will need to pass the name of the uniform as well as the value.
  87964. */
  87965. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87966. /**
  87967. * Lambda to Update a vec3 of float in a uniform buffer.
  87968. * This is dynamic to allow compat with webgl 1 and 2.
  87969. * You will need to pass the name of the uniform as well as the value.
  87970. */
  87971. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87972. /**
  87973. * Lambda to Update a vec4 of float in a uniform buffer.
  87974. * This is dynamic to allow compat with webgl 1 and 2.
  87975. * You will need to pass the name of the uniform as well as the value.
  87976. */
  87977. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87978. /**
  87979. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87980. * This is dynamic to allow compat with webgl 1 and 2.
  87981. * You will need to pass the name of the uniform as well as the value.
  87982. */
  87983. updateMatrix: (name: string, mat: Matrix) => void;
  87984. /**
  87985. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87986. * This is dynamic to allow compat with webgl 1 and 2.
  87987. * You will need to pass the name of the uniform as well as the value.
  87988. */
  87989. updateVector3: (name: string, vector: Vector3) => void;
  87990. /**
  87991. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87992. * This is dynamic to allow compat with webgl 1 and 2.
  87993. * You will need to pass the name of the uniform as well as the value.
  87994. */
  87995. updateVector4: (name: string, vector: Vector4) => void;
  87996. /**
  87997. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87998. * This is dynamic to allow compat with webgl 1 and 2.
  87999. * You will need to pass the name of the uniform as well as the value.
  88000. */
  88001. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88002. /**
  88003. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88004. * This is dynamic to allow compat with webgl 1 and 2.
  88005. * You will need to pass the name of the uniform as well as the value.
  88006. */
  88007. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88008. /**
  88009. * Instantiates a new Uniform buffer objects.
  88010. *
  88011. * Handles blocks of uniform on the GPU.
  88012. *
  88013. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88014. *
  88015. * For more information, please refer to :
  88016. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88017. * @param engine Define the engine the buffer is associated with
  88018. * @param data Define the data contained in the buffer
  88019. * @param dynamic Define if the buffer is updatable
  88020. */
  88021. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88022. /**
  88023. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88024. * or just falling back on setUniformXXX calls.
  88025. */
  88026. get useUbo(): boolean;
  88027. /**
  88028. * Indicates if the WebGL underlying uniform buffer is in sync
  88029. * with the javascript cache data.
  88030. */
  88031. get isSync(): boolean;
  88032. /**
  88033. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88034. * Also, a dynamic UniformBuffer will disable cache verification and always
  88035. * update the underlying WebGL uniform buffer to the GPU.
  88036. * @returns if Dynamic, otherwise false
  88037. */
  88038. isDynamic(): boolean;
  88039. /**
  88040. * The data cache on JS side.
  88041. * @returns the underlying data as a float array
  88042. */
  88043. getData(): Float32Array;
  88044. /**
  88045. * The underlying WebGL Uniform buffer.
  88046. * @returns the webgl buffer
  88047. */
  88048. getBuffer(): Nullable<DataBuffer>;
  88049. /**
  88050. * std140 layout specifies how to align data within an UBO structure.
  88051. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88052. * for specs.
  88053. */
  88054. private _fillAlignment;
  88055. /**
  88056. * Adds an uniform in the buffer.
  88057. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88058. * for the layout to be correct !
  88059. * @param name Name of the uniform, as used in the uniform block in the shader.
  88060. * @param size Data size, or data directly.
  88061. */
  88062. addUniform(name: string, size: number | number[]): void;
  88063. /**
  88064. * Adds a Matrix 4x4 to the uniform buffer.
  88065. * @param name Name of the uniform, as used in the uniform block in the shader.
  88066. * @param mat A 4x4 matrix.
  88067. */
  88068. addMatrix(name: string, mat: Matrix): void;
  88069. /**
  88070. * Adds a vec2 to the uniform buffer.
  88071. * @param name Name of the uniform, as used in the uniform block in the shader.
  88072. * @param x Define the x component value of the vec2
  88073. * @param y Define the y component value of the vec2
  88074. */
  88075. addFloat2(name: string, x: number, y: number): void;
  88076. /**
  88077. * Adds a vec3 to the uniform buffer.
  88078. * @param name Name of the uniform, as used in the uniform block in the shader.
  88079. * @param x Define the x component value of the vec3
  88080. * @param y Define the y component value of the vec3
  88081. * @param z Define the z component value of the vec3
  88082. */
  88083. addFloat3(name: string, x: number, y: number, z: number): void;
  88084. /**
  88085. * Adds a vec3 to the uniform buffer.
  88086. * @param name Name of the uniform, as used in the uniform block in the shader.
  88087. * @param color Define the vec3 from a Color
  88088. */
  88089. addColor3(name: string, color: Color3): void;
  88090. /**
  88091. * Adds a vec4 to the uniform buffer.
  88092. * @param name Name of the uniform, as used in the uniform block in the shader.
  88093. * @param color Define the rgb components from a Color
  88094. * @param alpha Define the a component of the vec4
  88095. */
  88096. addColor4(name: string, color: Color3, alpha: number): void;
  88097. /**
  88098. * Adds a vec3 to the uniform buffer.
  88099. * @param name Name of the uniform, as used in the uniform block in the shader.
  88100. * @param vector Define the vec3 components from a Vector
  88101. */
  88102. addVector3(name: string, vector: Vector3): void;
  88103. /**
  88104. * Adds a Matrix 3x3 to the uniform buffer.
  88105. * @param name Name of the uniform, as used in the uniform block in the shader.
  88106. */
  88107. addMatrix3x3(name: string): void;
  88108. /**
  88109. * Adds a Matrix 2x2 to the uniform buffer.
  88110. * @param name Name of the uniform, as used in the uniform block in the shader.
  88111. */
  88112. addMatrix2x2(name: string): void;
  88113. /**
  88114. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88115. */
  88116. create(): void;
  88117. /** @hidden */
  88118. _rebuild(): void;
  88119. /**
  88120. * Updates the WebGL Uniform Buffer on the GPU.
  88121. * If the `dynamic` flag is set to true, no cache comparison is done.
  88122. * Otherwise, the buffer will be updated only if the cache differs.
  88123. */
  88124. update(): void;
  88125. /**
  88126. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88127. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88128. * @param data Define the flattened data
  88129. * @param size Define the size of the data.
  88130. */
  88131. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88132. private _valueCache;
  88133. private _cacheMatrix;
  88134. private _updateMatrix3x3ForUniform;
  88135. private _updateMatrix3x3ForEffect;
  88136. private _updateMatrix2x2ForEffect;
  88137. private _updateMatrix2x2ForUniform;
  88138. private _updateFloatForEffect;
  88139. private _updateFloatForUniform;
  88140. private _updateFloat2ForEffect;
  88141. private _updateFloat2ForUniform;
  88142. private _updateFloat3ForEffect;
  88143. private _updateFloat3ForUniform;
  88144. private _updateFloat4ForEffect;
  88145. private _updateFloat4ForUniform;
  88146. private _updateMatrixForEffect;
  88147. private _updateMatrixForUniform;
  88148. private _updateVector3ForEffect;
  88149. private _updateVector3ForUniform;
  88150. private _updateVector4ForEffect;
  88151. private _updateVector4ForUniform;
  88152. private _updateColor3ForEffect;
  88153. private _updateColor3ForUniform;
  88154. private _updateColor4ForEffect;
  88155. private _updateColor4ForUniform;
  88156. /**
  88157. * Sets a sampler uniform on the effect.
  88158. * @param name Define the name of the sampler.
  88159. * @param texture Define the texture to set in the sampler
  88160. */
  88161. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88162. /**
  88163. * Directly updates the value of the uniform in the cache AND on the GPU.
  88164. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88165. * @param data Define the flattened data
  88166. */
  88167. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88168. /**
  88169. * Binds this uniform buffer to an effect.
  88170. * @param effect Define the effect to bind the buffer to
  88171. * @param name Name of the uniform block in the shader.
  88172. */
  88173. bindToEffect(effect: Effect, name: string): void;
  88174. /**
  88175. * Disposes the uniform buffer.
  88176. */
  88177. dispose(): void;
  88178. }
  88179. }
  88180. declare module BABYLON {
  88181. /**
  88182. * Enum that determines the text-wrapping mode to use.
  88183. */
  88184. export enum InspectableType {
  88185. /**
  88186. * Checkbox for booleans
  88187. */
  88188. Checkbox = 0,
  88189. /**
  88190. * Sliders for numbers
  88191. */
  88192. Slider = 1,
  88193. /**
  88194. * Vector3
  88195. */
  88196. Vector3 = 2,
  88197. /**
  88198. * Quaternions
  88199. */
  88200. Quaternion = 3,
  88201. /**
  88202. * Color3
  88203. */
  88204. Color3 = 4,
  88205. /**
  88206. * String
  88207. */
  88208. String = 5
  88209. }
  88210. /**
  88211. * Interface used to define custom inspectable properties.
  88212. * This interface is used by the inspector to display custom property grids
  88213. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88214. */
  88215. export interface IInspectable {
  88216. /**
  88217. * Gets the label to display
  88218. */
  88219. label: string;
  88220. /**
  88221. * Gets the name of the property to edit
  88222. */
  88223. propertyName: string;
  88224. /**
  88225. * Gets the type of the editor to use
  88226. */
  88227. type: InspectableType;
  88228. /**
  88229. * Gets the minimum value of the property when using in "slider" mode
  88230. */
  88231. min?: number;
  88232. /**
  88233. * Gets the maximum value of the property when using in "slider" mode
  88234. */
  88235. max?: number;
  88236. /**
  88237. * Gets the setp to use when using in "slider" mode
  88238. */
  88239. step?: number;
  88240. }
  88241. }
  88242. declare module BABYLON {
  88243. /**
  88244. * Class used to provide helper for timing
  88245. */
  88246. export class TimingTools {
  88247. /**
  88248. * Polyfill for setImmediate
  88249. * @param action defines the action to execute after the current execution block
  88250. */
  88251. static SetImmediate(action: () => void): void;
  88252. }
  88253. }
  88254. declare module BABYLON {
  88255. /**
  88256. * Class used to enable instatition of objects by class name
  88257. */
  88258. export class InstantiationTools {
  88259. /**
  88260. * Use this object to register external classes like custom textures or material
  88261. * to allow the laoders to instantiate them
  88262. */
  88263. static RegisteredExternalClasses: {
  88264. [key: string]: Object;
  88265. };
  88266. /**
  88267. * Tries to instantiate a new object from a given class name
  88268. * @param className defines the class name to instantiate
  88269. * @returns the new object or null if the system was not able to do the instantiation
  88270. */
  88271. static Instantiate(className: string): any;
  88272. }
  88273. }
  88274. declare module BABYLON {
  88275. /**
  88276. * Define options used to create a depth texture
  88277. */
  88278. export class DepthTextureCreationOptions {
  88279. /** Specifies whether or not a stencil should be allocated in the texture */
  88280. generateStencil?: boolean;
  88281. /** Specifies whether or not bilinear filtering is enable on the texture */
  88282. bilinearFiltering?: boolean;
  88283. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88284. comparisonFunction?: number;
  88285. /** Specifies if the created texture is a cube texture */
  88286. isCube?: boolean;
  88287. }
  88288. }
  88289. declare module BABYLON {
  88290. interface ThinEngine {
  88291. /**
  88292. * Creates a depth stencil cube texture.
  88293. * This is only available in WebGL 2.
  88294. * @param size The size of face edge in the cube texture.
  88295. * @param options The options defining the cube texture.
  88296. * @returns The cube texture
  88297. */
  88298. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88299. /**
  88300. * Creates a cube texture
  88301. * @param rootUrl defines the url where the files to load is located
  88302. * @param scene defines the current scene
  88303. * @param files defines the list of files to load (1 per face)
  88304. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88305. * @param onLoad defines an optional callback raised when the texture is loaded
  88306. * @param onError defines an optional callback raised if there is an issue to load the texture
  88307. * @param format defines the format of the data
  88308. * @param forcedExtension defines the extension to use to pick the right loader
  88309. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88310. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88311. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88312. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88313. * @returns the cube texture as an InternalTexture
  88314. */
  88315. 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;
  88316. /**
  88317. * Creates a cube texture
  88318. * @param rootUrl defines the url where the files to load is located
  88319. * @param scene defines the current scene
  88320. * @param files defines the list of files to load (1 per face)
  88321. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88322. * @param onLoad defines an optional callback raised when the texture is loaded
  88323. * @param onError defines an optional callback raised if there is an issue to load the texture
  88324. * @param format defines the format of the data
  88325. * @param forcedExtension defines the extension to use to pick the right loader
  88326. * @returns the cube texture as an InternalTexture
  88327. */
  88328. 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;
  88329. /**
  88330. * Creates a cube texture
  88331. * @param rootUrl defines the url where the files to load is located
  88332. * @param scene defines the current scene
  88333. * @param files defines the list of files to load (1 per face)
  88334. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88335. * @param onLoad defines an optional callback raised when the texture is loaded
  88336. * @param onError defines an optional callback raised if there is an issue to load the texture
  88337. * @param format defines the format of the data
  88338. * @param forcedExtension defines the extension to use to pick the right loader
  88339. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88340. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88341. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88342. * @returns the cube texture as an InternalTexture
  88343. */
  88344. 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;
  88345. /** @hidden */
  88346. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88347. /** @hidden */
  88348. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88349. /** @hidden */
  88350. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88351. /** @hidden */
  88352. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88353. /**
  88354. * @hidden
  88355. */
  88356. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88357. }
  88358. }
  88359. declare module BABYLON {
  88360. /**
  88361. * Class for creating a cube texture
  88362. */
  88363. export class CubeTexture extends BaseTexture {
  88364. private _delayedOnLoad;
  88365. /**
  88366. * Observable triggered once the texture has been loaded.
  88367. */
  88368. onLoadObservable: Observable<CubeTexture>;
  88369. /**
  88370. * The url of the texture
  88371. */
  88372. url: string;
  88373. /**
  88374. * Gets or sets the center of the bounding box associated with the cube texture.
  88375. * It must define where the camera used to render the texture was set
  88376. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88377. */
  88378. boundingBoxPosition: Vector3;
  88379. private _boundingBoxSize;
  88380. /**
  88381. * Gets or sets the size of the bounding box associated with the cube texture
  88382. * When defined, the cubemap will switch to local mode
  88383. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88384. * @example https://www.babylonjs-playground.com/#RNASML
  88385. */
  88386. set boundingBoxSize(value: Vector3);
  88387. /**
  88388. * Returns the bounding box size
  88389. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88390. */
  88391. get boundingBoxSize(): Vector3;
  88392. protected _rotationY: number;
  88393. /**
  88394. * Sets texture matrix rotation angle around Y axis in radians.
  88395. */
  88396. set rotationY(value: number);
  88397. /**
  88398. * Gets texture matrix rotation angle around Y axis radians.
  88399. */
  88400. get rotationY(): number;
  88401. /**
  88402. * Are mip maps generated for this texture or not.
  88403. */
  88404. get noMipmap(): boolean;
  88405. private _noMipmap;
  88406. private _files;
  88407. protected _forcedExtension: Nullable<string>;
  88408. private _extensions;
  88409. private _textureMatrix;
  88410. private _format;
  88411. private _createPolynomials;
  88412. /**
  88413. * Creates a cube texture from an array of image urls
  88414. * @param files defines an array of image urls
  88415. * @param scene defines the hosting scene
  88416. * @param noMipmap specifies if mip maps are not used
  88417. * @returns a cube texture
  88418. */
  88419. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88420. /**
  88421. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88422. * @param url defines the url of the prefiltered texture
  88423. * @param scene defines the scene the texture is attached to
  88424. * @param forcedExtension defines the extension of the file if different from the url
  88425. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88426. * @return the prefiltered texture
  88427. */
  88428. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88429. /**
  88430. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88431. * as prefiltered data.
  88432. * @param rootUrl defines the url of the texture or the root name of the six images
  88433. * @param null defines the scene or engine the texture is attached to
  88434. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88435. * @param noMipmap defines if mipmaps should be created or not
  88436. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88437. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88438. * @param onError defines a callback triggered in case of error during load
  88439. * @param format defines the internal format to use for the texture once loaded
  88440. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88441. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88442. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88443. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88444. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88445. * @return the cube texture
  88446. */
  88447. 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);
  88448. /**
  88449. * Get the current class name of the texture useful for serialization or dynamic coding.
  88450. * @returns "CubeTexture"
  88451. */
  88452. getClassName(): string;
  88453. /**
  88454. * Update the url (and optional buffer) of this texture if url was null during construction.
  88455. * @param url the url of the texture
  88456. * @param forcedExtension defines the extension to use
  88457. * @param onLoad callback called when the texture is loaded (defaults to null)
  88458. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88459. */
  88460. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88461. /**
  88462. * Delays loading of the cube texture
  88463. * @param forcedExtension defines the extension to use
  88464. */
  88465. delayLoad(forcedExtension?: string): void;
  88466. /**
  88467. * Returns the reflection texture matrix
  88468. * @returns the reflection texture matrix
  88469. */
  88470. getReflectionTextureMatrix(): Matrix;
  88471. /**
  88472. * Sets the reflection texture matrix
  88473. * @param value Reflection texture matrix
  88474. */
  88475. setReflectionTextureMatrix(value: Matrix): void;
  88476. /**
  88477. * Parses text to create a cube texture
  88478. * @param parsedTexture define the serialized text to read from
  88479. * @param scene defines the hosting scene
  88480. * @param rootUrl defines the root url of the cube texture
  88481. * @returns a cube texture
  88482. */
  88483. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88484. /**
  88485. * Makes a clone, or deep copy, of the cube texture
  88486. * @returns a new cube texture
  88487. */
  88488. clone(): CubeTexture;
  88489. }
  88490. }
  88491. declare module BABYLON {
  88492. /**
  88493. * Manages the defines for the Material
  88494. */
  88495. export class MaterialDefines {
  88496. /** @hidden */
  88497. protected _keys: string[];
  88498. private _isDirty;
  88499. /** @hidden */
  88500. _renderId: number;
  88501. /** @hidden */
  88502. _areLightsDirty: boolean;
  88503. /** @hidden */
  88504. _areLightsDisposed: boolean;
  88505. /** @hidden */
  88506. _areAttributesDirty: boolean;
  88507. /** @hidden */
  88508. _areTexturesDirty: boolean;
  88509. /** @hidden */
  88510. _areFresnelDirty: boolean;
  88511. /** @hidden */
  88512. _areMiscDirty: boolean;
  88513. /** @hidden */
  88514. _arePrePassDirty: boolean;
  88515. /** @hidden */
  88516. _areImageProcessingDirty: boolean;
  88517. /** @hidden */
  88518. _normals: boolean;
  88519. /** @hidden */
  88520. _uvs: boolean;
  88521. /** @hidden */
  88522. _needNormals: boolean;
  88523. /** @hidden */
  88524. _needUVs: boolean;
  88525. [id: string]: any;
  88526. /**
  88527. * Specifies if the material needs to be re-calculated
  88528. */
  88529. get isDirty(): boolean;
  88530. /**
  88531. * Marks the material to indicate that it has been re-calculated
  88532. */
  88533. markAsProcessed(): void;
  88534. /**
  88535. * Marks the material to indicate that it needs to be re-calculated
  88536. */
  88537. markAsUnprocessed(): void;
  88538. /**
  88539. * Marks the material to indicate all of its defines need to be re-calculated
  88540. */
  88541. markAllAsDirty(): void;
  88542. /**
  88543. * Marks the material to indicate that image processing needs to be re-calculated
  88544. */
  88545. markAsImageProcessingDirty(): void;
  88546. /**
  88547. * Marks the material to indicate the lights need to be re-calculated
  88548. * @param disposed Defines whether the light is dirty due to dispose or not
  88549. */
  88550. markAsLightDirty(disposed?: boolean): void;
  88551. /**
  88552. * Marks the attribute state as changed
  88553. */
  88554. markAsAttributesDirty(): void;
  88555. /**
  88556. * Marks the texture state as changed
  88557. */
  88558. markAsTexturesDirty(): void;
  88559. /**
  88560. * Marks the fresnel state as changed
  88561. */
  88562. markAsFresnelDirty(): void;
  88563. /**
  88564. * Marks the misc state as changed
  88565. */
  88566. markAsMiscDirty(): void;
  88567. /**
  88568. * Marks the prepass state as changed
  88569. */
  88570. markAsPrePassDirty(): void;
  88571. /**
  88572. * Rebuilds the material defines
  88573. */
  88574. rebuild(): void;
  88575. /**
  88576. * Specifies if two material defines are equal
  88577. * @param other - A material define instance to compare to
  88578. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88579. */
  88580. isEqual(other: MaterialDefines): boolean;
  88581. /**
  88582. * Clones this instance's defines to another instance
  88583. * @param other - material defines to clone values to
  88584. */
  88585. cloneTo(other: MaterialDefines): void;
  88586. /**
  88587. * Resets the material define values
  88588. */
  88589. reset(): void;
  88590. /**
  88591. * Converts the material define values to a string
  88592. * @returns - String of material define information
  88593. */
  88594. toString(): string;
  88595. }
  88596. }
  88597. declare module BABYLON {
  88598. /**
  88599. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88600. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88601. * 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;
  88602. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88603. */
  88604. export class ColorCurves {
  88605. private _dirty;
  88606. private _tempColor;
  88607. private _globalCurve;
  88608. private _highlightsCurve;
  88609. private _midtonesCurve;
  88610. private _shadowsCurve;
  88611. private _positiveCurve;
  88612. private _negativeCurve;
  88613. private _globalHue;
  88614. private _globalDensity;
  88615. private _globalSaturation;
  88616. private _globalExposure;
  88617. /**
  88618. * Gets the global Hue value.
  88619. * 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).
  88620. */
  88621. get globalHue(): number;
  88622. /**
  88623. * Sets the global Hue value.
  88624. * 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).
  88625. */
  88626. set globalHue(value: number);
  88627. /**
  88628. * Gets the global Density value.
  88629. * 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.
  88630. * Values less than zero provide a filter of opposite hue.
  88631. */
  88632. get globalDensity(): number;
  88633. /**
  88634. * Sets the global Density value.
  88635. * 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.
  88636. * Values less than zero provide a filter of opposite hue.
  88637. */
  88638. set globalDensity(value: number);
  88639. /**
  88640. * Gets the global Saturation value.
  88641. * 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.
  88642. */
  88643. get globalSaturation(): number;
  88644. /**
  88645. * Sets the global Saturation value.
  88646. * 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.
  88647. */
  88648. set globalSaturation(value: number);
  88649. /**
  88650. * Gets the global Exposure value.
  88651. * 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.
  88652. */
  88653. get globalExposure(): number;
  88654. /**
  88655. * Sets the global Exposure value.
  88656. * 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.
  88657. */
  88658. set globalExposure(value: number);
  88659. private _highlightsHue;
  88660. private _highlightsDensity;
  88661. private _highlightsSaturation;
  88662. private _highlightsExposure;
  88663. /**
  88664. * Gets the highlights Hue value.
  88665. * 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).
  88666. */
  88667. get highlightsHue(): number;
  88668. /**
  88669. * Sets the highlights Hue value.
  88670. * 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).
  88671. */
  88672. set highlightsHue(value: number);
  88673. /**
  88674. * Gets the highlights Density value.
  88675. * 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.
  88676. * Values less than zero provide a filter of opposite hue.
  88677. */
  88678. get highlightsDensity(): number;
  88679. /**
  88680. * Sets the highlights Density value.
  88681. * 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.
  88682. * Values less than zero provide a filter of opposite hue.
  88683. */
  88684. set highlightsDensity(value: number);
  88685. /**
  88686. * Gets the highlights Saturation value.
  88687. * 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.
  88688. */
  88689. get highlightsSaturation(): number;
  88690. /**
  88691. * Sets the highlights Saturation value.
  88692. * 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.
  88693. */
  88694. set highlightsSaturation(value: number);
  88695. /**
  88696. * Gets the highlights Exposure value.
  88697. * 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.
  88698. */
  88699. get highlightsExposure(): number;
  88700. /**
  88701. * Sets the highlights Exposure value.
  88702. * 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.
  88703. */
  88704. set highlightsExposure(value: number);
  88705. private _midtonesHue;
  88706. private _midtonesDensity;
  88707. private _midtonesSaturation;
  88708. private _midtonesExposure;
  88709. /**
  88710. * Gets the midtones Hue value.
  88711. * 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).
  88712. */
  88713. get midtonesHue(): number;
  88714. /**
  88715. * Sets the midtones Hue value.
  88716. * 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).
  88717. */
  88718. set midtonesHue(value: number);
  88719. /**
  88720. * Gets the midtones Density value.
  88721. * 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.
  88722. * Values less than zero provide a filter of opposite hue.
  88723. */
  88724. get midtonesDensity(): number;
  88725. /**
  88726. * Sets the midtones Density value.
  88727. * 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.
  88728. * Values less than zero provide a filter of opposite hue.
  88729. */
  88730. set midtonesDensity(value: number);
  88731. /**
  88732. * Gets the midtones Saturation value.
  88733. * 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.
  88734. */
  88735. get midtonesSaturation(): number;
  88736. /**
  88737. * Sets the midtones Saturation value.
  88738. * 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.
  88739. */
  88740. set midtonesSaturation(value: number);
  88741. /**
  88742. * Gets the midtones Exposure value.
  88743. * 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.
  88744. */
  88745. get midtonesExposure(): number;
  88746. /**
  88747. * Sets the midtones Exposure value.
  88748. * 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.
  88749. */
  88750. set midtonesExposure(value: number);
  88751. private _shadowsHue;
  88752. private _shadowsDensity;
  88753. private _shadowsSaturation;
  88754. private _shadowsExposure;
  88755. /**
  88756. * Gets the shadows Hue value.
  88757. * 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).
  88758. */
  88759. get shadowsHue(): number;
  88760. /**
  88761. * Sets the shadows Hue value.
  88762. * 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).
  88763. */
  88764. set shadowsHue(value: number);
  88765. /**
  88766. * Gets the shadows Density value.
  88767. * 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.
  88768. * Values less than zero provide a filter of opposite hue.
  88769. */
  88770. get shadowsDensity(): number;
  88771. /**
  88772. * Sets the shadows Density value.
  88773. * 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.
  88774. * Values less than zero provide a filter of opposite hue.
  88775. */
  88776. set shadowsDensity(value: number);
  88777. /**
  88778. * Gets the shadows Saturation value.
  88779. * 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.
  88780. */
  88781. get shadowsSaturation(): number;
  88782. /**
  88783. * Sets the shadows Saturation value.
  88784. * 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.
  88785. */
  88786. set shadowsSaturation(value: number);
  88787. /**
  88788. * Gets the shadows Exposure value.
  88789. * 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.
  88790. */
  88791. get shadowsExposure(): number;
  88792. /**
  88793. * Sets the shadows Exposure value.
  88794. * 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.
  88795. */
  88796. set shadowsExposure(value: number);
  88797. /**
  88798. * Returns the class name
  88799. * @returns The class name
  88800. */
  88801. getClassName(): string;
  88802. /**
  88803. * Binds the color curves to the shader.
  88804. * @param colorCurves The color curve to bind
  88805. * @param effect The effect to bind to
  88806. * @param positiveUniform The positive uniform shader parameter
  88807. * @param neutralUniform The neutral uniform shader parameter
  88808. * @param negativeUniform The negative uniform shader parameter
  88809. */
  88810. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88811. /**
  88812. * Prepare the list of uniforms associated with the ColorCurves effects.
  88813. * @param uniformsList The list of uniforms used in the effect
  88814. */
  88815. static PrepareUniforms(uniformsList: string[]): void;
  88816. /**
  88817. * Returns color grading data based on a hue, density, saturation and exposure value.
  88818. * @param filterHue The hue of the color filter.
  88819. * @param filterDensity The density of the color filter.
  88820. * @param saturation The saturation.
  88821. * @param exposure The exposure.
  88822. * @param result The result data container.
  88823. */
  88824. private getColorGradingDataToRef;
  88825. /**
  88826. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88827. * @param value The input slider value in range [-100,100].
  88828. * @returns Adjusted value.
  88829. */
  88830. private static applyColorGradingSliderNonlinear;
  88831. /**
  88832. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88833. * @param hue The hue (H) input.
  88834. * @param saturation The saturation (S) input.
  88835. * @param brightness The brightness (B) input.
  88836. * @result An RGBA color represented as Vector4.
  88837. */
  88838. private static fromHSBToRef;
  88839. /**
  88840. * Returns a value clamped between min and max
  88841. * @param value The value to clamp
  88842. * @param min The minimum of value
  88843. * @param max The maximum of value
  88844. * @returns The clamped value.
  88845. */
  88846. private static clamp;
  88847. /**
  88848. * Clones the current color curve instance.
  88849. * @return The cloned curves
  88850. */
  88851. clone(): ColorCurves;
  88852. /**
  88853. * Serializes the current color curve instance to a json representation.
  88854. * @return a JSON representation
  88855. */
  88856. serialize(): any;
  88857. /**
  88858. * Parses the color curve from a json representation.
  88859. * @param source the JSON source to parse
  88860. * @return The parsed curves
  88861. */
  88862. static Parse(source: any): ColorCurves;
  88863. }
  88864. }
  88865. declare module BABYLON {
  88866. /**
  88867. * Interface to follow in your material defines to integrate easily the
  88868. * Image proccessing functions.
  88869. * @hidden
  88870. */
  88871. export interface IImageProcessingConfigurationDefines {
  88872. IMAGEPROCESSING: boolean;
  88873. VIGNETTE: boolean;
  88874. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88875. VIGNETTEBLENDMODEOPAQUE: boolean;
  88876. TONEMAPPING: boolean;
  88877. TONEMAPPING_ACES: boolean;
  88878. CONTRAST: boolean;
  88879. EXPOSURE: boolean;
  88880. COLORCURVES: boolean;
  88881. COLORGRADING: boolean;
  88882. COLORGRADING3D: boolean;
  88883. SAMPLER3DGREENDEPTH: boolean;
  88884. SAMPLER3DBGRMAP: boolean;
  88885. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88886. }
  88887. /**
  88888. * @hidden
  88889. */
  88890. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88891. IMAGEPROCESSING: boolean;
  88892. VIGNETTE: boolean;
  88893. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88894. VIGNETTEBLENDMODEOPAQUE: boolean;
  88895. TONEMAPPING: boolean;
  88896. TONEMAPPING_ACES: boolean;
  88897. CONTRAST: boolean;
  88898. COLORCURVES: boolean;
  88899. COLORGRADING: boolean;
  88900. COLORGRADING3D: boolean;
  88901. SAMPLER3DGREENDEPTH: boolean;
  88902. SAMPLER3DBGRMAP: boolean;
  88903. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88904. EXPOSURE: boolean;
  88905. constructor();
  88906. }
  88907. /**
  88908. * This groups together the common properties used for image processing either in direct forward pass
  88909. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88910. * or not.
  88911. */
  88912. export class ImageProcessingConfiguration {
  88913. /**
  88914. * Default tone mapping applied in BabylonJS.
  88915. */
  88916. static readonly TONEMAPPING_STANDARD: number;
  88917. /**
  88918. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88919. * to other engines rendering to increase portability.
  88920. */
  88921. static readonly TONEMAPPING_ACES: number;
  88922. /**
  88923. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88924. */
  88925. colorCurves: Nullable<ColorCurves>;
  88926. private _colorCurvesEnabled;
  88927. /**
  88928. * Gets wether the color curves effect is enabled.
  88929. */
  88930. get colorCurvesEnabled(): boolean;
  88931. /**
  88932. * Sets wether the color curves effect is enabled.
  88933. */
  88934. set colorCurvesEnabled(value: boolean);
  88935. private _colorGradingTexture;
  88936. /**
  88937. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88938. */
  88939. get colorGradingTexture(): Nullable<BaseTexture>;
  88940. /**
  88941. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88942. */
  88943. set colorGradingTexture(value: Nullable<BaseTexture>);
  88944. private _colorGradingEnabled;
  88945. /**
  88946. * Gets wether the color grading effect is enabled.
  88947. */
  88948. get colorGradingEnabled(): boolean;
  88949. /**
  88950. * Sets wether the color grading effect is enabled.
  88951. */
  88952. set colorGradingEnabled(value: boolean);
  88953. private _colorGradingWithGreenDepth;
  88954. /**
  88955. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88956. */
  88957. get colorGradingWithGreenDepth(): boolean;
  88958. /**
  88959. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88960. */
  88961. set colorGradingWithGreenDepth(value: boolean);
  88962. private _colorGradingBGR;
  88963. /**
  88964. * Gets wether the color grading texture contains BGR values.
  88965. */
  88966. get colorGradingBGR(): boolean;
  88967. /**
  88968. * Sets wether the color grading texture contains BGR values.
  88969. */
  88970. set colorGradingBGR(value: boolean);
  88971. /** @hidden */
  88972. _exposure: number;
  88973. /**
  88974. * Gets the Exposure used in the effect.
  88975. */
  88976. get exposure(): number;
  88977. /**
  88978. * Sets the Exposure used in the effect.
  88979. */
  88980. set exposure(value: number);
  88981. private _toneMappingEnabled;
  88982. /**
  88983. * Gets wether the tone mapping effect is enabled.
  88984. */
  88985. get toneMappingEnabled(): boolean;
  88986. /**
  88987. * Sets wether the tone mapping effect is enabled.
  88988. */
  88989. set toneMappingEnabled(value: boolean);
  88990. private _toneMappingType;
  88991. /**
  88992. * Gets the type of tone mapping effect.
  88993. */
  88994. get toneMappingType(): number;
  88995. /**
  88996. * Sets the type of tone mapping effect used in BabylonJS.
  88997. */
  88998. set toneMappingType(value: number);
  88999. protected _contrast: number;
  89000. /**
  89001. * Gets the contrast used in the effect.
  89002. */
  89003. get contrast(): number;
  89004. /**
  89005. * Sets the contrast used in the effect.
  89006. */
  89007. set contrast(value: number);
  89008. /**
  89009. * Vignette stretch size.
  89010. */
  89011. vignetteStretch: number;
  89012. /**
  89013. * Vignette centre X Offset.
  89014. */
  89015. vignetteCentreX: number;
  89016. /**
  89017. * Vignette centre Y Offset.
  89018. */
  89019. vignetteCentreY: number;
  89020. /**
  89021. * Vignette weight or intensity of the vignette effect.
  89022. */
  89023. vignetteWeight: number;
  89024. /**
  89025. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89026. * if vignetteEnabled is set to true.
  89027. */
  89028. vignetteColor: Color4;
  89029. /**
  89030. * Camera field of view used by the Vignette effect.
  89031. */
  89032. vignetteCameraFov: number;
  89033. private _vignetteBlendMode;
  89034. /**
  89035. * Gets the vignette blend mode allowing different kind of effect.
  89036. */
  89037. get vignetteBlendMode(): number;
  89038. /**
  89039. * Sets the vignette blend mode allowing different kind of effect.
  89040. */
  89041. set vignetteBlendMode(value: number);
  89042. private _vignetteEnabled;
  89043. /**
  89044. * Gets wether the vignette effect is enabled.
  89045. */
  89046. get vignetteEnabled(): boolean;
  89047. /**
  89048. * Sets wether the vignette effect is enabled.
  89049. */
  89050. set vignetteEnabled(value: boolean);
  89051. private _applyByPostProcess;
  89052. /**
  89053. * Gets wether the image processing is applied through a post process or not.
  89054. */
  89055. get applyByPostProcess(): boolean;
  89056. /**
  89057. * Sets wether the image processing is applied through a post process or not.
  89058. */
  89059. set applyByPostProcess(value: boolean);
  89060. private _isEnabled;
  89061. /**
  89062. * Gets wether the image processing is enabled or not.
  89063. */
  89064. get isEnabled(): boolean;
  89065. /**
  89066. * Sets wether the image processing is enabled or not.
  89067. */
  89068. set isEnabled(value: boolean);
  89069. /**
  89070. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89071. */
  89072. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89073. /**
  89074. * Method called each time the image processing information changes requires to recompile the effect.
  89075. */
  89076. protected _updateParameters(): void;
  89077. /**
  89078. * Gets the current class name.
  89079. * @return "ImageProcessingConfiguration"
  89080. */
  89081. getClassName(): string;
  89082. /**
  89083. * Prepare the list of uniforms associated with the Image Processing effects.
  89084. * @param uniforms The list of uniforms used in the effect
  89085. * @param defines the list of defines currently in use
  89086. */
  89087. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89088. /**
  89089. * Prepare the list of samplers associated with the Image Processing effects.
  89090. * @param samplersList The list of uniforms used in the effect
  89091. * @param defines the list of defines currently in use
  89092. */
  89093. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89094. /**
  89095. * Prepare the list of defines associated to the shader.
  89096. * @param defines the list of defines to complete
  89097. * @param forPostProcess Define if we are currently in post process mode or not
  89098. */
  89099. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89100. /**
  89101. * Returns true if all the image processing information are ready.
  89102. * @returns True if ready, otherwise, false
  89103. */
  89104. isReady(): boolean;
  89105. /**
  89106. * Binds the image processing to the shader.
  89107. * @param effect The effect to bind to
  89108. * @param overrideAspectRatio Override the aspect ratio of the effect
  89109. */
  89110. bind(effect: Effect, overrideAspectRatio?: number): void;
  89111. /**
  89112. * Clones the current image processing instance.
  89113. * @return The cloned image processing
  89114. */
  89115. clone(): ImageProcessingConfiguration;
  89116. /**
  89117. * Serializes the current image processing instance to a json representation.
  89118. * @return a JSON representation
  89119. */
  89120. serialize(): any;
  89121. /**
  89122. * Parses the image processing from a json representation.
  89123. * @param source the JSON source to parse
  89124. * @return The parsed image processing
  89125. */
  89126. static Parse(source: any): ImageProcessingConfiguration;
  89127. private static _VIGNETTEMODE_MULTIPLY;
  89128. private static _VIGNETTEMODE_OPAQUE;
  89129. /**
  89130. * Used to apply the vignette as a mix with the pixel color.
  89131. */
  89132. static get VIGNETTEMODE_MULTIPLY(): number;
  89133. /**
  89134. * Used to apply the vignette as a replacement of the pixel color.
  89135. */
  89136. static get VIGNETTEMODE_OPAQUE(): number;
  89137. }
  89138. }
  89139. declare module BABYLON {
  89140. /** @hidden */
  89141. export var postprocessVertexShader: {
  89142. name: string;
  89143. shader: string;
  89144. };
  89145. }
  89146. declare module BABYLON {
  89147. /**
  89148. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89149. */
  89150. export type RenderTargetTextureSize = number | {
  89151. width: number;
  89152. height: number;
  89153. layers?: number;
  89154. };
  89155. interface ThinEngine {
  89156. /**
  89157. * Creates a new render target texture
  89158. * @param size defines the size of the texture
  89159. * @param options defines the options used to create the texture
  89160. * @returns a new render target texture stored in an InternalTexture
  89161. */
  89162. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89163. /**
  89164. * Creates a depth stencil texture.
  89165. * This is only available in WebGL 2 or with the depth texture extension available.
  89166. * @param size The size of face edge in the texture.
  89167. * @param options The options defining the texture.
  89168. * @returns The texture
  89169. */
  89170. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89171. /** @hidden */
  89172. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89173. }
  89174. }
  89175. declare module BABYLON {
  89176. /**
  89177. * Defines the kind of connection point for node based material
  89178. */
  89179. export enum NodeMaterialBlockConnectionPointTypes {
  89180. /** Float */
  89181. Float = 1,
  89182. /** Int */
  89183. Int = 2,
  89184. /** Vector2 */
  89185. Vector2 = 4,
  89186. /** Vector3 */
  89187. Vector3 = 8,
  89188. /** Vector4 */
  89189. Vector4 = 16,
  89190. /** Color3 */
  89191. Color3 = 32,
  89192. /** Color4 */
  89193. Color4 = 64,
  89194. /** Matrix */
  89195. Matrix = 128,
  89196. /** Custom object */
  89197. Object = 256,
  89198. /** Detect type based on connection */
  89199. AutoDetect = 1024,
  89200. /** Output type that will be defined by input type */
  89201. BasedOnInput = 2048
  89202. }
  89203. }
  89204. declare module BABYLON {
  89205. /**
  89206. * Enum used to define the target of a block
  89207. */
  89208. export enum NodeMaterialBlockTargets {
  89209. /** Vertex shader */
  89210. Vertex = 1,
  89211. /** Fragment shader */
  89212. Fragment = 2,
  89213. /** Neutral */
  89214. Neutral = 4,
  89215. /** Vertex and Fragment */
  89216. VertexAndFragment = 3
  89217. }
  89218. }
  89219. declare module BABYLON {
  89220. /**
  89221. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89222. */
  89223. export enum NodeMaterialBlockConnectionPointMode {
  89224. /** Value is an uniform */
  89225. Uniform = 0,
  89226. /** Value is a mesh attribute */
  89227. Attribute = 1,
  89228. /** Value is a varying between vertex and fragment shaders */
  89229. Varying = 2,
  89230. /** Mode is undefined */
  89231. Undefined = 3
  89232. }
  89233. }
  89234. declare module BABYLON {
  89235. /**
  89236. * Enum used to define system values e.g. values automatically provided by the system
  89237. */
  89238. export enum NodeMaterialSystemValues {
  89239. /** World */
  89240. World = 1,
  89241. /** View */
  89242. View = 2,
  89243. /** Projection */
  89244. Projection = 3,
  89245. /** ViewProjection */
  89246. ViewProjection = 4,
  89247. /** WorldView */
  89248. WorldView = 5,
  89249. /** WorldViewProjection */
  89250. WorldViewProjection = 6,
  89251. /** CameraPosition */
  89252. CameraPosition = 7,
  89253. /** Fog Color */
  89254. FogColor = 8,
  89255. /** Delta time */
  89256. DeltaTime = 9
  89257. }
  89258. }
  89259. declare module BABYLON {
  89260. /** Defines supported spaces */
  89261. export enum Space {
  89262. /** Local (object) space */
  89263. LOCAL = 0,
  89264. /** World space */
  89265. WORLD = 1,
  89266. /** Bone space */
  89267. BONE = 2
  89268. }
  89269. /** Defines the 3 main axes */
  89270. export class Axis {
  89271. /** X axis */
  89272. static X: Vector3;
  89273. /** Y axis */
  89274. static Y: Vector3;
  89275. /** Z axis */
  89276. static Z: Vector3;
  89277. }
  89278. }
  89279. declare module BABYLON {
  89280. /**
  89281. * Represents a camera frustum
  89282. */
  89283. export class Frustum {
  89284. /**
  89285. * Gets the planes representing the frustum
  89286. * @param transform matrix to be applied to the returned planes
  89287. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89288. */
  89289. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89290. /**
  89291. * Gets the near frustum plane transformed by the transform matrix
  89292. * @param transform transformation matrix to be applied to the resulting frustum plane
  89293. * @param frustumPlane the resuling frustum plane
  89294. */
  89295. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89296. /**
  89297. * Gets the far frustum plane transformed by the transform matrix
  89298. * @param transform transformation matrix to be applied to the resulting frustum plane
  89299. * @param frustumPlane the resuling frustum plane
  89300. */
  89301. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89302. /**
  89303. * Gets the left frustum plane transformed by the transform matrix
  89304. * @param transform transformation matrix to be applied to the resulting frustum plane
  89305. * @param frustumPlane the resuling frustum plane
  89306. */
  89307. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89308. /**
  89309. * Gets the right frustum plane transformed by the transform matrix
  89310. * @param transform transformation matrix to be applied to the resulting frustum plane
  89311. * @param frustumPlane the resuling frustum plane
  89312. */
  89313. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89314. /**
  89315. * Gets the top frustum plane transformed by the transform matrix
  89316. * @param transform transformation matrix to be applied to the resulting frustum plane
  89317. * @param frustumPlane the resuling frustum plane
  89318. */
  89319. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89320. /**
  89321. * Gets the bottom frustum plane transformed by the transform matrix
  89322. * @param transform transformation matrix to be applied to the resulting frustum plane
  89323. * @param frustumPlane the resuling frustum plane
  89324. */
  89325. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89326. /**
  89327. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89328. * @param transform transformation matrix to be applied to the resulting frustum planes
  89329. * @param frustumPlanes the resuling frustum planes
  89330. */
  89331. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89332. }
  89333. }
  89334. declare module BABYLON {
  89335. /**
  89336. * Interface for the size containing width and height
  89337. */
  89338. export interface ISize {
  89339. /**
  89340. * Width
  89341. */
  89342. width: number;
  89343. /**
  89344. * Heighht
  89345. */
  89346. height: number;
  89347. }
  89348. /**
  89349. * Size containing widht and height
  89350. */
  89351. export class Size implements ISize {
  89352. /**
  89353. * Width
  89354. */
  89355. width: number;
  89356. /**
  89357. * Height
  89358. */
  89359. height: number;
  89360. /**
  89361. * Creates a Size object from the given width and height (floats).
  89362. * @param width width of the new size
  89363. * @param height height of the new size
  89364. */
  89365. constructor(width: number, height: number);
  89366. /**
  89367. * Returns a string with the Size width and height
  89368. * @returns a string with the Size width and height
  89369. */
  89370. toString(): string;
  89371. /**
  89372. * "Size"
  89373. * @returns the string "Size"
  89374. */
  89375. getClassName(): string;
  89376. /**
  89377. * Returns the Size hash code.
  89378. * @returns a hash code for a unique width and height
  89379. */
  89380. getHashCode(): number;
  89381. /**
  89382. * Updates the current size from the given one.
  89383. * @param src the given size
  89384. */
  89385. copyFrom(src: Size): void;
  89386. /**
  89387. * Updates in place the current Size from the given floats.
  89388. * @param width width of the new size
  89389. * @param height height of the new size
  89390. * @returns the updated Size.
  89391. */
  89392. copyFromFloats(width: number, height: number): Size;
  89393. /**
  89394. * Updates in place the current Size from the given floats.
  89395. * @param width width to set
  89396. * @param height height to set
  89397. * @returns the updated Size.
  89398. */
  89399. set(width: number, height: number): Size;
  89400. /**
  89401. * Multiplies the width and height by numbers
  89402. * @param w factor to multiple the width by
  89403. * @param h factor to multiple the height by
  89404. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89405. */
  89406. multiplyByFloats(w: number, h: number): Size;
  89407. /**
  89408. * Clones the size
  89409. * @returns a new Size copied from the given one.
  89410. */
  89411. clone(): Size;
  89412. /**
  89413. * True if the current Size and the given one width and height are strictly equal.
  89414. * @param other the other size to compare against
  89415. * @returns True if the current Size and the given one width and height are strictly equal.
  89416. */
  89417. equals(other: Size): boolean;
  89418. /**
  89419. * The surface of the Size : width * height (float).
  89420. */
  89421. get surface(): number;
  89422. /**
  89423. * Create a new size of zero
  89424. * @returns a new Size set to (0.0, 0.0)
  89425. */
  89426. static Zero(): Size;
  89427. /**
  89428. * Sums the width and height of two sizes
  89429. * @param otherSize size to add to this size
  89430. * @returns a new Size set as the addition result of the current Size and the given one.
  89431. */
  89432. add(otherSize: Size): Size;
  89433. /**
  89434. * Subtracts the width and height of two
  89435. * @param otherSize size to subtract to this size
  89436. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89437. */
  89438. subtract(otherSize: Size): Size;
  89439. /**
  89440. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89441. * @param start starting size to lerp between
  89442. * @param end end size to lerp between
  89443. * @param amount amount to lerp between the start and end values
  89444. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89445. */
  89446. static Lerp(start: Size, end: Size, amount: number): Size;
  89447. }
  89448. }
  89449. declare module BABYLON {
  89450. /**
  89451. * Contains position and normal vectors for a vertex
  89452. */
  89453. export class PositionNormalVertex {
  89454. /** the position of the vertex (defaut: 0,0,0) */
  89455. position: Vector3;
  89456. /** the normal of the vertex (defaut: 0,1,0) */
  89457. normal: Vector3;
  89458. /**
  89459. * Creates a PositionNormalVertex
  89460. * @param position the position of the vertex (defaut: 0,0,0)
  89461. * @param normal the normal of the vertex (defaut: 0,1,0)
  89462. */
  89463. constructor(
  89464. /** the position of the vertex (defaut: 0,0,0) */
  89465. position?: Vector3,
  89466. /** the normal of the vertex (defaut: 0,1,0) */
  89467. normal?: Vector3);
  89468. /**
  89469. * Clones the PositionNormalVertex
  89470. * @returns the cloned PositionNormalVertex
  89471. */
  89472. clone(): PositionNormalVertex;
  89473. }
  89474. /**
  89475. * Contains position, normal and uv vectors for a vertex
  89476. */
  89477. export class PositionNormalTextureVertex {
  89478. /** the position of the vertex (defaut: 0,0,0) */
  89479. position: Vector3;
  89480. /** the normal of the vertex (defaut: 0,1,0) */
  89481. normal: Vector3;
  89482. /** the uv of the vertex (default: 0,0) */
  89483. uv: Vector2;
  89484. /**
  89485. * Creates a PositionNormalTextureVertex
  89486. * @param position the position of the vertex (defaut: 0,0,0)
  89487. * @param normal the normal of the vertex (defaut: 0,1,0)
  89488. * @param uv the uv of the vertex (default: 0,0)
  89489. */
  89490. constructor(
  89491. /** the position of the vertex (defaut: 0,0,0) */
  89492. position?: Vector3,
  89493. /** the normal of the vertex (defaut: 0,1,0) */
  89494. normal?: Vector3,
  89495. /** the uv of the vertex (default: 0,0) */
  89496. uv?: Vector2);
  89497. /**
  89498. * Clones the PositionNormalTextureVertex
  89499. * @returns the cloned PositionNormalTextureVertex
  89500. */
  89501. clone(): PositionNormalTextureVertex;
  89502. }
  89503. }
  89504. declare module BABYLON {
  89505. /**
  89506. * Enum defining the type of animations supported by InputBlock
  89507. */
  89508. export enum AnimatedInputBlockTypes {
  89509. /** No animation */
  89510. None = 0,
  89511. /** Time based animation. Will only work for floats */
  89512. Time = 1
  89513. }
  89514. }
  89515. declare module BABYLON {
  89516. /**
  89517. * Interface describing all the common properties and methods a shadow light needs to implement.
  89518. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89519. * as well as binding the different shadow properties to the effects.
  89520. */
  89521. export interface IShadowLight extends Light {
  89522. /**
  89523. * The light id in the scene (used in scene.findLighById for instance)
  89524. */
  89525. id: string;
  89526. /**
  89527. * The position the shdow will be casted from.
  89528. */
  89529. position: Vector3;
  89530. /**
  89531. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89532. */
  89533. direction: Vector3;
  89534. /**
  89535. * The transformed position. Position of the light in world space taking parenting in account.
  89536. */
  89537. transformedPosition: Vector3;
  89538. /**
  89539. * The transformed direction. Direction of the light in world space taking parenting in account.
  89540. */
  89541. transformedDirection: Vector3;
  89542. /**
  89543. * The friendly name of the light in the scene.
  89544. */
  89545. name: string;
  89546. /**
  89547. * Defines the shadow projection clipping minimum z value.
  89548. */
  89549. shadowMinZ: number;
  89550. /**
  89551. * Defines the shadow projection clipping maximum z value.
  89552. */
  89553. shadowMaxZ: number;
  89554. /**
  89555. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89556. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89557. */
  89558. computeTransformedInformation(): boolean;
  89559. /**
  89560. * Gets the scene the light belongs to.
  89561. * @returns The scene
  89562. */
  89563. getScene(): Scene;
  89564. /**
  89565. * Callback defining a custom Projection Matrix Builder.
  89566. * This can be used to override the default projection matrix computation.
  89567. */
  89568. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89569. /**
  89570. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89571. * @param matrix The materix to updated with the projection information
  89572. * @param viewMatrix The transform matrix of the light
  89573. * @param renderList The list of mesh to render in the map
  89574. * @returns The current light
  89575. */
  89576. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89577. /**
  89578. * Gets the current depth scale used in ESM.
  89579. * @returns The scale
  89580. */
  89581. getDepthScale(): number;
  89582. /**
  89583. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89584. * @returns true if a cube texture needs to be use
  89585. */
  89586. needCube(): boolean;
  89587. /**
  89588. * Detects if the projection matrix requires to be recomputed this frame.
  89589. * @returns true if it requires to be recomputed otherwise, false.
  89590. */
  89591. needProjectionMatrixCompute(): boolean;
  89592. /**
  89593. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89594. */
  89595. forceProjectionMatrixCompute(): void;
  89596. /**
  89597. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89598. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89599. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89600. */
  89601. getShadowDirection(faceIndex?: number): Vector3;
  89602. /**
  89603. * Gets the minZ used for shadow according to both the scene and the light.
  89604. * @param activeCamera The camera we are returning the min for
  89605. * @returns the depth min z
  89606. */
  89607. getDepthMinZ(activeCamera: Camera): number;
  89608. /**
  89609. * Gets the maxZ used for shadow according to both the scene and the light.
  89610. * @param activeCamera The camera we are returning the max for
  89611. * @returns the depth max z
  89612. */
  89613. getDepthMaxZ(activeCamera: Camera): number;
  89614. }
  89615. /**
  89616. * Base implementation IShadowLight
  89617. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89618. */
  89619. export abstract class ShadowLight extends Light implements IShadowLight {
  89620. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89621. protected _position: Vector3;
  89622. protected _setPosition(value: Vector3): void;
  89623. /**
  89624. * Sets the position the shadow will be casted from. Also use as the light position for both
  89625. * point and spot lights.
  89626. */
  89627. get position(): Vector3;
  89628. /**
  89629. * Sets the position the shadow will be casted from. Also use as the light position for both
  89630. * point and spot lights.
  89631. */
  89632. set position(value: Vector3);
  89633. protected _direction: Vector3;
  89634. protected _setDirection(value: Vector3): void;
  89635. /**
  89636. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89637. * Also use as the light direction on spot and directional lights.
  89638. */
  89639. get direction(): Vector3;
  89640. /**
  89641. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89642. * Also use as the light direction on spot and directional lights.
  89643. */
  89644. set direction(value: Vector3);
  89645. protected _shadowMinZ: number;
  89646. /**
  89647. * Gets the shadow projection clipping minimum z value.
  89648. */
  89649. get shadowMinZ(): number;
  89650. /**
  89651. * Sets the shadow projection clipping minimum z value.
  89652. */
  89653. set shadowMinZ(value: number);
  89654. protected _shadowMaxZ: number;
  89655. /**
  89656. * Sets the shadow projection clipping maximum z value.
  89657. */
  89658. get shadowMaxZ(): number;
  89659. /**
  89660. * Gets the shadow projection clipping maximum z value.
  89661. */
  89662. set shadowMaxZ(value: number);
  89663. /**
  89664. * Callback defining a custom Projection Matrix Builder.
  89665. * This can be used to override the default projection matrix computation.
  89666. */
  89667. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89668. /**
  89669. * The transformed position. Position of the light in world space taking parenting in account.
  89670. */
  89671. transformedPosition: Vector3;
  89672. /**
  89673. * The transformed direction. Direction of the light in world space taking parenting in account.
  89674. */
  89675. transformedDirection: Vector3;
  89676. private _needProjectionMatrixCompute;
  89677. /**
  89678. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89679. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89680. */
  89681. computeTransformedInformation(): boolean;
  89682. /**
  89683. * Return the depth scale used for the shadow map.
  89684. * @returns the depth scale.
  89685. */
  89686. getDepthScale(): number;
  89687. /**
  89688. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89689. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89690. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89691. */
  89692. getShadowDirection(faceIndex?: number): Vector3;
  89693. /**
  89694. * Returns the ShadowLight absolute position in the World.
  89695. * @returns the position vector in world space
  89696. */
  89697. getAbsolutePosition(): Vector3;
  89698. /**
  89699. * Sets the ShadowLight direction toward the passed target.
  89700. * @param target The point to target in local space
  89701. * @returns the updated ShadowLight direction
  89702. */
  89703. setDirectionToTarget(target: Vector3): Vector3;
  89704. /**
  89705. * Returns the light rotation in euler definition.
  89706. * @returns the x y z rotation in local space.
  89707. */
  89708. getRotation(): Vector3;
  89709. /**
  89710. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89711. * @returns true if a cube texture needs to be use
  89712. */
  89713. needCube(): boolean;
  89714. /**
  89715. * Detects if the projection matrix requires to be recomputed this frame.
  89716. * @returns true if it requires to be recomputed otherwise, false.
  89717. */
  89718. needProjectionMatrixCompute(): boolean;
  89719. /**
  89720. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89721. */
  89722. forceProjectionMatrixCompute(): void;
  89723. /** @hidden */
  89724. _initCache(): void;
  89725. /** @hidden */
  89726. _isSynchronized(): boolean;
  89727. /**
  89728. * Computes the world matrix of the node
  89729. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89730. * @returns the world matrix
  89731. */
  89732. computeWorldMatrix(force?: boolean): Matrix;
  89733. /**
  89734. * Gets the minZ used for shadow according to both the scene and the light.
  89735. * @param activeCamera The camera we are returning the min for
  89736. * @returns the depth min z
  89737. */
  89738. getDepthMinZ(activeCamera: Camera): number;
  89739. /**
  89740. * Gets the maxZ used for shadow according to both the scene and the light.
  89741. * @param activeCamera The camera we are returning the max for
  89742. * @returns the depth max z
  89743. */
  89744. getDepthMaxZ(activeCamera: Camera): number;
  89745. /**
  89746. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89747. * @param matrix The materix to updated with the projection information
  89748. * @param viewMatrix The transform matrix of the light
  89749. * @param renderList The list of mesh to render in the map
  89750. * @returns The current light
  89751. */
  89752. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89753. }
  89754. }
  89755. declare module BABYLON {
  89756. /** @hidden */
  89757. export var packingFunctions: {
  89758. name: string;
  89759. shader: string;
  89760. };
  89761. }
  89762. declare module BABYLON {
  89763. /** @hidden */
  89764. export var bayerDitherFunctions: {
  89765. name: string;
  89766. shader: string;
  89767. };
  89768. }
  89769. declare module BABYLON {
  89770. /** @hidden */
  89771. export var shadowMapFragmentDeclaration: {
  89772. name: string;
  89773. shader: string;
  89774. };
  89775. }
  89776. declare module BABYLON {
  89777. /** @hidden */
  89778. export var clipPlaneFragmentDeclaration: {
  89779. name: string;
  89780. shader: string;
  89781. };
  89782. }
  89783. declare module BABYLON {
  89784. /** @hidden */
  89785. export var clipPlaneFragment: {
  89786. name: string;
  89787. shader: string;
  89788. };
  89789. }
  89790. declare module BABYLON {
  89791. /** @hidden */
  89792. export var shadowMapFragment: {
  89793. name: string;
  89794. shader: string;
  89795. };
  89796. }
  89797. declare module BABYLON {
  89798. /** @hidden */
  89799. export var shadowMapPixelShader: {
  89800. name: string;
  89801. shader: string;
  89802. };
  89803. }
  89804. declare module BABYLON {
  89805. /** @hidden */
  89806. export var bonesDeclaration: {
  89807. name: string;
  89808. shader: string;
  89809. };
  89810. }
  89811. declare module BABYLON {
  89812. /** @hidden */
  89813. export var morphTargetsVertexGlobalDeclaration: {
  89814. name: string;
  89815. shader: string;
  89816. };
  89817. }
  89818. declare module BABYLON {
  89819. /** @hidden */
  89820. export var morphTargetsVertexDeclaration: {
  89821. name: string;
  89822. shader: string;
  89823. };
  89824. }
  89825. declare module BABYLON {
  89826. /** @hidden */
  89827. export var instancesDeclaration: {
  89828. name: string;
  89829. shader: string;
  89830. };
  89831. }
  89832. declare module BABYLON {
  89833. /** @hidden */
  89834. export var helperFunctions: {
  89835. name: string;
  89836. shader: string;
  89837. };
  89838. }
  89839. declare module BABYLON {
  89840. /** @hidden */
  89841. export var shadowMapVertexDeclaration: {
  89842. name: string;
  89843. shader: string;
  89844. };
  89845. }
  89846. declare module BABYLON {
  89847. /** @hidden */
  89848. export var clipPlaneVertexDeclaration: {
  89849. name: string;
  89850. shader: string;
  89851. };
  89852. }
  89853. declare module BABYLON {
  89854. /** @hidden */
  89855. export var morphTargetsVertex: {
  89856. name: string;
  89857. shader: string;
  89858. };
  89859. }
  89860. declare module BABYLON {
  89861. /** @hidden */
  89862. export var instancesVertex: {
  89863. name: string;
  89864. shader: string;
  89865. };
  89866. }
  89867. declare module BABYLON {
  89868. /** @hidden */
  89869. export var bonesVertex: {
  89870. name: string;
  89871. shader: string;
  89872. };
  89873. }
  89874. declare module BABYLON {
  89875. /** @hidden */
  89876. export var shadowMapVertexNormalBias: {
  89877. name: string;
  89878. shader: string;
  89879. };
  89880. }
  89881. declare module BABYLON {
  89882. /** @hidden */
  89883. export var shadowMapVertexMetric: {
  89884. name: string;
  89885. shader: string;
  89886. };
  89887. }
  89888. declare module BABYLON {
  89889. /** @hidden */
  89890. export var clipPlaneVertex: {
  89891. name: string;
  89892. shader: string;
  89893. };
  89894. }
  89895. declare module BABYLON {
  89896. /** @hidden */
  89897. export var shadowMapVertexShader: {
  89898. name: string;
  89899. shader: string;
  89900. };
  89901. }
  89902. declare module BABYLON {
  89903. /** @hidden */
  89904. export var depthBoxBlurPixelShader: {
  89905. name: string;
  89906. shader: string;
  89907. };
  89908. }
  89909. declare module BABYLON {
  89910. /** @hidden */
  89911. export var shadowMapFragmentSoftTransparentShadow: {
  89912. name: string;
  89913. shader: string;
  89914. };
  89915. }
  89916. declare module BABYLON {
  89917. /**
  89918. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89919. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89920. */
  89921. export class EffectFallbacks implements IEffectFallbacks {
  89922. private _defines;
  89923. private _currentRank;
  89924. private _maxRank;
  89925. private _mesh;
  89926. /**
  89927. * Removes the fallback from the bound mesh.
  89928. */
  89929. unBindMesh(): void;
  89930. /**
  89931. * Adds a fallback on the specified property.
  89932. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89933. * @param define The name of the define in the shader
  89934. */
  89935. addFallback(rank: number, define: string): void;
  89936. /**
  89937. * Sets the mesh to use CPU skinning when needing to fallback.
  89938. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89939. * @param mesh The mesh to use the fallbacks.
  89940. */
  89941. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89942. /**
  89943. * Checks to see if more fallbacks are still availible.
  89944. */
  89945. get hasMoreFallbacks(): boolean;
  89946. /**
  89947. * Removes the defines that should be removed when falling back.
  89948. * @param currentDefines defines the current define statements for the shader.
  89949. * @param effect defines the current effect we try to compile
  89950. * @returns The resulting defines with defines of the current rank removed.
  89951. */
  89952. reduce(currentDefines: string, effect: Effect): string;
  89953. }
  89954. }
  89955. declare module BABYLON {
  89956. /**
  89957. * Interface used to define Action
  89958. */
  89959. export interface IAction {
  89960. /**
  89961. * Trigger for the action
  89962. */
  89963. trigger: number;
  89964. /** Options of the trigger */
  89965. triggerOptions: any;
  89966. /**
  89967. * Gets the trigger parameters
  89968. * @returns the trigger parameters
  89969. */
  89970. getTriggerParameter(): any;
  89971. /**
  89972. * Internal only - executes current action event
  89973. * @hidden
  89974. */
  89975. _executeCurrent(evt?: ActionEvent): void;
  89976. /**
  89977. * Serialize placeholder for child classes
  89978. * @param parent of child
  89979. * @returns the serialized object
  89980. */
  89981. serialize(parent: any): any;
  89982. /**
  89983. * Internal only
  89984. * @hidden
  89985. */
  89986. _prepare(): void;
  89987. /**
  89988. * Internal only - manager for action
  89989. * @hidden
  89990. */
  89991. _actionManager: Nullable<AbstractActionManager>;
  89992. /**
  89993. * Adds action to chain of actions, may be a DoNothingAction
  89994. * @param action defines the next action to execute
  89995. * @returns The action passed in
  89996. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89997. */
  89998. then(action: IAction): IAction;
  89999. }
  90000. /**
  90001. * The action to be carried out following a trigger
  90002. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90003. */
  90004. export class Action implements IAction {
  90005. /** the trigger, with or without parameters, for the action */
  90006. triggerOptions: any;
  90007. /**
  90008. * Trigger for the action
  90009. */
  90010. trigger: number;
  90011. /**
  90012. * Internal only - manager for action
  90013. * @hidden
  90014. */
  90015. _actionManager: ActionManager;
  90016. private _nextActiveAction;
  90017. private _child;
  90018. private _condition?;
  90019. private _triggerParameter;
  90020. /**
  90021. * An event triggered prior to action being executed.
  90022. */
  90023. onBeforeExecuteObservable: Observable<Action>;
  90024. /**
  90025. * Creates a new Action
  90026. * @param triggerOptions the trigger, with or without parameters, for the action
  90027. * @param condition an optional determinant of action
  90028. */
  90029. constructor(
  90030. /** the trigger, with or without parameters, for the action */
  90031. triggerOptions: any, condition?: Condition);
  90032. /**
  90033. * Internal only
  90034. * @hidden
  90035. */
  90036. _prepare(): void;
  90037. /**
  90038. * Gets the trigger parameters
  90039. * @returns the trigger parameters
  90040. */
  90041. getTriggerParameter(): any;
  90042. /**
  90043. * Internal only - executes current action event
  90044. * @hidden
  90045. */
  90046. _executeCurrent(evt?: ActionEvent): void;
  90047. /**
  90048. * Execute placeholder for child classes
  90049. * @param evt optional action event
  90050. */
  90051. execute(evt?: ActionEvent): void;
  90052. /**
  90053. * Skips to next active action
  90054. */
  90055. skipToNextActiveAction(): void;
  90056. /**
  90057. * Adds action to chain of actions, may be a DoNothingAction
  90058. * @param action defines the next action to execute
  90059. * @returns The action passed in
  90060. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90061. */
  90062. then(action: Action): Action;
  90063. /**
  90064. * Internal only
  90065. * @hidden
  90066. */
  90067. _getProperty(propertyPath: string): string;
  90068. /**
  90069. * Internal only
  90070. * @hidden
  90071. */
  90072. _getEffectiveTarget(target: any, propertyPath: string): any;
  90073. /**
  90074. * Serialize placeholder for child classes
  90075. * @param parent of child
  90076. * @returns the serialized object
  90077. */
  90078. serialize(parent: any): any;
  90079. /**
  90080. * Internal only called by serialize
  90081. * @hidden
  90082. */
  90083. protected _serialize(serializedAction: any, parent?: any): any;
  90084. /**
  90085. * Internal only
  90086. * @hidden
  90087. */
  90088. static _SerializeValueAsString: (value: any) => string;
  90089. /**
  90090. * Internal only
  90091. * @hidden
  90092. */
  90093. static _GetTargetProperty: (target: Scene | Node) => {
  90094. name: string;
  90095. targetType: string;
  90096. value: string;
  90097. };
  90098. }
  90099. }
  90100. declare module BABYLON {
  90101. /**
  90102. * A Condition applied to an Action
  90103. */
  90104. export class Condition {
  90105. /**
  90106. * Internal only - manager for action
  90107. * @hidden
  90108. */
  90109. _actionManager: ActionManager;
  90110. /**
  90111. * Internal only
  90112. * @hidden
  90113. */
  90114. _evaluationId: number;
  90115. /**
  90116. * Internal only
  90117. * @hidden
  90118. */
  90119. _currentResult: boolean;
  90120. /**
  90121. * Creates a new Condition
  90122. * @param actionManager the manager of the action the condition is applied to
  90123. */
  90124. constructor(actionManager: ActionManager);
  90125. /**
  90126. * Check if the current condition is valid
  90127. * @returns a boolean
  90128. */
  90129. isValid(): boolean;
  90130. /**
  90131. * Internal only
  90132. * @hidden
  90133. */
  90134. _getProperty(propertyPath: string): string;
  90135. /**
  90136. * Internal only
  90137. * @hidden
  90138. */
  90139. _getEffectiveTarget(target: any, propertyPath: string): any;
  90140. /**
  90141. * Serialize placeholder for child classes
  90142. * @returns the serialized object
  90143. */
  90144. serialize(): any;
  90145. /**
  90146. * Internal only
  90147. * @hidden
  90148. */
  90149. protected _serialize(serializedCondition: any): any;
  90150. }
  90151. /**
  90152. * Defines specific conditional operators as extensions of Condition
  90153. */
  90154. export class ValueCondition extends Condition {
  90155. /** path to specify the property of the target the conditional operator uses */
  90156. propertyPath: string;
  90157. /** the value compared by the conditional operator against the current value of the property */
  90158. value: any;
  90159. /** the conditional operator, default ValueCondition.IsEqual */
  90160. operator: number;
  90161. /**
  90162. * Internal only
  90163. * @hidden
  90164. */
  90165. private static _IsEqual;
  90166. /**
  90167. * Internal only
  90168. * @hidden
  90169. */
  90170. private static _IsDifferent;
  90171. /**
  90172. * Internal only
  90173. * @hidden
  90174. */
  90175. private static _IsGreater;
  90176. /**
  90177. * Internal only
  90178. * @hidden
  90179. */
  90180. private static _IsLesser;
  90181. /**
  90182. * returns the number for IsEqual
  90183. */
  90184. static get IsEqual(): number;
  90185. /**
  90186. * Returns the number for IsDifferent
  90187. */
  90188. static get IsDifferent(): number;
  90189. /**
  90190. * Returns the number for IsGreater
  90191. */
  90192. static get IsGreater(): number;
  90193. /**
  90194. * Returns the number for IsLesser
  90195. */
  90196. static get IsLesser(): number;
  90197. /**
  90198. * Internal only The action manager for the condition
  90199. * @hidden
  90200. */
  90201. _actionManager: ActionManager;
  90202. /**
  90203. * Internal only
  90204. * @hidden
  90205. */
  90206. private _target;
  90207. /**
  90208. * Internal only
  90209. * @hidden
  90210. */
  90211. private _effectiveTarget;
  90212. /**
  90213. * Internal only
  90214. * @hidden
  90215. */
  90216. private _property;
  90217. /**
  90218. * Creates a new ValueCondition
  90219. * @param actionManager manager for the action the condition applies to
  90220. * @param target for the action
  90221. * @param propertyPath path to specify the property of the target the conditional operator uses
  90222. * @param value the value compared by the conditional operator against the current value of the property
  90223. * @param operator the conditional operator, default ValueCondition.IsEqual
  90224. */
  90225. constructor(actionManager: ActionManager, target: any,
  90226. /** path to specify the property of the target the conditional operator uses */
  90227. propertyPath: string,
  90228. /** the value compared by the conditional operator against the current value of the property */
  90229. value: any,
  90230. /** the conditional operator, default ValueCondition.IsEqual */
  90231. operator?: number);
  90232. /**
  90233. * Compares the given value with the property value for the specified conditional operator
  90234. * @returns the result of the comparison
  90235. */
  90236. isValid(): boolean;
  90237. /**
  90238. * Serialize the ValueCondition into a JSON compatible object
  90239. * @returns serialization object
  90240. */
  90241. serialize(): any;
  90242. /**
  90243. * Gets the name of the conditional operator for the ValueCondition
  90244. * @param operator the conditional operator
  90245. * @returns the name
  90246. */
  90247. static GetOperatorName(operator: number): string;
  90248. }
  90249. /**
  90250. * Defines a predicate condition as an extension of Condition
  90251. */
  90252. export class PredicateCondition extends Condition {
  90253. /** defines the predicate function used to validate the condition */
  90254. predicate: () => boolean;
  90255. /**
  90256. * Internal only - manager for action
  90257. * @hidden
  90258. */
  90259. _actionManager: ActionManager;
  90260. /**
  90261. * Creates a new PredicateCondition
  90262. * @param actionManager manager for the action the condition applies to
  90263. * @param predicate defines the predicate function used to validate the condition
  90264. */
  90265. constructor(actionManager: ActionManager,
  90266. /** defines the predicate function used to validate the condition */
  90267. predicate: () => boolean);
  90268. /**
  90269. * @returns the validity of the predicate condition
  90270. */
  90271. isValid(): boolean;
  90272. }
  90273. /**
  90274. * Defines a state condition as an extension of Condition
  90275. */
  90276. export class StateCondition extends Condition {
  90277. /** Value to compare with target state */
  90278. value: string;
  90279. /**
  90280. * Internal only - manager for action
  90281. * @hidden
  90282. */
  90283. _actionManager: ActionManager;
  90284. /**
  90285. * Internal only
  90286. * @hidden
  90287. */
  90288. private _target;
  90289. /**
  90290. * Creates a new StateCondition
  90291. * @param actionManager manager for the action the condition applies to
  90292. * @param target of the condition
  90293. * @param value to compare with target state
  90294. */
  90295. constructor(actionManager: ActionManager, target: any,
  90296. /** Value to compare with target state */
  90297. value: string);
  90298. /**
  90299. * Gets a boolean indicating if the current condition is met
  90300. * @returns the validity of the state
  90301. */
  90302. isValid(): boolean;
  90303. /**
  90304. * Serialize the StateCondition into a JSON compatible object
  90305. * @returns serialization object
  90306. */
  90307. serialize(): any;
  90308. }
  90309. }
  90310. declare module BABYLON {
  90311. /**
  90312. * This defines an action responsible to toggle a boolean once triggered.
  90313. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90314. */
  90315. export class SwitchBooleanAction extends Action {
  90316. /**
  90317. * The path to the boolean property in the target object
  90318. */
  90319. propertyPath: string;
  90320. private _target;
  90321. private _effectiveTarget;
  90322. private _property;
  90323. /**
  90324. * Instantiate the action
  90325. * @param triggerOptions defines the trigger options
  90326. * @param target defines the object containing the boolean
  90327. * @param propertyPath defines the path to the boolean property in the target object
  90328. * @param condition defines the trigger related conditions
  90329. */
  90330. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90331. /** @hidden */
  90332. _prepare(): void;
  90333. /**
  90334. * Execute the action toggle the boolean value.
  90335. */
  90336. execute(): void;
  90337. /**
  90338. * Serializes the actions and its related information.
  90339. * @param parent defines the object to serialize in
  90340. * @returns the serialized object
  90341. */
  90342. serialize(parent: any): any;
  90343. }
  90344. /**
  90345. * This defines an action responsible to set a the state field of the target
  90346. * to a desired value once triggered.
  90347. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90348. */
  90349. export class SetStateAction extends Action {
  90350. /**
  90351. * The value to store in the state field.
  90352. */
  90353. value: string;
  90354. private _target;
  90355. /**
  90356. * Instantiate the action
  90357. * @param triggerOptions defines the trigger options
  90358. * @param target defines the object containing the state property
  90359. * @param value defines the value to store in the state field
  90360. * @param condition defines the trigger related conditions
  90361. */
  90362. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90363. /**
  90364. * Execute the action and store the value on the target state property.
  90365. */
  90366. execute(): void;
  90367. /**
  90368. * Serializes the actions and its related information.
  90369. * @param parent defines the object to serialize in
  90370. * @returns the serialized object
  90371. */
  90372. serialize(parent: any): any;
  90373. }
  90374. /**
  90375. * This defines an action responsible to set a property of the target
  90376. * to a desired value once triggered.
  90377. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90378. */
  90379. export class SetValueAction extends Action {
  90380. /**
  90381. * The path of the property to set in the target.
  90382. */
  90383. propertyPath: string;
  90384. /**
  90385. * The value to set in the property
  90386. */
  90387. value: any;
  90388. private _target;
  90389. private _effectiveTarget;
  90390. private _property;
  90391. /**
  90392. * Instantiate the action
  90393. * @param triggerOptions defines the trigger options
  90394. * @param target defines the object containing the property
  90395. * @param propertyPath defines the path of the property to set in the target
  90396. * @param value defines the value to set in the property
  90397. * @param condition defines the trigger related conditions
  90398. */
  90399. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90400. /** @hidden */
  90401. _prepare(): void;
  90402. /**
  90403. * Execute the action and set the targetted property to the desired value.
  90404. */
  90405. execute(): void;
  90406. /**
  90407. * Serializes the actions and its related information.
  90408. * @param parent defines the object to serialize in
  90409. * @returns the serialized object
  90410. */
  90411. serialize(parent: any): any;
  90412. }
  90413. /**
  90414. * This defines an action responsible to increment the target value
  90415. * to a desired value once triggered.
  90416. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90417. */
  90418. export class IncrementValueAction extends Action {
  90419. /**
  90420. * The path of the property to increment in the target.
  90421. */
  90422. propertyPath: string;
  90423. /**
  90424. * The value we should increment the property by.
  90425. */
  90426. value: any;
  90427. private _target;
  90428. private _effectiveTarget;
  90429. private _property;
  90430. /**
  90431. * Instantiate the action
  90432. * @param triggerOptions defines the trigger options
  90433. * @param target defines the object containing the property
  90434. * @param propertyPath defines the path of the property to increment in the target
  90435. * @param value defines the value value we should increment the property by
  90436. * @param condition defines the trigger related conditions
  90437. */
  90438. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90439. /** @hidden */
  90440. _prepare(): void;
  90441. /**
  90442. * Execute the action and increment the target of the value amount.
  90443. */
  90444. execute(): void;
  90445. /**
  90446. * Serializes the actions and its related information.
  90447. * @param parent defines the object to serialize in
  90448. * @returns the serialized object
  90449. */
  90450. serialize(parent: any): any;
  90451. }
  90452. /**
  90453. * This defines an action responsible to start an animation once triggered.
  90454. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90455. */
  90456. export class PlayAnimationAction extends Action {
  90457. /**
  90458. * Where the animation should start (animation frame)
  90459. */
  90460. from: number;
  90461. /**
  90462. * Where the animation should stop (animation frame)
  90463. */
  90464. to: number;
  90465. /**
  90466. * Define if the animation should loop or stop after the first play.
  90467. */
  90468. loop?: boolean;
  90469. private _target;
  90470. /**
  90471. * Instantiate the action
  90472. * @param triggerOptions defines the trigger options
  90473. * @param target defines the target animation or animation name
  90474. * @param from defines from where the animation should start (animation frame)
  90475. * @param end defines where the animation should stop (animation frame)
  90476. * @param loop defines if the animation should loop or stop after the first play
  90477. * @param condition defines the trigger related conditions
  90478. */
  90479. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90480. /** @hidden */
  90481. _prepare(): void;
  90482. /**
  90483. * Execute the action and play the animation.
  90484. */
  90485. execute(): void;
  90486. /**
  90487. * Serializes the actions and its related information.
  90488. * @param parent defines the object to serialize in
  90489. * @returns the serialized object
  90490. */
  90491. serialize(parent: any): any;
  90492. }
  90493. /**
  90494. * This defines an action responsible to stop an animation once triggered.
  90495. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90496. */
  90497. export class StopAnimationAction extends Action {
  90498. private _target;
  90499. /**
  90500. * Instantiate the action
  90501. * @param triggerOptions defines the trigger options
  90502. * @param target defines the target animation or animation name
  90503. * @param condition defines the trigger related conditions
  90504. */
  90505. constructor(triggerOptions: any, target: any, condition?: Condition);
  90506. /** @hidden */
  90507. _prepare(): void;
  90508. /**
  90509. * Execute the action and stop the animation.
  90510. */
  90511. execute(): void;
  90512. /**
  90513. * Serializes the actions and its related information.
  90514. * @param parent defines the object to serialize in
  90515. * @returns the serialized object
  90516. */
  90517. serialize(parent: any): any;
  90518. }
  90519. /**
  90520. * This defines an action responsible that does nothing once triggered.
  90521. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90522. */
  90523. export class DoNothingAction extends Action {
  90524. /**
  90525. * Instantiate the action
  90526. * @param triggerOptions defines the trigger options
  90527. * @param condition defines the trigger related conditions
  90528. */
  90529. constructor(triggerOptions?: any, condition?: Condition);
  90530. /**
  90531. * Execute the action and do nothing.
  90532. */
  90533. execute(): void;
  90534. /**
  90535. * Serializes the actions and its related information.
  90536. * @param parent defines the object to serialize in
  90537. * @returns the serialized object
  90538. */
  90539. serialize(parent: any): any;
  90540. }
  90541. /**
  90542. * This defines an action responsible to trigger several actions once triggered.
  90543. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90544. */
  90545. export class CombineAction extends Action {
  90546. /**
  90547. * The list of aggregated animations to run.
  90548. */
  90549. children: Action[];
  90550. /**
  90551. * Instantiate the action
  90552. * @param triggerOptions defines the trigger options
  90553. * @param children defines the list of aggregated animations to run
  90554. * @param condition defines the trigger related conditions
  90555. */
  90556. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90557. /** @hidden */
  90558. _prepare(): void;
  90559. /**
  90560. * Execute the action and executes all the aggregated actions.
  90561. */
  90562. execute(evt: ActionEvent): void;
  90563. /**
  90564. * Serializes the actions and its related information.
  90565. * @param parent defines the object to serialize in
  90566. * @returns the serialized object
  90567. */
  90568. serialize(parent: any): any;
  90569. }
  90570. /**
  90571. * This defines an action responsible to run code (external event) once triggered.
  90572. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90573. */
  90574. export class ExecuteCodeAction extends Action {
  90575. /**
  90576. * The callback function to run.
  90577. */
  90578. func: (evt: ActionEvent) => void;
  90579. /**
  90580. * Instantiate the action
  90581. * @param triggerOptions defines the trigger options
  90582. * @param func defines the callback function to run
  90583. * @param condition defines the trigger related conditions
  90584. */
  90585. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90586. /**
  90587. * Execute the action and run the attached code.
  90588. */
  90589. execute(evt: ActionEvent): void;
  90590. }
  90591. /**
  90592. * This defines an action responsible to set the parent property of the target once triggered.
  90593. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90594. */
  90595. export class SetParentAction extends Action {
  90596. private _parent;
  90597. private _target;
  90598. /**
  90599. * Instantiate the action
  90600. * @param triggerOptions defines the trigger options
  90601. * @param target defines the target containing the parent property
  90602. * @param parent defines from where the animation should start (animation frame)
  90603. * @param condition defines the trigger related conditions
  90604. */
  90605. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90606. /** @hidden */
  90607. _prepare(): void;
  90608. /**
  90609. * Execute the action and set the parent property.
  90610. */
  90611. execute(): void;
  90612. /**
  90613. * Serializes the actions and its related information.
  90614. * @param parent defines the object to serialize in
  90615. * @returns the serialized object
  90616. */
  90617. serialize(parent: any): any;
  90618. }
  90619. }
  90620. declare module BABYLON {
  90621. /**
  90622. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90623. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90624. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90625. */
  90626. export class ActionManager extends AbstractActionManager {
  90627. /**
  90628. * Nothing
  90629. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90630. */
  90631. static readonly NothingTrigger: number;
  90632. /**
  90633. * On pick
  90634. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90635. */
  90636. static readonly OnPickTrigger: number;
  90637. /**
  90638. * On left pick
  90639. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90640. */
  90641. static readonly OnLeftPickTrigger: number;
  90642. /**
  90643. * On right pick
  90644. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90645. */
  90646. static readonly OnRightPickTrigger: number;
  90647. /**
  90648. * On center pick
  90649. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90650. */
  90651. static readonly OnCenterPickTrigger: number;
  90652. /**
  90653. * On pick down
  90654. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90655. */
  90656. static readonly OnPickDownTrigger: number;
  90657. /**
  90658. * On double pick
  90659. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90660. */
  90661. static readonly OnDoublePickTrigger: number;
  90662. /**
  90663. * On pick up
  90664. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90665. */
  90666. static readonly OnPickUpTrigger: number;
  90667. /**
  90668. * On pick out.
  90669. * This trigger will only be raised if you also declared a OnPickDown
  90670. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90671. */
  90672. static readonly OnPickOutTrigger: number;
  90673. /**
  90674. * On long press
  90675. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90676. */
  90677. static readonly OnLongPressTrigger: number;
  90678. /**
  90679. * On pointer over
  90680. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90681. */
  90682. static readonly OnPointerOverTrigger: number;
  90683. /**
  90684. * On pointer out
  90685. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90686. */
  90687. static readonly OnPointerOutTrigger: number;
  90688. /**
  90689. * On every frame
  90690. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90691. */
  90692. static readonly OnEveryFrameTrigger: number;
  90693. /**
  90694. * On intersection enter
  90695. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90696. */
  90697. static readonly OnIntersectionEnterTrigger: number;
  90698. /**
  90699. * On intersection exit
  90700. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90701. */
  90702. static readonly OnIntersectionExitTrigger: number;
  90703. /**
  90704. * On key down
  90705. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90706. */
  90707. static readonly OnKeyDownTrigger: number;
  90708. /**
  90709. * On key up
  90710. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90711. */
  90712. static readonly OnKeyUpTrigger: number;
  90713. private _scene;
  90714. /**
  90715. * Creates a new action manager
  90716. * @param scene defines the hosting scene
  90717. */
  90718. constructor(scene: Scene);
  90719. /**
  90720. * Releases all associated resources
  90721. */
  90722. dispose(): void;
  90723. /**
  90724. * Gets hosting scene
  90725. * @returns the hosting scene
  90726. */
  90727. getScene(): Scene;
  90728. /**
  90729. * Does this action manager handles actions of any of the given triggers
  90730. * @param triggers defines the triggers to be tested
  90731. * @return a boolean indicating whether one (or more) of the triggers is handled
  90732. */
  90733. hasSpecificTriggers(triggers: number[]): boolean;
  90734. /**
  90735. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90736. * speed.
  90737. * @param triggerA defines the trigger to be tested
  90738. * @param triggerB defines the trigger to be tested
  90739. * @return a boolean indicating whether one (or more) of the triggers is handled
  90740. */
  90741. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90742. /**
  90743. * Does this action manager handles actions of a given trigger
  90744. * @param trigger defines the trigger to be tested
  90745. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90746. * @return whether the trigger is handled
  90747. */
  90748. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90749. /**
  90750. * Does this action manager has pointer triggers
  90751. */
  90752. get hasPointerTriggers(): boolean;
  90753. /**
  90754. * Does this action manager has pick triggers
  90755. */
  90756. get hasPickTriggers(): boolean;
  90757. /**
  90758. * Registers an action to this action manager
  90759. * @param action defines the action to be registered
  90760. * @return the action amended (prepared) after registration
  90761. */
  90762. registerAction(action: IAction): Nullable<IAction>;
  90763. /**
  90764. * Unregisters an action to this action manager
  90765. * @param action defines the action to be unregistered
  90766. * @return a boolean indicating whether the action has been unregistered
  90767. */
  90768. unregisterAction(action: IAction): Boolean;
  90769. /**
  90770. * Process a specific trigger
  90771. * @param trigger defines the trigger to process
  90772. * @param evt defines the event details to be processed
  90773. */
  90774. processTrigger(trigger: number, evt?: IActionEvent): void;
  90775. /** @hidden */
  90776. _getEffectiveTarget(target: any, propertyPath: string): any;
  90777. /** @hidden */
  90778. _getProperty(propertyPath: string): string;
  90779. /**
  90780. * Serialize this manager to a JSON object
  90781. * @param name defines the property name to store this manager
  90782. * @returns a JSON representation of this manager
  90783. */
  90784. serialize(name: string): any;
  90785. /**
  90786. * Creates a new ActionManager from a JSON data
  90787. * @param parsedActions defines the JSON data to read from
  90788. * @param object defines the hosting mesh
  90789. * @param scene defines the hosting scene
  90790. */
  90791. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90792. /**
  90793. * Get a trigger name by index
  90794. * @param trigger defines the trigger index
  90795. * @returns a trigger name
  90796. */
  90797. static GetTriggerName(trigger: number): string;
  90798. }
  90799. }
  90800. declare module BABYLON {
  90801. /**
  90802. * Class used to represent a sprite
  90803. * @see https://doc.babylonjs.com/babylon101/sprites
  90804. */
  90805. export class Sprite implements IAnimatable {
  90806. /** defines the name */
  90807. name: string;
  90808. /** Gets or sets the current world position */
  90809. position: Vector3;
  90810. /** Gets or sets the main color */
  90811. color: Color4;
  90812. /** Gets or sets the width */
  90813. width: number;
  90814. /** Gets or sets the height */
  90815. height: number;
  90816. /** Gets or sets rotation angle */
  90817. angle: number;
  90818. /** Gets or sets the cell index in the sprite sheet */
  90819. cellIndex: number;
  90820. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90821. cellRef: string;
  90822. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90823. invertU: boolean;
  90824. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90825. invertV: boolean;
  90826. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90827. disposeWhenFinishedAnimating: boolean;
  90828. /** Gets the list of attached animations */
  90829. animations: Nullable<Array<Animation>>;
  90830. /** Gets or sets a boolean indicating if the sprite can be picked */
  90831. isPickable: boolean;
  90832. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90833. useAlphaForPicking: boolean;
  90834. /** @hidden */
  90835. _xOffset: number;
  90836. /** @hidden */
  90837. _yOffset: number;
  90838. /** @hidden */
  90839. _xSize: number;
  90840. /** @hidden */
  90841. _ySize: number;
  90842. /**
  90843. * Gets or sets the associated action manager
  90844. */
  90845. actionManager: Nullable<ActionManager>;
  90846. /**
  90847. * An event triggered when the control has been disposed
  90848. */
  90849. onDisposeObservable: Observable<Sprite>;
  90850. private _animationStarted;
  90851. private _loopAnimation;
  90852. private _fromIndex;
  90853. private _toIndex;
  90854. private _delay;
  90855. private _direction;
  90856. private _manager;
  90857. private _time;
  90858. private _onAnimationEnd;
  90859. /**
  90860. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90861. */
  90862. isVisible: boolean;
  90863. /**
  90864. * Gets or sets the sprite size
  90865. */
  90866. get size(): number;
  90867. set size(value: number);
  90868. /**
  90869. * Returns a boolean indicating if the animation is started
  90870. */
  90871. get animationStarted(): boolean;
  90872. /**
  90873. * Gets or sets the unique id of the sprite
  90874. */
  90875. uniqueId: number;
  90876. /**
  90877. * Gets the manager of this sprite
  90878. */
  90879. get manager(): ISpriteManager;
  90880. /**
  90881. * Creates a new Sprite
  90882. * @param name defines the name
  90883. * @param manager defines the manager
  90884. */
  90885. constructor(
  90886. /** defines the name */
  90887. name: string, manager: ISpriteManager);
  90888. /**
  90889. * Returns the string "Sprite"
  90890. * @returns "Sprite"
  90891. */
  90892. getClassName(): string;
  90893. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90894. get fromIndex(): number;
  90895. set fromIndex(value: number);
  90896. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90897. get toIndex(): number;
  90898. set toIndex(value: number);
  90899. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90900. get loopAnimation(): boolean;
  90901. set loopAnimation(value: boolean);
  90902. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90903. get delay(): number;
  90904. set delay(value: number);
  90905. /**
  90906. * Starts an animation
  90907. * @param from defines the initial key
  90908. * @param to defines the end key
  90909. * @param loop defines if the animation must loop
  90910. * @param delay defines the start delay (in ms)
  90911. * @param onAnimationEnd defines a callback to call when animation ends
  90912. */
  90913. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90914. /** Stops current animation (if any) */
  90915. stopAnimation(): void;
  90916. /** @hidden */
  90917. _animate(deltaTime: number): void;
  90918. /** Release associated resources */
  90919. dispose(): void;
  90920. /**
  90921. * Serializes the sprite to a JSON object
  90922. * @returns the JSON object
  90923. */
  90924. serialize(): any;
  90925. /**
  90926. * Parses a JSON object to create a new sprite
  90927. * @param parsedSprite The JSON object to parse
  90928. * @param manager defines the hosting manager
  90929. * @returns the new sprite
  90930. */
  90931. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90932. }
  90933. }
  90934. declare module BABYLON {
  90935. /**
  90936. * Information about the result of picking within a scene
  90937. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90938. */
  90939. export class PickingInfo {
  90940. /** @hidden */
  90941. _pickingUnavailable: boolean;
  90942. /**
  90943. * If the pick collided with an object
  90944. */
  90945. hit: boolean;
  90946. /**
  90947. * Distance away where the pick collided
  90948. */
  90949. distance: number;
  90950. /**
  90951. * The location of pick collision
  90952. */
  90953. pickedPoint: Nullable<Vector3>;
  90954. /**
  90955. * The mesh corresponding the the pick collision
  90956. */
  90957. pickedMesh: Nullable<AbstractMesh>;
  90958. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90959. bu: number;
  90960. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90961. bv: number;
  90962. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90963. faceId: number;
  90964. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90965. subMeshFaceId: number;
  90966. /** Id of the the submesh that was picked */
  90967. subMeshId: number;
  90968. /** If a sprite was picked, this will be the sprite the pick collided with */
  90969. pickedSprite: Nullable<Sprite>;
  90970. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90971. thinInstanceIndex: number;
  90972. /**
  90973. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90974. */
  90975. originMesh: Nullable<AbstractMesh>;
  90976. /**
  90977. * The ray that was used to perform the picking.
  90978. */
  90979. ray: Nullable<Ray>;
  90980. /**
  90981. * Gets the normal correspodning to the face the pick collided with
  90982. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90983. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90984. * @returns The normal correspodning to the face the pick collided with
  90985. */
  90986. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90987. /**
  90988. * Gets the texture coordinates of where the pick occured
  90989. * @returns the vector containing the coordnates of the texture
  90990. */
  90991. getTextureCoordinates(): Nullable<Vector2>;
  90992. }
  90993. }
  90994. declare module BABYLON {
  90995. /**
  90996. * Class representing a ray with position and direction
  90997. */
  90998. export class Ray {
  90999. /** origin point */
  91000. origin: Vector3;
  91001. /** direction */
  91002. direction: Vector3;
  91003. /** length of the ray */
  91004. length: number;
  91005. private static readonly _TmpVector3;
  91006. private _tmpRay;
  91007. /**
  91008. * Creates a new ray
  91009. * @param origin origin point
  91010. * @param direction direction
  91011. * @param length length of the ray
  91012. */
  91013. constructor(
  91014. /** origin point */
  91015. origin: Vector3,
  91016. /** direction */
  91017. direction: Vector3,
  91018. /** length of the ray */
  91019. length?: number);
  91020. /**
  91021. * Checks if the ray intersects a box
  91022. * This does not account for the ray lenght by design to improve perfs.
  91023. * @param minimum bound of the box
  91024. * @param maximum bound of the box
  91025. * @param intersectionTreshold extra extend to be added to the box in all direction
  91026. * @returns if the box was hit
  91027. */
  91028. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91029. /**
  91030. * Checks if the ray intersects a box
  91031. * This does not account for the ray lenght by design to improve perfs.
  91032. * @param box the bounding box to check
  91033. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91034. * @returns if the box was hit
  91035. */
  91036. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91037. /**
  91038. * If the ray hits a sphere
  91039. * @param sphere the bounding sphere to check
  91040. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91041. * @returns true if it hits the sphere
  91042. */
  91043. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91044. /**
  91045. * If the ray hits a triange
  91046. * @param vertex0 triangle vertex
  91047. * @param vertex1 triangle vertex
  91048. * @param vertex2 triangle vertex
  91049. * @returns intersection information if hit
  91050. */
  91051. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91052. /**
  91053. * Checks if ray intersects a plane
  91054. * @param plane the plane to check
  91055. * @returns the distance away it was hit
  91056. */
  91057. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91058. /**
  91059. * Calculate the intercept of a ray on a given axis
  91060. * @param axis to check 'x' | 'y' | 'z'
  91061. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91062. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91063. */
  91064. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91065. /**
  91066. * Checks if ray intersects a mesh
  91067. * @param mesh the mesh to check
  91068. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91069. * @returns picking info of the intersecton
  91070. */
  91071. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91072. /**
  91073. * Checks if ray intersects a mesh
  91074. * @param meshes the meshes to check
  91075. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91076. * @param results array to store result in
  91077. * @returns Array of picking infos
  91078. */
  91079. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91080. private _comparePickingInfo;
  91081. private static smallnum;
  91082. private static rayl;
  91083. /**
  91084. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91085. * @param sega the first point of the segment to test the intersection against
  91086. * @param segb the second point of the segment to test the intersection against
  91087. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91088. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91089. */
  91090. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91091. /**
  91092. * Update the ray from viewport position
  91093. * @param x position
  91094. * @param y y position
  91095. * @param viewportWidth viewport width
  91096. * @param viewportHeight viewport height
  91097. * @param world world matrix
  91098. * @param view view matrix
  91099. * @param projection projection matrix
  91100. * @returns this ray updated
  91101. */
  91102. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91103. /**
  91104. * Creates a ray with origin and direction of 0,0,0
  91105. * @returns the new ray
  91106. */
  91107. static Zero(): Ray;
  91108. /**
  91109. * Creates a new ray from screen space and viewport
  91110. * @param x position
  91111. * @param y y position
  91112. * @param viewportWidth viewport width
  91113. * @param viewportHeight viewport height
  91114. * @param world world matrix
  91115. * @param view view matrix
  91116. * @param projection projection matrix
  91117. * @returns new ray
  91118. */
  91119. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91120. /**
  91121. * 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
  91122. * transformed to the given world matrix.
  91123. * @param origin The origin point
  91124. * @param end The end point
  91125. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91126. * @returns the new ray
  91127. */
  91128. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91129. /**
  91130. * Transforms a ray by a matrix
  91131. * @param ray ray to transform
  91132. * @param matrix matrix to apply
  91133. * @returns the resulting new ray
  91134. */
  91135. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91136. /**
  91137. * Transforms a ray by a matrix
  91138. * @param ray ray to transform
  91139. * @param matrix matrix to apply
  91140. * @param result ray to store result in
  91141. */
  91142. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91143. /**
  91144. * Unproject a ray from screen space to object space
  91145. * @param sourceX defines the screen space x coordinate to use
  91146. * @param sourceY defines the screen space y coordinate to use
  91147. * @param viewportWidth defines the current width of the viewport
  91148. * @param viewportHeight defines the current height of the viewport
  91149. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91150. * @param view defines the view matrix to use
  91151. * @param projection defines the projection matrix to use
  91152. */
  91153. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91154. }
  91155. /**
  91156. * Type used to define predicate used to select faces when a mesh intersection is detected
  91157. */
  91158. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91159. interface Scene {
  91160. /** @hidden */
  91161. _tempPickingRay: Nullable<Ray>;
  91162. /** @hidden */
  91163. _cachedRayForTransform: Ray;
  91164. /** @hidden */
  91165. _pickWithRayInverseMatrix: Matrix;
  91166. /** @hidden */
  91167. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91168. /** @hidden */
  91169. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91170. /** @hidden */
  91171. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91172. }
  91173. }
  91174. declare module BABYLON {
  91175. /**
  91176. * Groups all the scene component constants in one place to ease maintenance.
  91177. * @hidden
  91178. */
  91179. export class SceneComponentConstants {
  91180. static readonly NAME_EFFECTLAYER: string;
  91181. static readonly NAME_LAYER: string;
  91182. static readonly NAME_LENSFLARESYSTEM: string;
  91183. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91184. static readonly NAME_PARTICLESYSTEM: string;
  91185. static readonly NAME_GAMEPAD: string;
  91186. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91187. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91188. static readonly NAME_PREPASSRENDERER: string;
  91189. static readonly NAME_DEPTHRENDERER: string;
  91190. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91191. static readonly NAME_SPRITE: string;
  91192. static readonly NAME_SUBSURFACE: string;
  91193. static readonly NAME_OUTLINERENDERER: string;
  91194. static readonly NAME_PROCEDURALTEXTURE: string;
  91195. static readonly NAME_SHADOWGENERATOR: string;
  91196. static readonly NAME_OCTREE: string;
  91197. static readonly NAME_PHYSICSENGINE: string;
  91198. static readonly NAME_AUDIO: string;
  91199. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91200. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91201. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91202. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91203. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91204. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91205. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91206. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91207. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91208. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91209. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91210. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91211. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91212. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91213. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91214. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91215. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91216. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91217. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91218. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91219. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91220. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91221. static readonly STEP_AFTERRENDER_AUDIO: number;
  91222. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91223. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91224. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91225. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91226. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91227. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91228. static readonly STEP_POINTERMOVE_SPRITE: number;
  91229. static readonly STEP_POINTERDOWN_SPRITE: number;
  91230. static readonly STEP_POINTERUP_SPRITE: number;
  91231. }
  91232. /**
  91233. * This represents a scene component.
  91234. *
  91235. * This is used to decouple the dependency the scene is having on the different workloads like
  91236. * layers, post processes...
  91237. */
  91238. export interface ISceneComponent {
  91239. /**
  91240. * The name of the component. Each component must have a unique name.
  91241. */
  91242. name: string;
  91243. /**
  91244. * The scene the component belongs to.
  91245. */
  91246. scene: Scene;
  91247. /**
  91248. * Register the component to one instance of a scene.
  91249. */
  91250. register(): void;
  91251. /**
  91252. * Rebuilds the elements related to this component in case of
  91253. * context lost for instance.
  91254. */
  91255. rebuild(): void;
  91256. /**
  91257. * Disposes the component and the associated ressources.
  91258. */
  91259. dispose(): void;
  91260. }
  91261. /**
  91262. * This represents a SERIALIZABLE scene component.
  91263. *
  91264. * This extends Scene Component to add Serialization methods on top.
  91265. */
  91266. export interface ISceneSerializableComponent extends ISceneComponent {
  91267. /**
  91268. * Adds all the elements from the container to the scene
  91269. * @param container the container holding the elements
  91270. */
  91271. addFromContainer(container: AbstractScene): void;
  91272. /**
  91273. * Removes all the elements in the container from the scene
  91274. * @param container contains the elements to remove
  91275. * @param dispose if the removed element should be disposed (default: false)
  91276. */
  91277. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91278. /**
  91279. * Serializes the component data to the specified json object
  91280. * @param serializationObject The object to serialize to
  91281. */
  91282. serialize(serializationObject: any): void;
  91283. }
  91284. /**
  91285. * Strong typing of a Mesh related stage step action
  91286. */
  91287. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91288. /**
  91289. * Strong typing of a Evaluate Sub Mesh related stage step action
  91290. */
  91291. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91292. /**
  91293. * Strong typing of a Active Mesh related stage step action
  91294. */
  91295. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91296. /**
  91297. * Strong typing of a Camera related stage step action
  91298. */
  91299. export type CameraStageAction = (camera: Camera) => void;
  91300. /**
  91301. * Strong typing of a Camera Frame buffer related stage step action
  91302. */
  91303. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91304. /**
  91305. * Strong typing of a Render Target related stage step action
  91306. */
  91307. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91308. /**
  91309. * Strong typing of a RenderingGroup related stage step action
  91310. */
  91311. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91312. /**
  91313. * Strong typing of a Mesh Render related stage step action
  91314. */
  91315. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91316. /**
  91317. * Strong typing of a simple stage step action
  91318. */
  91319. export type SimpleStageAction = () => void;
  91320. /**
  91321. * Strong typing of a render target action.
  91322. */
  91323. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91324. /**
  91325. * Strong typing of a pointer move action.
  91326. */
  91327. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91328. /**
  91329. * Strong typing of a pointer up/down action.
  91330. */
  91331. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91332. /**
  91333. * Representation of a stage in the scene (Basically a list of ordered steps)
  91334. * @hidden
  91335. */
  91336. export class Stage<T extends Function> extends Array<{
  91337. index: number;
  91338. component: ISceneComponent;
  91339. action: T;
  91340. }> {
  91341. /**
  91342. * Hide ctor from the rest of the world.
  91343. * @param items The items to add.
  91344. */
  91345. private constructor();
  91346. /**
  91347. * Creates a new Stage.
  91348. * @returns A new instance of a Stage
  91349. */
  91350. static Create<T extends Function>(): Stage<T>;
  91351. /**
  91352. * Registers a step in an ordered way in the targeted stage.
  91353. * @param index Defines the position to register the step in
  91354. * @param component Defines the component attached to the step
  91355. * @param action Defines the action to launch during the step
  91356. */
  91357. registerStep(index: number, component: ISceneComponent, action: T): void;
  91358. /**
  91359. * Clears all the steps from the stage.
  91360. */
  91361. clear(): void;
  91362. }
  91363. }
  91364. declare module BABYLON {
  91365. interface Scene {
  91366. /** @hidden */
  91367. _pointerOverSprite: Nullable<Sprite>;
  91368. /** @hidden */
  91369. _pickedDownSprite: Nullable<Sprite>;
  91370. /** @hidden */
  91371. _tempSpritePickingRay: Nullable<Ray>;
  91372. /**
  91373. * All of the sprite managers added to this scene
  91374. * @see https://doc.babylonjs.com/babylon101/sprites
  91375. */
  91376. spriteManagers: Array<ISpriteManager>;
  91377. /**
  91378. * An event triggered when sprites rendering is about to start
  91379. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91380. */
  91381. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91382. /**
  91383. * An event triggered when sprites rendering is done
  91384. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91385. */
  91386. onAfterSpritesRenderingObservable: Observable<Scene>;
  91387. /** @hidden */
  91388. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91389. /** Launch a ray to try to pick a sprite in the scene
  91390. * @param x position on screen
  91391. * @param y position on screen
  91392. * @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
  91393. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91394. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91395. * @returns a PickingInfo
  91396. */
  91397. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91398. /** Use the given ray to pick a sprite in the scene
  91399. * @param ray The ray (in world space) to use to pick meshes
  91400. * @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
  91401. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91402. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91403. * @returns a PickingInfo
  91404. */
  91405. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91406. /** @hidden */
  91407. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91408. /** Launch a ray to try to pick sprites in the scene
  91409. * @param x position on screen
  91410. * @param y position on screen
  91411. * @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
  91412. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91413. * @returns a PickingInfo array
  91414. */
  91415. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91416. /** Use the given ray to pick sprites in the scene
  91417. * @param ray The ray (in world space) to use to pick meshes
  91418. * @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
  91419. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91420. * @returns a PickingInfo array
  91421. */
  91422. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91423. /**
  91424. * Force the sprite under the pointer
  91425. * @param sprite defines the sprite to use
  91426. */
  91427. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91428. /**
  91429. * Gets the sprite under the pointer
  91430. * @returns a Sprite or null if no sprite is under the pointer
  91431. */
  91432. getPointerOverSprite(): Nullable<Sprite>;
  91433. }
  91434. /**
  91435. * Defines the sprite scene component responsible to manage sprites
  91436. * in a given scene.
  91437. */
  91438. export class SpriteSceneComponent implements ISceneComponent {
  91439. /**
  91440. * The component name helpfull to identify the component in the list of scene components.
  91441. */
  91442. readonly name: string;
  91443. /**
  91444. * The scene the component belongs to.
  91445. */
  91446. scene: Scene;
  91447. /** @hidden */
  91448. private _spritePredicate;
  91449. /**
  91450. * Creates a new instance of the component for the given scene
  91451. * @param scene Defines the scene to register the component in
  91452. */
  91453. constructor(scene: Scene);
  91454. /**
  91455. * Registers the component in a given scene
  91456. */
  91457. register(): void;
  91458. /**
  91459. * Rebuilds the elements related to this component in case of
  91460. * context lost for instance.
  91461. */
  91462. rebuild(): void;
  91463. /**
  91464. * Disposes the component and the associated ressources.
  91465. */
  91466. dispose(): void;
  91467. private _pickSpriteButKeepRay;
  91468. private _pointerMove;
  91469. private _pointerDown;
  91470. private _pointerUp;
  91471. }
  91472. }
  91473. declare module BABYLON {
  91474. /** @hidden */
  91475. export var fogFragmentDeclaration: {
  91476. name: string;
  91477. shader: string;
  91478. };
  91479. }
  91480. declare module BABYLON {
  91481. /** @hidden */
  91482. export var fogFragment: {
  91483. name: string;
  91484. shader: string;
  91485. };
  91486. }
  91487. declare module BABYLON {
  91488. /** @hidden */
  91489. export var spritesPixelShader: {
  91490. name: string;
  91491. shader: string;
  91492. };
  91493. }
  91494. declare module BABYLON {
  91495. /** @hidden */
  91496. export var fogVertexDeclaration: {
  91497. name: string;
  91498. shader: string;
  91499. };
  91500. }
  91501. declare module BABYLON {
  91502. /** @hidden */
  91503. export var spritesVertexShader: {
  91504. name: string;
  91505. shader: string;
  91506. };
  91507. }
  91508. declare module BABYLON {
  91509. /**
  91510. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91511. */
  91512. export interface ISpriteManager extends IDisposable {
  91513. /**
  91514. * Gets manager's name
  91515. */
  91516. name: string;
  91517. /**
  91518. * Restricts the camera to viewing objects with the same layerMask.
  91519. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91520. */
  91521. layerMask: number;
  91522. /**
  91523. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91524. */
  91525. isPickable: boolean;
  91526. /**
  91527. * Gets the hosting scene
  91528. */
  91529. scene: Scene;
  91530. /**
  91531. * Specifies the rendering group id for this mesh (0 by default)
  91532. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91533. */
  91534. renderingGroupId: number;
  91535. /**
  91536. * Defines the list of sprites managed by the manager.
  91537. */
  91538. sprites: Array<Sprite>;
  91539. /**
  91540. * Gets or sets the spritesheet texture
  91541. */
  91542. texture: Texture;
  91543. /** Defines the default width of a cell in the spritesheet */
  91544. cellWidth: number;
  91545. /** Defines the default height of a cell in the spritesheet */
  91546. cellHeight: number;
  91547. /**
  91548. * Tests the intersection of a sprite with a specific ray.
  91549. * @param ray The ray we are sending to test the collision
  91550. * @param camera The camera space we are sending rays in
  91551. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91552. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91553. * @returns picking info or null.
  91554. */
  91555. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91556. /**
  91557. * Intersects the sprites with a ray
  91558. * @param ray defines the ray to intersect with
  91559. * @param camera defines the current active camera
  91560. * @param predicate defines a predicate used to select candidate sprites
  91561. * @returns null if no hit or a PickingInfo array
  91562. */
  91563. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91564. /**
  91565. * Renders the list of sprites on screen.
  91566. */
  91567. render(): void;
  91568. }
  91569. /**
  91570. * Class used to manage multiple sprites on the same spritesheet
  91571. * @see https://doc.babylonjs.com/babylon101/sprites
  91572. */
  91573. export class SpriteManager implements ISpriteManager {
  91574. /** defines the manager's name */
  91575. name: string;
  91576. /** Define the Url to load snippets */
  91577. static SnippetUrl: string;
  91578. /** Snippet ID if the manager was created from the snippet server */
  91579. snippetId: string;
  91580. /** Gets the list of sprites */
  91581. sprites: Sprite[];
  91582. /** Gets or sets the rendering group id (0 by default) */
  91583. renderingGroupId: number;
  91584. /** Gets or sets camera layer mask */
  91585. layerMask: number;
  91586. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91587. fogEnabled: boolean;
  91588. /** Gets or sets a boolean indicating if the sprites are pickable */
  91589. isPickable: boolean;
  91590. /** Defines the default width of a cell in the spritesheet */
  91591. cellWidth: number;
  91592. /** Defines the default height of a cell in the spritesheet */
  91593. cellHeight: number;
  91594. /** Associative array from JSON sprite data file */
  91595. private _cellData;
  91596. /** Array of sprite names from JSON sprite data file */
  91597. private _spriteMap;
  91598. /** True when packed cell data from JSON file is ready*/
  91599. private _packedAndReady;
  91600. private _textureContent;
  91601. private _useInstancing;
  91602. /**
  91603. * An event triggered when the manager is disposed.
  91604. */
  91605. onDisposeObservable: Observable<SpriteManager>;
  91606. private _onDisposeObserver;
  91607. /**
  91608. * Callback called when the manager is disposed
  91609. */
  91610. set onDispose(callback: () => void);
  91611. private _capacity;
  91612. private _fromPacked;
  91613. private _spriteTexture;
  91614. private _epsilon;
  91615. private _scene;
  91616. private _vertexData;
  91617. private _buffer;
  91618. private _vertexBuffers;
  91619. private _spriteBuffer;
  91620. private _indexBuffer;
  91621. private _effectBase;
  91622. private _effectFog;
  91623. private _vertexBufferSize;
  91624. /**
  91625. * Gets or sets the unique id of the sprite
  91626. */
  91627. uniqueId: number;
  91628. /**
  91629. * Gets the array of sprites
  91630. */
  91631. get children(): Sprite[];
  91632. /**
  91633. * Gets the hosting scene
  91634. */
  91635. get scene(): Scene;
  91636. /**
  91637. * Gets the capacity of the manager
  91638. */
  91639. get capacity(): number;
  91640. /**
  91641. * Gets or sets the spritesheet texture
  91642. */
  91643. get texture(): Texture;
  91644. set texture(value: Texture);
  91645. private _blendMode;
  91646. /**
  91647. * Blend mode use to render the particle, it can be any of
  91648. * the static Constants.ALPHA_x properties provided in this class.
  91649. * Default value is Constants.ALPHA_COMBINE
  91650. */
  91651. get blendMode(): number;
  91652. set blendMode(blendMode: number);
  91653. /** Disables writing to the depth buffer when rendering the sprites.
  91654. * It can be handy to disable depth writing when using textures without alpha channel
  91655. * and setting some specific blend modes.
  91656. */
  91657. disableDepthWrite: boolean;
  91658. /**
  91659. * Creates a new sprite manager
  91660. * @param name defines the manager's name
  91661. * @param imgUrl defines the sprite sheet url
  91662. * @param capacity defines the maximum allowed number of sprites
  91663. * @param cellSize defines the size of a sprite cell
  91664. * @param scene defines the hosting scene
  91665. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91666. * @param samplingMode defines the smapling mode to use with spritesheet
  91667. * @param fromPacked set to false; do not alter
  91668. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91669. */
  91670. constructor(
  91671. /** defines the manager's name */
  91672. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91673. /**
  91674. * Returns the string "SpriteManager"
  91675. * @returns "SpriteManager"
  91676. */
  91677. getClassName(): string;
  91678. private _makePacked;
  91679. private _appendSpriteVertex;
  91680. private _checkTextureAlpha;
  91681. /**
  91682. * Intersects the sprites with a ray
  91683. * @param ray defines the ray to intersect with
  91684. * @param camera defines the current active camera
  91685. * @param predicate defines a predicate used to select candidate sprites
  91686. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91687. * @returns null if no hit or a PickingInfo
  91688. */
  91689. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91690. /**
  91691. * Intersects the sprites with a ray
  91692. * @param ray defines the ray to intersect with
  91693. * @param camera defines the current active camera
  91694. * @param predicate defines a predicate used to select candidate sprites
  91695. * @returns null if no hit or a PickingInfo array
  91696. */
  91697. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91698. /**
  91699. * Render all child sprites
  91700. */
  91701. render(): void;
  91702. /**
  91703. * Release associated resources
  91704. */
  91705. dispose(): void;
  91706. /**
  91707. * Serializes the sprite manager to a JSON object
  91708. * @param serializeTexture defines if the texture must be serialized as well
  91709. * @returns the JSON object
  91710. */
  91711. serialize(serializeTexture?: boolean): any;
  91712. /**
  91713. * Parses a JSON object to create a new sprite manager.
  91714. * @param parsedManager The JSON object to parse
  91715. * @param scene The scene to create the sprite managerin
  91716. * @param rootUrl The root url to use to load external dependencies like texture
  91717. * @returns the new sprite manager
  91718. */
  91719. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91720. /**
  91721. * Creates a sprite manager from a snippet saved in a remote file
  91722. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91723. * @param url defines the url to load from
  91724. * @param scene defines the hosting scene
  91725. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91726. * @returns a promise that will resolve to the new sprite manager
  91727. */
  91728. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91729. /**
  91730. * Creates a sprite manager from a snippet saved by the sprite editor
  91731. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91732. * @param scene defines the hosting scene
  91733. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91734. * @returns a promise that will resolve to the new sprite manager
  91735. */
  91736. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91737. }
  91738. }
  91739. declare module BABYLON {
  91740. /** Interface used by value gradients (color, factor, ...) */
  91741. export interface IValueGradient {
  91742. /**
  91743. * Gets or sets the gradient value (between 0 and 1)
  91744. */
  91745. gradient: number;
  91746. }
  91747. /** Class used to store color4 gradient */
  91748. export class ColorGradient implements IValueGradient {
  91749. /**
  91750. * Gets or sets the gradient value (between 0 and 1)
  91751. */
  91752. gradient: number;
  91753. /**
  91754. * Gets or sets first associated color
  91755. */
  91756. color1: Color4;
  91757. /**
  91758. * Gets or sets second associated color
  91759. */
  91760. color2?: Color4 | undefined;
  91761. /**
  91762. * Creates a new color4 gradient
  91763. * @param gradient gets or sets the gradient value (between 0 and 1)
  91764. * @param color1 gets or sets first associated color
  91765. * @param color2 gets or sets first second color
  91766. */
  91767. constructor(
  91768. /**
  91769. * Gets or sets the gradient value (between 0 and 1)
  91770. */
  91771. gradient: number,
  91772. /**
  91773. * Gets or sets first associated color
  91774. */
  91775. color1: Color4,
  91776. /**
  91777. * Gets or sets second associated color
  91778. */
  91779. color2?: Color4 | undefined);
  91780. /**
  91781. * Will get a color picked randomly between color1 and color2.
  91782. * If color2 is undefined then color1 will be used
  91783. * @param result defines the target Color4 to store the result in
  91784. */
  91785. getColorToRef(result: Color4): void;
  91786. }
  91787. /** Class used to store color 3 gradient */
  91788. export class Color3Gradient implements IValueGradient {
  91789. /**
  91790. * Gets or sets the gradient value (between 0 and 1)
  91791. */
  91792. gradient: number;
  91793. /**
  91794. * Gets or sets the associated color
  91795. */
  91796. color: Color3;
  91797. /**
  91798. * Creates a new color3 gradient
  91799. * @param gradient gets or sets the gradient value (between 0 and 1)
  91800. * @param color gets or sets associated color
  91801. */
  91802. constructor(
  91803. /**
  91804. * Gets or sets the gradient value (between 0 and 1)
  91805. */
  91806. gradient: number,
  91807. /**
  91808. * Gets or sets the associated color
  91809. */
  91810. color: Color3);
  91811. }
  91812. /** Class used to store factor gradient */
  91813. export class FactorGradient implements IValueGradient {
  91814. /**
  91815. * Gets or sets the gradient value (between 0 and 1)
  91816. */
  91817. gradient: number;
  91818. /**
  91819. * Gets or sets first associated factor
  91820. */
  91821. factor1: number;
  91822. /**
  91823. * Gets or sets second associated factor
  91824. */
  91825. factor2?: number | undefined;
  91826. /**
  91827. * Creates a new factor gradient
  91828. * @param gradient gets or sets the gradient value (between 0 and 1)
  91829. * @param factor1 gets or sets first associated factor
  91830. * @param factor2 gets or sets second associated factor
  91831. */
  91832. constructor(
  91833. /**
  91834. * Gets or sets the gradient value (between 0 and 1)
  91835. */
  91836. gradient: number,
  91837. /**
  91838. * Gets or sets first associated factor
  91839. */
  91840. factor1: number,
  91841. /**
  91842. * Gets or sets second associated factor
  91843. */
  91844. factor2?: number | undefined);
  91845. /**
  91846. * Will get a number picked randomly between factor1 and factor2.
  91847. * If factor2 is undefined then factor1 will be used
  91848. * @returns the picked number
  91849. */
  91850. getFactor(): number;
  91851. }
  91852. /**
  91853. * Helper used to simplify some generic gradient tasks
  91854. */
  91855. export class GradientHelper {
  91856. /**
  91857. * Gets the current gradient from an array of IValueGradient
  91858. * @param ratio defines the current ratio to get
  91859. * @param gradients defines the array of IValueGradient
  91860. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91861. */
  91862. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91863. }
  91864. }
  91865. declare module BABYLON {
  91866. interface ThinEngine {
  91867. /**
  91868. * Creates a raw texture
  91869. * @param data defines the data to store in the texture
  91870. * @param width defines the width of the texture
  91871. * @param height defines the height of the texture
  91872. * @param format defines the format of the data
  91873. * @param generateMipMaps defines if the engine should generate the mip levels
  91874. * @param invertY defines if data must be stored with Y axis inverted
  91875. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91876. * @param compression defines the compression used (null by default)
  91877. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91878. * @returns the raw texture inside an InternalTexture
  91879. */
  91880. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91881. /**
  91882. * Update a raw texture
  91883. * @param texture defines the texture to update
  91884. * @param data defines the data to store in the texture
  91885. * @param format defines the format of the data
  91886. * @param invertY defines if data must be stored with Y axis inverted
  91887. */
  91888. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91889. /**
  91890. * Update a raw texture
  91891. * @param texture defines the texture to update
  91892. * @param data defines the data to store in the texture
  91893. * @param format defines the format of the data
  91894. * @param invertY defines if data must be stored with Y axis inverted
  91895. * @param compression defines the compression used (null by default)
  91896. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91897. */
  91898. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91899. /**
  91900. * Creates a new raw cube texture
  91901. * @param data defines the array of data to use to create each face
  91902. * @param size defines the size of the textures
  91903. * @param format defines the format of the data
  91904. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91905. * @param generateMipMaps defines if the engine should generate the mip levels
  91906. * @param invertY defines if data must be stored with Y axis inverted
  91907. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91908. * @param compression defines the compression used (null by default)
  91909. * @returns the cube texture as an InternalTexture
  91910. */
  91911. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91912. /**
  91913. * Update a raw cube texture
  91914. * @param texture defines the texture to udpdate
  91915. * @param data defines the data to store
  91916. * @param format defines the data format
  91917. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91918. * @param invertY defines if data must be stored with Y axis inverted
  91919. */
  91920. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91921. /**
  91922. * Update a raw cube texture
  91923. * @param texture defines the texture to udpdate
  91924. * @param data defines the data to store
  91925. * @param format defines the data format
  91926. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91927. * @param invertY defines if data must be stored with Y axis inverted
  91928. * @param compression defines the compression used (null by default)
  91929. */
  91930. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91931. /**
  91932. * Update a raw cube texture
  91933. * @param texture defines the texture to udpdate
  91934. * @param data defines the data to store
  91935. * @param format defines the data format
  91936. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91937. * @param invertY defines if data must be stored with Y axis inverted
  91938. * @param compression defines the compression used (null by default)
  91939. * @param level defines which level of the texture to update
  91940. */
  91941. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91942. /**
  91943. * Creates a new raw cube texture from a specified url
  91944. * @param url defines the url where the data is located
  91945. * @param scene defines the current scene
  91946. * @param size defines the size of the textures
  91947. * @param format defines the format of the data
  91948. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91949. * @param noMipmap defines if the engine should avoid generating the mip levels
  91950. * @param callback defines a callback used to extract texture data from loaded data
  91951. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91952. * @param onLoad defines a callback called when texture is loaded
  91953. * @param onError defines a callback called if there is an error
  91954. * @returns the cube texture as an InternalTexture
  91955. */
  91956. 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;
  91957. /**
  91958. * Creates a new raw cube texture from a specified url
  91959. * @param url defines the url where the data is located
  91960. * @param scene defines the current scene
  91961. * @param size defines the size of the textures
  91962. * @param format defines the format of the data
  91963. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91964. * @param noMipmap defines if the engine should avoid generating the mip levels
  91965. * @param callback defines a callback used to extract texture data from loaded data
  91966. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91967. * @param onLoad defines a callback called when texture is loaded
  91968. * @param onError defines a callback called if there is an error
  91969. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91970. * @param invertY defines if data must be stored with Y axis inverted
  91971. * @returns the cube texture as an InternalTexture
  91972. */
  91973. 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;
  91974. /**
  91975. * Creates a new raw 3D texture
  91976. * @param data defines the data used to create the texture
  91977. * @param width defines the width of the texture
  91978. * @param height defines the height of the texture
  91979. * @param depth defines the depth of the texture
  91980. * @param format defines the format of the texture
  91981. * @param generateMipMaps defines if the engine must generate mip levels
  91982. * @param invertY defines if data must be stored with Y axis inverted
  91983. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91984. * @param compression defines the compressed used (can be null)
  91985. * @param textureType defines the compressed used (can be null)
  91986. * @returns a new raw 3D texture (stored in an InternalTexture)
  91987. */
  91988. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91989. /**
  91990. * Update a raw 3D texture
  91991. * @param texture defines the texture to update
  91992. * @param data defines the data to store
  91993. * @param format defines the data format
  91994. * @param invertY defines if data must be stored with Y axis inverted
  91995. */
  91996. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91997. /**
  91998. * Update a raw 3D texture
  91999. * @param texture defines the texture to update
  92000. * @param data defines the data to store
  92001. * @param format defines the data format
  92002. * @param invertY defines if data must be stored with Y axis inverted
  92003. * @param compression defines the used compression (can be null)
  92004. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92005. */
  92006. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92007. /**
  92008. * Creates a new raw 2D array texture
  92009. * @param data defines the data used to create the texture
  92010. * @param width defines the width of the texture
  92011. * @param height defines the height of the texture
  92012. * @param depth defines the number of layers of the texture
  92013. * @param format defines the format of the texture
  92014. * @param generateMipMaps defines if the engine must generate mip levels
  92015. * @param invertY defines if data must be stored with Y axis inverted
  92016. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92017. * @param compression defines the compressed used (can be null)
  92018. * @param textureType defines the compressed used (can be null)
  92019. * @returns a new raw 2D array texture (stored in an InternalTexture)
  92020. */
  92021. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92022. /**
  92023. * Update a raw 2D array texture
  92024. * @param texture defines the texture to update
  92025. * @param data defines the data to store
  92026. * @param format defines the data format
  92027. * @param invertY defines if data must be stored with Y axis inverted
  92028. */
  92029. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92030. /**
  92031. * Update a raw 2D array texture
  92032. * @param texture defines the texture to update
  92033. * @param data defines the data to store
  92034. * @param format defines the data format
  92035. * @param invertY defines if data must be stored with Y axis inverted
  92036. * @param compression defines the used compression (can be null)
  92037. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92038. */
  92039. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92040. }
  92041. }
  92042. declare module BABYLON {
  92043. /**
  92044. * Raw texture can help creating a texture directly from an array of data.
  92045. * This can be super useful if you either get the data from an uncompressed source or
  92046. * if you wish to create your texture pixel by pixel.
  92047. */
  92048. export class RawTexture extends Texture {
  92049. /**
  92050. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92051. */
  92052. format: number;
  92053. /**
  92054. * Instantiates a new RawTexture.
  92055. * Raw texture can help creating a texture directly from an array of data.
  92056. * This can be super useful if you either get the data from an uncompressed source or
  92057. * if you wish to create your texture pixel by pixel.
  92058. * @param data define the array of data to use to create the texture
  92059. * @param width define the width of the texture
  92060. * @param height define the height of the texture
  92061. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92062. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92063. * @param generateMipMaps define whether mip maps should be generated or not
  92064. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92065. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92066. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92067. */
  92068. constructor(data: ArrayBufferView, width: number, height: number,
  92069. /**
  92070. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92071. */
  92072. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92073. /**
  92074. * Updates the texture underlying data.
  92075. * @param data Define the new data of the texture
  92076. */
  92077. update(data: ArrayBufferView): void;
  92078. /**
  92079. * Creates a luminance texture from some data.
  92080. * @param data Define the texture data
  92081. * @param width Define the width of the texture
  92082. * @param height Define the height of the texture
  92083. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92084. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92085. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92086. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92087. * @returns the luminance texture
  92088. */
  92089. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92090. /**
  92091. * Creates a luminance alpha texture from some data.
  92092. * @param data Define the texture data
  92093. * @param width Define the width of the texture
  92094. * @param height Define the height of the texture
  92095. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92096. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92097. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92098. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92099. * @returns the luminance alpha texture
  92100. */
  92101. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92102. /**
  92103. * Creates an alpha texture from some data.
  92104. * @param data Define the texture data
  92105. * @param width Define the width of the texture
  92106. * @param height Define the height of the texture
  92107. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92108. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92109. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92110. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92111. * @returns the alpha texture
  92112. */
  92113. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92114. /**
  92115. * Creates a RGB texture from some data.
  92116. * @param data Define the texture data
  92117. * @param width Define the width of the texture
  92118. * @param height Define the height of the texture
  92119. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92120. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92121. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92122. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92123. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92124. * @returns the RGB alpha texture
  92125. */
  92126. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92127. /**
  92128. * Creates a RGBA texture from some data.
  92129. * @param data Define the texture data
  92130. * @param width Define the width of the texture
  92131. * @param height Define the height of the texture
  92132. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92133. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92134. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92135. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92136. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92137. * @returns the RGBA texture
  92138. */
  92139. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92140. /**
  92141. * Creates a R texture from some data.
  92142. * @param data Define the texture data
  92143. * @param width Define the width of the texture
  92144. * @param height Define the height of the texture
  92145. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92146. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92147. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92148. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92149. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92150. * @returns the R texture
  92151. */
  92152. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92153. }
  92154. }
  92155. declare module BABYLON {
  92156. interface ThinEngine {
  92157. /**
  92158. * Update a dynamic index buffer
  92159. * @param indexBuffer defines the target index buffer
  92160. * @param indices defines the data to update
  92161. * @param offset defines the offset in the target index buffer where update should start
  92162. */
  92163. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92164. /**
  92165. * Updates a dynamic vertex buffer.
  92166. * @param vertexBuffer the vertex buffer to update
  92167. * @param data the data used to update the vertex buffer
  92168. * @param byteOffset the byte offset of the data
  92169. * @param byteLength the byte length of the data
  92170. */
  92171. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92172. }
  92173. }
  92174. declare module BABYLON {
  92175. interface AbstractScene {
  92176. /**
  92177. * The list of procedural textures added to the scene
  92178. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92179. */
  92180. proceduralTextures: Array<ProceduralTexture>;
  92181. }
  92182. /**
  92183. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92184. * in a given scene.
  92185. */
  92186. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92187. /**
  92188. * The component name helpfull to identify the component in the list of scene components.
  92189. */
  92190. readonly name: string;
  92191. /**
  92192. * The scene the component belongs to.
  92193. */
  92194. scene: Scene;
  92195. /**
  92196. * Creates a new instance of the component for the given scene
  92197. * @param scene Defines the scene to register the component in
  92198. */
  92199. constructor(scene: Scene);
  92200. /**
  92201. * Registers the component in a given scene
  92202. */
  92203. register(): void;
  92204. /**
  92205. * Rebuilds the elements related to this component in case of
  92206. * context lost for instance.
  92207. */
  92208. rebuild(): void;
  92209. /**
  92210. * Disposes the component and the associated ressources.
  92211. */
  92212. dispose(): void;
  92213. private _beforeClear;
  92214. }
  92215. }
  92216. declare module BABYLON {
  92217. interface ThinEngine {
  92218. /**
  92219. * Creates a new render target cube texture
  92220. * @param size defines the size of the texture
  92221. * @param options defines the options used to create the texture
  92222. * @returns a new render target cube texture stored in an InternalTexture
  92223. */
  92224. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92225. }
  92226. }
  92227. declare module BABYLON {
  92228. /** @hidden */
  92229. export var proceduralVertexShader: {
  92230. name: string;
  92231. shader: string;
  92232. };
  92233. }
  92234. declare module BABYLON {
  92235. /**
  92236. * 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.
  92237. * This is the base class of any Procedural texture and contains most of the shareable code.
  92238. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92239. */
  92240. export class ProceduralTexture extends Texture {
  92241. /**
  92242. * Define if the texture is enabled or not (disabled texture will not render)
  92243. */
  92244. isEnabled: boolean;
  92245. /**
  92246. * Define if the texture must be cleared before rendering (default is true)
  92247. */
  92248. autoClear: boolean;
  92249. /**
  92250. * Callback called when the texture is generated
  92251. */
  92252. onGenerated: () => void;
  92253. /**
  92254. * Event raised when the texture is generated
  92255. */
  92256. onGeneratedObservable: Observable<ProceduralTexture>;
  92257. /**
  92258. * Event raised before the texture is generated
  92259. */
  92260. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92261. /**
  92262. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92263. */
  92264. nodeMaterialSource: Nullable<NodeMaterial>;
  92265. /** @hidden */
  92266. _generateMipMaps: boolean;
  92267. /** @hidden **/
  92268. _effect: Effect;
  92269. /** @hidden */
  92270. _textures: {
  92271. [key: string]: Texture;
  92272. };
  92273. /** @hidden */
  92274. protected _fallbackTexture: Nullable<Texture>;
  92275. private _size;
  92276. private _currentRefreshId;
  92277. private _frameId;
  92278. private _refreshRate;
  92279. private _vertexBuffers;
  92280. private _indexBuffer;
  92281. private _uniforms;
  92282. private _samplers;
  92283. private _fragment;
  92284. private _floats;
  92285. private _ints;
  92286. private _floatsArrays;
  92287. private _colors3;
  92288. private _colors4;
  92289. private _vectors2;
  92290. private _vectors3;
  92291. private _matrices;
  92292. private _fallbackTextureUsed;
  92293. private _fullEngine;
  92294. private _cachedDefines;
  92295. private _contentUpdateId;
  92296. private _contentData;
  92297. /**
  92298. * Instantiates a new procedural texture.
  92299. * 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.
  92300. * This is the base class of any Procedural texture and contains most of the shareable code.
  92301. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92302. * @param name Define the name of the texture
  92303. * @param size Define the size of the texture to create
  92304. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92305. * @param scene Define the scene the texture belongs to
  92306. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92307. * @param generateMipMaps Define if the texture should creates mip maps or not
  92308. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92309. * @param textureType The FBO internal texture type
  92310. */
  92311. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  92312. /**
  92313. * The effect that is created when initializing the post process.
  92314. * @returns The created effect corresponding the the postprocess.
  92315. */
  92316. getEffect(): Effect;
  92317. /**
  92318. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92319. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92320. */
  92321. getContent(): Nullable<ArrayBufferView>;
  92322. private _createIndexBuffer;
  92323. /** @hidden */
  92324. _rebuild(): void;
  92325. /**
  92326. * Resets the texture in order to recreate its associated resources.
  92327. * This can be called in case of context loss
  92328. */
  92329. reset(): void;
  92330. protected _getDefines(): string;
  92331. /**
  92332. * Is the texture ready to be used ? (rendered at least once)
  92333. * @returns true if ready, otherwise, false.
  92334. */
  92335. isReady(): boolean;
  92336. /**
  92337. * Resets the refresh counter of the texture and start bak from scratch.
  92338. * Could be useful to regenerate the texture if it is setup to render only once.
  92339. */
  92340. resetRefreshCounter(): void;
  92341. /**
  92342. * Set the fragment shader to use in order to render the texture.
  92343. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92344. */
  92345. setFragment(fragment: any): void;
  92346. /**
  92347. * Define the refresh rate of the texture or the rendering frequency.
  92348. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92349. */
  92350. get refreshRate(): number;
  92351. set refreshRate(value: number);
  92352. /** @hidden */
  92353. _shouldRender(): boolean;
  92354. /**
  92355. * Get the size the texture is rendering at.
  92356. * @returns the size (on cube texture it is always squared)
  92357. */
  92358. getRenderSize(): RenderTargetTextureSize;
  92359. /**
  92360. * Resize the texture to new value.
  92361. * @param size Define the new size the texture should have
  92362. * @param generateMipMaps Define whether the new texture should create mip maps
  92363. */
  92364. resize(size: number, generateMipMaps: boolean): void;
  92365. private _checkUniform;
  92366. /**
  92367. * Set a texture in the shader program used to render.
  92368. * @param name Define the name of the uniform samplers as defined in the shader
  92369. * @param texture Define the texture to bind to this sampler
  92370. * @return the texture itself allowing "fluent" like uniform updates
  92371. */
  92372. setTexture(name: string, texture: Texture): ProceduralTexture;
  92373. /**
  92374. * Set a float in the shader.
  92375. * @param name Define the name of the uniform as defined in the shader
  92376. * @param value Define the value to give to the uniform
  92377. * @return the texture itself allowing "fluent" like uniform updates
  92378. */
  92379. setFloat(name: string, value: number): ProceduralTexture;
  92380. /**
  92381. * Set a int in the shader.
  92382. * @param name Define the name of the uniform as defined in the shader
  92383. * @param value Define the value to give to the uniform
  92384. * @return the texture itself allowing "fluent" like uniform updates
  92385. */
  92386. setInt(name: string, value: number): ProceduralTexture;
  92387. /**
  92388. * Set an array of floats in the shader.
  92389. * @param name Define the name of the uniform as defined in the shader
  92390. * @param value Define the value to give to the uniform
  92391. * @return the texture itself allowing "fluent" like uniform updates
  92392. */
  92393. setFloats(name: string, value: number[]): ProceduralTexture;
  92394. /**
  92395. * Set a vec3 in the shader from a Color3.
  92396. * @param name Define the name of the uniform as defined in the shader
  92397. * @param value Define the value to give to the uniform
  92398. * @return the texture itself allowing "fluent" like uniform updates
  92399. */
  92400. setColor3(name: string, value: Color3): ProceduralTexture;
  92401. /**
  92402. * Set a vec4 in the shader from a Color4.
  92403. * @param name Define the name of the uniform as defined in the shader
  92404. * @param value Define the value to give to the uniform
  92405. * @return the texture itself allowing "fluent" like uniform updates
  92406. */
  92407. setColor4(name: string, value: Color4): ProceduralTexture;
  92408. /**
  92409. * Set a vec2 in the shader from a Vector2.
  92410. * @param name Define the name of the uniform as defined in the shader
  92411. * @param value Define the value to give to the uniform
  92412. * @return the texture itself allowing "fluent" like uniform updates
  92413. */
  92414. setVector2(name: string, value: Vector2): ProceduralTexture;
  92415. /**
  92416. * Set a vec3 in the shader from a Vector3.
  92417. * @param name Define the name of the uniform as defined in the shader
  92418. * @param value Define the value to give to the uniform
  92419. * @return the texture itself allowing "fluent" like uniform updates
  92420. */
  92421. setVector3(name: string, value: Vector3): ProceduralTexture;
  92422. /**
  92423. * Set a mat4 in the shader from a MAtrix.
  92424. * @param name Define the name of the uniform as defined in the shader
  92425. * @param value Define the value to give to the uniform
  92426. * @return the texture itself allowing "fluent" like uniform updates
  92427. */
  92428. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92429. /**
  92430. * Render the texture to its associated render target.
  92431. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92432. */
  92433. render(useCameraPostProcess?: boolean): void;
  92434. /**
  92435. * Clone the texture.
  92436. * @returns the cloned texture
  92437. */
  92438. clone(): ProceduralTexture;
  92439. /**
  92440. * Dispose the texture and release its asoociated resources.
  92441. */
  92442. dispose(): void;
  92443. }
  92444. }
  92445. declare module BABYLON {
  92446. /**
  92447. * This represents the base class for particle system in Babylon.
  92448. * 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.
  92449. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92450. * @example https://doc.babylonjs.com/babylon101/particles
  92451. */
  92452. export class BaseParticleSystem {
  92453. /**
  92454. * Source color is added to the destination color without alpha affecting the result
  92455. */
  92456. static BLENDMODE_ONEONE: number;
  92457. /**
  92458. * Blend current color and particle color using particle’s alpha
  92459. */
  92460. static BLENDMODE_STANDARD: number;
  92461. /**
  92462. * Add current color and particle color multiplied by particle’s alpha
  92463. */
  92464. static BLENDMODE_ADD: number;
  92465. /**
  92466. * Multiply current color with particle color
  92467. */
  92468. static BLENDMODE_MULTIPLY: number;
  92469. /**
  92470. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92471. */
  92472. static BLENDMODE_MULTIPLYADD: number;
  92473. /**
  92474. * List of animations used by the particle system.
  92475. */
  92476. animations: Animation[];
  92477. /**
  92478. * Gets or sets the unique id of the particle system
  92479. */
  92480. uniqueId: number;
  92481. /**
  92482. * The id of the Particle system.
  92483. */
  92484. id: string;
  92485. /**
  92486. * The friendly name of the Particle system.
  92487. */
  92488. name: string;
  92489. /**
  92490. * Snippet ID if the particle system was created from the snippet server
  92491. */
  92492. snippetId: string;
  92493. /**
  92494. * The rendering group used by the Particle system to chose when to render.
  92495. */
  92496. renderingGroupId: number;
  92497. /**
  92498. * The emitter represents the Mesh or position we are attaching the particle system to.
  92499. */
  92500. emitter: Nullable<AbstractMesh | Vector3>;
  92501. /**
  92502. * The maximum number of particles to emit per frame
  92503. */
  92504. emitRate: number;
  92505. /**
  92506. * If you want to launch only a few particles at once, that can be done, as well.
  92507. */
  92508. manualEmitCount: number;
  92509. /**
  92510. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92511. */
  92512. updateSpeed: number;
  92513. /**
  92514. * The amount of time the particle system is running (depends of the overall update speed).
  92515. */
  92516. targetStopDuration: number;
  92517. /**
  92518. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92519. */
  92520. disposeOnStop: boolean;
  92521. /**
  92522. * Minimum power of emitting particles.
  92523. */
  92524. minEmitPower: number;
  92525. /**
  92526. * Maximum power of emitting particles.
  92527. */
  92528. maxEmitPower: number;
  92529. /**
  92530. * Minimum life time of emitting particles.
  92531. */
  92532. minLifeTime: number;
  92533. /**
  92534. * Maximum life time of emitting particles.
  92535. */
  92536. maxLifeTime: number;
  92537. /**
  92538. * Minimum Size of emitting particles.
  92539. */
  92540. minSize: number;
  92541. /**
  92542. * Maximum Size of emitting particles.
  92543. */
  92544. maxSize: number;
  92545. /**
  92546. * Minimum scale of emitting particles on X axis.
  92547. */
  92548. minScaleX: number;
  92549. /**
  92550. * Maximum scale of emitting particles on X axis.
  92551. */
  92552. maxScaleX: number;
  92553. /**
  92554. * Minimum scale of emitting particles on Y axis.
  92555. */
  92556. minScaleY: number;
  92557. /**
  92558. * Maximum scale of emitting particles on Y axis.
  92559. */
  92560. maxScaleY: number;
  92561. /**
  92562. * Gets or sets the minimal initial rotation in radians.
  92563. */
  92564. minInitialRotation: number;
  92565. /**
  92566. * Gets or sets the maximal initial rotation in radians.
  92567. */
  92568. maxInitialRotation: number;
  92569. /**
  92570. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92571. */
  92572. minAngularSpeed: number;
  92573. /**
  92574. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92575. */
  92576. maxAngularSpeed: number;
  92577. /**
  92578. * The texture used to render each particle. (this can be a spritesheet)
  92579. */
  92580. particleTexture: Nullable<BaseTexture>;
  92581. /**
  92582. * The layer mask we are rendering the particles through.
  92583. */
  92584. layerMask: number;
  92585. /**
  92586. * This can help using your own shader to render the particle system.
  92587. * The according effect will be created
  92588. */
  92589. customShader: any;
  92590. /**
  92591. * By default particle system starts as soon as they are created. This prevents the
  92592. * automatic start to happen and let you decide when to start emitting particles.
  92593. */
  92594. preventAutoStart: boolean;
  92595. private _noiseTexture;
  92596. /**
  92597. * Gets or sets a texture used to add random noise to particle positions
  92598. */
  92599. get noiseTexture(): Nullable<ProceduralTexture>;
  92600. set noiseTexture(value: Nullable<ProceduralTexture>);
  92601. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92602. noiseStrength: Vector3;
  92603. /**
  92604. * Callback triggered when the particle animation is ending.
  92605. */
  92606. onAnimationEnd: Nullable<() => void>;
  92607. /**
  92608. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92609. */
  92610. blendMode: number;
  92611. /**
  92612. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92613. * to override the particles.
  92614. */
  92615. forceDepthWrite: boolean;
  92616. /** 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 */
  92617. preWarmCycles: number;
  92618. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92619. preWarmStepOffset: number;
  92620. /**
  92621. * 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)
  92622. */
  92623. spriteCellChangeSpeed: number;
  92624. /**
  92625. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92626. */
  92627. startSpriteCellID: number;
  92628. /**
  92629. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92630. */
  92631. endSpriteCellID: number;
  92632. /**
  92633. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92634. */
  92635. spriteCellWidth: number;
  92636. /**
  92637. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92638. */
  92639. spriteCellHeight: number;
  92640. /**
  92641. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92642. */
  92643. spriteRandomStartCell: boolean;
  92644. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92645. translationPivot: Vector2;
  92646. /** @hidden */
  92647. protected _isAnimationSheetEnabled: boolean;
  92648. /**
  92649. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92650. */
  92651. beginAnimationOnStart: boolean;
  92652. /**
  92653. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92654. */
  92655. beginAnimationFrom: number;
  92656. /**
  92657. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92658. */
  92659. beginAnimationTo: number;
  92660. /**
  92661. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92662. */
  92663. beginAnimationLoop: boolean;
  92664. /**
  92665. * Gets or sets a world offset applied to all particles
  92666. */
  92667. worldOffset: Vector3;
  92668. /**
  92669. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92670. */
  92671. get isAnimationSheetEnabled(): boolean;
  92672. set isAnimationSheetEnabled(value: boolean);
  92673. /**
  92674. * Get hosting scene
  92675. * @returns the scene
  92676. */
  92677. getScene(): Nullable<Scene>;
  92678. /**
  92679. * You can use gravity if you want to give an orientation to your particles.
  92680. */
  92681. gravity: Vector3;
  92682. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92683. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92684. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92685. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92686. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92687. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92688. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92689. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92690. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92691. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92692. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92693. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92694. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92695. /**
  92696. * Defines the delay in milliseconds before starting the system (0 by default)
  92697. */
  92698. startDelay: number;
  92699. /**
  92700. * Gets the current list of drag gradients.
  92701. * You must use addDragGradient and removeDragGradient to udpate this list
  92702. * @returns the list of drag gradients
  92703. */
  92704. getDragGradients(): Nullable<Array<FactorGradient>>;
  92705. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92706. limitVelocityDamping: number;
  92707. /**
  92708. * Gets the current list of limit velocity gradients.
  92709. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92710. * @returns the list of limit velocity gradients
  92711. */
  92712. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92713. /**
  92714. * Gets the current list of color gradients.
  92715. * You must use addColorGradient and removeColorGradient to udpate this list
  92716. * @returns the list of color gradients
  92717. */
  92718. getColorGradients(): Nullable<Array<ColorGradient>>;
  92719. /**
  92720. * Gets the current list of size gradients.
  92721. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92722. * @returns the list of size gradients
  92723. */
  92724. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92725. /**
  92726. * Gets the current list of color remap gradients.
  92727. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92728. * @returns the list of color remap gradients
  92729. */
  92730. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92731. /**
  92732. * Gets the current list of alpha remap gradients.
  92733. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92734. * @returns the list of alpha remap gradients
  92735. */
  92736. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92737. /**
  92738. * Gets the current list of life time gradients.
  92739. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92740. * @returns the list of life time gradients
  92741. */
  92742. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92743. /**
  92744. * Gets the current list of angular speed gradients.
  92745. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92746. * @returns the list of angular speed gradients
  92747. */
  92748. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92749. /**
  92750. * Gets the current list of velocity gradients.
  92751. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92752. * @returns the list of velocity gradients
  92753. */
  92754. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92755. /**
  92756. * Gets the current list of start size gradients.
  92757. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92758. * @returns the list of start size gradients
  92759. */
  92760. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92761. /**
  92762. * Gets the current list of emit rate gradients.
  92763. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92764. * @returns the list of emit rate gradients
  92765. */
  92766. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92767. /**
  92768. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92769. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92770. */
  92771. get direction1(): Vector3;
  92772. set direction1(value: Vector3);
  92773. /**
  92774. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92775. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92776. */
  92777. get direction2(): Vector3;
  92778. set direction2(value: Vector3);
  92779. /**
  92780. * 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.
  92781. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92782. */
  92783. get minEmitBox(): Vector3;
  92784. set minEmitBox(value: Vector3);
  92785. /**
  92786. * 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.
  92787. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92788. */
  92789. get maxEmitBox(): Vector3;
  92790. set maxEmitBox(value: Vector3);
  92791. /**
  92792. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92793. */
  92794. color1: Color4;
  92795. /**
  92796. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92797. */
  92798. color2: Color4;
  92799. /**
  92800. * Color the particle will have at the end of its lifetime
  92801. */
  92802. colorDead: Color4;
  92803. /**
  92804. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92805. */
  92806. textureMask: Color4;
  92807. /**
  92808. * The particle emitter type defines the emitter used by the particle system.
  92809. * It can be for example box, sphere, or cone...
  92810. */
  92811. particleEmitterType: IParticleEmitterType;
  92812. /** @hidden */
  92813. _isSubEmitter: boolean;
  92814. /**
  92815. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92816. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92817. */
  92818. billboardMode: number;
  92819. protected _isBillboardBased: boolean;
  92820. /**
  92821. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92822. */
  92823. get isBillboardBased(): boolean;
  92824. set isBillboardBased(value: boolean);
  92825. /**
  92826. * The scene the particle system belongs to.
  92827. */
  92828. protected _scene: Nullable<Scene>;
  92829. /**
  92830. * The engine the particle system belongs to.
  92831. */
  92832. protected _engine: ThinEngine;
  92833. /**
  92834. * Local cache of defines for image processing.
  92835. */
  92836. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92837. /**
  92838. * Default configuration related to image processing available in the standard Material.
  92839. */
  92840. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92841. /**
  92842. * Gets the image processing configuration used either in this material.
  92843. */
  92844. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92845. /**
  92846. * Sets the Default image processing configuration used either in the this material.
  92847. *
  92848. * If sets to null, the scene one is in use.
  92849. */
  92850. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92851. /**
  92852. * Attaches a new image processing configuration to the Standard Material.
  92853. * @param configuration
  92854. */
  92855. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92856. /** @hidden */
  92857. protected _reset(): void;
  92858. /** @hidden */
  92859. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92860. /**
  92861. * Instantiates a particle system.
  92862. * 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.
  92863. * @param name The name of the particle system
  92864. */
  92865. constructor(name: string);
  92866. /**
  92867. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92868. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92869. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92870. * @returns the emitter
  92871. */
  92872. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92873. /**
  92874. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92875. * @param radius The radius of the hemisphere to emit from
  92876. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92877. * @returns the emitter
  92878. */
  92879. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92880. /**
  92881. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92882. * @param radius The radius of the sphere to emit from
  92883. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92884. * @returns the emitter
  92885. */
  92886. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92887. /**
  92888. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92889. * @param radius The radius of the sphere to emit from
  92890. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92891. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92892. * @returns the emitter
  92893. */
  92894. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92895. /**
  92896. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92897. * @param radius The radius of the emission cylinder
  92898. * @param height The height of the emission cylinder
  92899. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92900. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92901. * @returns the emitter
  92902. */
  92903. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92904. /**
  92905. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92906. * @param radius The radius of the cylinder to emit from
  92907. * @param height The height of the emission cylinder
  92908. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92909. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92910. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92911. * @returns the emitter
  92912. */
  92913. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92914. /**
  92915. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92916. * @param radius The radius of the cone to emit from
  92917. * @param angle The base angle of the cone
  92918. * @returns the emitter
  92919. */
  92920. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92921. /**
  92922. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92923. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92924. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92925. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92926. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92927. * @returns the emitter
  92928. */
  92929. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92930. }
  92931. }
  92932. declare module BABYLON {
  92933. /**
  92934. * Type of sub emitter
  92935. */
  92936. export enum SubEmitterType {
  92937. /**
  92938. * Attached to the particle over it's lifetime
  92939. */
  92940. ATTACHED = 0,
  92941. /**
  92942. * Created when the particle dies
  92943. */
  92944. END = 1
  92945. }
  92946. /**
  92947. * Sub emitter class used to emit particles from an existing particle
  92948. */
  92949. export class SubEmitter {
  92950. /**
  92951. * the particle system to be used by the sub emitter
  92952. */
  92953. particleSystem: ParticleSystem;
  92954. /**
  92955. * Type of the submitter (Default: END)
  92956. */
  92957. type: SubEmitterType;
  92958. /**
  92959. * 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)
  92960. * Note: This only is supported when using an emitter of type Mesh
  92961. */
  92962. inheritDirection: boolean;
  92963. /**
  92964. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92965. */
  92966. inheritedVelocityAmount: number;
  92967. /**
  92968. * Creates a sub emitter
  92969. * @param particleSystem the particle system to be used by the sub emitter
  92970. */
  92971. constructor(
  92972. /**
  92973. * the particle system to be used by the sub emitter
  92974. */
  92975. particleSystem: ParticleSystem);
  92976. /**
  92977. * Clones the sub emitter
  92978. * @returns the cloned sub emitter
  92979. */
  92980. clone(): SubEmitter;
  92981. /**
  92982. * Serialize current object to a JSON object
  92983. * @returns the serialized object
  92984. */
  92985. serialize(): any;
  92986. /** @hidden */
  92987. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92988. /**
  92989. * Creates a new SubEmitter from a serialized JSON version
  92990. * @param serializationObject defines the JSON object to read from
  92991. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92992. * @param rootUrl defines the rootUrl for data loading
  92993. * @returns a new SubEmitter
  92994. */
  92995. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92996. /** Release associated resources */
  92997. dispose(): void;
  92998. }
  92999. }
  93000. declare module BABYLON {
  93001. /** @hidden */
  93002. export var imageProcessingDeclaration: {
  93003. name: string;
  93004. shader: string;
  93005. };
  93006. }
  93007. declare module BABYLON {
  93008. /** @hidden */
  93009. export var imageProcessingFunctions: {
  93010. name: string;
  93011. shader: string;
  93012. };
  93013. }
  93014. declare module BABYLON {
  93015. /** @hidden */
  93016. export var particlesPixelShader: {
  93017. name: string;
  93018. shader: string;
  93019. };
  93020. }
  93021. declare module BABYLON {
  93022. /** @hidden */
  93023. export var particlesVertexShader: {
  93024. name: string;
  93025. shader: string;
  93026. };
  93027. }
  93028. declare module BABYLON {
  93029. /**
  93030. * Interface used to define entities containing multiple clip planes
  93031. */
  93032. export interface IClipPlanesHolder {
  93033. /**
  93034. * Gets or sets the active clipplane 1
  93035. */
  93036. clipPlane: Nullable<Plane>;
  93037. /**
  93038. * Gets or sets the active clipplane 2
  93039. */
  93040. clipPlane2: Nullable<Plane>;
  93041. /**
  93042. * Gets or sets the active clipplane 3
  93043. */
  93044. clipPlane3: Nullable<Plane>;
  93045. /**
  93046. * Gets or sets the active clipplane 4
  93047. */
  93048. clipPlane4: Nullable<Plane>;
  93049. /**
  93050. * Gets or sets the active clipplane 5
  93051. */
  93052. clipPlane5: Nullable<Plane>;
  93053. /**
  93054. * Gets or sets the active clipplane 6
  93055. */
  93056. clipPlane6: Nullable<Plane>;
  93057. }
  93058. }
  93059. declare module BABYLON {
  93060. /**
  93061. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93062. *
  93063. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93064. *
  93065. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93066. */
  93067. export class ThinMaterialHelper {
  93068. /**
  93069. * Binds the clip plane information from the holder to the effect.
  93070. * @param effect The effect we are binding the data to
  93071. * @param holder The entity containing the clip plane information
  93072. */
  93073. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93074. }
  93075. }
  93076. declare module BABYLON {
  93077. interface ThinEngine {
  93078. /**
  93079. * Sets alpha constants used by some alpha blending modes
  93080. * @param r defines the red component
  93081. * @param g defines the green component
  93082. * @param b defines the blue component
  93083. * @param a defines the alpha component
  93084. */
  93085. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93086. /**
  93087. * Sets the current alpha mode
  93088. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93089. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93090. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93091. */
  93092. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93093. /**
  93094. * Gets the current alpha mode
  93095. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93096. * @returns the current alpha mode
  93097. */
  93098. getAlphaMode(): number;
  93099. /**
  93100. * Sets the current alpha equation
  93101. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93102. */
  93103. setAlphaEquation(equation: number): void;
  93104. /**
  93105. * Gets the current alpha equation.
  93106. * @returns the current alpha equation
  93107. */
  93108. getAlphaEquation(): number;
  93109. }
  93110. }
  93111. declare module BABYLON {
  93112. /**
  93113. * This represents a particle system in Babylon.
  93114. * 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.
  93115. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93116. * @example https://doc.babylonjs.com/babylon101/particles
  93117. */
  93118. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93119. /**
  93120. * Billboard mode will only apply to Y axis
  93121. */
  93122. static readonly BILLBOARDMODE_Y: number;
  93123. /**
  93124. * Billboard mode will apply to all axes
  93125. */
  93126. static readonly BILLBOARDMODE_ALL: number;
  93127. /**
  93128. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93129. */
  93130. static readonly BILLBOARDMODE_STRETCHED: number;
  93131. /**
  93132. * This function can be defined to provide custom update for active particles.
  93133. * This function will be called instead of regular update (age, position, color, etc.).
  93134. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93135. */
  93136. updateFunction: (particles: Particle[]) => void;
  93137. private _emitterWorldMatrix;
  93138. /**
  93139. * This function can be defined to specify initial direction for every new particle.
  93140. * It by default use the emitterType defined function
  93141. */
  93142. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93143. /**
  93144. * This function can be defined to specify initial position for every new particle.
  93145. * It by default use the emitterType defined function
  93146. */
  93147. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93148. /**
  93149. * @hidden
  93150. */
  93151. _inheritedVelocityOffset: Vector3;
  93152. /**
  93153. * An event triggered when the system is disposed
  93154. */
  93155. onDisposeObservable: Observable<IParticleSystem>;
  93156. private _onDisposeObserver;
  93157. /**
  93158. * Sets a callback that will be triggered when the system is disposed
  93159. */
  93160. set onDispose(callback: () => void);
  93161. private _particles;
  93162. private _epsilon;
  93163. private _capacity;
  93164. private _stockParticles;
  93165. private _newPartsExcess;
  93166. private _vertexData;
  93167. private _vertexBuffer;
  93168. private _vertexBuffers;
  93169. private _spriteBuffer;
  93170. private _indexBuffer;
  93171. private _effect;
  93172. private _customEffect;
  93173. private _cachedDefines;
  93174. private _scaledColorStep;
  93175. private _colorDiff;
  93176. private _scaledDirection;
  93177. private _scaledGravity;
  93178. private _currentRenderId;
  93179. private _alive;
  93180. private _useInstancing;
  93181. private _started;
  93182. private _stopped;
  93183. private _actualFrame;
  93184. private _scaledUpdateSpeed;
  93185. private _vertexBufferSize;
  93186. /** @hidden */
  93187. _currentEmitRateGradient: Nullable<FactorGradient>;
  93188. /** @hidden */
  93189. _currentEmitRate1: number;
  93190. /** @hidden */
  93191. _currentEmitRate2: number;
  93192. /** @hidden */
  93193. _currentStartSizeGradient: Nullable<FactorGradient>;
  93194. /** @hidden */
  93195. _currentStartSize1: number;
  93196. /** @hidden */
  93197. _currentStartSize2: number;
  93198. private readonly _rawTextureWidth;
  93199. private _rampGradientsTexture;
  93200. private _useRampGradients;
  93201. /** Gets or sets a matrix to use to compute projection */
  93202. defaultProjectionMatrix: Matrix;
  93203. /** Gets or sets a matrix to use to compute view */
  93204. defaultViewMatrix: Matrix;
  93205. /** Gets or sets a boolean indicating that ramp gradients must be used
  93206. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93207. */
  93208. get useRampGradients(): boolean;
  93209. set useRampGradients(value: boolean);
  93210. /**
  93211. * 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.
  93212. * 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: [])
  93213. */
  93214. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93215. private _subEmitters;
  93216. /**
  93217. * @hidden
  93218. * If the particle systems emitter should be disposed when the particle system is disposed
  93219. */
  93220. _disposeEmitterOnDispose: boolean;
  93221. /**
  93222. * The current active Sub-systems, this property is used by the root particle system only.
  93223. */
  93224. activeSubSystems: Array<ParticleSystem>;
  93225. /**
  93226. * Specifies if the particles are updated in emitter local space or world space
  93227. */
  93228. isLocal: boolean;
  93229. private _rootParticleSystem;
  93230. /**
  93231. * Gets the current list of active particles
  93232. */
  93233. get particles(): Particle[];
  93234. /**
  93235. * Gets the number of particles active at the same time.
  93236. * @returns The number of active particles.
  93237. */
  93238. getActiveCount(): number;
  93239. /**
  93240. * Returns the string "ParticleSystem"
  93241. * @returns a string containing the class name
  93242. */
  93243. getClassName(): string;
  93244. /**
  93245. * Gets a boolean indicating that the system is stopping
  93246. * @returns true if the system is currently stopping
  93247. */
  93248. isStopping(): boolean;
  93249. /**
  93250. * Gets the custom effect used to render the particles
  93251. * @param blendMode Blend mode for which the effect should be retrieved
  93252. * @returns The effect
  93253. */
  93254. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93255. /**
  93256. * Sets the custom effect used to render the particles
  93257. * @param effect The effect to set
  93258. * @param blendMode Blend mode for which the effect should be set
  93259. */
  93260. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93261. /** @hidden */
  93262. private _onBeforeDrawParticlesObservable;
  93263. /**
  93264. * Observable that will be called just before the particles are drawn
  93265. */
  93266. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93267. /**
  93268. * Gets the name of the particle vertex shader
  93269. */
  93270. get vertexShaderName(): string;
  93271. /**
  93272. * Instantiates a particle system.
  93273. * 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.
  93274. * @param name The name of the particle system
  93275. * @param capacity The max number of particles alive at the same time
  93276. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93277. * @param customEffect a custom effect used to change the way particles are rendered by default
  93278. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93279. * @param epsilon Offset used to render the particles
  93280. */
  93281. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93282. private _addFactorGradient;
  93283. private _removeFactorGradient;
  93284. /**
  93285. * Adds a new life time gradient
  93286. * @param gradient defines the gradient to use (between 0 and 1)
  93287. * @param factor defines the life time factor to affect to the specified gradient
  93288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93289. * @returns the current particle system
  93290. */
  93291. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93292. /**
  93293. * Remove a specific life time gradient
  93294. * @param gradient defines the gradient to remove
  93295. * @returns the current particle system
  93296. */
  93297. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93298. /**
  93299. * Adds a new size gradient
  93300. * @param gradient defines the gradient to use (between 0 and 1)
  93301. * @param factor defines the size factor to affect to the specified gradient
  93302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93303. * @returns the current particle system
  93304. */
  93305. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93306. /**
  93307. * Remove a specific size gradient
  93308. * @param gradient defines the gradient to remove
  93309. * @returns the current particle system
  93310. */
  93311. removeSizeGradient(gradient: number): IParticleSystem;
  93312. /**
  93313. * Adds a new color remap gradient
  93314. * @param gradient defines the gradient to use (between 0 and 1)
  93315. * @param min defines the color remap minimal range
  93316. * @param max defines the color remap maximal range
  93317. * @returns the current particle system
  93318. */
  93319. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93320. /**
  93321. * Remove a specific color remap gradient
  93322. * @param gradient defines the gradient to remove
  93323. * @returns the current particle system
  93324. */
  93325. removeColorRemapGradient(gradient: number): IParticleSystem;
  93326. /**
  93327. * Adds a new alpha remap gradient
  93328. * @param gradient defines the gradient to use (between 0 and 1)
  93329. * @param min defines the alpha remap minimal range
  93330. * @param max defines the alpha remap maximal range
  93331. * @returns the current particle system
  93332. */
  93333. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93334. /**
  93335. * Remove a specific alpha remap gradient
  93336. * @param gradient defines the gradient to remove
  93337. * @returns the current particle system
  93338. */
  93339. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93340. /**
  93341. * Adds a new angular speed gradient
  93342. * @param gradient defines the gradient to use (between 0 and 1)
  93343. * @param factor defines the angular speed to affect to the specified gradient
  93344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93345. * @returns the current particle system
  93346. */
  93347. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93348. /**
  93349. * Remove a specific angular speed gradient
  93350. * @param gradient defines the gradient to remove
  93351. * @returns the current particle system
  93352. */
  93353. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93354. /**
  93355. * Adds a new velocity gradient
  93356. * @param gradient defines the gradient to use (between 0 and 1)
  93357. * @param factor defines the velocity to affect to the specified gradient
  93358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93359. * @returns the current particle system
  93360. */
  93361. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93362. /**
  93363. * Remove a specific velocity gradient
  93364. * @param gradient defines the gradient to remove
  93365. * @returns the current particle system
  93366. */
  93367. removeVelocityGradient(gradient: number): IParticleSystem;
  93368. /**
  93369. * Adds a new limit velocity gradient
  93370. * @param gradient defines the gradient to use (between 0 and 1)
  93371. * @param factor defines the limit velocity value to affect to the specified gradient
  93372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93373. * @returns the current particle system
  93374. */
  93375. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93376. /**
  93377. * Remove a specific limit velocity gradient
  93378. * @param gradient defines the gradient to remove
  93379. * @returns the current particle system
  93380. */
  93381. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93382. /**
  93383. * Adds a new drag gradient
  93384. * @param gradient defines the gradient to use (between 0 and 1)
  93385. * @param factor defines the drag value to affect to the specified gradient
  93386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93387. * @returns the current particle system
  93388. */
  93389. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93390. /**
  93391. * Remove a specific drag gradient
  93392. * @param gradient defines the gradient to remove
  93393. * @returns the current particle system
  93394. */
  93395. removeDragGradient(gradient: number): IParticleSystem;
  93396. /**
  93397. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93398. * @param gradient defines the gradient to use (between 0 and 1)
  93399. * @param factor defines the emit rate value to affect to the specified gradient
  93400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93401. * @returns the current particle system
  93402. */
  93403. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93404. /**
  93405. * Remove a specific emit rate gradient
  93406. * @param gradient defines the gradient to remove
  93407. * @returns the current particle system
  93408. */
  93409. removeEmitRateGradient(gradient: number): IParticleSystem;
  93410. /**
  93411. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93412. * @param gradient defines the gradient to use (between 0 and 1)
  93413. * @param factor defines the start size value to affect to the specified gradient
  93414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93415. * @returns the current particle system
  93416. */
  93417. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93418. /**
  93419. * Remove a specific start size gradient
  93420. * @param gradient defines the gradient to remove
  93421. * @returns the current particle system
  93422. */
  93423. removeStartSizeGradient(gradient: number): IParticleSystem;
  93424. private _createRampGradientTexture;
  93425. /**
  93426. * Gets the current list of ramp gradients.
  93427. * You must use addRampGradient and removeRampGradient to udpate this list
  93428. * @returns the list of ramp gradients
  93429. */
  93430. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93431. /** Force the system to rebuild all gradients that need to be resync */
  93432. forceRefreshGradients(): void;
  93433. private _syncRampGradientTexture;
  93434. /**
  93435. * Adds a new ramp gradient used to remap particle colors
  93436. * @param gradient defines the gradient to use (between 0 and 1)
  93437. * @param color defines the color to affect to the specified gradient
  93438. * @returns the current particle system
  93439. */
  93440. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93441. /**
  93442. * Remove a specific ramp gradient
  93443. * @param gradient defines the gradient to remove
  93444. * @returns the current particle system
  93445. */
  93446. removeRampGradient(gradient: number): ParticleSystem;
  93447. /**
  93448. * Adds a new color gradient
  93449. * @param gradient defines the gradient to use (between 0 and 1)
  93450. * @param color1 defines the color to affect to the specified gradient
  93451. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93452. * @returns this particle system
  93453. */
  93454. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93455. /**
  93456. * Remove a specific color gradient
  93457. * @param gradient defines the gradient to remove
  93458. * @returns this particle system
  93459. */
  93460. removeColorGradient(gradient: number): IParticleSystem;
  93461. private _fetchR;
  93462. protected _reset(): void;
  93463. private _resetEffect;
  93464. private _createVertexBuffers;
  93465. private _createIndexBuffer;
  93466. /**
  93467. * Gets the maximum number of particles active at the same time.
  93468. * @returns The max number of active particles.
  93469. */
  93470. getCapacity(): number;
  93471. /**
  93472. * Gets whether there are still active particles in the system.
  93473. * @returns True if it is alive, otherwise false.
  93474. */
  93475. isAlive(): boolean;
  93476. /**
  93477. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93478. * @returns True if it has been started, otherwise false.
  93479. */
  93480. isStarted(): boolean;
  93481. private _prepareSubEmitterInternalArray;
  93482. /**
  93483. * Starts the particle system and begins to emit
  93484. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93485. */
  93486. start(delay?: number): void;
  93487. /**
  93488. * Stops the particle system.
  93489. * @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.
  93490. */
  93491. stop(stopSubEmitters?: boolean): void;
  93492. /**
  93493. * Remove all active particles
  93494. */
  93495. reset(): void;
  93496. /**
  93497. * @hidden (for internal use only)
  93498. */
  93499. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93500. /**
  93501. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93502. * Its lifetime will start back at 0.
  93503. */
  93504. recycleParticle: (particle: Particle) => void;
  93505. private _stopSubEmitters;
  93506. private _createParticle;
  93507. private _removeFromRoot;
  93508. private _emitFromParticle;
  93509. private _update;
  93510. /** @hidden */
  93511. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93512. /** @hidden */
  93513. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93514. /**
  93515. * Fill the defines array according to the current settings of the particle system
  93516. * @param defines Array to be updated
  93517. * @param blendMode blend mode to take into account when updating the array
  93518. */
  93519. fillDefines(defines: Array<string>, blendMode: number): void;
  93520. /**
  93521. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93522. * @param uniforms Uniforms array to fill
  93523. * @param attributes Attributes array to fill
  93524. * @param samplers Samplers array to fill
  93525. */
  93526. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93527. /** @hidden */
  93528. private _getEffect;
  93529. /**
  93530. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93531. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93532. */
  93533. animate(preWarmOnly?: boolean): void;
  93534. private _appendParticleVertices;
  93535. /**
  93536. * Rebuilds the particle system.
  93537. */
  93538. rebuild(): void;
  93539. /**
  93540. * Is this system ready to be used/rendered
  93541. * @return true if the system is ready
  93542. */
  93543. isReady(): boolean;
  93544. private _render;
  93545. /**
  93546. * Renders the particle system in its current state.
  93547. * @returns the current number of particles
  93548. */
  93549. render(): number;
  93550. /**
  93551. * Disposes the particle system and free the associated resources
  93552. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93553. */
  93554. dispose(disposeTexture?: boolean): void;
  93555. /**
  93556. * Clones the particle system.
  93557. * @param name The name of the cloned object
  93558. * @param newEmitter The new emitter to use
  93559. * @returns the cloned particle system
  93560. */
  93561. clone(name: string, newEmitter: any): ParticleSystem;
  93562. /**
  93563. * Serializes the particle system to a JSON object
  93564. * @param serializeTexture defines if the texture must be serialized as well
  93565. * @returns the JSON object
  93566. */
  93567. serialize(serializeTexture?: boolean): any;
  93568. /** @hidden */
  93569. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93570. /** @hidden */
  93571. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93572. /**
  93573. * Parses a JSON object to create a particle system.
  93574. * @param parsedParticleSystem The JSON object to parse
  93575. * @param sceneOrEngine The scene or the engine to create the particle system in
  93576. * @param rootUrl The root url to use to load external dependencies like texture
  93577. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93578. * @returns the Parsed particle system
  93579. */
  93580. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93581. }
  93582. }
  93583. declare module BABYLON {
  93584. /**
  93585. * A particle represents one of the element emitted by a particle system.
  93586. * This is mainly define by its coordinates, direction, velocity and age.
  93587. */
  93588. export class Particle {
  93589. /**
  93590. * The particle system the particle belongs to.
  93591. */
  93592. particleSystem: ParticleSystem;
  93593. private static _Count;
  93594. /**
  93595. * Unique ID of the particle
  93596. */
  93597. id: number;
  93598. /**
  93599. * The world position of the particle in the scene.
  93600. */
  93601. position: Vector3;
  93602. /**
  93603. * The world direction of the particle in the scene.
  93604. */
  93605. direction: Vector3;
  93606. /**
  93607. * The color of the particle.
  93608. */
  93609. color: Color4;
  93610. /**
  93611. * The color change of the particle per step.
  93612. */
  93613. colorStep: Color4;
  93614. /**
  93615. * Defines how long will the life of the particle be.
  93616. */
  93617. lifeTime: number;
  93618. /**
  93619. * The current age of the particle.
  93620. */
  93621. age: number;
  93622. /**
  93623. * The current size of the particle.
  93624. */
  93625. size: number;
  93626. /**
  93627. * The current scale of the particle.
  93628. */
  93629. scale: Vector2;
  93630. /**
  93631. * The current angle of the particle.
  93632. */
  93633. angle: number;
  93634. /**
  93635. * Defines how fast is the angle changing.
  93636. */
  93637. angularSpeed: number;
  93638. /**
  93639. * Defines the cell index used by the particle to be rendered from a sprite.
  93640. */
  93641. cellIndex: number;
  93642. /**
  93643. * The information required to support color remapping
  93644. */
  93645. remapData: Vector4;
  93646. /** @hidden */
  93647. _randomCellOffset?: number;
  93648. /** @hidden */
  93649. _initialDirection: Nullable<Vector3>;
  93650. /** @hidden */
  93651. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93652. /** @hidden */
  93653. _initialStartSpriteCellID: number;
  93654. /** @hidden */
  93655. _initialEndSpriteCellID: number;
  93656. /** @hidden */
  93657. _currentColorGradient: Nullable<ColorGradient>;
  93658. /** @hidden */
  93659. _currentColor1: Color4;
  93660. /** @hidden */
  93661. _currentColor2: Color4;
  93662. /** @hidden */
  93663. _currentSizeGradient: Nullable<FactorGradient>;
  93664. /** @hidden */
  93665. _currentSize1: number;
  93666. /** @hidden */
  93667. _currentSize2: number;
  93668. /** @hidden */
  93669. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93670. /** @hidden */
  93671. _currentAngularSpeed1: number;
  93672. /** @hidden */
  93673. _currentAngularSpeed2: number;
  93674. /** @hidden */
  93675. _currentVelocityGradient: Nullable<FactorGradient>;
  93676. /** @hidden */
  93677. _currentVelocity1: number;
  93678. /** @hidden */
  93679. _currentVelocity2: number;
  93680. /** @hidden */
  93681. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93682. /** @hidden */
  93683. _currentLimitVelocity1: number;
  93684. /** @hidden */
  93685. _currentLimitVelocity2: number;
  93686. /** @hidden */
  93687. _currentDragGradient: Nullable<FactorGradient>;
  93688. /** @hidden */
  93689. _currentDrag1: number;
  93690. /** @hidden */
  93691. _currentDrag2: number;
  93692. /** @hidden */
  93693. _randomNoiseCoordinates1: Vector3;
  93694. /** @hidden */
  93695. _randomNoiseCoordinates2: Vector3;
  93696. /** @hidden */
  93697. _localPosition?: Vector3;
  93698. /**
  93699. * Creates a new instance Particle
  93700. * @param particleSystem the particle system the particle belongs to
  93701. */
  93702. constructor(
  93703. /**
  93704. * The particle system the particle belongs to.
  93705. */
  93706. particleSystem: ParticleSystem);
  93707. private updateCellInfoFromSystem;
  93708. /**
  93709. * Defines how the sprite cell index is updated for the particle
  93710. */
  93711. updateCellIndex(): void;
  93712. /** @hidden */
  93713. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93714. /** @hidden */
  93715. _inheritParticleInfoToSubEmitters(): void;
  93716. /** @hidden */
  93717. _reset(): void;
  93718. /**
  93719. * Copy the properties of particle to another one.
  93720. * @param other the particle to copy the information to.
  93721. */
  93722. copyTo(other: Particle): void;
  93723. }
  93724. }
  93725. declare module BABYLON {
  93726. /**
  93727. * Particle emitter represents a volume emitting particles.
  93728. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93729. */
  93730. export interface IParticleEmitterType {
  93731. /**
  93732. * Called by the particle System when the direction is computed for the created particle.
  93733. * @param worldMatrix is the world matrix of the particle system
  93734. * @param directionToUpdate is the direction vector to update with the result
  93735. * @param particle is the particle we are computed the direction for
  93736. * @param isLocal defines if the direction should be set in local space
  93737. */
  93738. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93739. /**
  93740. * Called by the particle System when the position is computed for the created particle.
  93741. * @param worldMatrix is the world matrix of the particle system
  93742. * @param positionToUpdate is the position vector to update with the result
  93743. * @param particle is the particle we are computed the position for
  93744. * @param isLocal defines if the position should be set in local space
  93745. */
  93746. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93747. /**
  93748. * Clones the current emitter and returns a copy of it
  93749. * @returns the new emitter
  93750. */
  93751. clone(): IParticleEmitterType;
  93752. /**
  93753. * Called by the GPUParticleSystem to setup the update shader
  93754. * @param effect defines the update shader
  93755. */
  93756. applyToShader(effect: Effect): void;
  93757. /**
  93758. * Returns a string to use to update the GPU particles update shader
  93759. * @returns the effect defines string
  93760. */
  93761. getEffectDefines(): string;
  93762. /**
  93763. * Returns a string representing the class name
  93764. * @returns a string containing the class name
  93765. */
  93766. getClassName(): string;
  93767. /**
  93768. * Serializes the particle system to a JSON object.
  93769. * @returns the JSON object
  93770. */
  93771. serialize(): any;
  93772. /**
  93773. * Parse properties from a JSON object
  93774. * @param serializationObject defines the JSON object
  93775. * @param scene defines the hosting scene
  93776. */
  93777. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93778. }
  93779. }
  93780. declare module BABYLON {
  93781. /**
  93782. * Particle emitter emitting particles from the inside of a box.
  93783. * It emits the particles randomly between 2 given directions.
  93784. */
  93785. export class BoxParticleEmitter implements IParticleEmitterType {
  93786. /**
  93787. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93788. */
  93789. direction1: Vector3;
  93790. /**
  93791. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93792. */
  93793. direction2: Vector3;
  93794. /**
  93795. * 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.
  93796. */
  93797. minEmitBox: Vector3;
  93798. /**
  93799. * 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.
  93800. */
  93801. maxEmitBox: Vector3;
  93802. /**
  93803. * Creates a new instance BoxParticleEmitter
  93804. */
  93805. constructor();
  93806. /**
  93807. * Called by the particle System when the direction is computed for the created particle.
  93808. * @param worldMatrix is the world matrix of the particle system
  93809. * @param directionToUpdate is the direction vector to update with the result
  93810. * @param particle is the particle we are computed the direction for
  93811. * @param isLocal defines if the direction should be set in local space
  93812. */
  93813. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93814. /**
  93815. * Called by the particle System when the position is computed for the created particle.
  93816. * @param worldMatrix is the world matrix of the particle system
  93817. * @param positionToUpdate is the position vector to update with the result
  93818. * @param particle is the particle we are computed the position for
  93819. * @param isLocal defines if the position should be set in local space
  93820. */
  93821. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93822. /**
  93823. * Clones the current emitter and returns a copy of it
  93824. * @returns the new emitter
  93825. */
  93826. clone(): BoxParticleEmitter;
  93827. /**
  93828. * Called by the GPUParticleSystem to setup the update shader
  93829. * @param effect defines the update shader
  93830. */
  93831. applyToShader(effect: Effect): void;
  93832. /**
  93833. * Returns a string to use to update the GPU particles update shader
  93834. * @returns a string containng the defines string
  93835. */
  93836. getEffectDefines(): string;
  93837. /**
  93838. * Returns the string "BoxParticleEmitter"
  93839. * @returns a string containing the class name
  93840. */
  93841. getClassName(): string;
  93842. /**
  93843. * Serializes the particle system to a JSON object.
  93844. * @returns the JSON object
  93845. */
  93846. serialize(): any;
  93847. /**
  93848. * Parse properties from a JSON object
  93849. * @param serializationObject defines the JSON object
  93850. */
  93851. parse(serializationObject: any): void;
  93852. }
  93853. }
  93854. declare module BABYLON {
  93855. /**
  93856. * Particle emitter emitting particles from the inside of a cone.
  93857. * It emits the particles alongside the cone volume from the base to the particle.
  93858. * The emission direction might be randomized.
  93859. */
  93860. export class ConeParticleEmitter implements IParticleEmitterType {
  93861. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93862. directionRandomizer: number;
  93863. private _radius;
  93864. private _angle;
  93865. private _height;
  93866. /**
  93867. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93868. */
  93869. radiusRange: number;
  93870. /**
  93871. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93872. */
  93873. heightRange: number;
  93874. /**
  93875. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93876. */
  93877. emitFromSpawnPointOnly: boolean;
  93878. /**
  93879. * Gets or sets the radius of the emission cone
  93880. */
  93881. get radius(): number;
  93882. set radius(value: number);
  93883. /**
  93884. * Gets or sets the angle of the emission cone
  93885. */
  93886. get angle(): number;
  93887. set angle(value: number);
  93888. private _buildHeight;
  93889. /**
  93890. * Creates a new instance ConeParticleEmitter
  93891. * @param radius the radius of the emission cone (1 by default)
  93892. * @param angle the cone base angle (PI by default)
  93893. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93894. */
  93895. constructor(radius?: number, angle?: number,
  93896. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93897. directionRandomizer?: number);
  93898. /**
  93899. * Called by the particle System when the direction is computed for the created particle.
  93900. * @param worldMatrix is the world matrix of the particle system
  93901. * @param directionToUpdate is the direction vector to update with the result
  93902. * @param particle is the particle we are computed the direction for
  93903. * @param isLocal defines if the direction should be set in local space
  93904. */
  93905. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93906. /**
  93907. * Called by the particle System when the position is computed for the created particle.
  93908. * @param worldMatrix is the world matrix of the particle system
  93909. * @param positionToUpdate is the position vector to update with the result
  93910. * @param particle is the particle we are computed the position for
  93911. * @param isLocal defines if the position should be set in local space
  93912. */
  93913. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93914. /**
  93915. * Clones the current emitter and returns a copy of it
  93916. * @returns the new emitter
  93917. */
  93918. clone(): ConeParticleEmitter;
  93919. /**
  93920. * Called by the GPUParticleSystem to setup the update shader
  93921. * @param effect defines the update shader
  93922. */
  93923. applyToShader(effect: Effect): void;
  93924. /**
  93925. * Returns a string to use to update the GPU particles update shader
  93926. * @returns a string containng the defines string
  93927. */
  93928. getEffectDefines(): string;
  93929. /**
  93930. * Returns the string "ConeParticleEmitter"
  93931. * @returns a string containing the class name
  93932. */
  93933. getClassName(): string;
  93934. /**
  93935. * Serializes the particle system to a JSON object.
  93936. * @returns the JSON object
  93937. */
  93938. serialize(): any;
  93939. /**
  93940. * Parse properties from a JSON object
  93941. * @param serializationObject defines the JSON object
  93942. */
  93943. parse(serializationObject: any): void;
  93944. }
  93945. }
  93946. declare module BABYLON {
  93947. /**
  93948. * Particle emitter emitting particles from the inside of a cylinder.
  93949. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93950. */
  93951. export class CylinderParticleEmitter implements IParticleEmitterType {
  93952. /**
  93953. * The radius of the emission cylinder.
  93954. */
  93955. radius: number;
  93956. /**
  93957. * The height of the emission cylinder.
  93958. */
  93959. height: number;
  93960. /**
  93961. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93962. */
  93963. radiusRange: number;
  93964. /**
  93965. * How much to randomize the particle direction [0-1].
  93966. */
  93967. directionRandomizer: number;
  93968. /**
  93969. * Creates a new instance CylinderParticleEmitter
  93970. * @param radius the radius of the emission cylinder (1 by default)
  93971. * @param height the height of the emission cylinder (1 by default)
  93972. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93973. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93974. */
  93975. constructor(
  93976. /**
  93977. * The radius of the emission cylinder.
  93978. */
  93979. radius?: number,
  93980. /**
  93981. * The height of the emission cylinder.
  93982. */
  93983. height?: 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. * Called by the particle System when the direction is computed for the created particle.
  93994. * @param worldMatrix is the world matrix of the particle system
  93995. * @param directionToUpdate is the direction vector to update with the result
  93996. * @param particle is the particle we are computed the direction for
  93997. * @param isLocal defines if the direction should be set in local space
  93998. */
  93999. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94000. /**
  94001. * Called by the particle System when the position is computed for the created particle.
  94002. * @param worldMatrix is the world matrix of the particle system
  94003. * @param positionToUpdate is the position vector to update with the result
  94004. * @param particle is the particle we are computed the position for
  94005. * @param isLocal defines if the position should be set in local space
  94006. */
  94007. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94008. /**
  94009. * Clones the current emitter and returns a copy of it
  94010. * @returns the new emitter
  94011. */
  94012. clone(): CylinderParticleEmitter;
  94013. /**
  94014. * Called by the GPUParticleSystem to setup the update shader
  94015. * @param effect defines the update shader
  94016. */
  94017. applyToShader(effect: Effect): void;
  94018. /**
  94019. * Returns a string to use to update the GPU particles update shader
  94020. * @returns a string containng the defines string
  94021. */
  94022. getEffectDefines(): string;
  94023. /**
  94024. * Returns the string "CylinderParticleEmitter"
  94025. * @returns a string containing the class name
  94026. */
  94027. getClassName(): string;
  94028. /**
  94029. * Serializes the particle system to a JSON object.
  94030. * @returns the JSON object
  94031. */
  94032. serialize(): any;
  94033. /**
  94034. * Parse properties from a JSON object
  94035. * @param serializationObject defines the JSON object
  94036. */
  94037. parse(serializationObject: any): void;
  94038. }
  94039. /**
  94040. * Particle emitter emitting particles from the inside of a cylinder.
  94041. * It emits the particles randomly between two vectors.
  94042. */
  94043. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94044. /**
  94045. * The min limit of the emission direction.
  94046. */
  94047. direction1: Vector3;
  94048. /**
  94049. * The max limit of the emission direction.
  94050. */
  94051. direction2: Vector3;
  94052. /**
  94053. * Creates a new instance CylinderDirectedParticleEmitter
  94054. * @param radius the radius of the emission cylinder (1 by default)
  94055. * @param height the height of the emission cylinder (1 by default)
  94056. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94057. * @param direction1 the min limit of the emission direction (up vector by default)
  94058. * @param direction2 the max limit of the emission direction (up vector by default)
  94059. */
  94060. constructor(radius?: number, height?: number, radiusRange?: number,
  94061. /**
  94062. * The min limit of the emission direction.
  94063. */
  94064. direction1?: Vector3,
  94065. /**
  94066. * The max limit of the emission direction.
  94067. */
  94068. direction2?: Vector3);
  94069. /**
  94070. * Called by the particle System when the direction is computed for the created particle.
  94071. * @param worldMatrix is the world matrix of the particle system
  94072. * @param directionToUpdate is the direction vector to update with the result
  94073. * @param particle is the particle we are computed the direction for
  94074. */
  94075. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94076. /**
  94077. * Clones the current emitter and returns a copy of it
  94078. * @returns the new emitter
  94079. */
  94080. clone(): CylinderDirectedParticleEmitter;
  94081. /**
  94082. * Called by the GPUParticleSystem to setup the update shader
  94083. * @param effect defines the update shader
  94084. */
  94085. applyToShader(effect: Effect): void;
  94086. /**
  94087. * Returns a string to use to update the GPU particles update shader
  94088. * @returns a string containng the defines string
  94089. */
  94090. getEffectDefines(): string;
  94091. /**
  94092. * Returns the string "CylinderDirectedParticleEmitter"
  94093. * @returns a string containing the class name
  94094. */
  94095. getClassName(): string;
  94096. /**
  94097. * Serializes the particle system to a JSON object.
  94098. * @returns the JSON object
  94099. */
  94100. serialize(): any;
  94101. /**
  94102. * Parse properties from a JSON object
  94103. * @param serializationObject defines the JSON object
  94104. */
  94105. parse(serializationObject: any): void;
  94106. }
  94107. }
  94108. declare module BABYLON {
  94109. /**
  94110. * Particle emitter emitting particles from the inside of a hemisphere.
  94111. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94112. */
  94113. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94114. /**
  94115. * The radius of the emission hemisphere.
  94116. */
  94117. radius: number;
  94118. /**
  94119. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94120. */
  94121. radiusRange: number;
  94122. /**
  94123. * How much to randomize the particle direction [0-1].
  94124. */
  94125. directionRandomizer: number;
  94126. /**
  94127. * Creates a new instance HemisphericParticleEmitter
  94128. * @param radius the radius of the emission hemisphere (1 by default)
  94129. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94130. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94131. */
  94132. constructor(
  94133. /**
  94134. * The radius of the emission hemisphere.
  94135. */
  94136. radius?: number,
  94137. /**
  94138. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94139. */
  94140. radiusRange?: number,
  94141. /**
  94142. * How much to randomize the particle direction [0-1].
  94143. */
  94144. directionRandomizer?: number);
  94145. /**
  94146. * Called by the particle System when the direction is computed for the created particle.
  94147. * @param worldMatrix is the world matrix of the particle system
  94148. * @param directionToUpdate is the direction vector to update with the result
  94149. * @param particle is the particle we are computed the direction for
  94150. * @param isLocal defines if the direction should be set in local space
  94151. */
  94152. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94153. /**
  94154. * Called by the particle System when the position is computed for the created particle.
  94155. * @param worldMatrix is the world matrix of the particle system
  94156. * @param positionToUpdate is the position vector to update with the result
  94157. * @param particle is the particle we are computed the position for
  94158. * @param isLocal defines if the position should be set in local space
  94159. */
  94160. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94161. /**
  94162. * Clones the current emitter and returns a copy of it
  94163. * @returns the new emitter
  94164. */
  94165. clone(): HemisphericParticleEmitter;
  94166. /**
  94167. * Called by the GPUParticleSystem to setup the update shader
  94168. * @param effect defines the update shader
  94169. */
  94170. applyToShader(effect: Effect): void;
  94171. /**
  94172. * Returns a string to use to update the GPU particles update shader
  94173. * @returns a string containng the defines string
  94174. */
  94175. getEffectDefines(): string;
  94176. /**
  94177. * Returns the string "HemisphericParticleEmitter"
  94178. * @returns a string containing the class name
  94179. */
  94180. getClassName(): string;
  94181. /**
  94182. * Serializes the particle system to a JSON object.
  94183. * @returns the JSON object
  94184. */
  94185. serialize(): any;
  94186. /**
  94187. * Parse properties from a JSON object
  94188. * @param serializationObject defines the JSON object
  94189. */
  94190. parse(serializationObject: any): void;
  94191. }
  94192. }
  94193. declare module BABYLON {
  94194. /**
  94195. * Particle emitter emitting particles from a point.
  94196. * It emits the particles randomly between 2 given directions.
  94197. */
  94198. export class PointParticleEmitter implements IParticleEmitterType {
  94199. /**
  94200. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94201. */
  94202. direction1: Vector3;
  94203. /**
  94204. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94205. */
  94206. direction2: Vector3;
  94207. /**
  94208. * Creates a new instance PointParticleEmitter
  94209. */
  94210. constructor();
  94211. /**
  94212. * Called by the particle System when the direction is computed for the created particle.
  94213. * @param worldMatrix is the world matrix of the particle system
  94214. * @param directionToUpdate is the direction vector to update with the result
  94215. * @param particle is the particle we are computed the direction for
  94216. * @param isLocal defines if the direction should be set in local space
  94217. */
  94218. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94219. /**
  94220. * Called by the particle System when the position is computed for the created particle.
  94221. * @param worldMatrix is the world matrix of the particle system
  94222. * @param positionToUpdate is the position vector to update with the result
  94223. * @param particle is the particle we are computed the position for
  94224. * @param isLocal defines if the position should be set in local space
  94225. */
  94226. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94227. /**
  94228. * Clones the current emitter and returns a copy of it
  94229. * @returns the new emitter
  94230. */
  94231. clone(): PointParticleEmitter;
  94232. /**
  94233. * Called by the GPUParticleSystem to setup the update shader
  94234. * @param effect defines the update shader
  94235. */
  94236. applyToShader(effect: Effect): void;
  94237. /**
  94238. * Returns a string to use to update the GPU particles update shader
  94239. * @returns a string containng the defines string
  94240. */
  94241. getEffectDefines(): string;
  94242. /**
  94243. * Returns the string "PointParticleEmitter"
  94244. * @returns a string containing the class name
  94245. */
  94246. getClassName(): string;
  94247. /**
  94248. * Serializes the particle system to a JSON object.
  94249. * @returns the JSON object
  94250. */
  94251. serialize(): any;
  94252. /**
  94253. * Parse properties from a JSON object
  94254. * @param serializationObject defines the JSON object
  94255. */
  94256. parse(serializationObject: any): void;
  94257. }
  94258. }
  94259. declare module BABYLON {
  94260. /**
  94261. * Particle emitter emitting particles from the inside of a sphere.
  94262. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94263. */
  94264. export class SphereParticleEmitter implements IParticleEmitterType {
  94265. /**
  94266. * The radius of the emission sphere.
  94267. */
  94268. radius: number;
  94269. /**
  94270. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94271. */
  94272. radiusRange: number;
  94273. /**
  94274. * How much to randomize the particle direction [0-1].
  94275. */
  94276. directionRandomizer: number;
  94277. /**
  94278. * Creates a new instance SphereParticleEmitter
  94279. * @param radius the radius of the emission sphere (1 by default)
  94280. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94281. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94282. */
  94283. constructor(
  94284. /**
  94285. * The radius of the emission sphere.
  94286. */
  94287. radius?: number,
  94288. /**
  94289. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94290. */
  94291. radiusRange?: number,
  94292. /**
  94293. * How much to randomize the particle direction [0-1].
  94294. */
  94295. directionRandomizer?: number);
  94296. /**
  94297. * Called by the particle System when the direction is computed for the created particle.
  94298. * @param worldMatrix is the world matrix of the particle system
  94299. * @param directionToUpdate is the direction vector to update with the result
  94300. * @param particle is the particle we are computed the direction for
  94301. * @param isLocal defines if the direction should be set in local space
  94302. */
  94303. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94304. /**
  94305. * Called by the particle System when the position is computed for the created particle.
  94306. * @param worldMatrix is the world matrix of the particle system
  94307. * @param positionToUpdate is the position vector to update with the result
  94308. * @param particle is the particle we are computed the position for
  94309. * @param isLocal defines if the position should be set in local space
  94310. */
  94311. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94312. /**
  94313. * Clones the current emitter and returns a copy of it
  94314. * @returns the new emitter
  94315. */
  94316. clone(): SphereParticleEmitter;
  94317. /**
  94318. * Called by the GPUParticleSystem to setup the update shader
  94319. * @param effect defines the update shader
  94320. */
  94321. applyToShader(effect: Effect): void;
  94322. /**
  94323. * Returns a string to use to update the GPU particles update shader
  94324. * @returns a string containng the defines string
  94325. */
  94326. getEffectDefines(): string;
  94327. /**
  94328. * Returns the string "SphereParticleEmitter"
  94329. * @returns a string containing the class name
  94330. */
  94331. getClassName(): string;
  94332. /**
  94333. * Serializes the particle system to a JSON object.
  94334. * @returns the JSON object
  94335. */
  94336. serialize(): any;
  94337. /**
  94338. * Parse properties from a JSON object
  94339. * @param serializationObject defines the JSON object
  94340. */
  94341. parse(serializationObject: any): void;
  94342. }
  94343. /**
  94344. * Particle emitter emitting particles from the inside of a sphere.
  94345. * It emits the particles randomly between two vectors.
  94346. */
  94347. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94348. /**
  94349. * The min limit of the emission direction.
  94350. */
  94351. direction1: Vector3;
  94352. /**
  94353. * The max limit of the emission direction.
  94354. */
  94355. direction2: Vector3;
  94356. /**
  94357. * Creates a new instance SphereDirectedParticleEmitter
  94358. * @param radius the radius of the emission sphere (1 by default)
  94359. * @param direction1 the min limit of the emission direction (up vector by default)
  94360. * @param direction2 the max limit of the emission direction (up vector by default)
  94361. */
  94362. constructor(radius?: number,
  94363. /**
  94364. * The min limit of the emission direction.
  94365. */
  94366. direction1?: Vector3,
  94367. /**
  94368. * The max limit of the emission direction.
  94369. */
  94370. direction2?: Vector3);
  94371. /**
  94372. * Called by the particle System when the direction is computed for the created particle.
  94373. * @param worldMatrix is the world matrix of the particle system
  94374. * @param directionToUpdate is the direction vector to update with the result
  94375. * @param particle is the particle we are computed the direction for
  94376. */
  94377. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94378. /**
  94379. * Clones the current emitter and returns a copy of it
  94380. * @returns the new emitter
  94381. */
  94382. clone(): SphereDirectedParticleEmitter;
  94383. /**
  94384. * Called by the GPUParticleSystem to setup the update shader
  94385. * @param effect defines the update shader
  94386. */
  94387. applyToShader(effect: Effect): void;
  94388. /**
  94389. * Returns a string to use to update the GPU particles update shader
  94390. * @returns a string containng the defines string
  94391. */
  94392. getEffectDefines(): string;
  94393. /**
  94394. * Returns the string "SphereDirectedParticleEmitter"
  94395. * @returns a string containing the class name
  94396. */
  94397. getClassName(): string;
  94398. /**
  94399. * Serializes the particle system to a JSON object.
  94400. * @returns the JSON object
  94401. */
  94402. serialize(): any;
  94403. /**
  94404. * Parse properties from a JSON object
  94405. * @param serializationObject defines the JSON object
  94406. */
  94407. parse(serializationObject: any): void;
  94408. }
  94409. }
  94410. declare module BABYLON {
  94411. /**
  94412. * Particle emitter emitting particles from a custom list of positions.
  94413. */
  94414. export class CustomParticleEmitter implements IParticleEmitterType {
  94415. /**
  94416. * Gets or sets the position generator that will create the inital position of each particle.
  94417. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94418. */
  94419. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94420. /**
  94421. * Gets or sets the destination generator that will create the final destination of each particle.
  94422. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94423. */
  94424. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94425. /**
  94426. * Creates a new instance CustomParticleEmitter
  94427. */
  94428. constructor();
  94429. /**
  94430. * Called by the particle System when the direction is computed for the created particle.
  94431. * @param worldMatrix is the world matrix of the particle system
  94432. * @param directionToUpdate is the direction vector to update with the result
  94433. * @param particle is the particle we are computed the direction for
  94434. * @param isLocal defines if the direction should be set in local space
  94435. */
  94436. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94437. /**
  94438. * Called by the particle System when the position is computed for the created particle.
  94439. * @param worldMatrix is the world matrix of the particle system
  94440. * @param positionToUpdate is the position vector to update with the result
  94441. * @param particle is the particle we are computed the position for
  94442. * @param isLocal defines if the position should be set in local space
  94443. */
  94444. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94445. /**
  94446. * Clones the current emitter and returns a copy of it
  94447. * @returns the new emitter
  94448. */
  94449. clone(): CustomParticleEmitter;
  94450. /**
  94451. * Called by the GPUParticleSystem to setup the update shader
  94452. * @param effect defines the update shader
  94453. */
  94454. applyToShader(effect: Effect): void;
  94455. /**
  94456. * Returns a string to use to update the GPU particles update shader
  94457. * @returns a string containng the defines string
  94458. */
  94459. getEffectDefines(): string;
  94460. /**
  94461. * Returns the string "PointParticleEmitter"
  94462. * @returns a string containing the class name
  94463. */
  94464. getClassName(): string;
  94465. /**
  94466. * Serializes the particle system to a JSON object.
  94467. * @returns the JSON object
  94468. */
  94469. serialize(): any;
  94470. /**
  94471. * Parse properties from a JSON object
  94472. * @param serializationObject defines the JSON object
  94473. */
  94474. parse(serializationObject: any): void;
  94475. }
  94476. }
  94477. declare module BABYLON {
  94478. /**
  94479. * Particle emitter emitting particles from the inside of a box.
  94480. * It emits the particles randomly between 2 given directions.
  94481. */
  94482. export class MeshParticleEmitter implements IParticleEmitterType {
  94483. private _indices;
  94484. private _positions;
  94485. private _normals;
  94486. private _storedNormal;
  94487. private _mesh;
  94488. /**
  94489. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94490. */
  94491. direction1: Vector3;
  94492. /**
  94493. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94494. */
  94495. direction2: Vector3;
  94496. /**
  94497. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94498. */
  94499. useMeshNormalsForDirection: boolean;
  94500. /** Defines the mesh to use as source */
  94501. get mesh(): Nullable<AbstractMesh>;
  94502. set mesh(value: Nullable<AbstractMesh>);
  94503. /**
  94504. * Creates a new instance MeshParticleEmitter
  94505. * @param mesh defines the mesh to use as source
  94506. */
  94507. constructor(mesh?: Nullable<AbstractMesh>);
  94508. /**
  94509. * Called by the particle System when the direction is computed for the created particle.
  94510. * @param worldMatrix is the world matrix of the particle system
  94511. * @param directionToUpdate is the direction vector to update with the result
  94512. * @param particle is the particle we are computed the direction for
  94513. * @param isLocal defines if the direction should be set in local space
  94514. */
  94515. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94516. /**
  94517. * Called by the particle System when the position is computed for the created particle.
  94518. * @param worldMatrix is the world matrix of the particle system
  94519. * @param positionToUpdate is the position vector to update with the result
  94520. * @param particle is the particle we are computed the position for
  94521. * @param isLocal defines if the position should be set in local space
  94522. */
  94523. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94524. /**
  94525. * Clones the current emitter and returns a copy of it
  94526. * @returns the new emitter
  94527. */
  94528. clone(): MeshParticleEmitter;
  94529. /**
  94530. * Called by the GPUParticleSystem to setup the update shader
  94531. * @param effect defines the update shader
  94532. */
  94533. applyToShader(effect: Effect): void;
  94534. /**
  94535. * Returns a string to use to update the GPU particles update shader
  94536. * @returns a string containng the defines string
  94537. */
  94538. getEffectDefines(): string;
  94539. /**
  94540. * Returns the string "BoxParticleEmitter"
  94541. * @returns a string containing the class name
  94542. */
  94543. getClassName(): string;
  94544. /**
  94545. * Serializes the particle system to a JSON object.
  94546. * @returns the JSON object
  94547. */
  94548. serialize(): any;
  94549. /**
  94550. * Parse properties from a JSON object
  94551. * @param serializationObject defines the JSON object
  94552. * @param scene defines the hosting scene
  94553. */
  94554. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94555. }
  94556. }
  94557. declare module BABYLON {
  94558. /**
  94559. * Interface representing a particle system in Babylon.js.
  94560. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94561. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94562. */
  94563. export interface IParticleSystem {
  94564. /**
  94565. * List of animations used by the particle system.
  94566. */
  94567. animations: Animation[];
  94568. /**
  94569. * The id of the Particle system.
  94570. */
  94571. id: string;
  94572. /**
  94573. * The name of the Particle system.
  94574. */
  94575. name: string;
  94576. /**
  94577. * The emitter represents the Mesh or position we are attaching the particle system to.
  94578. */
  94579. emitter: Nullable<AbstractMesh | Vector3>;
  94580. /**
  94581. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94582. */
  94583. isBillboardBased: boolean;
  94584. /**
  94585. * The rendering group used by the Particle system to chose when to render.
  94586. */
  94587. renderingGroupId: number;
  94588. /**
  94589. * The layer mask we are rendering the particles through.
  94590. */
  94591. layerMask: number;
  94592. /**
  94593. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94594. */
  94595. updateSpeed: number;
  94596. /**
  94597. * The amount of time the particle system is running (depends of the overall update speed).
  94598. */
  94599. targetStopDuration: number;
  94600. /**
  94601. * The texture used to render each particle. (this can be a spritesheet)
  94602. */
  94603. particleTexture: Nullable<BaseTexture>;
  94604. /**
  94605. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94606. */
  94607. blendMode: number;
  94608. /**
  94609. * Minimum life time of emitting particles.
  94610. */
  94611. minLifeTime: number;
  94612. /**
  94613. * Maximum life time of emitting particles.
  94614. */
  94615. maxLifeTime: number;
  94616. /**
  94617. * Minimum Size of emitting particles.
  94618. */
  94619. minSize: number;
  94620. /**
  94621. * Maximum Size of emitting particles.
  94622. */
  94623. maxSize: number;
  94624. /**
  94625. * Minimum scale of emitting particles on X axis.
  94626. */
  94627. minScaleX: number;
  94628. /**
  94629. * Maximum scale of emitting particles on X axis.
  94630. */
  94631. maxScaleX: number;
  94632. /**
  94633. * Minimum scale of emitting particles on Y axis.
  94634. */
  94635. minScaleY: number;
  94636. /**
  94637. * Maximum scale of emitting particles on Y axis.
  94638. */
  94639. maxScaleY: number;
  94640. /**
  94641. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94642. */
  94643. color1: Color4;
  94644. /**
  94645. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94646. */
  94647. color2: Color4;
  94648. /**
  94649. * Color the particle will have at the end of its lifetime.
  94650. */
  94651. colorDead: Color4;
  94652. /**
  94653. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94654. */
  94655. emitRate: number;
  94656. /**
  94657. * You can use gravity if you want to give an orientation to your particles.
  94658. */
  94659. gravity: Vector3;
  94660. /**
  94661. * Minimum power of emitting particles.
  94662. */
  94663. minEmitPower: number;
  94664. /**
  94665. * Maximum power of emitting particles.
  94666. */
  94667. maxEmitPower: number;
  94668. /**
  94669. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94670. */
  94671. minAngularSpeed: number;
  94672. /**
  94673. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94674. */
  94675. maxAngularSpeed: number;
  94676. /**
  94677. * Gets or sets the minimal initial rotation in radians.
  94678. */
  94679. minInitialRotation: number;
  94680. /**
  94681. * Gets or sets the maximal initial rotation in radians.
  94682. */
  94683. maxInitialRotation: number;
  94684. /**
  94685. * The particle emitter type defines the emitter used by the particle system.
  94686. * It can be for example box, sphere, or cone...
  94687. */
  94688. particleEmitterType: Nullable<IParticleEmitterType>;
  94689. /**
  94690. * Defines the delay in milliseconds before starting the system (0 by default)
  94691. */
  94692. startDelay: number;
  94693. /**
  94694. * 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
  94695. */
  94696. preWarmCycles: number;
  94697. /**
  94698. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94699. */
  94700. preWarmStepOffset: number;
  94701. /**
  94702. * 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)
  94703. */
  94704. spriteCellChangeSpeed: number;
  94705. /**
  94706. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94707. */
  94708. startSpriteCellID: number;
  94709. /**
  94710. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94711. */
  94712. endSpriteCellID: number;
  94713. /**
  94714. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94715. */
  94716. spriteCellWidth: number;
  94717. /**
  94718. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94719. */
  94720. spriteCellHeight: number;
  94721. /**
  94722. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94723. */
  94724. spriteRandomStartCell: boolean;
  94725. /**
  94726. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94727. */
  94728. isAnimationSheetEnabled: boolean;
  94729. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94730. translationPivot: Vector2;
  94731. /**
  94732. * Gets or sets a texture used to add random noise to particle positions
  94733. */
  94734. noiseTexture: Nullable<BaseTexture>;
  94735. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94736. noiseStrength: Vector3;
  94737. /**
  94738. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94739. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94740. */
  94741. billboardMode: number;
  94742. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94743. limitVelocityDamping: number;
  94744. /**
  94745. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94746. */
  94747. beginAnimationOnStart: boolean;
  94748. /**
  94749. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94750. */
  94751. beginAnimationFrom: number;
  94752. /**
  94753. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94754. */
  94755. beginAnimationTo: number;
  94756. /**
  94757. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94758. */
  94759. beginAnimationLoop: boolean;
  94760. /**
  94761. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94762. */
  94763. disposeOnStop: boolean;
  94764. /**
  94765. * Specifies if the particles are updated in emitter local space or world space
  94766. */
  94767. isLocal: boolean;
  94768. /** Snippet ID if the particle system was created from the snippet server */
  94769. snippetId: string;
  94770. /** Gets or sets a matrix to use to compute projection */
  94771. defaultProjectionMatrix: Matrix;
  94772. /**
  94773. * Gets the maximum number of particles active at the same time.
  94774. * @returns The max number of active particles.
  94775. */
  94776. getCapacity(): number;
  94777. /**
  94778. * Gets the number of particles active at the same time.
  94779. * @returns The number of active particles.
  94780. */
  94781. getActiveCount(): number;
  94782. /**
  94783. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94784. * @returns True if it has been started, otherwise false.
  94785. */
  94786. isStarted(): boolean;
  94787. /**
  94788. * Animates the particle system for this frame.
  94789. */
  94790. animate(): void;
  94791. /**
  94792. * Renders the particle system in its current state.
  94793. * @returns the current number of particles
  94794. */
  94795. render(): number;
  94796. /**
  94797. * Dispose the particle system and frees its associated resources.
  94798. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94799. */
  94800. dispose(disposeTexture?: boolean): void;
  94801. /**
  94802. * An event triggered when the system is disposed
  94803. */
  94804. onDisposeObservable: Observable<IParticleSystem>;
  94805. /**
  94806. * Clones the particle system.
  94807. * @param name The name of the cloned object
  94808. * @param newEmitter The new emitter to use
  94809. * @returns the cloned particle system
  94810. */
  94811. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94812. /**
  94813. * Serializes the particle system to a JSON object
  94814. * @param serializeTexture defines if the texture must be serialized as well
  94815. * @returns the JSON object
  94816. */
  94817. serialize(serializeTexture: boolean): any;
  94818. /**
  94819. * Rebuild the particle system
  94820. */
  94821. rebuild(): void;
  94822. /** Force the system to rebuild all gradients that need to be resync */
  94823. forceRefreshGradients(): void;
  94824. /**
  94825. * Starts the particle system and begins to emit
  94826. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94827. */
  94828. start(delay?: number): void;
  94829. /**
  94830. * Stops the particle system.
  94831. */
  94832. stop(): void;
  94833. /**
  94834. * Remove all active particles
  94835. */
  94836. reset(): void;
  94837. /**
  94838. * Gets a boolean indicating that the system is stopping
  94839. * @returns true if the system is currently stopping
  94840. */
  94841. isStopping(): boolean;
  94842. /**
  94843. * Is this system ready to be used/rendered
  94844. * @return true if the system is ready
  94845. */
  94846. isReady(): boolean;
  94847. /**
  94848. * Returns the string "ParticleSystem"
  94849. * @returns a string containing the class name
  94850. */
  94851. getClassName(): string;
  94852. /**
  94853. * Gets the custom effect used to render the particles
  94854. * @param blendMode Blend mode for which the effect should be retrieved
  94855. * @returns The effect
  94856. */
  94857. getCustomEffect(blendMode: number): Nullable<Effect>;
  94858. /**
  94859. * Sets the custom effect used to render the particles
  94860. * @param effect The effect to set
  94861. * @param blendMode Blend mode for which the effect should be set
  94862. */
  94863. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94864. /**
  94865. * Fill the defines array according to the current settings of the particle system
  94866. * @param defines Array to be updated
  94867. * @param blendMode blend mode to take into account when updating the array
  94868. */
  94869. fillDefines(defines: Array<string>, blendMode: number): void;
  94870. /**
  94871. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94872. * @param uniforms Uniforms array to fill
  94873. * @param attributes Attributes array to fill
  94874. * @param samplers Samplers array to fill
  94875. */
  94876. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94877. /**
  94878. * Observable that will be called just before the particles are drawn
  94879. */
  94880. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94881. /**
  94882. * Gets the name of the particle vertex shader
  94883. */
  94884. vertexShaderName: string;
  94885. /**
  94886. * Adds a new color gradient
  94887. * @param gradient defines the gradient to use (between 0 and 1)
  94888. * @param color1 defines the color to affect to the specified gradient
  94889. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94890. * @returns the current particle system
  94891. */
  94892. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94893. /**
  94894. * Remove a specific color gradient
  94895. * @param gradient defines the gradient to remove
  94896. * @returns the current particle system
  94897. */
  94898. removeColorGradient(gradient: number): IParticleSystem;
  94899. /**
  94900. * Adds a new size gradient
  94901. * @param gradient defines the gradient to use (between 0 and 1)
  94902. * @param factor defines the size factor to affect to the specified gradient
  94903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94904. * @returns the current particle system
  94905. */
  94906. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94907. /**
  94908. * Remove a specific size gradient
  94909. * @param gradient defines the gradient to remove
  94910. * @returns the current particle system
  94911. */
  94912. removeSizeGradient(gradient: number): IParticleSystem;
  94913. /**
  94914. * Gets the current list of color gradients.
  94915. * You must use addColorGradient and removeColorGradient to udpate this list
  94916. * @returns the list of color gradients
  94917. */
  94918. getColorGradients(): Nullable<Array<ColorGradient>>;
  94919. /**
  94920. * Gets the current list of size gradients.
  94921. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94922. * @returns the list of size gradients
  94923. */
  94924. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94925. /**
  94926. * Gets the current list of angular speed gradients.
  94927. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94928. * @returns the list of angular speed gradients
  94929. */
  94930. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94931. /**
  94932. * Adds a new angular speed gradient
  94933. * @param gradient defines the gradient to use (between 0 and 1)
  94934. * @param factor defines the angular speed to affect to the specified gradient
  94935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94936. * @returns the current particle system
  94937. */
  94938. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94939. /**
  94940. * Remove a specific angular speed gradient
  94941. * @param gradient defines the gradient to remove
  94942. * @returns the current particle system
  94943. */
  94944. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94945. /**
  94946. * Gets the current list of velocity gradients.
  94947. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94948. * @returns the list of velocity gradients
  94949. */
  94950. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94951. /**
  94952. * Adds a new velocity gradient
  94953. * @param gradient defines the gradient to use (between 0 and 1)
  94954. * @param factor defines the velocity to affect to the specified gradient
  94955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94956. * @returns the current particle system
  94957. */
  94958. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94959. /**
  94960. * Remove a specific velocity gradient
  94961. * @param gradient defines the gradient to remove
  94962. * @returns the current particle system
  94963. */
  94964. removeVelocityGradient(gradient: number): IParticleSystem;
  94965. /**
  94966. * Gets the current list of limit velocity gradients.
  94967. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94968. * @returns the list of limit velocity gradients
  94969. */
  94970. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94971. /**
  94972. * Adds a new limit velocity gradient
  94973. * @param gradient defines the gradient to use (between 0 and 1)
  94974. * @param factor defines the limit velocity to affect to the specified gradient
  94975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94976. * @returns the current particle system
  94977. */
  94978. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94979. /**
  94980. * Remove a specific limit velocity gradient
  94981. * @param gradient defines the gradient to remove
  94982. * @returns the current particle system
  94983. */
  94984. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94985. /**
  94986. * Adds a new drag gradient
  94987. * @param gradient defines the gradient to use (between 0 and 1)
  94988. * @param factor defines the drag to affect to the specified gradient
  94989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94990. * @returns the current particle system
  94991. */
  94992. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94993. /**
  94994. * Remove a specific drag gradient
  94995. * @param gradient defines the gradient to remove
  94996. * @returns the current particle system
  94997. */
  94998. removeDragGradient(gradient: number): IParticleSystem;
  94999. /**
  95000. * Gets the current list of drag gradients.
  95001. * You must use addDragGradient and removeDragGradient to udpate this list
  95002. * @returns the list of drag gradients
  95003. */
  95004. getDragGradients(): Nullable<Array<FactorGradient>>;
  95005. /**
  95006. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  95007. * @param gradient defines the gradient to use (between 0 and 1)
  95008. * @param factor defines the emit rate to affect to the specified gradient
  95009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95010. * @returns the current particle system
  95011. */
  95012. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95013. /**
  95014. * Remove a specific emit rate gradient
  95015. * @param gradient defines the gradient to remove
  95016. * @returns the current particle system
  95017. */
  95018. removeEmitRateGradient(gradient: number): IParticleSystem;
  95019. /**
  95020. * Gets the current list of emit rate gradients.
  95021. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  95022. * @returns the list of emit rate gradients
  95023. */
  95024. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  95025. /**
  95026. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  95027. * @param gradient defines the gradient to use (between 0 and 1)
  95028. * @param factor defines the start size to affect to the specified gradient
  95029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95030. * @returns the current particle system
  95031. */
  95032. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95033. /**
  95034. * Remove a specific start size gradient
  95035. * @param gradient defines the gradient to remove
  95036. * @returns the current particle system
  95037. */
  95038. removeStartSizeGradient(gradient: number): IParticleSystem;
  95039. /**
  95040. * Gets the current list of start size gradients.
  95041. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95042. * @returns the list of start size gradients
  95043. */
  95044. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95045. /**
  95046. * Adds a new life time gradient
  95047. * @param gradient defines the gradient to use (between 0 and 1)
  95048. * @param factor defines the life time factor to affect to the specified gradient
  95049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95050. * @returns the current particle system
  95051. */
  95052. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95053. /**
  95054. * Remove a specific life time gradient
  95055. * @param gradient defines the gradient to remove
  95056. * @returns the current particle system
  95057. */
  95058. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95059. /**
  95060. * Gets the current list of life time gradients.
  95061. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95062. * @returns the list of life time gradients
  95063. */
  95064. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95065. /**
  95066. * Gets the current list of color gradients.
  95067. * You must use addColorGradient and removeColorGradient to udpate this list
  95068. * @returns the list of color gradients
  95069. */
  95070. getColorGradients(): Nullable<Array<ColorGradient>>;
  95071. /**
  95072. * Adds a new ramp gradient used to remap particle colors
  95073. * @param gradient defines the gradient to use (between 0 and 1)
  95074. * @param color defines the color to affect to the specified gradient
  95075. * @returns the current particle system
  95076. */
  95077. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95078. /**
  95079. * Gets the current list of ramp gradients.
  95080. * You must use addRampGradient and removeRampGradient to udpate this list
  95081. * @returns the list of ramp gradients
  95082. */
  95083. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95084. /** Gets or sets a boolean indicating that ramp gradients must be used
  95085. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95086. */
  95087. useRampGradients: boolean;
  95088. /**
  95089. * Adds a new color remap gradient
  95090. * @param gradient defines the gradient to use (between 0 and 1)
  95091. * @param min defines the color remap minimal range
  95092. * @param max defines the color remap maximal range
  95093. * @returns the current particle system
  95094. */
  95095. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95096. /**
  95097. * Gets the current list of color remap gradients.
  95098. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95099. * @returns the list of color remap gradients
  95100. */
  95101. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95102. /**
  95103. * Adds a new alpha remap gradient
  95104. * @param gradient defines the gradient to use (between 0 and 1)
  95105. * @param min defines the alpha remap minimal range
  95106. * @param max defines the alpha remap maximal range
  95107. * @returns the current particle system
  95108. */
  95109. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95110. /**
  95111. * Gets the current list of alpha remap gradients.
  95112. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95113. * @returns the list of alpha remap gradients
  95114. */
  95115. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95116. /**
  95117. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95118. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95119. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95120. * @returns the emitter
  95121. */
  95122. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95123. /**
  95124. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95125. * @param radius The radius of the hemisphere to emit from
  95126. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95127. * @returns the emitter
  95128. */
  95129. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95130. /**
  95131. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95132. * @param radius The radius of the sphere to emit from
  95133. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95134. * @returns the emitter
  95135. */
  95136. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95137. /**
  95138. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95139. * @param radius The radius of the sphere to emit from
  95140. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95141. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95142. * @returns the emitter
  95143. */
  95144. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95145. /**
  95146. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95147. * @param radius The radius of the emission cylinder
  95148. * @param height The height of the emission cylinder
  95149. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95150. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95151. * @returns the emitter
  95152. */
  95153. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95154. /**
  95155. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95156. * @param radius The radius of the cylinder to emit from
  95157. * @param height The height of the emission cylinder
  95158. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95159. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95160. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95161. * @returns the emitter
  95162. */
  95163. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95164. /**
  95165. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95166. * @param radius The radius of the cone to emit from
  95167. * @param angle The base angle of the cone
  95168. * @returns the emitter
  95169. */
  95170. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95171. /**
  95172. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95173. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95174. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95175. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95176. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95177. * @returns the emitter
  95178. */
  95179. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95180. /**
  95181. * Get hosting scene
  95182. * @returns the scene
  95183. */
  95184. getScene(): Nullable<Scene>;
  95185. }
  95186. }
  95187. declare module BABYLON {
  95188. /**
  95189. * 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.
  95190. * @see https://doc.babylonjs.com/how_to/transformnode
  95191. */
  95192. export class TransformNode extends Node {
  95193. /**
  95194. * Object will not rotate to face the camera
  95195. */
  95196. static BILLBOARDMODE_NONE: number;
  95197. /**
  95198. * Object will rotate to face the camera but only on the x axis
  95199. */
  95200. static BILLBOARDMODE_X: number;
  95201. /**
  95202. * Object will rotate to face the camera but only on the y axis
  95203. */
  95204. static BILLBOARDMODE_Y: number;
  95205. /**
  95206. * Object will rotate to face the camera but only on the z axis
  95207. */
  95208. static BILLBOARDMODE_Z: number;
  95209. /**
  95210. * Object will rotate to face the camera
  95211. */
  95212. static BILLBOARDMODE_ALL: number;
  95213. /**
  95214. * Object will rotate to face the camera's position instead of orientation
  95215. */
  95216. static BILLBOARDMODE_USE_POSITION: number;
  95217. private static _TmpRotation;
  95218. private static _TmpScaling;
  95219. private static _TmpTranslation;
  95220. private _forward;
  95221. private _forwardInverted;
  95222. private _up;
  95223. private _right;
  95224. private _rightInverted;
  95225. private _position;
  95226. private _rotation;
  95227. private _rotationQuaternion;
  95228. protected _scaling: Vector3;
  95229. protected _isDirty: boolean;
  95230. private _transformToBoneReferal;
  95231. private _isAbsoluteSynced;
  95232. private _billboardMode;
  95233. /**
  95234. * Gets or sets the billboard mode. Default is 0.
  95235. *
  95236. * | Value | Type | Description |
  95237. * | --- | --- | --- |
  95238. * | 0 | BILLBOARDMODE_NONE | |
  95239. * | 1 | BILLBOARDMODE_X | |
  95240. * | 2 | BILLBOARDMODE_Y | |
  95241. * | 4 | BILLBOARDMODE_Z | |
  95242. * | 7 | BILLBOARDMODE_ALL | |
  95243. *
  95244. */
  95245. get billboardMode(): number;
  95246. set billboardMode(value: number);
  95247. private _preserveParentRotationForBillboard;
  95248. /**
  95249. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95250. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95251. */
  95252. get preserveParentRotationForBillboard(): boolean;
  95253. set preserveParentRotationForBillboard(value: boolean);
  95254. /**
  95255. * 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
  95256. */
  95257. scalingDeterminant: number;
  95258. private _infiniteDistance;
  95259. /**
  95260. * Gets or sets the distance of the object to max, often used by skybox
  95261. */
  95262. get infiniteDistance(): boolean;
  95263. set infiniteDistance(value: boolean);
  95264. /**
  95265. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95266. * By default the system will update normals to compensate
  95267. */
  95268. ignoreNonUniformScaling: boolean;
  95269. /**
  95270. * 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
  95271. */
  95272. reIntegrateRotationIntoRotationQuaternion: boolean;
  95273. /** @hidden */
  95274. _poseMatrix: Nullable<Matrix>;
  95275. /** @hidden */
  95276. _localMatrix: Matrix;
  95277. private _usePivotMatrix;
  95278. private _absolutePosition;
  95279. private _absoluteScaling;
  95280. private _absoluteRotationQuaternion;
  95281. private _pivotMatrix;
  95282. private _pivotMatrixInverse;
  95283. /** @hidden */
  95284. _postMultiplyPivotMatrix: boolean;
  95285. protected _isWorldMatrixFrozen: boolean;
  95286. /** @hidden */
  95287. _indexInSceneTransformNodesArray: number;
  95288. /**
  95289. * An event triggered after the world matrix is updated
  95290. */
  95291. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95292. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95293. /**
  95294. * Gets a string identifying the name of the class
  95295. * @returns "TransformNode" string
  95296. */
  95297. getClassName(): string;
  95298. /**
  95299. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95300. */
  95301. get position(): Vector3;
  95302. set position(newPosition: Vector3);
  95303. /**
  95304. * 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)).
  95305. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95306. */
  95307. get rotation(): Vector3;
  95308. set rotation(newRotation: Vector3);
  95309. /**
  95310. * 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)).
  95311. */
  95312. get scaling(): Vector3;
  95313. set scaling(newScaling: Vector3);
  95314. /**
  95315. * 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).
  95316. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95317. */
  95318. get rotationQuaternion(): Nullable<Quaternion>;
  95319. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95320. /**
  95321. * The forward direction of that transform in world space.
  95322. */
  95323. get forward(): Vector3;
  95324. /**
  95325. * The up direction of that transform in world space.
  95326. */
  95327. get up(): Vector3;
  95328. /**
  95329. * The right direction of that transform in world space.
  95330. */
  95331. get right(): Vector3;
  95332. /**
  95333. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95334. * @param matrix the matrix to copy the pose from
  95335. * @returns this TransformNode.
  95336. */
  95337. updatePoseMatrix(matrix: Matrix): TransformNode;
  95338. /**
  95339. * Returns the mesh Pose matrix.
  95340. * @returns the pose matrix
  95341. */
  95342. getPoseMatrix(): Matrix;
  95343. /** @hidden */
  95344. _isSynchronized(): boolean;
  95345. /** @hidden */
  95346. _initCache(): void;
  95347. /**
  95348. * Flag the transform node as dirty (Forcing it to update everything)
  95349. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95350. * @returns this transform node
  95351. */
  95352. markAsDirty(property: string): TransformNode;
  95353. /**
  95354. * Returns the current mesh absolute position.
  95355. * Returns a Vector3.
  95356. */
  95357. get absolutePosition(): Vector3;
  95358. /**
  95359. * Returns the current mesh absolute scaling.
  95360. * Returns a Vector3.
  95361. */
  95362. get absoluteScaling(): Vector3;
  95363. /**
  95364. * Returns the current mesh absolute rotation.
  95365. * Returns a Quaternion.
  95366. */
  95367. get absoluteRotationQuaternion(): Quaternion;
  95368. /**
  95369. * Sets a new matrix to apply before all other transformation
  95370. * @param matrix defines the transform matrix
  95371. * @returns the current TransformNode
  95372. */
  95373. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95374. /**
  95375. * Sets a new pivot matrix to the current node
  95376. * @param matrix defines the new pivot matrix to use
  95377. * @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
  95378. * @returns the current TransformNode
  95379. */
  95380. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95381. /**
  95382. * Returns the mesh pivot matrix.
  95383. * Default : Identity.
  95384. * @returns the matrix
  95385. */
  95386. getPivotMatrix(): Matrix;
  95387. /**
  95388. * Instantiate (when possible) or clone that node with its hierarchy
  95389. * @param newParent defines the new parent to use for the instance (or clone)
  95390. * @param options defines options to configure how copy is done
  95391. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95392. * @returns an instance (or a clone) of the current node with its hiearchy
  95393. */
  95394. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95395. doNotInstantiate: boolean;
  95396. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95397. /**
  95398. * Prevents the World matrix to be computed any longer
  95399. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95400. * @returns the TransformNode.
  95401. */
  95402. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95403. /**
  95404. * Allows back the World matrix computation.
  95405. * @returns the TransformNode.
  95406. */
  95407. unfreezeWorldMatrix(): this;
  95408. /**
  95409. * True if the World matrix has been frozen.
  95410. */
  95411. get isWorldMatrixFrozen(): boolean;
  95412. /**
  95413. * Retuns the mesh absolute position in the World.
  95414. * @returns a Vector3.
  95415. */
  95416. getAbsolutePosition(): Vector3;
  95417. /**
  95418. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95419. * @param absolutePosition the absolute position to set
  95420. * @returns the TransformNode.
  95421. */
  95422. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95423. /**
  95424. * Sets the mesh position in its local space.
  95425. * @param vector3 the position to set in localspace
  95426. * @returns the TransformNode.
  95427. */
  95428. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95429. /**
  95430. * Returns the mesh position in the local space from the current World matrix values.
  95431. * @returns a new Vector3.
  95432. */
  95433. getPositionExpressedInLocalSpace(): Vector3;
  95434. /**
  95435. * Translates the mesh along the passed Vector3 in its local space.
  95436. * @param vector3 the distance to translate in localspace
  95437. * @returns the TransformNode.
  95438. */
  95439. locallyTranslate(vector3: Vector3): TransformNode;
  95440. private static _lookAtVectorCache;
  95441. /**
  95442. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95443. * @param targetPoint the position (must be in same space as current mesh) to look at
  95444. * @param yawCor optional yaw (y-axis) correction in radians
  95445. * @param pitchCor optional pitch (x-axis) correction in radians
  95446. * @param rollCor optional roll (z-axis) correction in radians
  95447. * @param space the choosen space of the target
  95448. * @returns the TransformNode.
  95449. */
  95450. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95451. /**
  95452. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95453. * This Vector3 is expressed in the World space.
  95454. * @param localAxis axis to rotate
  95455. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95456. */
  95457. getDirection(localAxis: Vector3): Vector3;
  95458. /**
  95459. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95460. * localAxis is expressed in the mesh local space.
  95461. * result is computed in the Wordl space from the mesh World matrix.
  95462. * @param localAxis axis to rotate
  95463. * @param result the resulting transformnode
  95464. * @returns this TransformNode.
  95465. */
  95466. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95467. /**
  95468. * Sets this transform node rotation to the given local axis.
  95469. * @param localAxis the axis in local space
  95470. * @param yawCor optional yaw (y-axis) correction in radians
  95471. * @param pitchCor optional pitch (x-axis) correction in radians
  95472. * @param rollCor optional roll (z-axis) correction in radians
  95473. * @returns this TransformNode
  95474. */
  95475. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95476. /**
  95477. * Sets a new pivot point to the current node
  95478. * @param point defines the new pivot point to use
  95479. * @param space defines if the point is in world or local space (local by default)
  95480. * @returns the current TransformNode
  95481. */
  95482. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95483. /**
  95484. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95485. * @returns the pivot point
  95486. */
  95487. getPivotPoint(): Vector3;
  95488. /**
  95489. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95490. * @param result the vector3 to store the result
  95491. * @returns this TransformNode.
  95492. */
  95493. getPivotPointToRef(result: Vector3): TransformNode;
  95494. /**
  95495. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95496. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95497. */
  95498. getAbsolutePivotPoint(): Vector3;
  95499. /**
  95500. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95501. * @param result vector3 to store the result
  95502. * @returns this TransformNode.
  95503. */
  95504. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95505. /**
  95506. * Defines the passed node as the parent of the current node.
  95507. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95508. * @see https://doc.babylonjs.com/how_to/parenting
  95509. * @param node the node ot set as the parent
  95510. * @returns this TransformNode.
  95511. */
  95512. setParent(node: Nullable<Node>): TransformNode;
  95513. private _nonUniformScaling;
  95514. /**
  95515. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95516. */
  95517. get nonUniformScaling(): boolean;
  95518. /** @hidden */
  95519. _updateNonUniformScalingState(value: boolean): boolean;
  95520. /**
  95521. * Attach the current TransformNode to another TransformNode associated with a bone
  95522. * @param bone Bone affecting the TransformNode
  95523. * @param affectedTransformNode TransformNode associated with the bone
  95524. * @returns this object
  95525. */
  95526. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95527. /**
  95528. * Detach the transform node if its associated with a bone
  95529. * @returns this object
  95530. */
  95531. detachFromBone(): TransformNode;
  95532. private static _rotationAxisCache;
  95533. /**
  95534. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95535. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95536. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95537. * The passed axis is also normalized.
  95538. * @param axis the axis to rotate around
  95539. * @param amount the amount to rotate in radians
  95540. * @param space Space to rotate in (Default: local)
  95541. * @returns the TransformNode.
  95542. */
  95543. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95544. /**
  95545. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95546. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95547. * The passed axis is also normalized. .
  95548. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95549. * @param point the point to rotate around
  95550. * @param axis the axis to rotate around
  95551. * @param amount the amount to rotate in radians
  95552. * @returns the TransformNode
  95553. */
  95554. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95555. /**
  95556. * Translates the mesh along the axis vector for the passed distance in the given space.
  95557. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95558. * @param axis the axis to translate in
  95559. * @param distance the distance to translate
  95560. * @param space Space to rotate in (Default: local)
  95561. * @returns the TransformNode.
  95562. */
  95563. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95564. /**
  95565. * Adds a rotation step to the mesh current rotation.
  95566. * x, y, z are Euler angles expressed in radians.
  95567. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95568. * This means this rotation is made in the mesh local space only.
  95569. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95570. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95571. * ```javascript
  95572. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95573. * ```
  95574. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95575. * 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.
  95576. * @param x Rotation to add
  95577. * @param y Rotation to add
  95578. * @param z Rotation to add
  95579. * @returns the TransformNode.
  95580. */
  95581. addRotation(x: number, y: number, z: number): TransformNode;
  95582. /**
  95583. * @hidden
  95584. */
  95585. protected _getEffectiveParent(): Nullable<Node>;
  95586. /**
  95587. * Computes the world matrix of the node
  95588. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95589. * @returns the world matrix
  95590. */
  95591. computeWorldMatrix(force?: boolean): Matrix;
  95592. /**
  95593. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95594. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95595. */
  95596. resetLocalMatrix(independentOfChildren?: boolean): void;
  95597. protected _afterComputeWorldMatrix(): void;
  95598. /**
  95599. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95600. * @param func callback function to add
  95601. *
  95602. * @returns the TransformNode.
  95603. */
  95604. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95605. /**
  95606. * Removes a registered callback function.
  95607. * @param func callback function to remove
  95608. * @returns the TransformNode.
  95609. */
  95610. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95611. /**
  95612. * Gets the position of the current mesh in camera space
  95613. * @param camera defines the camera to use
  95614. * @returns a position
  95615. */
  95616. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95617. /**
  95618. * Returns the distance from the mesh to the active camera
  95619. * @param camera defines the camera to use
  95620. * @returns the distance
  95621. */
  95622. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95623. /**
  95624. * Clone the current transform node
  95625. * @param name Name of the new clone
  95626. * @param newParent New parent for the clone
  95627. * @param doNotCloneChildren Do not clone children hierarchy
  95628. * @returns the new transform node
  95629. */
  95630. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95631. /**
  95632. * Serializes the objects information.
  95633. * @param currentSerializationObject defines the object to serialize in
  95634. * @returns the serialized object
  95635. */
  95636. serialize(currentSerializationObject?: any): any;
  95637. /**
  95638. * Returns a new TransformNode object parsed from the source provided.
  95639. * @param parsedTransformNode is the source.
  95640. * @param scene the scne the object belongs to
  95641. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95642. * @returns a new TransformNode object parsed from the source provided.
  95643. */
  95644. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95645. /**
  95646. * Get all child-transformNodes of this node
  95647. * @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
  95648. * @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
  95649. * @returns an array of TransformNode
  95650. */
  95651. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95652. /**
  95653. * Releases resources associated with this transform node.
  95654. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95655. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95656. */
  95657. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95658. /**
  95659. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95660. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95661. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95662. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95663. * @returns the current mesh
  95664. */
  95665. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95666. private _syncAbsoluteScalingAndRotation;
  95667. }
  95668. }
  95669. declare module BABYLON {
  95670. /**
  95671. * Class used to override all child animations of a given target
  95672. */
  95673. export class AnimationPropertiesOverride {
  95674. /**
  95675. * Gets or sets a value indicating if animation blending must be used
  95676. */
  95677. enableBlending: boolean;
  95678. /**
  95679. * Gets or sets the blending speed to use when enableBlending is true
  95680. */
  95681. blendingSpeed: number;
  95682. /**
  95683. * Gets or sets the default loop mode to use
  95684. */
  95685. loopMode: number;
  95686. }
  95687. }
  95688. declare module BABYLON {
  95689. /**
  95690. * Class used to store bone information
  95691. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95692. */
  95693. export class Bone extends Node {
  95694. /**
  95695. * defines the bone name
  95696. */
  95697. name: string;
  95698. private static _tmpVecs;
  95699. private static _tmpQuat;
  95700. private static _tmpMats;
  95701. /**
  95702. * Gets the list of child bones
  95703. */
  95704. children: Bone[];
  95705. /** Gets the animations associated with this bone */
  95706. animations: Animation[];
  95707. /**
  95708. * Gets or sets bone length
  95709. */
  95710. length: number;
  95711. /**
  95712. * @hidden Internal only
  95713. * Set this value to map this bone to a different index in the transform matrices
  95714. * Set this value to -1 to exclude the bone from the transform matrices
  95715. */
  95716. _index: Nullable<number>;
  95717. private _skeleton;
  95718. private _localMatrix;
  95719. private _restPose;
  95720. private _bindPose;
  95721. private _baseMatrix;
  95722. private _absoluteTransform;
  95723. private _invertedAbsoluteTransform;
  95724. private _parent;
  95725. private _scalingDeterminant;
  95726. private _worldTransform;
  95727. private _localScaling;
  95728. private _localRotation;
  95729. private _localPosition;
  95730. private _needToDecompose;
  95731. private _needToCompose;
  95732. /** @hidden */
  95733. _linkedTransformNode: Nullable<TransformNode>;
  95734. /** @hidden */
  95735. _waitingTransformNodeId: Nullable<string>;
  95736. /** @hidden */
  95737. get _matrix(): Matrix;
  95738. /** @hidden */
  95739. set _matrix(value: Matrix);
  95740. /**
  95741. * Create a new bone
  95742. * @param name defines the bone name
  95743. * @param skeleton defines the parent skeleton
  95744. * @param parentBone defines the parent (can be null if the bone is the root)
  95745. * @param localMatrix defines the local matrix
  95746. * @param restPose defines the rest pose matrix
  95747. * @param baseMatrix defines the base matrix
  95748. * @param index defines index of the bone in the hiearchy
  95749. */
  95750. constructor(
  95751. /**
  95752. * defines the bone name
  95753. */
  95754. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95755. /**
  95756. * Gets the current object class name.
  95757. * @return the class name
  95758. */
  95759. getClassName(): string;
  95760. /**
  95761. * Gets the parent skeleton
  95762. * @returns a skeleton
  95763. */
  95764. getSkeleton(): Skeleton;
  95765. /**
  95766. * Gets parent bone
  95767. * @returns a bone or null if the bone is the root of the bone hierarchy
  95768. */
  95769. getParent(): Nullable<Bone>;
  95770. /**
  95771. * Returns an array containing the root bones
  95772. * @returns an array containing the root bones
  95773. */
  95774. getChildren(): Array<Bone>;
  95775. /**
  95776. * Gets the node index in matrix array generated for rendering
  95777. * @returns the node index
  95778. */
  95779. getIndex(): number;
  95780. /**
  95781. * Sets the parent bone
  95782. * @param parent defines the parent (can be null if the bone is the root)
  95783. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95784. */
  95785. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95786. /**
  95787. * Gets the local matrix
  95788. * @returns a matrix
  95789. */
  95790. getLocalMatrix(): Matrix;
  95791. /**
  95792. * Gets the base matrix (initial matrix which remains unchanged)
  95793. * @returns a matrix
  95794. */
  95795. getBaseMatrix(): Matrix;
  95796. /**
  95797. * Gets the rest pose matrix
  95798. * @returns a matrix
  95799. */
  95800. getRestPose(): Matrix;
  95801. /**
  95802. * Sets the rest pose matrix
  95803. * @param matrix the local-space rest pose to set for this bone
  95804. */
  95805. setRestPose(matrix: Matrix): void;
  95806. /**
  95807. * Gets the bind pose matrix
  95808. * @returns the bind pose matrix
  95809. */
  95810. getBindPose(): Matrix;
  95811. /**
  95812. * Sets the bind pose matrix
  95813. * @param matrix the local-space bind pose to set for this bone
  95814. */
  95815. setBindPose(matrix: Matrix): void;
  95816. /**
  95817. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95818. */
  95819. getWorldMatrix(): Matrix;
  95820. /**
  95821. * Sets the local matrix to rest pose matrix
  95822. */
  95823. returnToRest(): void;
  95824. /**
  95825. * Gets the inverse of the absolute transform matrix.
  95826. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95827. * @returns a matrix
  95828. */
  95829. getInvertedAbsoluteTransform(): Matrix;
  95830. /**
  95831. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95832. * @returns a matrix
  95833. */
  95834. getAbsoluteTransform(): Matrix;
  95835. /**
  95836. * Links with the given transform node.
  95837. * The local matrix of this bone is copied from the transform node every frame.
  95838. * @param transformNode defines the transform node to link to
  95839. */
  95840. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95841. /**
  95842. * Gets the node used to drive the bone's transformation
  95843. * @returns a transform node or null
  95844. */
  95845. getTransformNode(): Nullable<TransformNode>;
  95846. /** Gets or sets current position (in local space) */
  95847. get position(): Vector3;
  95848. set position(newPosition: Vector3);
  95849. /** Gets or sets current rotation (in local space) */
  95850. get rotation(): Vector3;
  95851. set rotation(newRotation: Vector3);
  95852. /** Gets or sets current rotation quaternion (in local space) */
  95853. get rotationQuaternion(): Quaternion;
  95854. set rotationQuaternion(newRotation: Quaternion);
  95855. /** Gets or sets current scaling (in local space) */
  95856. get scaling(): Vector3;
  95857. set scaling(newScaling: Vector3);
  95858. /**
  95859. * Gets the animation properties override
  95860. */
  95861. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95862. private _decompose;
  95863. private _compose;
  95864. /**
  95865. * Update the base and local matrices
  95866. * @param matrix defines the new base or local matrix
  95867. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95868. * @param updateLocalMatrix defines if the local matrix should be updated
  95869. */
  95870. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95871. /** @hidden */
  95872. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95873. /**
  95874. * Flag the bone as dirty (Forcing it to update everything)
  95875. */
  95876. markAsDirty(): void;
  95877. /** @hidden */
  95878. _markAsDirtyAndCompose(): void;
  95879. private _markAsDirtyAndDecompose;
  95880. /**
  95881. * Translate the bone in local or world space
  95882. * @param vec The amount to translate the bone
  95883. * @param space The space that the translation is in
  95884. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95885. */
  95886. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95887. /**
  95888. * Set the postion of the bone in local or world space
  95889. * @param position The position to set the bone
  95890. * @param space The space that the position is in
  95891. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95892. */
  95893. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95894. /**
  95895. * Set the absolute position of the bone (world space)
  95896. * @param position The position to set the bone
  95897. * @param mesh The mesh that this bone is attached to
  95898. */
  95899. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95900. /**
  95901. * Scale the bone on the x, y and z axes (in local space)
  95902. * @param x The amount to scale the bone on the x axis
  95903. * @param y The amount to scale the bone on the y axis
  95904. * @param z The amount to scale the bone on the z axis
  95905. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95906. */
  95907. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95908. /**
  95909. * Set the bone scaling in local space
  95910. * @param scale defines the scaling vector
  95911. */
  95912. setScale(scale: Vector3): void;
  95913. /**
  95914. * Gets the current scaling in local space
  95915. * @returns the current scaling vector
  95916. */
  95917. getScale(): Vector3;
  95918. /**
  95919. * Gets the current scaling in local space and stores it in a target vector
  95920. * @param result defines the target vector
  95921. */
  95922. getScaleToRef(result: Vector3): void;
  95923. /**
  95924. * Set the yaw, pitch, and roll of the bone in local or world space
  95925. * @param yaw The rotation of the bone on the y axis
  95926. * @param pitch The rotation of the bone on the x axis
  95927. * @param roll The rotation of the bone on the z axis
  95928. * @param space The space that the axes of rotation are in
  95929. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95930. */
  95931. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95932. /**
  95933. * Add a rotation to the bone on an axis in local or world space
  95934. * @param axis The axis to rotate the bone on
  95935. * @param amount The amount to rotate the bone
  95936. * @param space The space that the axis is in
  95937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95938. */
  95939. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95940. /**
  95941. * Set the rotation of the bone to a particular axis angle in local or world space
  95942. * @param axis The axis to rotate the bone on
  95943. * @param angle The angle that the bone should be rotated to
  95944. * @param space The space that the axis is in
  95945. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95946. */
  95947. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95948. /**
  95949. * Set the euler rotation of the bone in local or world space
  95950. * @param rotation The euler rotation that the bone should be set to
  95951. * @param space The space that the rotation is in
  95952. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95953. */
  95954. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95955. /**
  95956. * Set the quaternion rotation of the bone in local or world space
  95957. * @param quat The quaternion rotation that the bone should be set to
  95958. * @param space The space that the rotation is in
  95959. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95960. */
  95961. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95962. /**
  95963. * Set the rotation matrix of the bone in local or world space
  95964. * @param rotMat The rotation matrix that the bone should be set to
  95965. * @param space The space that the rotation is in
  95966. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95967. */
  95968. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95969. private _rotateWithMatrix;
  95970. private _getNegativeRotationToRef;
  95971. /**
  95972. * Get the position of the bone in local or world space
  95973. * @param space The space that the returned position is in
  95974. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95975. * @returns The position of the bone
  95976. */
  95977. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95978. /**
  95979. * Copy the position of the bone to a vector3 in local or world space
  95980. * @param space The space that the returned position is in
  95981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95982. * @param result The vector3 to copy the position to
  95983. */
  95984. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95985. /**
  95986. * Get the absolute position of the bone (world space)
  95987. * @param mesh The mesh that this bone is attached to
  95988. * @returns The absolute position of the bone
  95989. */
  95990. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95991. /**
  95992. * Copy the absolute position of the bone (world space) to the result param
  95993. * @param mesh The mesh that this bone is attached to
  95994. * @param result The vector3 to copy the absolute position to
  95995. */
  95996. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95997. /**
  95998. * Compute the absolute transforms of this bone and its children
  95999. */
  96000. computeAbsoluteTransforms(): void;
  96001. /**
  96002. * Get the world direction from an axis that is in the local space of the bone
  96003. * @param localAxis The local direction that is used to compute the world direction
  96004. * @param mesh The mesh that this bone is attached to
  96005. * @returns The world direction
  96006. */
  96007. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96008. /**
  96009. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  96010. * @param localAxis The local direction that is used to compute the world direction
  96011. * @param mesh The mesh that this bone is attached to
  96012. * @param result The vector3 that the world direction will be copied to
  96013. */
  96014. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96015. /**
  96016. * Get the euler rotation of the bone in local or world space
  96017. * @param space The space that the rotation should be in
  96018. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96019. * @returns The euler rotation
  96020. */
  96021. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96022. /**
  96023. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  96024. * @param space The space that the rotation should be in
  96025. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96026. * @param result The vector3 that the rotation should be copied to
  96027. */
  96028. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96029. /**
  96030. * Get the quaternion rotation of the bone in either local or world space
  96031. * @param space The space that the rotation should be in
  96032. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96033. * @returns The quaternion rotation
  96034. */
  96035. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96036. /**
  96037. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96038. * @param space The space that the rotation should be in
  96039. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96040. * @param result The quaternion that the rotation should be copied to
  96041. */
  96042. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96043. /**
  96044. * Get the rotation matrix of the bone in local or world space
  96045. * @param space The space that the rotation should be in
  96046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96047. * @returns The rotation matrix
  96048. */
  96049. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96050. /**
  96051. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96052. * @param space The space that the rotation should be in
  96053. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96054. * @param result The quaternion that the rotation should be copied to
  96055. */
  96056. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96057. /**
  96058. * Get the world position of a point that is in the local space of the bone
  96059. * @param position The local position
  96060. * @param mesh The mesh that this bone is attached to
  96061. * @returns The world position
  96062. */
  96063. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96064. /**
  96065. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96066. * @param position The local position
  96067. * @param mesh The mesh that this bone is attached to
  96068. * @param result The vector3 that the world position should be copied to
  96069. */
  96070. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96071. /**
  96072. * Get the local position of a point that is in world space
  96073. * @param position The world position
  96074. * @param mesh The mesh that this bone is attached to
  96075. * @returns The local position
  96076. */
  96077. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96078. /**
  96079. * Get the local position of a point that is in world space and copy it to the result param
  96080. * @param position The world position
  96081. * @param mesh The mesh that this bone is attached to
  96082. * @param result The vector3 that the local position should be copied to
  96083. */
  96084. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96085. /**
  96086. * Set the current local matrix as the restPose for this bone.
  96087. */
  96088. setCurrentPoseAsRest(): void;
  96089. }
  96090. }
  96091. declare module BABYLON {
  96092. /**
  96093. * Defines a runtime animation
  96094. */
  96095. export class RuntimeAnimation {
  96096. private _events;
  96097. /**
  96098. * The current frame of the runtime animation
  96099. */
  96100. private _currentFrame;
  96101. /**
  96102. * The animation used by the runtime animation
  96103. */
  96104. private _animation;
  96105. /**
  96106. * The target of the runtime animation
  96107. */
  96108. private _target;
  96109. /**
  96110. * The initiating animatable
  96111. */
  96112. private _host;
  96113. /**
  96114. * The original value of the runtime animation
  96115. */
  96116. private _originalValue;
  96117. /**
  96118. * The original blend value of the runtime animation
  96119. */
  96120. private _originalBlendValue;
  96121. /**
  96122. * The offsets cache of the runtime animation
  96123. */
  96124. private _offsetsCache;
  96125. /**
  96126. * The high limits cache of the runtime animation
  96127. */
  96128. private _highLimitsCache;
  96129. /**
  96130. * Specifies if the runtime animation has been stopped
  96131. */
  96132. private _stopped;
  96133. /**
  96134. * The blending factor of the runtime animation
  96135. */
  96136. private _blendingFactor;
  96137. /**
  96138. * The BabylonJS scene
  96139. */
  96140. private _scene;
  96141. /**
  96142. * The current value of the runtime animation
  96143. */
  96144. private _currentValue;
  96145. /** @hidden */
  96146. _animationState: _IAnimationState;
  96147. /**
  96148. * The active target of the runtime animation
  96149. */
  96150. private _activeTargets;
  96151. private _currentActiveTarget;
  96152. private _directTarget;
  96153. /**
  96154. * The target path of the runtime animation
  96155. */
  96156. private _targetPath;
  96157. /**
  96158. * The weight of the runtime animation
  96159. */
  96160. private _weight;
  96161. /**
  96162. * The ratio offset of the runtime animation
  96163. */
  96164. private _ratioOffset;
  96165. /**
  96166. * The previous delay of the runtime animation
  96167. */
  96168. private _previousDelay;
  96169. /**
  96170. * The previous ratio of the runtime animation
  96171. */
  96172. private _previousRatio;
  96173. private _enableBlending;
  96174. private _keys;
  96175. private _minFrame;
  96176. private _maxFrame;
  96177. private _minValue;
  96178. private _maxValue;
  96179. private _targetIsArray;
  96180. /**
  96181. * Gets the current frame of the runtime animation
  96182. */
  96183. get currentFrame(): number;
  96184. /**
  96185. * Gets the weight of the runtime animation
  96186. */
  96187. get weight(): number;
  96188. /**
  96189. * Gets the current value of the runtime animation
  96190. */
  96191. get currentValue(): any;
  96192. /**
  96193. * Gets the target path of the runtime animation
  96194. */
  96195. get targetPath(): string;
  96196. /**
  96197. * Gets the actual target of the runtime animation
  96198. */
  96199. get target(): any;
  96200. /**
  96201. * Gets the additive state of the runtime animation
  96202. */
  96203. get isAdditive(): boolean;
  96204. /** @hidden */
  96205. _onLoop: () => void;
  96206. /**
  96207. * Create a new RuntimeAnimation object
  96208. * @param target defines the target of the animation
  96209. * @param animation defines the source animation object
  96210. * @param scene defines the hosting scene
  96211. * @param host defines the initiating Animatable
  96212. */
  96213. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96214. private _preparePath;
  96215. /**
  96216. * Gets the animation from the runtime animation
  96217. */
  96218. get animation(): Animation;
  96219. /**
  96220. * Resets the runtime animation to the beginning
  96221. * @param restoreOriginal defines whether to restore the target property to the original value
  96222. */
  96223. reset(restoreOriginal?: boolean): void;
  96224. /**
  96225. * Specifies if the runtime animation is stopped
  96226. * @returns Boolean specifying if the runtime animation is stopped
  96227. */
  96228. isStopped(): boolean;
  96229. /**
  96230. * Disposes of the runtime animation
  96231. */
  96232. dispose(): void;
  96233. /**
  96234. * Apply the interpolated value to the target
  96235. * @param currentValue defines the value computed by the animation
  96236. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96237. */
  96238. setValue(currentValue: any, weight: number): void;
  96239. private _getOriginalValues;
  96240. private _setValue;
  96241. /**
  96242. * Gets the loop pmode of the runtime animation
  96243. * @returns Loop Mode
  96244. */
  96245. private _getCorrectLoopMode;
  96246. /**
  96247. * Move the current animation to a given frame
  96248. * @param frame defines the frame to move to
  96249. */
  96250. goToFrame(frame: number): void;
  96251. /**
  96252. * @hidden Internal use only
  96253. */
  96254. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96255. /**
  96256. * Execute the current animation
  96257. * @param delay defines the delay to add to the current frame
  96258. * @param from defines the lower bound of the animation range
  96259. * @param to defines the upper bound of the animation range
  96260. * @param loop defines if the current animation must loop
  96261. * @param speedRatio defines the current speed ratio
  96262. * @param weight defines the weight of the animation (default is -1 so no weight)
  96263. * @param onLoop optional callback called when animation loops
  96264. * @returns a boolean indicating if the animation is running
  96265. */
  96266. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96267. }
  96268. }
  96269. declare module BABYLON {
  96270. /**
  96271. * Class used to store an actual running animation
  96272. */
  96273. export class Animatable {
  96274. /** defines the target object */
  96275. target: any;
  96276. /** defines the starting frame number (default is 0) */
  96277. fromFrame: number;
  96278. /** defines the ending frame number (default is 100) */
  96279. toFrame: number;
  96280. /** defines if the animation must loop (default is false) */
  96281. loopAnimation: boolean;
  96282. /** defines a callback to call when animation ends if it is not looping */
  96283. onAnimationEnd?: (() => void) | null | undefined;
  96284. /** defines a callback to call when animation loops */
  96285. onAnimationLoop?: (() => void) | null | undefined;
  96286. /** defines whether the animation should be evaluated additively */
  96287. isAdditive: boolean;
  96288. private _localDelayOffset;
  96289. private _pausedDelay;
  96290. private _runtimeAnimations;
  96291. private _paused;
  96292. private _scene;
  96293. private _speedRatio;
  96294. private _weight;
  96295. private _syncRoot;
  96296. /**
  96297. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96298. * This will only apply for non looping animation (default is true)
  96299. */
  96300. disposeOnEnd: boolean;
  96301. /**
  96302. * Gets a boolean indicating if the animation has started
  96303. */
  96304. animationStarted: boolean;
  96305. /**
  96306. * Observer raised when the animation ends
  96307. */
  96308. onAnimationEndObservable: Observable<Animatable>;
  96309. /**
  96310. * Observer raised when the animation loops
  96311. */
  96312. onAnimationLoopObservable: Observable<Animatable>;
  96313. /**
  96314. * Gets the root Animatable used to synchronize and normalize animations
  96315. */
  96316. get syncRoot(): Nullable<Animatable>;
  96317. /**
  96318. * Gets the current frame of the first RuntimeAnimation
  96319. * Used to synchronize Animatables
  96320. */
  96321. get masterFrame(): number;
  96322. /**
  96323. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96324. */
  96325. get weight(): number;
  96326. set weight(value: number);
  96327. /**
  96328. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96329. */
  96330. get speedRatio(): number;
  96331. set speedRatio(value: number);
  96332. /**
  96333. * Creates a new Animatable
  96334. * @param scene defines the hosting scene
  96335. * @param target defines the target object
  96336. * @param fromFrame defines the starting frame number (default is 0)
  96337. * @param toFrame defines the ending frame number (default is 100)
  96338. * @param loopAnimation defines if the animation must loop (default is false)
  96339. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96340. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96341. * @param animations defines a group of animation to add to the new Animatable
  96342. * @param onAnimationLoop defines a callback to call when animation loops
  96343. * @param isAdditive defines whether the animation should be evaluated additively
  96344. */
  96345. constructor(scene: Scene,
  96346. /** defines the target object */
  96347. target: any,
  96348. /** defines the starting frame number (default is 0) */
  96349. fromFrame?: number,
  96350. /** defines the ending frame number (default is 100) */
  96351. toFrame?: number,
  96352. /** defines if the animation must loop (default is false) */
  96353. loopAnimation?: boolean, speedRatio?: number,
  96354. /** defines a callback to call when animation ends if it is not looping */
  96355. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96356. /** defines a callback to call when animation loops */
  96357. onAnimationLoop?: (() => void) | null | undefined,
  96358. /** defines whether the animation should be evaluated additively */
  96359. isAdditive?: boolean);
  96360. /**
  96361. * Synchronize and normalize current Animatable with a source Animatable
  96362. * This is useful when using animation weights and when animations are not of the same length
  96363. * @param root defines the root Animatable to synchronize with
  96364. * @returns the current Animatable
  96365. */
  96366. syncWith(root: Animatable): Animatable;
  96367. /**
  96368. * Gets the list of runtime animations
  96369. * @returns an array of RuntimeAnimation
  96370. */
  96371. getAnimations(): RuntimeAnimation[];
  96372. /**
  96373. * Adds more animations to the current animatable
  96374. * @param target defines the target of the animations
  96375. * @param animations defines the new animations to add
  96376. */
  96377. appendAnimations(target: any, animations: Animation[]): void;
  96378. /**
  96379. * Gets the source animation for a specific property
  96380. * @param property defines the propertyu to look for
  96381. * @returns null or the source animation for the given property
  96382. */
  96383. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96384. /**
  96385. * Gets the runtime animation for a specific property
  96386. * @param property defines the propertyu to look for
  96387. * @returns null or the runtime animation for the given property
  96388. */
  96389. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96390. /**
  96391. * Resets the animatable to its original state
  96392. */
  96393. reset(): void;
  96394. /**
  96395. * Allows the animatable to blend with current running animations
  96396. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96397. * @param blendingSpeed defines the blending speed to use
  96398. */
  96399. enableBlending(blendingSpeed: number): void;
  96400. /**
  96401. * Disable animation blending
  96402. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96403. */
  96404. disableBlending(): void;
  96405. /**
  96406. * Jump directly to a given frame
  96407. * @param frame defines the frame to jump to
  96408. */
  96409. goToFrame(frame: number): void;
  96410. /**
  96411. * Pause the animation
  96412. */
  96413. pause(): void;
  96414. /**
  96415. * Restart the animation
  96416. */
  96417. restart(): void;
  96418. private _raiseOnAnimationEnd;
  96419. /**
  96420. * Stop and delete the current animation
  96421. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96422. * @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)
  96423. */
  96424. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96425. /**
  96426. * Wait asynchronously for the animation to end
  96427. * @returns a promise which will be fullfilled when the animation ends
  96428. */
  96429. waitAsync(): Promise<Animatable>;
  96430. /** @hidden */
  96431. _animate(delay: number): boolean;
  96432. }
  96433. interface Scene {
  96434. /** @hidden */
  96435. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96436. /** @hidden */
  96437. _processLateAnimationBindingsForMatrices(holder: {
  96438. totalWeight: number;
  96439. totalAdditiveWeight: number;
  96440. animations: RuntimeAnimation[];
  96441. additiveAnimations: RuntimeAnimation[];
  96442. originalValue: Matrix;
  96443. }): any;
  96444. /** @hidden */
  96445. _processLateAnimationBindingsForQuaternions(holder: {
  96446. totalWeight: number;
  96447. totalAdditiveWeight: number;
  96448. animations: RuntimeAnimation[];
  96449. additiveAnimations: RuntimeAnimation[];
  96450. originalValue: Quaternion;
  96451. }, refQuaternion: Quaternion): Quaternion;
  96452. /** @hidden */
  96453. _processLateAnimationBindings(): void;
  96454. /**
  96455. * Will start the animation sequence of a given target
  96456. * @param target defines the target
  96457. * @param from defines from which frame should animation start
  96458. * @param to defines until which frame should animation run.
  96459. * @param weight defines the weight to apply to the animation (1.0 by default)
  96460. * @param loop defines if the animation loops
  96461. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96462. * @param onAnimationEnd defines the function to be executed when the animation ends
  96463. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96464. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96465. * @param onAnimationLoop defines the callback to call when an animation loops
  96466. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96467. * @returns the animatable object created for this animation
  96468. */
  96469. 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;
  96470. /**
  96471. * Will start the animation sequence of a given target
  96472. * @param target defines the target
  96473. * @param from defines from which frame should animation start
  96474. * @param to defines until which frame should animation run.
  96475. * @param loop defines if the animation loops
  96476. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96477. * @param onAnimationEnd defines the function to be executed when the animation ends
  96478. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96479. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96480. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96481. * @param onAnimationLoop defines the callback to call when an animation loops
  96482. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96483. * @returns the animatable object created for this animation
  96484. */
  96485. 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;
  96486. /**
  96487. * Will start the animation sequence of a given target and its hierarchy
  96488. * @param target defines the target
  96489. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  96490. * @param from defines from which frame should animation start
  96491. * @param to defines until which frame should animation run.
  96492. * @param loop defines if the animation loops
  96493. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96494. * @param onAnimationEnd defines the function to be executed when the animation ends
  96495. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96496. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96497. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96498. * @param onAnimationLoop defines the callback to call when an animation loops
  96499. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96500. * @returns the list of created animatables
  96501. */
  96502. 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[];
  96503. /**
  96504. * Begin a new animation on a given node
  96505. * @param target defines the target where the animation will take place
  96506. * @param animations defines the list of animations to start
  96507. * @param from defines the initial value
  96508. * @param to defines the final value
  96509. * @param loop defines if you want animation to loop (off by default)
  96510. * @param speedRatio defines the speed ratio to apply to all animations
  96511. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96512. * @param onAnimationLoop defines the callback to call when an animation loops
  96513. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96514. * @returns the list of created animatables
  96515. */
  96516. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96517. /**
  96518. * Begin a new animation on a given node and its hierarchy
  96519. * @param target defines the root node where the animation will take place
  96520. * @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.
  96521. * @param animations defines the list of animations to start
  96522. * @param from defines the initial value
  96523. * @param to defines the final value
  96524. * @param loop defines if you want animation to loop (off by default)
  96525. * @param speedRatio defines the speed ratio to apply to all animations
  96526. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96527. * @param onAnimationLoop defines the callback to call when an animation loops
  96528. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96529. * @returns the list of animatables created for all nodes
  96530. */
  96531. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96532. /**
  96533. * Gets the animatable associated with a specific target
  96534. * @param target defines the target of the animatable
  96535. * @returns the required animatable if found
  96536. */
  96537. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96538. /**
  96539. * Gets all animatables associated with a given target
  96540. * @param target defines the target to look animatables for
  96541. * @returns an array of Animatables
  96542. */
  96543. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96544. /**
  96545. * Stops and removes all animations that have been applied to the scene
  96546. */
  96547. stopAllAnimations(): void;
  96548. /**
  96549. * Gets the current delta time used by animation engine
  96550. */
  96551. deltaTime: number;
  96552. }
  96553. interface Bone {
  96554. /**
  96555. * Copy an animation range from another bone
  96556. * @param source defines the source bone
  96557. * @param rangeName defines the range name to copy
  96558. * @param frameOffset defines the frame offset
  96559. * @param rescaleAsRequired defines if rescaling must be applied if required
  96560. * @param skelDimensionsRatio defines the scaling ratio
  96561. * @returns true if operation was successful
  96562. */
  96563. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96564. }
  96565. }
  96566. declare module BABYLON {
  96567. /**
  96568. * Class used to handle skinning animations
  96569. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96570. */
  96571. export class Skeleton implements IAnimatable {
  96572. /** defines the skeleton name */
  96573. name: string;
  96574. /** defines the skeleton Id */
  96575. id: string;
  96576. /**
  96577. * Defines the list of child bones
  96578. */
  96579. bones: Bone[];
  96580. /**
  96581. * Defines an estimate of the dimension of the skeleton at rest
  96582. */
  96583. dimensionsAtRest: Vector3;
  96584. /**
  96585. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96586. */
  96587. needInitialSkinMatrix: boolean;
  96588. /**
  96589. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96590. */
  96591. overrideMesh: Nullable<AbstractMesh>;
  96592. /**
  96593. * Gets the list of animations attached to this skeleton
  96594. */
  96595. animations: Array<Animation>;
  96596. private _scene;
  96597. private _isDirty;
  96598. private _transformMatrices;
  96599. private _transformMatrixTexture;
  96600. private _meshesWithPoseMatrix;
  96601. private _animatables;
  96602. private _identity;
  96603. private _synchronizedWithMesh;
  96604. private _ranges;
  96605. private _lastAbsoluteTransformsUpdateId;
  96606. private _canUseTextureForBones;
  96607. private _uniqueId;
  96608. /** @hidden */
  96609. _numBonesWithLinkedTransformNode: number;
  96610. /** @hidden */
  96611. _hasWaitingData: Nullable<boolean>;
  96612. /** @hidden */
  96613. _waitingOverrideMeshId: Nullable<string>;
  96614. /**
  96615. * Specifies if the skeleton should be serialized
  96616. */
  96617. doNotSerialize: boolean;
  96618. private _useTextureToStoreBoneMatrices;
  96619. /**
  96620. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96621. * Please note that this option is not available if the hardware does not support it
  96622. */
  96623. get useTextureToStoreBoneMatrices(): boolean;
  96624. set useTextureToStoreBoneMatrices(value: boolean);
  96625. private _animationPropertiesOverride;
  96626. /**
  96627. * Gets or sets the animation properties override
  96628. */
  96629. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96630. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96631. /**
  96632. * List of inspectable custom properties (used by the Inspector)
  96633. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96634. */
  96635. inspectableCustomProperties: IInspectable[];
  96636. /**
  96637. * An observable triggered before computing the skeleton's matrices
  96638. */
  96639. onBeforeComputeObservable: Observable<Skeleton>;
  96640. /**
  96641. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96642. */
  96643. get isUsingTextureForMatrices(): boolean;
  96644. /**
  96645. * Gets the unique ID of this skeleton
  96646. */
  96647. get uniqueId(): number;
  96648. /**
  96649. * Creates a new skeleton
  96650. * @param name defines the skeleton name
  96651. * @param id defines the skeleton Id
  96652. * @param scene defines the hosting scene
  96653. */
  96654. constructor(
  96655. /** defines the skeleton name */
  96656. name: string,
  96657. /** defines the skeleton Id */
  96658. id: string, scene: Scene);
  96659. /**
  96660. * Gets the current object class name.
  96661. * @return the class name
  96662. */
  96663. getClassName(): string;
  96664. /**
  96665. * Returns an array containing the root bones
  96666. * @returns an array containing the root bones
  96667. */
  96668. getChildren(): Array<Bone>;
  96669. /**
  96670. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96671. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96672. * @returns a Float32Array containing matrices data
  96673. */
  96674. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96675. /**
  96676. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96677. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96678. * @returns a raw texture containing the data
  96679. */
  96680. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96681. /**
  96682. * Gets the current hosting scene
  96683. * @returns a scene object
  96684. */
  96685. getScene(): Scene;
  96686. /**
  96687. * Gets a string representing the current skeleton data
  96688. * @param fullDetails defines a boolean indicating if we want a verbose version
  96689. * @returns a string representing the current skeleton data
  96690. */
  96691. toString(fullDetails?: boolean): string;
  96692. /**
  96693. * Get bone's index searching by name
  96694. * @param name defines bone's name to search for
  96695. * @return the indice of the bone. Returns -1 if not found
  96696. */
  96697. getBoneIndexByName(name: string): number;
  96698. /**
  96699. * Creater a new animation range
  96700. * @param name defines the name of the range
  96701. * @param from defines the start key
  96702. * @param to defines the end key
  96703. */
  96704. createAnimationRange(name: string, from: number, to: number): void;
  96705. /**
  96706. * Delete a specific animation range
  96707. * @param name defines the name of the range
  96708. * @param deleteFrames defines if frames must be removed as well
  96709. */
  96710. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96711. /**
  96712. * Gets a specific animation range
  96713. * @param name defines the name of the range to look for
  96714. * @returns the requested animation range or null if not found
  96715. */
  96716. getAnimationRange(name: string): Nullable<AnimationRange>;
  96717. /**
  96718. * Gets the list of all animation ranges defined on this skeleton
  96719. * @returns an array
  96720. */
  96721. getAnimationRanges(): Nullable<AnimationRange>[];
  96722. /**
  96723. * Copy animation range from a source skeleton.
  96724. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96725. * @param source defines the source skeleton
  96726. * @param name defines the name of the range to copy
  96727. * @param rescaleAsRequired defines if rescaling must be applied if required
  96728. * @returns true if operation was successful
  96729. */
  96730. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96731. /**
  96732. * Forces the skeleton to go to rest pose
  96733. */
  96734. returnToRest(): void;
  96735. private _getHighestAnimationFrame;
  96736. /**
  96737. * Begin a specific animation range
  96738. * @param name defines the name of the range to start
  96739. * @param loop defines if looping must be turned on (false by default)
  96740. * @param speedRatio defines the speed ratio to apply (1 by default)
  96741. * @param onAnimationEnd defines a callback which will be called when animation will end
  96742. * @returns a new animatable
  96743. */
  96744. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96745. /**
  96746. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96747. * @param skeleton defines the Skeleton containing the animation range to convert
  96748. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96749. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96750. * @returns the original skeleton
  96751. */
  96752. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96753. /** @hidden */
  96754. _markAsDirty(): void;
  96755. /** @hidden */
  96756. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96757. /** @hidden */
  96758. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96759. private _computeTransformMatrices;
  96760. /**
  96761. * Build all resources required to render a skeleton
  96762. */
  96763. prepare(): void;
  96764. /**
  96765. * Gets the list of animatables currently running for this skeleton
  96766. * @returns an array of animatables
  96767. */
  96768. getAnimatables(): IAnimatable[];
  96769. /**
  96770. * Clone the current skeleton
  96771. * @param name defines the name of the new skeleton
  96772. * @param id defines the id of the new skeleton
  96773. * @returns the new skeleton
  96774. */
  96775. clone(name: string, id?: string): Skeleton;
  96776. /**
  96777. * Enable animation blending for this skeleton
  96778. * @param blendingSpeed defines the blending speed to apply
  96779. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96780. */
  96781. enableBlending(blendingSpeed?: number): void;
  96782. /**
  96783. * Releases all resources associated with the current skeleton
  96784. */
  96785. dispose(): void;
  96786. /**
  96787. * Serialize the skeleton in a JSON object
  96788. * @returns a JSON object
  96789. */
  96790. serialize(): any;
  96791. /**
  96792. * Creates a new skeleton from serialized data
  96793. * @param parsedSkeleton defines the serialized data
  96794. * @param scene defines the hosting scene
  96795. * @returns a new skeleton
  96796. */
  96797. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96798. /**
  96799. * Compute all node absolute transforms
  96800. * @param forceUpdate defines if computation must be done even if cache is up to date
  96801. */
  96802. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96803. /**
  96804. * Gets the root pose matrix
  96805. * @returns a matrix
  96806. */
  96807. getPoseMatrix(): Nullable<Matrix>;
  96808. /**
  96809. * Sorts bones per internal index
  96810. */
  96811. sortBones(): void;
  96812. private _sortBones;
  96813. /**
  96814. * Set the current local matrix as the restPose for all bones in the skeleton.
  96815. */
  96816. setCurrentPoseAsRest(): void;
  96817. }
  96818. }
  96819. declare module BABYLON {
  96820. /**
  96821. * Creates an instance based on a source mesh.
  96822. */
  96823. export class InstancedMesh extends AbstractMesh {
  96824. private _sourceMesh;
  96825. private _currentLOD;
  96826. /** @hidden */
  96827. _indexInSourceMeshInstanceArray: number;
  96828. constructor(name: string, source: Mesh);
  96829. /**
  96830. * Returns the string "InstancedMesh".
  96831. */
  96832. getClassName(): string;
  96833. /** Gets the list of lights affecting that mesh */
  96834. get lightSources(): Light[];
  96835. _resyncLightSources(): void;
  96836. _resyncLightSource(light: Light): void;
  96837. _removeLightSource(light: Light, dispose: boolean): void;
  96838. /**
  96839. * If the source mesh receives shadows
  96840. */
  96841. get receiveShadows(): boolean;
  96842. /**
  96843. * The material of the source mesh
  96844. */
  96845. get material(): Nullable<Material>;
  96846. /**
  96847. * Visibility of the source mesh
  96848. */
  96849. get visibility(): number;
  96850. /**
  96851. * Skeleton of the source mesh
  96852. */
  96853. get skeleton(): Nullable<Skeleton>;
  96854. /**
  96855. * Rendering ground id of the source mesh
  96856. */
  96857. get renderingGroupId(): number;
  96858. set renderingGroupId(value: number);
  96859. /**
  96860. * Returns the total number of vertices (integer).
  96861. */
  96862. getTotalVertices(): number;
  96863. /**
  96864. * Returns a positive integer : the total number of indices in this mesh geometry.
  96865. * @returns the numner of indices or zero if the mesh has no geometry.
  96866. */
  96867. getTotalIndices(): number;
  96868. /**
  96869. * The source mesh of the instance
  96870. */
  96871. get sourceMesh(): Mesh;
  96872. /**
  96873. * Creates a new InstancedMesh object from the mesh model.
  96874. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96875. * @param name defines the name of the new instance
  96876. * @returns a new InstancedMesh
  96877. */
  96878. createInstance(name: string): InstancedMesh;
  96879. /**
  96880. * Is this node ready to be used/rendered
  96881. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96882. * @return {boolean} is it ready
  96883. */
  96884. isReady(completeCheck?: boolean): boolean;
  96885. /**
  96886. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96887. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96888. * @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.
  96889. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96890. */
  96891. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96892. /**
  96893. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96894. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96895. * The `data` are either a numeric array either a Float32Array.
  96896. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96897. * 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).
  96898. * Note that a new underlying VertexBuffer object is created each call.
  96899. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96900. *
  96901. * Possible `kind` values :
  96902. * - VertexBuffer.PositionKind
  96903. * - VertexBuffer.UVKind
  96904. * - VertexBuffer.UV2Kind
  96905. * - VertexBuffer.UV3Kind
  96906. * - VertexBuffer.UV4Kind
  96907. * - VertexBuffer.UV5Kind
  96908. * - VertexBuffer.UV6Kind
  96909. * - VertexBuffer.ColorKind
  96910. * - VertexBuffer.MatricesIndicesKind
  96911. * - VertexBuffer.MatricesIndicesExtraKind
  96912. * - VertexBuffer.MatricesWeightsKind
  96913. * - VertexBuffer.MatricesWeightsExtraKind
  96914. *
  96915. * Returns the Mesh.
  96916. */
  96917. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96918. /**
  96919. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96920. * If the mesh has no geometry, it is simply returned as it is.
  96921. * The `data` are either a numeric array either a Float32Array.
  96922. * No new underlying VertexBuffer object is created.
  96923. * 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.
  96924. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96925. *
  96926. * Possible `kind` values :
  96927. * - VertexBuffer.PositionKind
  96928. * - VertexBuffer.UVKind
  96929. * - VertexBuffer.UV2Kind
  96930. * - VertexBuffer.UV3Kind
  96931. * - VertexBuffer.UV4Kind
  96932. * - VertexBuffer.UV5Kind
  96933. * - VertexBuffer.UV6Kind
  96934. * - VertexBuffer.ColorKind
  96935. * - VertexBuffer.MatricesIndicesKind
  96936. * - VertexBuffer.MatricesIndicesExtraKind
  96937. * - VertexBuffer.MatricesWeightsKind
  96938. * - VertexBuffer.MatricesWeightsExtraKind
  96939. *
  96940. * Returns the Mesh.
  96941. */
  96942. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96943. /**
  96944. * Sets the mesh indices.
  96945. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96946. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96947. * This method creates a new index buffer each call.
  96948. * Returns the Mesh.
  96949. */
  96950. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96951. /**
  96952. * Boolean : True if the mesh owns the requested kind of data.
  96953. */
  96954. isVerticesDataPresent(kind: string): boolean;
  96955. /**
  96956. * Returns an array of indices (IndicesArray).
  96957. */
  96958. getIndices(): Nullable<IndicesArray>;
  96959. get _positions(): Nullable<Vector3[]>;
  96960. /**
  96961. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96962. * This means the mesh underlying bounding box and sphere are recomputed.
  96963. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96964. * @returns the current mesh
  96965. */
  96966. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96967. /** @hidden */
  96968. _preActivate(): InstancedMesh;
  96969. /** @hidden */
  96970. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96971. /** @hidden */
  96972. _postActivate(): void;
  96973. getWorldMatrix(): Matrix;
  96974. get isAnInstance(): boolean;
  96975. /**
  96976. * Returns the current associated LOD AbstractMesh.
  96977. */
  96978. getLOD(camera: Camera): AbstractMesh;
  96979. /** @hidden */
  96980. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96981. /** @hidden */
  96982. _syncSubMeshes(): InstancedMesh;
  96983. /** @hidden */
  96984. _generatePointsArray(): boolean;
  96985. /** @hidden */
  96986. _updateBoundingInfo(): AbstractMesh;
  96987. /**
  96988. * Creates a new InstancedMesh from the current mesh.
  96989. * - name (string) : the cloned mesh name
  96990. * - newParent (optional Node) : the optional Node to parent the clone to.
  96991. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96992. *
  96993. * Returns the clone.
  96994. */
  96995. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96996. /**
  96997. * Disposes the InstancedMesh.
  96998. * Returns nothing.
  96999. */
  97000. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97001. }
  97002. interface Mesh {
  97003. /**
  97004. * Register a custom buffer that will be instanced
  97005. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97006. * @param kind defines the buffer kind
  97007. * @param stride defines the stride in floats
  97008. */
  97009. registerInstancedBuffer(kind: string, stride: number): void;
  97010. /**
  97011. * true to use the edge renderer for all instances of this mesh
  97012. */
  97013. edgesShareWithInstances: boolean;
  97014. /** @hidden */
  97015. _userInstancedBuffersStorage: {
  97016. data: {
  97017. [key: string]: Float32Array;
  97018. };
  97019. sizes: {
  97020. [key: string]: number;
  97021. };
  97022. vertexBuffers: {
  97023. [key: string]: Nullable<VertexBuffer>;
  97024. };
  97025. strides: {
  97026. [key: string]: number;
  97027. };
  97028. };
  97029. }
  97030. interface AbstractMesh {
  97031. /**
  97032. * Object used to store instanced buffers defined by user
  97033. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97034. */
  97035. instancedBuffers: {
  97036. [key: string]: any;
  97037. };
  97038. }
  97039. }
  97040. declare module BABYLON {
  97041. /**
  97042. * Defines the options associated with the creation of a shader material.
  97043. */
  97044. export interface IShaderMaterialOptions {
  97045. /**
  97046. * Does the material work in alpha blend mode
  97047. */
  97048. needAlphaBlending: boolean;
  97049. /**
  97050. * Does the material work in alpha test mode
  97051. */
  97052. needAlphaTesting: boolean;
  97053. /**
  97054. * The list of attribute names used in the shader
  97055. */
  97056. attributes: string[];
  97057. /**
  97058. * The list of unifrom names used in the shader
  97059. */
  97060. uniforms: string[];
  97061. /**
  97062. * The list of UBO names used in the shader
  97063. */
  97064. uniformBuffers: string[];
  97065. /**
  97066. * The list of sampler names used in the shader
  97067. */
  97068. samplers: string[];
  97069. /**
  97070. * The list of defines used in the shader
  97071. */
  97072. defines: string[];
  97073. }
  97074. /**
  97075. * 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.
  97076. *
  97077. * This returned material effects how the mesh will look based on the code in the shaders.
  97078. *
  97079. * @see https://doc.babylonjs.com/how_to/shader_material
  97080. */
  97081. export class ShaderMaterial extends Material {
  97082. private _shaderPath;
  97083. private _options;
  97084. private _textures;
  97085. private _textureArrays;
  97086. private _floats;
  97087. private _ints;
  97088. private _floatsArrays;
  97089. private _colors3;
  97090. private _colors3Arrays;
  97091. private _colors4;
  97092. private _colors4Arrays;
  97093. private _vectors2;
  97094. private _vectors3;
  97095. private _vectors4;
  97096. private _matrices;
  97097. private _matrixArrays;
  97098. private _matrices3x3;
  97099. private _matrices2x2;
  97100. private _vectors2Arrays;
  97101. private _vectors3Arrays;
  97102. private _vectors4Arrays;
  97103. private _cachedWorldViewMatrix;
  97104. private _cachedWorldViewProjectionMatrix;
  97105. private _renderId;
  97106. private _multiview;
  97107. private _cachedDefines;
  97108. /** Define the Url to load snippets */
  97109. static SnippetUrl: string;
  97110. /** Snippet ID if the material was created from the snippet server */
  97111. snippetId: string;
  97112. /**
  97113. * Instantiate a new shader material.
  97114. * 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.
  97115. * This returned material effects how the mesh will look based on the code in the shaders.
  97116. * @see https://doc.babylonjs.com/how_to/shader_material
  97117. * @param name Define the name of the material in the scene
  97118. * @param scene Define the scene the material belongs to
  97119. * @param shaderPath Defines the route to the shader code in one of three ways:
  97120. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97121. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97122. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97123. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97124. * @param options Define the options used to create the shader
  97125. */
  97126. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97127. /**
  97128. * Gets the shader path used to define the shader code
  97129. * It can be modified to trigger a new compilation
  97130. */
  97131. get shaderPath(): any;
  97132. /**
  97133. * Sets the shader path used to define the shader code
  97134. * It can be modified to trigger a new compilation
  97135. */
  97136. set shaderPath(shaderPath: any);
  97137. /**
  97138. * Gets the options used to compile the shader.
  97139. * They can be modified to trigger a new compilation
  97140. */
  97141. get options(): IShaderMaterialOptions;
  97142. /**
  97143. * Gets the current class name of the material e.g. "ShaderMaterial"
  97144. * Mainly use in serialization.
  97145. * @returns the class name
  97146. */
  97147. getClassName(): string;
  97148. /**
  97149. * Specifies if the material will require alpha blending
  97150. * @returns a boolean specifying if alpha blending is needed
  97151. */
  97152. needAlphaBlending(): boolean;
  97153. /**
  97154. * Specifies if this material should be rendered in alpha test mode
  97155. * @returns a boolean specifying if an alpha test is needed.
  97156. */
  97157. needAlphaTesting(): boolean;
  97158. private _checkUniform;
  97159. /**
  97160. * Set a texture in the shader.
  97161. * @param name Define the name of the uniform samplers as defined in the shader
  97162. * @param texture Define the texture to bind to this sampler
  97163. * @return the material itself allowing "fluent" like uniform updates
  97164. */
  97165. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97166. /**
  97167. * Set a texture array in the shader.
  97168. * @param name Define the name of the uniform sampler array as defined in the shader
  97169. * @param textures Define the list of textures to bind to this sampler
  97170. * @return the material itself allowing "fluent" like uniform updates
  97171. */
  97172. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97173. /**
  97174. * Set a float in the shader.
  97175. * @param name Define the name of the uniform as defined in the shader
  97176. * @param value Define the value to give to the uniform
  97177. * @return the material itself allowing "fluent" like uniform updates
  97178. */
  97179. setFloat(name: string, value: number): ShaderMaterial;
  97180. /**
  97181. * Set a int in the shader.
  97182. * @param name Define the name of the uniform as defined in the shader
  97183. * @param value Define the value to give to the uniform
  97184. * @return the material itself allowing "fluent" like uniform updates
  97185. */
  97186. setInt(name: string, value: number): ShaderMaterial;
  97187. /**
  97188. * Set an array of floats in the shader.
  97189. * @param name Define the name of the uniform as defined in the shader
  97190. * @param value Define the value to give to the uniform
  97191. * @return the material itself allowing "fluent" like uniform updates
  97192. */
  97193. setFloats(name: string, value: number[]): ShaderMaterial;
  97194. /**
  97195. * Set a vec3 in the shader from a Color3.
  97196. * @param name Define the name of the uniform as defined in the shader
  97197. * @param value Define the value to give to the uniform
  97198. * @return the material itself allowing "fluent" like uniform updates
  97199. */
  97200. setColor3(name: string, value: Color3): ShaderMaterial;
  97201. /**
  97202. * Set a vec3 array in the shader from a Color3 array.
  97203. * @param name Define the name of the uniform as defined in the shader
  97204. * @param value Define the value to give to the uniform
  97205. * @return the material itself allowing "fluent" like uniform updates
  97206. */
  97207. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97208. /**
  97209. * Set a vec4 in the shader from a Color4.
  97210. * @param name Define the name of the uniform as defined in the shader
  97211. * @param value Define the value to give to the uniform
  97212. * @return the material itself allowing "fluent" like uniform updates
  97213. */
  97214. setColor4(name: string, value: Color4): ShaderMaterial;
  97215. /**
  97216. * Set a vec4 array in the shader from a Color4 array.
  97217. * @param name Define the name of the uniform as defined in the shader
  97218. * @param value Define the value to give to the uniform
  97219. * @return the material itself allowing "fluent" like uniform updates
  97220. */
  97221. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97222. /**
  97223. * Set a vec2 in the shader from a Vector2.
  97224. * @param name Define the name of the uniform as defined in the shader
  97225. * @param value Define the value to give to the uniform
  97226. * @return the material itself allowing "fluent" like uniform updates
  97227. */
  97228. setVector2(name: string, value: Vector2): ShaderMaterial;
  97229. /**
  97230. * Set a vec3 in the shader from a Vector3.
  97231. * @param name Define the name of the uniform as defined in the shader
  97232. * @param value Define the value to give to the uniform
  97233. * @return the material itself allowing "fluent" like uniform updates
  97234. */
  97235. setVector3(name: string, value: Vector3): ShaderMaterial;
  97236. /**
  97237. * Set a vec4 in the shader from a Vector4.
  97238. * @param name Define the name of the uniform as defined in the shader
  97239. * @param value Define the value to give to the uniform
  97240. * @return the material itself allowing "fluent" like uniform updates
  97241. */
  97242. setVector4(name: string, value: Vector4): ShaderMaterial;
  97243. /**
  97244. * Set a mat4 in the shader from a Matrix.
  97245. * @param name Define the name of the uniform as defined in the shader
  97246. * @param value Define the value to give to the uniform
  97247. * @return the material itself allowing "fluent" like uniform updates
  97248. */
  97249. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97250. /**
  97251. * Set a float32Array in the shader from a matrix array.
  97252. * @param name Define the name of the uniform as defined in the shader
  97253. * @param value Define the value to give to the uniform
  97254. * @return the material itself allowing "fluent" like uniform updates
  97255. */
  97256. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97257. /**
  97258. * Set a mat3 in the shader from a Float32Array.
  97259. * @param name Define the name of the uniform as defined in the shader
  97260. * @param value Define the value to give to the uniform
  97261. * @return the material itself allowing "fluent" like uniform updates
  97262. */
  97263. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97264. /**
  97265. * Set a mat2 in the shader from a Float32Array.
  97266. * @param name Define the name of the uniform as defined in the shader
  97267. * @param value Define the value to give to the uniform
  97268. * @return the material itself allowing "fluent" like uniform updates
  97269. */
  97270. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97271. /**
  97272. * Set a vec2 array in the shader from a number array.
  97273. * @param name Define the name of the uniform as defined in the shader
  97274. * @param value Define the value to give to the uniform
  97275. * @return the material itself allowing "fluent" like uniform updates
  97276. */
  97277. setArray2(name: string, value: number[]): ShaderMaterial;
  97278. /**
  97279. * Set a vec3 array in the shader from a number array.
  97280. * @param name Define the name of the uniform as defined in the shader
  97281. * @param value Define the value to give to the uniform
  97282. * @return the material itself allowing "fluent" like uniform updates
  97283. */
  97284. setArray3(name: string, value: number[]): ShaderMaterial;
  97285. /**
  97286. * Set a vec4 array in the shader from a number array.
  97287. * @param name Define the name of the uniform as defined in the shader
  97288. * @param value Define the value to give to the uniform
  97289. * @return the material itself allowing "fluent" like uniform updates
  97290. */
  97291. setArray4(name: string, value: number[]): ShaderMaterial;
  97292. private _checkCache;
  97293. /**
  97294. * Specifies that the submesh is ready to be used
  97295. * @param mesh defines the mesh to check
  97296. * @param subMesh defines which submesh to check
  97297. * @param useInstances specifies that instances should be used
  97298. * @returns a boolean indicating that the submesh is ready or not
  97299. */
  97300. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97301. /**
  97302. * Checks if the material is ready to render the requested mesh
  97303. * @param mesh Define the mesh to render
  97304. * @param useInstances Define whether or not the material is used with instances
  97305. * @returns true if ready, otherwise false
  97306. */
  97307. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97308. /**
  97309. * Binds the world matrix to the material
  97310. * @param world defines the world transformation matrix
  97311. * @param effectOverride - If provided, use this effect instead of internal effect
  97312. */
  97313. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97314. /**
  97315. * Binds the submesh to this material by preparing the effect and shader to draw
  97316. * @param world defines the world transformation matrix
  97317. * @param mesh defines the mesh containing the submesh
  97318. * @param subMesh defines the submesh to bind the material to
  97319. */
  97320. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97321. /**
  97322. * Binds the material to the mesh
  97323. * @param world defines the world transformation matrix
  97324. * @param mesh defines the mesh to bind the material to
  97325. * @param effectOverride - If provided, use this effect instead of internal effect
  97326. */
  97327. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97328. protected _afterBind(mesh?: Mesh): void;
  97329. /**
  97330. * Gets the active textures from the material
  97331. * @returns an array of textures
  97332. */
  97333. getActiveTextures(): BaseTexture[];
  97334. /**
  97335. * Specifies if the material uses a texture
  97336. * @param texture defines the texture to check against the material
  97337. * @returns a boolean specifying if the material uses the texture
  97338. */
  97339. hasTexture(texture: BaseTexture): boolean;
  97340. /**
  97341. * Makes a duplicate of the material, and gives it a new name
  97342. * @param name defines the new name for the duplicated material
  97343. * @returns the cloned material
  97344. */
  97345. clone(name: string): ShaderMaterial;
  97346. /**
  97347. * Disposes the material
  97348. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97349. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97350. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97351. */
  97352. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97353. /**
  97354. * Serializes this material in a JSON representation
  97355. * @returns the serialized material object
  97356. */
  97357. serialize(): any;
  97358. /**
  97359. * Creates a shader material from parsed shader material data
  97360. * @param source defines the JSON represnetation of the material
  97361. * @param scene defines the hosting scene
  97362. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97363. * @returns a new material
  97364. */
  97365. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97366. /**
  97367. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97368. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97369. * @param url defines the url to load from
  97370. * @param scene defines the hosting scene
  97371. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97372. * @returns a promise that will resolve to the new ShaderMaterial
  97373. */
  97374. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97375. /**
  97376. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97377. * @param snippetId defines the snippet to load
  97378. * @param scene defines the hosting scene
  97379. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97380. * @returns a promise that will resolve to the new ShaderMaterial
  97381. */
  97382. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97383. }
  97384. }
  97385. declare module BABYLON {
  97386. /** @hidden */
  97387. export var colorPixelShader: {
  97388. name: string;
  97389. shader: string;
  97390. };
  97391. }
  97392. declare module BABYLON {
  97393. /** @hidden */
  97394. export var colorVertexShader: {
  97395. name: string;
  97396. shader: string;
  97397. };
  97398. }
  97399. declare module BABYLON {
  97400. /**
  97401. * Line mesh
  97402. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97403. */
  97404. export class LinesMesh extends Mesh {
  97405. /**
  97406. * If vertex color should be applied to the mesh
  97407. */
  97408. readonly useVertexColor?: boolean | undefined;
  97409. /**
  97410. * If vertex alpha should be applied to the mesh
  97411. */
  97412. readonly useVertexAlpha?: boolean | undefined;
  97413. /**
  97414. * Color of the line (Default: White)
  97415. */
  97416. color: Color3;
  97417. /**
  97418. * Alpha of the line (Default: 1)
  97419. */
  97420. alpha: number;
  97421. /**
  97422. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97423. * This margin is expressed in world space coordinates, so its value may vary.
  97424. * Default value is 0.1
  97425. */
  97426. intersectionThreshold: number;
  97427. private _colorShader;
  97428. private color4;
  97429. /**
  97430. * Creates a new LinesMesh
  97431. * @param name defines the name
  97432. * @param scene defines the hosting scene
  97433. * @param parent defines the parent mesh if any
  97434. * @param source defines the optional source LinesMesh used to clone data from
  97435. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97436. * When false, achieved by calling a clone(), also passing False.
  97437. * This will make creation of children, recursive.
  97438. * @param useVertexColor defines if this LinesMesh supports vertex color
  97439. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97440. */
  97441. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97442. /**
  97443. * If vertex color should be applied to the mesh
  97444. */
  97445. useVertexColor?: boolean | undefined,
  97446. /**
  97447. * If vertex alpha should be applied to the mesh
  97448. */
  97449. useVertexAlpha?: boolean | undefined);
  97450. private _addClipPlaneDefine;
  97451. private _removeClipPlaneDefine;
  97452. isReady(): boolean;
  97453. /**
  97454. * Returns the string "LineMesh"
  97455. */
  97456. getClassName(): string;
  97457. /**
  97458. * @hidden
  97459. */
  97460. get material(): Material;
  97461. /**
  97462. * @hidden
  97463. */
  97464. set material(value: Material);
  97465. /**
  97466. * @hidden
  97467. */
  97468. get checkCollisions(): boolean;
  97469. /** @hidden */
  97470. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97471. /** @hidden */
  97472. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97473. /**
  97474. * Disposes of the line mesh
  97475. * @param doNotRecurse If children should be disposed
  97476. */
  97477. dispose(doNotRecurse?: boolean): void;
  97478. /**
  97479. * Returns a new LineMesh object cloned from the current one.
  97480. */
  97481. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97482. /**
  97483. * Creates a new InstancedLinesMesh object from the mesh model.
  97484. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97485. * @param name defines the name of the new instance
  97486. * @returns a new InstancedLinesMesh
  97487. */
  97488. createInstance(name: string): InstancedLinesMesh;
  97489. }
  97490. /**
  97491. * Creates an instance based on a source LinesMesh
  97492. */
  97493. export class InstancedLinesMesh extends InstancedMesh {
  97494. /**
  97495. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97496. * This margin is expressed in world space coordinates, so its value may vary.
  97497. * Initilized with the intersectionThreshold value of the source LinesMesh
  97498. */
  97499. intersectionThreshold: number;
  97500. constructor(name: string, source: LinesMesh);
  97501. /**
  97502. * Returns the string "InstancedLinesMesh".
  97503. */
  97504. getClassName(): string;
  97505. }
  97506. }
  97507. declare module BABYLON {
  97508. /** @hidden */
  97509. export var linePixelShader: {
  97510. name: string;
  97511. shader: string;
  97512. };
  97513. }
  97514. declare module BABYLON {
  97515. /** @hidden */
  97516. export var lineVertexShader: {
  97517. name: string;
  97518. shader: string;
  97519. };
  97520. }
  97521. declare module BABYLON {
  97522. interface Scene {
  97523. /** @hidden */
  97524. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97525. }
  97526. interface AbstractMesh {
  97527. /**
  97528. * Gets the edgesRenderer associated with the mesh
  97529. */
  97530. edgesRenderer: Nullable<EdgesRenderer>;
  97531. }
  97532. interface LinesMesh {
  97533. /**
  97534. * Enables the edge rendering mode on the mesh.
  97535. * This mode makes the mesh edges visible
  97536. * @param epsilon defines the maximal distance between two angles to detect a face
  97537. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97538. * @returns the currentAbstractMesh
  97539. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97540. */
  97541. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97542. }
  97543. interface InstancedLinesMesh {
  97544. /**
  97545. * Enables the edge rendering mode on the mesh.
  97546. * This mode makes the mesh edges visible
  97547. * @param epsilon defines the maximal distance between two angles to detect a face
  97548. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97549. * @returns the current InstancedLinesMesh
  97550. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97551. */
  97552. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97553. }
  97554. /**
  97555. * Defines the minimum contract an Edges renderer should follow.
  97556. */
  97557. export interface IEdgesRenderer extends IDisposable {
  97558. /**
  97559. * Gets or sets a boolean indicating if the edgesRenderer is active
  97560. */
  97561. isEnabled: boolean;
  97562. /**
  97563. * Renders the edges of the attached mesh,
  97564. */
  97565. render(): void;
  97566. /**
  97567. * Checks wether or not the edges renderer is ready to render.
  97568. * @return true if ready, otherwise false.
  97569. */
  97570. isReady(): boolean;
  97571. /**
  97572. * List of instances to render in case the source mesh has instances
  97573. */
  97574. customInstances: SmartArray<Matrix>;
  97575. }
  97576. /**
  97577. * Defines the additional options of the edges renderer
  97578. */
  97579. export interface IEdgesRendererOptions {
  97580. /**
  97581. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97582. * If not defined, the default value is true
  97583. */
  97584. useAlternateEdgeFinder?: boolean;
  97585. /**
  97586. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97587. * If not defined, the default value is true.
  97588. * 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)
  97589. * This option is used only if useAlternateEdgeFinder = true
  97590. */
  97591. useFastVertexMerger?: boolean;
  97592. /**
  97593. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97594. * The default value is 1e-6
  97595. * This option is used only if useAlternateEdgeFinder = true
  97596. */
  97597. epsilonVertexMerge?: number;
  97598. /**
  97599. * 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
  97600. * 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.
  97601. * This option is used only if useAlternateEdgeFinder = true
  97602. */
  97603. applyTessellation?: boolean;
  97604. /**
  97605. * 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
  97606. * The default value is 1e-6
  97607. * This option is used only if useAlternateEdgeFinder = true
  97608. */
  97609. epsilonVertexAligned?: number;
  97610. }
  97611. /**
  97612. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97613. */
  97614. export class EdgesRenderer implements IEdgesRenderer {
  97615. /**
  97616. * Define the size of the edges with an orthographic camera
  97617. */
  97618. edgesWidthScalerForOrthographic: number;
  97619. /**
  97620. * Define the size of the edges with a perspective camera
  97621. */
  97622. edgesWidthScalerForPerspective: number;
  97623. protected _source: AbstractMesh;
  97624. protected _linesPositions: number[];
  97625. protected _linesNormals: number[];
  97626. protected _linesIndices: number[];
  97627. protected _epsilon: number;
  97628. protected _indicesCount: number;
  97629. protected _lineShader: ShaderMaterial;
  97630. protected _ib: DataBuffer;
  97631. protected _buffers: {
  97632. [key: string]: Nullable<VertexBuffer>;
  97633. };
  97634. protected _buffersForInstances: {
  97635. [key: string]: Nullable<VertexBuffer>;
  97636. };
  97637. protected _checkVerticesInsteadOfIndices: boolean;
  97638. protected _options: Nullable<IEdgesRendererOptions>;
  97639. private _meshRebuildObserver;
  97640. private _meshDisposeObserver;
  97641. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97642. isEnabled: boolean;
  97643. /**
  97644. * List of instances to render in case the source mesh has instances
  97645. */
  97646. customInstances: SmartArray<Matrix>;
  97647. private static GetShader;
  97648. /**
  97649. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97650. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97651. * @param source Mesh used to create edges
  97652. * @param epsilon sum of angles in adjacency to check for edge
  97653. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97654. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97655. * @param options The options to apply when generating the edges
  97656. */
  97657. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97658. protected _prepareRessources(): void;
  97659. /** @hidden */
  97660. _rebuild(): void;
  97661. /**
  97662. * Releases the required resources for the edges renderer
  97663. */
  97664. dispose(): void;
  97665. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97666. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97667. /**
  97668. * Checks if the pair of p0 and p1 is en edge
  97669. * @param faceIndex
  97670. * @param edge
  97671. * @param faceNormals
  97672. * @param p0
  97673. * @param p1
  97674. * @private
  97675. */
  97676. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97677. /**
  97678. * push line into the position, normal and index buffer
  97679. * @protected
  97680. */
  97681. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97682. /**
  97683. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97684. */
  97685. private _tessellateTriangle;
  97686. private _generateEdgesLinesAlternate;
  97687. /**
  97688. * Generates lines edges from adjacencjes
  97689. * @private
  97690. */
  97691. _generateEdgesLines(): void;
  97692. /**
  97693. * Checks wether or not the edges renderer is ready to render.
  97694. * @return true if ready, otherwise false.
  97695. */
  97696. isReady(): boolean;
  97697. /**
  97698. * Renders the edges of the attached mesh,
  97699. */
  97700. render(): void;
  97701. }
  97702. /**
  97703. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97704. */
  97705. export class LineEdgesRenderer extends EdgesRenderer {
  97706. /**
  97707. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97708. * @param source LineMesh used to generate edges
  97709. * @param epsilon not important (specified angle for edge detection)
  97710. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97711. */
  97712. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97713. /**
  97714. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97715. */
  97716. _generateEdgesLines(): void;
  97717. }
  97718. }
  97719. declare module BABYLON {
  97720. /**
  97721. * This represents the object necessary to create a rendering group.
  97722. * This is exclusively used and created by the rendering manager.
  97723. * To modify the behavior, you use the available helpers in your scene or meshes.
  97724. * @hidden
  97725. */
  97726. export class RenderingGroup {
  97727. index: number;
  97728. private static _zeroVector;
  97729. private _scene;
  97730. private _opaqueSubMeshes;
  97731. private _transparentSubMeshes;
  97732. private _alphaTestSubMeshes;
  97733. private _depthOnlySubMeshes;
  97734. private _particleSystems;
  97735. private _spriteManagers;
  97736. private _opaqueSortCompareFn;
  97737. private _alphaTestSortCompareFn;
  97738. private _transparentSortCompareFn;
  97739. private _renderOpaque;
  97740. private _renderAlphaTest;
  97741. private _renderTransparent;
  97742. /** @hidden */
  97743. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97744. onBeforeTransparentRendering: () => void;
  97745. /**
  97746. * Set the opaque sort comparison function.
  97747. * If null the sub meshes will be render in the order they were created
  97748. */
  97749. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97750. /**
  97751. * Set the alpha test sort comparison function.
  97752. * If null the sub meshes will be render in the order they were created
  97753. */
  97754. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97755. /**
  97756. * Set the transparent sort comparison function.
  97757. * If null the sub meshes will be render in the order they were created
  97758. */
  97759. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97760. /**
  97761. * Creates a new rendering group.
  97762. * @param index The rendering group index
  97763. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97764. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97765. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97766. */
  97767. 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>);
  97768. /**
  97769. * Render all the sub meshes contained in the group.
  97770. * @param customRenderFunction Used to override the default render behaviour of the group.
  97771. * @returns true if rendered some submeshes.
  97772. */
  97773. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97774. /**
  97775. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97776. * @param subMeshes The submeshes to render
  97777. */
  97778. private renderOpaqueSorted;
  97779. /**
  97780. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97781. * @param subMeshes The submeshes to render
  97782. */
  97783. private renderAlphaTestSorted;
  97784. /**
  97785. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97786. * @param subMeshes The submeshes to render
  97787. */
  97788. private renderTransparentSorted;
  97789. /**
  97790. * Renders the submeshes in a specified order.
  97791. * @param subMeshes The submeshes to sort before render
  97792. * @param sortCompareFn The comparison function use to sort
  97793. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97794. * @param transparent Specifies to activate blending if true
  97795. */
  97796. private static renderSorted;
  97797. /**
  97798. * Renders the submeshes in the order they were dispatched (no sort applied).
  97799. * @param subMeshes The submeshes to render
  97800. */
  97801. private static renderUnsorted;
  97802. /**
  97803. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97804. * are rendered back to front if in the same alpha index.
  97805. *
  97806. * @param a The first submesh
  97807. * @param b The second submesh
  97808. * @returns The result of the comparison
  97809. */
  97810. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97811. /**
  97812. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97813. * are rendered back to front.
  97814. *
  97815. * @param a The first submesh
  97816. * @param b The second submesh
  97817. * @returns The result of the comparison
  97818. */
  97819. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97820. /**
  97821. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97822. * are rendered front to back (prevent overdraw).
  97823. *
  97824. * @param a The first submesh
  97825. * @param b The second submesh
  97826. * @returns The result of the comparison
  97827. */
  97828. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97829. /**
  97830. * Resets the different lists of submeshes to prepare a new frame.
  97831. */
  97832. prepare(): void;
  97833. dispose(): void;
  97834. /**
  97835. * Inserts the submesh in its correct queue depending on its material.
  97836. * @param subMesh The submesh to dispatch
  97837. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97838. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97839. */
  97840. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97841. dispatchSprites(spriteManager: ISpriteManager): void;
  97842. dispatchParticles(particleSystem: IParticleSystem): void;
  97843. private _renderParticles;
  97844. private _renderSprites;
  97845. }
  97846. }
  97847. declare module BABYLON {
  97848. /**
  97849. * Interface describing the different options available in the rendering manager
  97850. * regarding Auto Clear between groups.
  97851. */
  97852. export interface IRenderingManagerAutoClearSetup {
  97853. /**
  97854. * Defines whether or not autoclear is enable.
  97855. */
  97856. autoClear: boolean;
  97857. /**
  97858. * Defines whether or not to autoclear the depth buffer.
  97859. */
  97860. depth: boolean;
  97861. /**
  97862. * Defines whether or not to autoclear the stencil buffer.
  97863. */
  97864. stencil: boolean;
  97865. }
  97866. /**
  97867. * This class is used by the onRenderingGroupObservable
  97868. */
  97869. export class RenderingGroupInfo {
  97870. /**
  97871. * The Scene that being rendered
  97872. */
  97873. scene: Scene;
  97874. /**
  97875. * The camera currently used for the rendering pass
  97876. */
  97877. camera: Nullable<Camera>;
  97878. /**
  97879. * The ID of the renderingGroup being processed
  97880. */
  97881. renderingGroupId: number;
  97882. }
  97883. /**
  97884. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97885. * It is enable to manage the different groups as well as the different necessary sort functions.
  97886. * This should not be used directly aside of the few static configurations
  97887. */
  97888. export class RenderingManager {
  97889. /**
  97890. * The max id used for rendering groups (not included)
  97891. */
  97892. static MAX_RENDERINGGROUPS: number;
  97893. /**
  97894. * The min id used for rendering groups (included)
  97895. */
  97896. static MIN_RENDERINGGROUPS: number;
  97897. /**
  97898. * Used to globally prevent autoclearing scenes.
  97899. */
  97900. static AUTOCLEAR: boolean;
  97901. /**
  97902. * @hidden
  97903. */
  97904. _useSceneAutoClearSetup: boolean;
  97905. private _scene;
  97906. private _renderingGroups;
  97907. private _depthStencilBufferAlreadyCleaned;
  97908. private _autoClearDepthStencil;
  97909. private _customOpaqueSortCompareFn;
  97910. private _customAlphaTestSortCompareFn;
  97911. private _customTransparentSortCompareFn;
  97912. private _renderingGroupInfo;
  97913. /**
  97914. * Instantiates a new rendering group for a particular scene
  97915. * @param scene Defines the scene the groups belongs to
  97916. */
  97917. constructor(scene: Scene);
  97918. private _clearDepthStencilBuffer;
  97919. /**
  97920. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97921. * @hidden
  97922. */
  97923. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97924. /**
  97925. * Resets the different information of the group to prepare a new frame
  97926. * @hidden
  97927. */
  97928. reset(): void;
  97929. /**
  97930. * Dispose and release the group and its associated resources.
  97931. * @hidden
  97932. */
  97933. dispose(): void;
  97934. /**
  97935. * Clear the info related to rendering groups preventing retention points during dispose.
  97936. */
  97937. freeRenderingGroups(): void;
  97938. private _prepareRenderingGroup;
  97939. /**
  97940. * Add a sprite manager to the rendering manager in order to render it this frame.
  97941. * @param spriteManager Define the sprite manager to render
  97942. */
  97943. dispatchSprites(spriteManager: ISpriteManager): void;
  97944. /**
  97945. * Add a particle system to the rendering manager in order to render it this frame.
  97946. * @param particleSystem Define the particle system to render
  97947. */
  97948. dispatchParticles(particleSystem: IParticleSystem): void;
  97949. /**
  97950. * Add a submesh to the manager in order to render it this frame
  97951. * @param subMesh The submesh to dispatch
  97952. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97953. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97954. */
  97955. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97956. /**
  97957. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97958. * This allowed control for front to back rendering or reversly depending of the special needs.
  97959. *
  97960. * @param renderingGroupId The rendering group id corresponding to its index
  97961. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97962. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97963. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97964. */
  97965. 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;
  97966. /**
  97967. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97968. *
  97969. * @param renderingGroupId The rendering group id corresponding to its index
  97970. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97971. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97972. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97973. */
  97974. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97975. /**
  97976. * Gets the current auto clear configuration for one rendering group of the rendering
  97977. * manager.
  97978. * @param index the rendering group index to get the information for
  97979. * @returns The auto clear setup for the requested rendering group
  97980. */
  97981. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97982. }
  97983. }
  97984. declare module BABYLON {
  97985. /**
  97986. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97987. */
  97988. export interface ICustomShaderOptions {
  97989. /**
  97990. * Gets or sets the custom shader name to use
  97991. */
  97992. shaderName: string;
  97993. /**
  97994. * The list of attribute names used in the shader
  97995. */
  97996. attributes?: string[];
  97997. /**
  97998. * The list of unifrom names used in the shader
  97999. */
  98000. uniforms?: string[];
  98001. /**
  98002. * The list of sampler names used in the shader
  98003. */
  98004. samplers?: string[];
  98005. /**
  98006. * The list of defines used in the shader
  98007. */
  98008. defines?: string[];
  98009. }
  98010. /**
  98011. * Interface to implement to create a shadow generator compatible with BJS.
  98012. */
  98013. export interface IShadowGenerator {
  98014. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98015. id: string;
  98016. /**
  98017. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98018. * @returns The render target texture if present otherwise, null
  98019. */
  98020. getShadowMap(): Nullable<RenderTargetTexture>;
  98021. /**
  98022. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98023. * @param subMesh The submesh we want to render in the shadow map
  98024. * @param useInstances Defines wether will draw in the map using instances
  98025. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98026. * @returns true if ready otherwise, false
  98027. */
  98028. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98029. /**
  98030. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98031. * @param defines Defines of the material we want to update
  98032. * @param lightIndex Index of the light in the enabled light list of the material
  98033. */
  98034. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98035. /**
  98036. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98037. * defined in the generator but impacting the effect).
  98038. * It implies the unifroms available on the materials are the standard BJS ones.
  98039. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98040. * @param effect The effect we are binfing the information for
  98041. */
  98042. bindShadowLight(lightIndex: string, effect: Effect): void;
  98043. /**
  98044. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98045. * (eq to shadow prjection matrix * light transform matrix)
  98046. * @returns The transform matrix used to create the shadow map
  98047. */
  98048. getTransformMatrix(): Matrix;
  98049. /**
  98050. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98051. * Cube and 2D textures for instance.
  98052. */
  98053. recreateShadowMap(): void;
  98054. /**
  98055. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98056. * @param onCompiled Callback triggered at the and of the effects compilation
  98057. * @param options Sets of optional options forcing the compilation with different modes
  98058. */
  98059. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98060. useInstances: boolean;
  98061. }>): void;
  98062. /**
  98063. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98064. * @param options Sets of optional options forcing the compilation with different modes
  98065. * @returns A promise that resolves when the compilation completes
  98066. */
  98067. forceCompilationAsync(options?: Partial<{
  98068. useInstances: boolean;
  98069. }>): Promise<void>;
  98070. /**
  98071. * Serializes the shadow generator setup to a json object.
  98072. * @returns The serialized JSON object
  98073. */
  98074. serialize(): any;
  98075. /**
  98076. * Disposes the Shadow map and related Textures and effects.
  98077. */
  98078. dispose(): void;
  98079. }
  98080. /**
  98081. * Default implementation IShadowGenerator.
  98082. * This is the main object responsible of generating shadows in the framework.
  98083. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98084. */
  98085. export class ShadowGenerator implements IShadowGenerator {
  98086. /**
  98087. * Name of the shadow generator class
  98088. */
  98089. static CLASSNAME: string;
  98090. /**
  98091. * Shadow generator mode None: no filtering applied.
  98092. */
  98093. static readonly FILTER_NONE: number;
  98094. /**
  98095. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98096. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98097. */
  98098. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98099. /**
  98100. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98101. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98102. */
  98103. static readonly FILTER_POISSONSAMPLING: number;
  98104. /**
  98105. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98106. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98107. */
  98108. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98109. /**
  98110. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98111. * edge artifacts on steep falloff.
  98112. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98113. */
  98114. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98115. /**
  98116. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98117. * edge artifacts on steep falloff.
  98118. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98119. */
  98120. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98121. /**
  98122. * Shadow generator mode PCF: Percentage Closer Filtering
  98123. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98124. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98125. */
  98126. static readonly FILTER_PCF: number;
  98127. /**
  98128. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98129. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98130. * Contact Hardening
  98131. */
  98132. static readonly FILTER_PCSS: number;
  98133. /**
  98134. * Reserved for PCF and PCSS
  98135. * Highest Quality.
  98136. *
  98137. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98138. *
  98139. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98140. */
  98141. static readonly QUALITY_HIGH: number;
  98142. /**
  98143. * Reserved for PCF and PCSS
  98144. * Good tradeoff for quality/perf cross devices
  98145. *
  98146. * Execute PCF on a 3*3 kernel.
  98147. *
  98148. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98149. */
  98150. static readonly QUALITY_MEDIUM: number;
  98151. /**
  98152. * Reserved for PCF and PCSS
  98153. * The lowest quality but the fastest.
  98154. *
  98155. * Execute PCF on a 1*1 kernel.
  98156. *
  98157. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98158. */
  98159. static readonly QUALITY_LOW: number;
  98160. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98161. id: string;
  98162. /** Gets or sets the custom shader name to use */
  98163. customShaderOptions: ICustomShaderOptions;
  98164. /**
  98165. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98166. */
  98167. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98168. /**
  98169. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98170. */
  98171. onAfterShadowMapRenderObservable: Observable<Effect>;
  98172. /**
  98173. * Observable triggered before a mesh is rendered in the shadow map.
  98174. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98175. */
  98176. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98177. /**
  98178. * Observable triggered after a mesh is rendered in the shadow map.
  98179. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98180. */
  98181. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98182. protected _bias: number;
  98183. /**
  98184. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98185. */
  98186. get bias(): number;
  98187. /**
  98188. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98189. */
  98190. set bias(bias: number);
  98191. protected _normalBias: number;
  98192. /**
  98193. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98194. */
  98195. get normalBias(): number;
  98196. /**
  98197. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98198. */
  98199. set normalBias(normalBias: number);
  98200. protected _blurBoxOffset: number;
  98201. /**
  98202. * Gets the blur box offset: offset applied during the blur pass.
  98203. * Only useful if useKernelBlur = false
  98204. */
  98205. get blurBoxOffset(): number;
  98206. /**
  98207. * Sets the blur box offset: offset applied during the blur pass.
  98208. * Only useful if useKernelBlur = false
  98209. */
  98210. set blurBoxOffset(value: number);
  98211. protected _blurScale: number;
  98212. /**
  98213. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98214. * 2 means half of the size.
  98215. */
  98216. get blurScale(): number;
  98217. /**
  98218. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98219. * 2 means half of the size.
  98220. */
  98221. set blurScale(value: number);
  98222. protected _blurKernel: number;
  98223. /**
  98224. * Gets the blur kernel: kernel size of the blur pass.
  98225. * Only useful if useKernelBlur = true
  98226. */
  98227. get blurKernel(): number;
  98228. /**
  98229. * Sets the blur kernel: kernel size of the blur pass.
  98230. * Only useful if useKernelBlur = true
  98231. */
  98232. set blurKernel(value: number);
  98233. protected _useKernelBlur: boolean;
  98234. /**
  98235. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98236. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98237. */
  98238. get useKernelBlur(): boolean;
  98239. /**
  98240. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98241. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98242. */
  98243. set useKernelBlur(value: boolean);
  98244. protected _depthScale: number;
  98245. /**
  98246. * Gets the depth scale used in ESM mode.
  98247. */
  98248. get depthScale(): number;
  98249. /**
  98250. * Sets the depth scale used in ESM mode.
  98251. * This can override the scale stored on the light.
  98252. */
  98253. set depthScale(value: number);
  98254. protected _validateFilter(filter: number): number;
  98255. protected _filter: number;
  98256. /**
  98257. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98258. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98259. */
  98260. get filter(): number;
  98261. /**
  98262. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98263. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98264. */
  98265. set filter(value: number);
  98266. /**
  98267. * Gets if the current filter is set to Poisson Sampling.
  98268. */
  98269. get usePoissonSampling(): boolean;
  98270. /**
  98271. * Sets the current filter to Poisson Sampling.
  98272. */
  98273. set usePoissonSampling(value: boolean);
  98274. /**
  98275. * Gets if the current filter is set to ESM.
  98276. */
  98277. get useExponentialShadowMap(): boolean;
  98278. /**
  98279. * Sets the current filter is to ESM.
  98280. */
  98281. set useExponentialShadowMap(value: boolean);
  98282. /**
  98283. * Gets if the current filter is set to filtered ESM.
  98284. */
  98285. get useBlurExponentialShadowMap(): boolean;
  98286. /**
  98287. * Gets if the current filter is set to filtered ESM.
  98288. */
  98289. set useBlurExponentialShadowMap(value: boolean);
  98290. /**
  98291. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98292. * exponential to prevent steep falloff artifacts).
  98293. */
  98294. get useCloseExponentialShadowMap(): boolean;
  98295. /**
  98296. * Sets the current filter to "close ESM" (using the inverse of the
  98297. * exponential to prevent steep falloff artifacts).
  98298. */
  98299. set useCloseExponentialShadowMap(value: boolean);
  98300. /**
  98301. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98302. * exponential to prevent steep falloff artifacts).
  98303. */
  98304. get useBlurCloseExponentialShadowMap(): boolean;
  98305. /**
  98306. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98307. * exponential to prevent steep falloff artifacts).
  98308. */
  98309. set useBlurCloseExponentialShadowMap(value: boolean);
  98310. /**
  98311. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98312. */
  98313. get usePercentageCloserFiltering(): boolean;
  98314. /**
  98315. * Sets the current filter to "PCF" (percentage closer filtering).
  98316. */
  98317. set usePercentageCloserFiltering(value: boolean);
  98318. protected _filteringQuality: number;
  98319. /**
  98320. * Gets the PCF or PCSS Quality.
  98321. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98322. */
  98323. get filteringQuality(): number;
  98324. /**
  98325. * Sets the PCF or PCSS Quality.
  98326. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98327. */
  98328. set filteringQuality(filteringQuality: number);
  98329. /**
  98330. * Gets if the current filter is set to "PCSS" (contact hardening).
  98331. */
  98332. get useContactHardeningShadow(): boolean;
  98333. /**
  98334. * Sets the current filter to "PCSS" (contact hardening).
  98335. */
  98336. set useContactHardeningShadow(value: boolean);
  98337. protected _contactHardeningLightSizeUVRatio: number;
  98338. /**
  98339. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98340. * Using a ratio helps keeping shape stability independently of the map size.
  98341. *
  98342. * It does not account for the light projection as it was having too much
  98343. * instability during the light setup or during light position changes.
  98344. *
  98345. * Only valid if useContactHardeningShadow is true.
  98346. */
  98347. get contactHardeningLightSizeUVRatio(): number;
  98348. /**
  98349. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98350. * Using a ratio helps keeping shape stability independently of the map size.
  98351. *
  98352. * It does not account for the light projection as it was having too much
  98353. * instability during the light setup or during light position changes.
  98354. *
  98355. * Only valid if useContactHardeningShadow is true.
  98356. */
  98357. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98358. protected _darkness: number;
  98359. /** Gets or sets the actual darkness of a shadow */
  98360. get darkness(): number;
  98361. set darkness(value: number);
  98362. /**
  98363. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98364. * 0 means strongest and 1 would means no shadow.
  98365. * @returns the darkness.
  98366. */
  98367. getDarkness(): number;
  98368. /**
  98369. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98370. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98371. * @returns the shadow generator allowing fluent coding.
  98372. */
  98373. setDarkness(darkness: number): ShadowGenerator;
  98374. protected _transparencyShadow: boolean;
  98375. /** Gets or sets the ability to have transparent shadow */
  98376. get transparencyShadow(): boolean;
  98377. set transparencyShadow(value: boolean);
  98378. /**
  98379. * Sets the ability to have transparent shadow (boolean).
  98380. * @param transparent True if transparent else False
  98381. * @returns the shadow generator allowing fluent coding
  98382. */
  98383. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98384. /**
  98385. * Enables or disables shadows with varying strength based on the transparency
  98386. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98387. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98388. * mesh.visibility * alphaTexture.a
  98389. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98390. */
  98391. enableSoftTransparentShadow: boolean;
  98392. protected _shadowMap: Nullable<RenderTargetTexture>;
  98393. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98394. /**
  98395. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98396. * @returns The render target texture if present otherwise, null
  98397. */
  98398. getShadowMap(): Nullable<RenderTargetTexture>;
  98399. /**
  98400. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98401. * @returns The render target texture if the shadow map is present otherwise, null
  98402. */
  98403. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98404. /**
  98405. * Gets the class name of that object
  98406. * @returns "ShadowGenerator"
  98407. */
  98408. getClassName(): string;
  98409. /**
  98410. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98411. * @param mesh Mesh to add
  98412. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98413. * @returns the Shadow Generator itself
  98414. */
  98415. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98416. /**
  98417. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98418. * @param mesh Mesh to remove
  98419. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98420. * @returns the Shadow Generator itself
  98421. */
  98422. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98423. /**
  98424. * Controls the extent to which the shadows fade out at the edge of the frustum
  98425. */
  98426. frustumEdgeFalloff: number;
  98427. protected _light: IShadowLight;
  98428. /**
  98429. * Returns the associated light object.
  98430. * @returns the light generating the shadow
  98431. */
  98432. getLight(): IShadowLight;
  98433. /**
  98434. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98435. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98436. * It might on the other hand introduce peter panning.
  98437. */
  98438. forceBackFacesOnly: boolean;
  98439. protected _scene: Scene;
  98440. protected _lightDirection: Vector3;
  98441. protected _effect: Effect;
  98442. protected _viewMatrix: Matrix;
  98443. protected _projectionMatrix: Matrix;
  98444. protected _transformMatrix: Matrix;
  98445. protected _cachedPosition: Vector3;
  98446. protected _cachedDirection: Vector3;
  98447. protected _cachedDefines: string;
  98448. protected _currentRenderID: number;
  98449. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98450. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98451. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98452. protected _blurPostProcesses: PostProcess[];
  98453. protected _mapSize: number;
  98454. protected _currentFaceIndex: number;
  98455. protected _currentFaceIndexCache: number;
  98456. protected _textureType: number;
  98457. protected _defaultTextureMatrix: Matrix;
  98458. protected _storedUniqueId: Nullable<number>;
  98459. /** @hidden */
  98460. static _SceneComponentInitialization: (scene: Scene) => void;
  98461. /**
  98462. * Creates a ShadowGenerator object.
  98463. * A ShadowGenerator is the required tool to use the shadows.
  98464. * Each light casting shadows needs to use its own ShadowGenerator.
  98465. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98466. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98467. * @param light The light object generating the shadows.
  98468. * @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.
  98469. */
  98470. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98471. protected _initializeGenerator(): void;
  98472. protected _createTargetRenderTexture(): void;
  98473. protected _initializeShadowMap(): void;
  98474. protected _initializeBlurRTTAndPostProcesses(): void;
  98475. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98476. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98477. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98478. protected _applyFilterValues(): void;
  98479. /**
  98480. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98481. * @param onCompiled Callback triggered at the and of the effects compilation
  98482. * @param options Sets of optional options forcing the compilation with different modes
  98483. */
  98484. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98485. useInstances: boolean;
  98486. }>): void;
  98487. /**
  98488. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98489. * @param options Sets of optional options forcing the compilation with different modes
  98490. * @returns A promise that resolves when the compilation completes
  98491. */
  98492. forceCompilationAsync(options?: Partial<{
  98493. useInstances: boolean;
  98494. }>): Promise<void>;
  98495. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98496. private _prepareShadowDefines;
  98497. /**
  98498. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98499. * @param subMesh The submesh we want to render in the shadow map
  98500. * @param useInstances Defines wether will draw in the map using instances
  98501. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98502. * @returns true if ready otherwise, false
  98503. */
  98504. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98505. /**
  98506. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98507. * @param defines Defines of the material we want to update
  98508. * @param lightIndex Index of the light in the enabled light list of the material
  98509. */
  98510. prepareDefines(defines: any, lightIndex: number): void;
  98511. /**
  98512. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98513. * defined in the generator but impacting the effect).
  98514. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98515. * @param effect The effect we are binfing the information for
  98516. */
  98517. bindShadowLight(lightIndex: string, effect: Effect): void;
  98518. /**
  98519. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98520. * (eq to shadow prjection matrix * light transform matrix)
  98521. * @returns The transform matrix used to create the shadow map
  98522. */
  98523. getTransformMatrix(): Matrix;
  98524. /**
  98525. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98526. * Cube and 2D textures for instance.
  98527. */
  98528. recreateShadowMap(): void;
  98529. protected _disposeBlurPostProcesses(): void;
  98530. protected _disposeRTTandPostProcesses(): void;
  98531. /**
  98532. * Disposes the ShadowGenerator.
  98533. * Returns nothing.
  98534. */
  98535. dispose(): void;
  98536. /**
  98537. * Serializes the shadow generator setup to a json object.
  98538. * @returns The serialized JSON object
  98539. */
  98540. serialize(): any;
  98541. /**
  98542. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98543. * @param parsedShadowGenerator The JSON object to parse
  98544. * @param scene The scene to create the shadow map for
  98545. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98546. * @returns The parsed shadow generator
  98547. */
  98548. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98549. }
  98550. }
  98551. declare module BABYLON {
  98552. /**
  98553. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98554. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98555. * 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.
  98556. */
  98557. export abstract class Light extends Node {
  98558. /**
  98559. * Falloff Default: light is falling off following the material specification:
  98560. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98561. */
  98562. static readonly FALLOFF_DEFAULT: number;
  98563. /**
  98564. * Falloff Physical: light is falling off following the inverse squared distance law.
  98565. */
  98566. static readonly FALLOFF_PHYSICAL: number;
  98567. /**
  98568. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98569. * to enhance interoperability with other engines.
  98570. */
  98571. static readonly FALLOFF_GLTF: number;
  98572. /**
  98573. * Falloff Standard: light is falling off like in the standard material
  98574. * to enhance interoperability with other materials.
  98575. */
  98576. static readonly FALLOFF_STANDARD: number;
  98577. /**
  98578. * If every light affecting the material is in this lightmapMode,
  98579. * material.lightmapTexture adds or multiplies
  98580. * (depends on material.useLightmapAsShadowmap)
  98581. * after every other light calculations.
  98582. */
  98583. static readonly LIGHTMAP_DEFAULT: number;
  98584. /**
  98585. * material.lightmapTexture as only diffuse lighting from this light
  98586. * adds only specular lighting from this light
  98587. * adds dynamic shadows
  98588. */
  98589. static readonly LIGHTMAP_SPECULAR: number;
  98590. /**
  98591. * material.lightmapTexture as only lighting
  98592. * no light calculation from this light
  98593. * only adds dynamic shadows from this light
  98594. */
  98595. static readonly LIGHTMAP_SHADOWSONLY: number;
  98596. /**
  98597. * Each light type uses the default quantity according to its type:
  98598. * point/spot lights use luminous intensity
  98599. * directional lights use illuminance
  98600. */
  98601. static readonly INTENSITYMODE_AUTOMATIC: number;
  98602. /**
  98603. * lumen (lm)
  98604. */
  98605. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98606. /**
  98607. * candela (lm/sr)
  98608. */
  98609. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98610. /**
  98611. * lux (lm/m^2)
  98612. */
  98613. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98614. /**
  98615. * nit (cd/m^2)
  98616. */
  98617. static readonly INTENSITYMODE_LUMINANCE: number;
  98618. /**
  98619. * Light type const id of the point light.
  98620. */
  98621. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98622. /**
  98623. * Light type const id of the directional light.
  98624. */
  98625. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98626. /**
  98627. * Light type const id of the spot light.
  98628. */
  98629. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98630. /**
  98631. * Light type const id of the hemispheric light.
  98632. */
  98633. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98634. /**
  98635. * Diffuse gives the basic color to an object.
  98636. */
  98637. diffuse: Color3;
  98638. /**
  98639. * Specular produces a highlight color on an object.
  98640. * Note: This is note affecting PBR materials.
  98641. */
  98642. specular: Color3;
  98643. /**
  98644. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98645. * falling off base on range or angle.
  98646. * This can be set to any values in Light.FALLOFF_x.
  98647. *
  98648. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98649. * other types of materials.
  98650. */
  98651. falloffType: number;
  98652. /**
  98653. * Strength of the light.
  98654. * Note: By default it is define in the framework own unit.
  98655. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98656. */
  98657. intensity: number;
  98658. private _range;
  98659. protected _inverseSquaredRange: number;
  98660. /**
  98661. * Defines how far from the source the light is impacting in scene units.
  98662. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98663. */
  98664. get range(): number;
  98665. /**
  98666. * Defines how far from the source the light is impacting in scene units.
  98667. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98668. */
  98669. set range(value: number);
  98670. /**
  98671. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98672. * of light.
  98673. */
  98674. private _photometricScale;
  98675. private _intensityMode;
  98676. /**
  98677. * Gets the photometric scale used to interpret the intensity.
  98678. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98679. */
  98680. get intensityMode(): number;
  98681. /**
  98682. * Sets the photometric scale used to interpret the intensity.
  98683. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98684. */
  98685. set intensityMode(value: number);
  98686. private _radius;
  98687. /**
  98688. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98689. */
  98690. get radius(): number;
  98691. /**
  98692. * sets the light radius used by PBR Materials to simulate soft area lights.
  98693. */
  98694. set radius(value: number);
  98695. private _renderPriority;
  98696. /**
  98697. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98698. * exceeding the number allowed of the materials.
  98699. */
  98700. renderPriority: number;
  98701. private _shadowEnabled;
  98702. /**
  98703. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98704. * the current shadow generator.
  98705. */
  98706. get shadowEnabled(): boolean;
  98707. /**
  98708. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98709. * the current shadow generator.
  98710. */
  98711. set shadowEnabled(value: boolean);
  98712. private _includedOnlyMeshes;
  98713. /**
  98714. * Gets the only meshes impacted by this light.
  98715. */
  98716. get includedOnlyMeshes(): AbstractMesh[];
  98717. /**
  98718. * Sets the only meshes impacted by this light.
  98719. */
  98720. set includedOnlyMeshes(value: AbstractMesh[]);
  98721. private _excludedMeshes;
  98722. /**
  98723. * Gets the meshes not impacted by this light.
  98724. */
  98725. get excludedMeshes(): AbstractMesh[];
  98726. /**
  98727. * Sets the meshes not impacted by this light.
  98728. */
  98729. set excludedMeshes(value: AbstractMesh[]);
  98730. private _excludeWithLayerMask;
  98731. /**
  98732. * Gets the layer id use to find what meshes are not impacted by the light.
  98733. * Inactive if 0
  98734. */
  98735. get excludeWithLayerMask(): number;
  98736. /**
  98737. * Sets the layer id use to find what meshes are not impacted by the light.
  98738. * Inactive if 0
  98739. */
  98740. set excludeWithLayerMask(value: number);
  98741. private _includeOnlyWithLayerMask;
  98742. /**
  98743. * Gets the layer id use to find what meshes are impacted by the light.
  98744. * Inactive if 0
  98745. */
  98746. get includeOnlyWithLayerMask(): number;
  98747. /**
  98748. * Sets the layer id use to find what meshes are impacted by the light.
  98749. * Inactive if 0
  98750. */
  98751. set includeOnlyWithLayerMask(value: number);
  98752. private _lightmapMode;
  98753. /**
  98754. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98755. */
  98756. get lightmapMode(): number;
  98757. /**
  98758. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98759. */
  98760. set lightmapMode(value: number);
  98761. /**
  98762. * Shadow generator associted to the light.
  98763. * @hidden Internal use only.
  98764. */
  98765. _shadowGenerator: Nullable<IShadowGenerator>;
  98766. /**
  98767. * @hidden Internal use only.
  98768. */
  98769. _excludedMeshesIds: string[];
  98770. /**
  98771. * @hidden Internal use only.
  98772. */
  98773. _includedOnlyMeshesIds: string[];
  98774. /**
  98775. * The current light unifom buffer.
  98776. * @hidden Internal use only.
  98777. */
  98778. _uniformBuffer: UniformBuffer;
  98779. /** @hidden */
  98780. _renderId: number;
  98781. /**
  98782. * Creates a Light object in the scene.
  98783. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98784. * @param name The firendly name of the light
  98785. * @param scene The scene the light belongs too
  98786. */
  98787. constructor(name: string, scene: Scene);
  98788. protected abstract _buildUniformLayout(): void;
  98789. /**
  98790. * Sets the passed Effect "effect" with the Light information.
  98791. * @param effect The effect to update
  98792. * @param lightIndex The index of the light in the effect to update
  98793. * @returns The light
  98794. */
  98795. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98796. /**
  98797. * Sets the passed Effect "effect" with the Light textures.
  98798. * @param effect The effect to update
  98799. * @param lightIndex The index of the light in the effect to update
  98800. * @returns The light
  98801. */
  98802. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98803. /**
  98804. * Binds the lights information from the scene to the effect for the given mesh.
  98805. * @param lightIndex Light index
  98806. * @param scene The scene where the light belongs to
  98807. * @param effect The effect we are binding the data to
  98808. * @param useSpecular Defines if specular is supported
  98809. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98810. */
  98811. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98812. /**
  98813. * Sets the passed Effect "effect" with the Light information.
  98814. * @param effect The effect to update
  98815. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98816. * @returns The light
  98817. */
  98818. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98819. /**
  98820. * Returns the string "Light".
  98821. * @returns the class name
  98822. */
  98823. getClassName(): string;
  98824. /** @hidden */
  98825. readonly _isLight: boolean;
  98826. /**
  98827. * Converts the light information to a readable string for debug purpose.
  98828. * @param fullDetails Supports for multiple levels of logging within scene loading
  98829. * @returns the human readable light info
  98830. */
  98831. toString(fullDetails?: boolean): string;
  98832. /** @hidden */
  98833. protected _syncParentEnabledState(): void;
  98834. /**
  98835. * Set the enabled state of this node.
  98836. * @param value - the new enabled state
  98837. */
  98838. setEnabled(value: boolean): void;
  98839. /**
  98840. * Returns the Light associated shadow generator if any.
  98841. * @return the associated shadow generator.
  98842. */
  98843. getShadowGenerator(): Nullable<IShadowGenerator>;
  98844. /**
  98845. * Returns a Vector3, the absolute light position in the World.
  98846. * @returns the world space position of the light
  98847. */
  98848. getAbsolutePosition(): Vector3;
  98849. /**
  98850. * Specifies if the light will affect the passed mesh.
  98851. * @param mesh The mesh to test against the light
  98852. * @return true the mesh is affected otherwise, false.
  98853. */
  98854. canAffectMesh(mesh: AbstractMesh): boolean;
  98855. /**
  98856. * Sort function to order lights for rendering.
  98857. * @param a First Light object to compare to second.
  98858. * @param b Second Light object to compare first.
  98859. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98860. */
  98861. static CompareLightsPriority(a: Light, b: Light): number;
  98862. /**
  98863. * Releases resources associated with this node.
  98864. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98865. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98866. */
  98867. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98868. /**
  98869. * Returns the light type ID (integer).
  98870. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98871. */
  98872. getTypeID(): number;
  98873. /**
  98874. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98875. * @returns the scaled intensity in intensity mode unit
  98876. */
  98877. getScaledIntensity(): number;
  98878. /**
  98879. * Returns a new Light object, named "name", from the current one.
  98880. * @param name The name of the cloned light
  98881. * @param newParent The parent of this light, if it has one
  98882. * @returns the new created light
  98883. */
  98884. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98885. /**
  98886. * Serializes the current light into a Serialization object.
  98887. * @returns the serialized object.
  98888. */
  98889. serialize(): any;
  98890. /**
  98891. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98892. * This new light is named "name" and added to the passed scene.
  98893. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98894. * @param name The friendly name of the light
  98895. * @param scene The scene the new light will belong to
  98896. * @returns the constructor function
  98897. */
  98898. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98899. /**
  98900. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98901. * @param parsedLight The JSON representation of the light
  98902. * @param scene The scene to create the parsed light in
  98903. * @returns the created light after parsing
  98904. */
  98905. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98906. private _hookArrayForExcluded;
  98907. private _hookArrayForIncludedOnly;
  98908. private _resyncMeshes;
  98909. /**
  98910. * Forces the meshes to update their light related information in their rendering used effects
  98911. * @hidden Internal Use Only
  98912. */
  98913. _markMeshesAsLightDirty(): void;
  98914. /**
  98915. * Recomputes the cached photometric scale if needed.
  98916. */
  98917. private _computePhotometricScale;
  98918. /**
  98919. * Returns the Photometric Scale according to the light type and intensity mode.
  98920. */
  98921. private _getPhotometricScale;
  98922. /**
  98923. * Reorder the light in the scene according to their defined priority.
  98924. * @hidden Internal Use Only
  98925. */
  98926. _reorderLightsInScene(): void;
  98927. /**
  98928. * Prepares the list of defines specific to the light type.
  98929. * @param defines the list of defines
  98930. * @param lightIndex defines the index of the light for the effect
  98931. */
  98932. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98933. }
  98934. }
  98935. declare module BABYLON {
  98936. /**
  98937. * Configuration needed for prepass-capable materials
  98938. */
  98939. export class PrePassConfiguration {
  98940. /**
  98941. * Previous world matrices of meshes carrying this material
  98942. * Used for computing velocity
  98943. */
  98944. previousWorldMatrices: {
  98945. [index: number]: Matrix;
  98946. };
  98947. /**
  98948. * Previous view project matrix
  98949. * Used for computing velocity
  98950. */
  98951. previousViewProjection: Matrix;
  98952. /**
  98953. * Previous bones of meshes carrying this material
  98954. * Used for computing velocity
  98955. */
  98956. previousBones: {
  98957. [index: number]: Float32Array;
  98958. };
  98959. /**
  98960. * Add the required uniforms to the current list.
  98961. * @param uniforms defines the current uniform list.
  98962. */
  98963. static AddUniforms(uniforms: string[]): void;
  98964. /**
  98965. * Add the required samplers to the current list.
  98966. * @param samplers defines the current sampler list.
  98967. */
  98968. static AddSamplers(samplers: string[]): void;
  98969. /**
  98970. * Binds the material data.
  98971. * @param effect defines the effect to update
  98972. * @param scene defines the scene the material belongs to.
  98973. * @param mesh The mesh
  98974. * @param world World matrix of this mesh
  98975. * @param isFrozen Is the material frozen
  98976. */
  98977. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  98978. }
  98979. }
  98980. declare module BABYLON {
  98981. /**
  98982. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98983. * This is the base of the follow, arc rotate cameras and Free camera
  98984. * @see https://doc.babylonjs.com/features/cameras
  98985. */
  98986. export class TargetCamera extends Camera {
  98987. private static _RigCamTransformMatrix;
  98988. private static _TargetTransformMatrix;
  98989. private static _TargetFocalPoint;
  98990. private _tmpUpVector;
  98991. private _tmpTargetVector;
  98992. /**
  98993. * Define the current direction the camera is moving to
  98994. */
  98995. cameraDirection: Vector3;
  98996. /**
  98997. * Define the current rotation the camera is rotating to
  98998. */
  98999. cameraRotation: Vector2;
  99000. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  99001. ignoreParentScaling: boolean;
  99002. /**
  99003. * When set, the up vector of the camera will be updated by the rotation of the camera
  99004. */
  99005. updateUpVectorFromRotation: boolean;
  99006. private _tmpQuaternion;
  99007. /**
  99008. * Define the current rotation of the camera
  99009. */
  99010. rotation: Vector3;
  99011. /**
  99012. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  99013. */
  99014. rotationQuaternion: Quaternion;
  99015. /**
  99016. * Define the current speed of the camera
  99017. */
  99018. speed: number;
  99019. /**
  99020. * Add constraint to the camera to prevent it to move freely in all directions and
  99021. * around all axis.
  99022. */
  99023. noRotationConstraint: boolean;
  99024. /**
  99025. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  99026. * panning
  99027. */
  99028. invertRotation: boolean;
  99029. /**
  99030. * Speed multiplier for inverse camera panning
  99031. */
  99032. inverseRotationSpeed: number;
  99033. /**
  99034. * Define the current target of the camera as an object or a position.
  99035. */
  99036. lockedTarget: any;
  99037. /** @hidden */
  99038. _currentTarget: Vector3;
  99039. /** @hidden */
  99040. _initialFocalDistance: number;
  99041. /** @hidden */
  99042. _viewMatrix: Matrix;
  99043. /** @hidden */
  99044. _camMatrix: Matrix;
  99045. /** @hidden */
  99046. _cameraTransformMatrix: Matrix;
  99047. /** @hidden */
  99048. _cameraRotationMatrix: Matrix;
  99049. /** @hidden */
  99050. _referencePoint: Vector3;
  99051. /** @hidden */
  99052. _transformedReferencePoint: Vector3;
  99053. /** @hidden */
  99054. _reset: () => void;
  99055. private _defaultUp;
  99056. /**
  99057. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99058. * This is the base of the follow, arc rotate cameras and Free camera
  99059. * @see https://doc.babylonjs.com/features/cameras
  99060. * @param name Defines the name of the camera in the scene
  99061. * @param position Defines the start position of the camera in the scene
  99062. * @param scene Defines the scene the camera belongs to
  99063. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99064. */
  99065. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99066. /**
  99067. * Gets the position in front of the camera at a given distance.
  99068. * @param distance The distance from the camera we want the position to be
  99069. * @returns the position
  99070. */
  99071. getFrontPosition(distance: number): Vector3;
  99072. /** @hidden */
  99073. _getLockedTargetPosition(): Nullable<Vector3>;
  99074. private _storedPosition;
  99075. private _storedRotation;
  99076. private _storedRotationQuaternion;
  99077. /**
  99078. * Store current camera state of the camera (fov, position, rotation, etc..)
  99079. * @returns the camera
  99080. */
  99081. storeState(): Camera;
  99082. /**
  99083. * Restored camera state. You must call storeState() first
  99084. * @returns whether it was successful or not
  99085. * @hidden
  99086. */
  99087. _restoreStateValues(): boolean;
  99088. /** @hidden */
  99089. _initCache(): void;
  99090. /** @hidden */
  99091. _updateCache(ignoreParentClass?: boolean): void;
  99092. /** @hidden */
  99093. _isSynchronizedViewMatrix(): boolean;
  99094. /** @hidden */
  99095. _computeLocalCameraSpeed(): number;
  99096. /**
  99097. * Defines the target the camera should look at.
  99098. * @param target Defines the new target as a Vector or a mesh
  99099. */
  99100. setTarget(target: Vector3): void;
  99101. /**
  99102. * Defines the target point of the camera.
  99103. * The camera looks towards it form the radius distance.
  99104. */
  99105. get target(): Vector3;
  99106. set target(value: Vector3);
  99107. /**
  99108. * Return the current target position of the camera. This value is expressed in local space.
  99109. * @returns the target position
  99110. */
  99111. getTarget(): Vector3;
  99112. /** @hidden */
  99113. _decideIfNeedsToMove(): boolean;
  99114. /** @hidden */
  99115. _updatePosition(): void;
  99116. /** @hidden */
  99117. _checkInputs(): void;
  99118. protected _updateCameraRotationMatrix(): void;
  99119. /**
  99120. * 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)
  99121. * @returns the current camera
  99122. */
  99123. private _rotateUpVectorWithCameraRotationMatrix;
  99124. private _cachedRotationZ;
  99125. private _cachedQuaternionRotationZ;
  99126. /** @hidden */
  99127. _getViewMatrix(): Matrix;
  99128. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99129. /**
  99130. * @hidden
  99131. */
  99132. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99133. /**
  99134. * @hidden
  99135. */
  99136. _updateRigCameras(): void;
  99137. private _getRigCamPositionAndTarget;
  99138. /**
  99139. * Gets the current object class name.
  99140. * @return the class name
  99141. */
  99142. getClassName(): string;
  99143. }
  99144. }
  99145. declare module BABYLON {
  99146. /**
  99147. * Gather the list of keyboard event types as constants.
  99148. */
  99149. export class KeyboardEventTypes {
  99150. /**
  99151. * The keydown event is fired when a key becomes active (pressed).
  99152. */
  99153. static readonly KEYDOWN: number;
  99154. /**
  99155. * The keyup event is fired when a key has been released.
  99156. */
  99157. static readonly KEYUP: number;
  99158. }
  99159. /**
  99160. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99161. */
  99162. export class KeyboardInfo {
  99163. /**
  99164. * Defines the type of event (KeyboardEventTypes)
  99165. */
  99166. type: number;
  99167. /**
  99168. * Defines the related dom event
  99169. */
  99170. event: KeyboardEvent;
  99171. /**
  99172. * Instantiates a new keyboard info.
  99173. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99174. * @param type Defines the type of event (KeyboardEventTypes)
  99175. * @param event Defines the related dom event
  99176. */
  99177. constructor(
  99178. /**
  99179. * Defines the type of event (KeyboardEventTypes)
  99180. */
  99181. type: number,
  99182. /**
  99183. * Defines the related dom event
  99184. */
  99185. event: KeyboardEvent);
  99186. }
  99187. /**
  99188. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99189. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99190. */
  99191. export class KeyboardInfoPre extends KeyboardInfo {
  99192. /**
  99193. * Defines the type of event (KeyboardEventTypes)
  99194. */
  99195. type: number;
  99196. /**
  99197. * Defines the related dom event
  99198. */
  99199. event: KeyboardEvent;
  99200. /**
  99201. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99202. */
  99203. skipOnPointerObservable: boolean;
  99204. /**
  99205. * Instantiates a new keyboard pre info.
  99206. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99207. * @param type Defines the type of event (KeyboardEventTypes)
  99208. * @param event Defines the related dom event
  99209. */
  99210. constructor(
  99211. /**
  99212. * Defines the type of event (KeyboardEventTypes)
  99213. */
  99214. type: number,
  99215. /**
  99216. * Defines the related dom event
  99217. */
  99218. event: KeyboardEvent);
  99219. }
  99220. }
  99221. declare module BABYLON {
  99222. /**
  99223. * Manage the keyboard inputs to control the movement of a free camera.
  99224. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99225. */
  99226. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99227. /**
  99228. * Defines the camera the input is attached to.
  99229. */
  99230. camera: FreeCamera;
  99231. /**
  99232. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99233. */
  99234. keysUp: number[];
  99235. /**
  99236. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99237. */
  99238. keysUpward: number[];
  99239. /**
  99240. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99241. */
  99242. keysDown: number[];
  99243. /**
  99244. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99245. */
  99246. keysDownward: number[];
  99247. /**
  99248. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99249. */
  99250. keysLeft: number[];
  99251. /**
  99252. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99253. */
  99254. keysRight: number[];
  99255. private _keys;
  99256. private _onCanvasBlurObserver;
  99257. private _onKeyboardObserver;
  99258. private _engine;
  99259. private _scene;
  99260. /**
  99261. * Attach the input controls to a specific dom element to get the input from.
  99262. * @param element Defines the element the controls should be listened from
  99263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99264. */
  99265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99266. /**
  99267. * Detach the current controls from the specified dom element.
  99268. * @param element Defines the element to stop listening the inputs from
  99269. */
  99270. detachControl(element: Nullable<HTMLElement>): void;
  99271. /**
  99272. * Update the current camera state depending on the inputs that have been used this frame.
  99273. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99274. */
  99275. checkInputs(): void;
  99276. /**
  99277. * Gets the class name of the current intput.
  99278. * @returns the class name
  99279. */
  99280. getClassName(): string;
  99281. /** @hidden */
  99282. _onLostFocus(): void;
  99283. /**
  99284. * Get the friendly name associated with the input class.
  99285. * @returns the input friendly name
  99286. */
  99287. getSimpleName(): string;
  99288. }
  99289. }
  99290. declare module BABYLON {
  99291. /**
  99292. * Gather the list of pointer event types as constants.
  99293. */
  99294. export class PointerEventTypes {
  99295. /**
  99296. * 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.
  99297. */
  99298. static readonly POINTERDOWN: number;
  99299. /**
  99300. * The pointerup event is fired when a pointer is no longer active.
  99301. */
  99302. static readonly POINTERUP: number;
  99303. /**
  99304. * The pointermove event is fired when a pointer changes coordinates.
  99305. */
  99306. static readonly POINTERMOVE: number;
  99307. /**
  99308. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99309. */
  99310. static readonly POINTERWHEEL: number;
  99311. /**
  99312. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99313. */
  99314. static readonly POINTERPICK: number;
  99315. /**
  99316. * The pointertap event is fired when a the object has been touched and released without drag.
  99317. */
  99318. static readonly POINTERTAP: number;
  99319. /**
  99320. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99321. */
  99322. static readonly POINTERDOUBLETAP: number;
  99323. }
  99324. /**
  99325. * Base class of pointer info types.
  99326. */
  99327. export class PointerInfoBase {
  99328. /**
  99329. * Defines the type of event (PointerEventTypes)
  99330. */
  99331. type: number;
  99332. /**
  99333. * Defines the related dom event
  99334. */
  99335. event: PointerEvent | MouseWheelEvent;
  99336. /**
  99337. * Instantiates the base class of pointers info.
  99338. * @param type Defines the type of event (PointerEventTypes)
  99339. * @param event Defines the related dom event
  99340. */
  99341. constructor(
  99342. /**
  99343. * Defines the type of event (PointerEventTypes)
  99344. */
  99345. type: number,
  99346. /**
  99347. * Defines the related dom event
  99348. */
  99349. event: PointerEvent | MouseWheelEvent);
  99350. }
  99351. /**
  99352. * This class is used to store pointer related info for the onPrePointerObservable event.
  99353. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99354. */
  99355. export class PointerInfoPre extends PointerInfoBase {
  99356. /**
  99357. * Ray from a pointer if availible (eg. 6dof controller)
  99358. */
  99359. ray: Nullable<Ray>;
  99360. /**
  99361. * Defines the local position of the pointer on the canvas.
  99362. */
  99363. localPosition: Vector2;
  99364. /**
  99365. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99366. */
  99367. skipOnPointerObservable: boolean;
  99368. /**
  99369. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99370. * @param type Defines the type of event (PointerEventTypes)
  99371. * @param event Defines the related dom event
  99372. * @param localX Defines the local x coordinates of the pointer when the event occured
  99373. * @param localY Defines the local y coordinates of the pointer when the event occured
  99374. */
  99375. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99376. }
  99377. /**
  99378. * This type contains all the data related to a pointer event in Babylon.js.
  99379. * 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.
  99380. */
  99381. export class PointerInfo extends PointerInfoBase {
  99382. /**
  99383. * Defines the picking info associated to the info (if any)\
  99384. */
  99385. pickInfo: Nullable<PickingInfo>;
  99386. /**
  99387. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99388. * @param type Defines the type of event (PointerEventTypes)
  99389. * @param event Defines the related dom event
  99390. * @param pickInfo Defines the picking info associated to the info (if any)\
  99391. */
  99392. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99393. /**
  99394. * Defines the picking info associated to the info (if any)\
  99395. */
  99396. pickInfo: Nullable<PickingInfo>);
  99397. }
  99398. /**
  99399. * Data relating to a touch event on the screen.
  99400. */
  99401. export interface PointerTouch {
  99402. /**
  99403. * X coordinate of touch.
  99404. */
  99405. x: number;
  99406. /**
  99407. * Y coordinate of touch.
  99408. */
  99409. y: number;
  99410. /**
  99411. * Id of touch. Unique for each finger.
  99412. */
  99413. pointerId: number;
  99414. /**
  99415. * Event type passed from DOM.
  99416. */
  99417. type: any;
  99418. }
  99419. }
  99420. declare module BABYLON {
  99421. /**
  99422. * Manage the mouse inputs to control the movement of a free camera.
  99423. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99424. */
  99425. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99426. /**
  99427. * Define if touch is enabled in the mouse input
  99428. */
  99429. touchEnabled: boolean;
  99430. /**
  99431. * Defines the camera the input is attached to.
  99432. */
  99433. camera: FreeCamera;
  99434. /**
  99435. * Defines the buttons associated with the input to handle camera move.
  99436. */
  99437. buttons: number[];
  99438. /**
  99439. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99440. */
  99441. angularSensibility: number;
  99442. private _pointerInput;
  99443. private _onMouseMove;
  99444. private _observer;
  99445. private previousPosition;
  99446. /**
  99447. * Observable for when a pointer move event occurs containing the move offset
  99448. */
  99449. onPointerMovedObservable: Observable<{
  99450. offsetX: number;
  99451. offsetY: number;
  99452. }>;
  99453. /**
  99454. * @hidden
  99455. * If the camera should be rotated automatically based on pointer movement
  99456. */
  99457. _allowCameraRotation: boolean;
  99458. /**
  99459. * Manage the mouse inputs to control the movement of a free camera.
  99460. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99461. * @param touchEnabled Defines if touch is enabled or not
  99462. */
  99463. constructor(
  99464. /**
  99465. * Define if touch is enabled in the mouse input
  99466. */
  99467. touchEnabled?: boolean);
  99468. /**
  99469. * Attach the input controls to a specific dom element to get the input from.
  99470. * @param element Defines the element the controls should be listened from
  99471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99472. */
  99473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99474. /**
  99475. * Called on JS contextmenu event.
  99476. * Override this method to provide functionality.
  99477. */
  99478. protected onContextMenu(evt: PointerEvent): void;
  99479. /**
  99480. * Detach the current controls from the specified dom element.
  99481. * @param element Defines the element to stop listening the inputs from
  99482. */
  99483. detachControl(element: Nullable<HTMLElement>): void;
  99484. /**
  99485. * Gets the class name of the current intput.
  99486. * @returns the class name
  99487. */
  99488. getClassName(): string;
  99489. /**
  99490. * Get the friendly name associated with the input class.
  99491. * @returns the input friendly name
  99492. */
  99493. getSimpleName(): string;
  99494. }
  99495. }
  99496. declare module BABYLON {
  99497. /**
  99498. * Manage the touch inputs to control the movement of a free camera.
  99499. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99500. */
  99501. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99502. /**
  99503. * Define if mouse events can be treated as touch events
  99504. */
  99505. allowMouse: boolean;
  99506. /**
  99507. * Defines the camera the input is attached to.
  99508. */
  99509. camera: FreeCamera;
  99510. /**
  99511. * Defines the touch sensibility for rotation.
  99512. * The higher the faster.
  99513. */
  99514. touchAngularSensibility: number;
  99515. /**
  99516. * Defines the touch sensibility for move.
  99517. * The higher the faster.
  99518. */
  99519. touchMoveSensibility: number;
  99520. private _offsetX;
  99521. private _offsetY;
  99522. private _pointerPressed;
  99523. private _pointerInput;
  99524. private _observer;
  99525. private _onLostFocus;
  99526. /**
  99527. * Manage the touch inputs to control the movement of a free camera.
  99528. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99529. * @param allowMouse Defines if mouse events can be treated as touch events
  99530. */
  99531. constructor(
  99532. /**
  99533. * Define if mouse events can be treated as touch events
  99534. */
  99535. allowMouse?: boolean);
  99536. /**
  99537. * Attach the input controls to a specific dom element to get the input from.
  99538. * @param element Defines the element the controls should be listened from
  99539. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99540. */
  99541. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99542. /**
  99543. * Detach the current controls from the specified dom element.
  99544. * @param element Defines the element to stop listening the inputs from
  99545. */
  99546. detachControl(element: Nullable<HTMLElement>): void;
  99547. /**
  99548. * Update the current camera state depending on the inputs that have been used this frame.
  99549. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99550. */
  99551. checkInputs(): void;
  99552. /**
  99553. * Gets the class name of the current intput.
  99554. * @returns the class name
  99555. */
  99556. getClassName(): string;
  99557. /**
  99558. * Get the friendly name associated with the input class.
  99559. * @returns the input friendly name
  99560. */
  99561. getSimpleName(): string;
  99562. }
  99563. }
  99564. declare module BABYLON {
  99565. /**
  99566. * Default Inputs manager for the FreeCamera.
  99567. * It groups all the default supported inputs for ease of use.
  99568. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99569. */
  99570. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99571. /**
  99572. * @hidden
  99573. */
  99574. _mouseInput: Nullable<FreeCameraMouseInput>;
  99575. /**
  99576. * Instantiates a new FreeCameraInputsManager.
  99577. * @param camera Defines the camera the inputs belong to
  99578. */
  99579. constructor(camera: FreeCamera);
  99580. /**
  99581. * Add keyboard input support to the input manager.
  99582. * @returns the current input manager
  99583. */
  99584. addKeyboard(): FreeCameraInputsManager;
  99585. /**
  99586. * Add mouse input support to the input manager.
  99587. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99588. * @returns the current input manager
  99589. */
  99590. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99591. /**
  99592. * Removes the mouse input support from the manager
  99593. * @returns the current input manager
  99594. */
  99595. removeMouse(): FreeCameraInputsManager;
  99596. /**
  99597. * Add touch input support to the input manager.
  99598. * @returns the current input manager
  99599. */
  99600. addTouch(): FreeCameraInputsManager;
  99601. /**
  99602. * Remove all attached input methods from a camera
  99603. */
  99604. clear(): void;
  99605. }
  99606. }
  99607. declare module BABYLON {
  99608. /**
  99609. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99610. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99611. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99612. */
  99613. export class FreeCamera extends TargetCamera {
  99614. /**
  99615. * Define the collision ellipsoid of the camera.
  99616. * This is helpful to simulate a camera body like the player body around the camera
  99617. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99618. */
  99619. ellipsoid: Vector3;
  99620. /**
  99621. * Define an offset for the position of the ellipsoid around the camera.
  99622. * This can be helpful to determine the center of the body near the gravity center of the body
  99623. * instead of its head.
  99624. */
  99625. ellipsoidOffset: Vector3;
  99626. /**
  99627. * Enable or disable collisions of the camera with the rest of the scene objects.
  99628. */
  99629. checkCollisions: boolean;
  99630. /**
  99631. * Enable or disable gravity on the camera.
  99632. */
  99633. applyGravity: boolean;
  99634. /**
  99635. * Define the input manager associated to the camera.
  99636. */
  99637. inputs: FreeCameraInputsManager;
  99638. /**
  99639. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99640. * Higher values reduce sensitivity.
  99641. */
  99642. get angularSensibility(): number;
  99643. /**
  99644. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99645. * Higher values reduce sensitivity.
  99646. */
  99647. set angularSensibility(value: number);
  99648. /**
  99649. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99650. */
  99651. get keysUp(): number[];
  99652. set keysUp(value: number[]);
  99653. /**
  99654. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99655. */
  99656. get keysUpward(): number[];
  99657. set keysUpward(value: number[]);
  99658. /**
  99659. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99660. */
  99661. get keysDown(): number[];
  99662. set keysDown(value: number[]);
  99663. /**
  99664. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99665. */
  99666. get keysDownward(): number[];
  99667. set keysDownward(value: number[]);
  99668. /**
  99669. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99670. */
  99671. get keysLeft(): number[];
  99672. set keysLeft(value: number[]);
  99673. /**
  99674. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99675. */
  99676. get keysRight(): number[];
  99677. set keysRight(value: number[]);
  99678. /**
  99679. * Event raised when the camera collide with a mesh in the scene.
  99680. */
  99681. onCollide: (collidedMesh: AbstractMesh) => void;
  99682. private _collider;
  99683. private _needMoveForGravity;
  99684. private _oldPosition;
  99685. private _diffPosition;
  99686. private _newPosition;
  99687. /** @hidden */
  99688. _localDirection: Vector3;
  99689. /** @hidden */
  99690. _transformedDirection: Vector3;
  99691. /**
  99692. * Instantiates a Free Camera.
  99693. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99694. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99695. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99696. * @param name Define the name of the camera in the scene
  99697. * @param position Define the start position of the camera in the scene
  99698. * @param scene Define the scene the camera belongs to
  99699. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99700. */
  99701. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99702. /**
  99703. * Attached controls to the current camera.
  99704. * @param element Defines the element the controls should be listened from
  99705. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99706. */
  99707. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99708. /**
  99709. * Detach the current controls from the camera.
  99710. * The camera will stop reacting to inputs.
  99711. * @param element Defines the element to stop listening the inputs from
  99712. */
  99713. detachControl(element: HTMLElement): void;
  99714. private _collisionMask;
  99715. /**
  99716. * Define a collision mask to limit the list of object the camera can collide with
  99717. */
  99718. get collisionMask(): number;
  99719. set collisionMask(mask: number);
  99720. /** @hidden */
  99721. _collideWithWorld(displacement: Vector3): void;
  99722. private _onCollisionPositionChange;
  99723. /** @hidden */
  99724. _checkInputs(): void;
  99725. /** @hidden */
  99726. _decideIfNeedsToMove(): boolean;
  99727. /** @hidden */
  99728. _updatePosition(): void;
  99729. /**
  99730. * Destroy the camera and release the current resources hold by it.
  99731. */
  99732. dispose(): void;
  99733. /**
  99734. * Gets the current object class name.
  99735. * @return the class name
  99736. */
  99737. getClassName(): string;
  99738. }
  99739. }
  99740. declare module BABYLON {
  99741. /**
  99742. * Represents a gamepad control stick position
  99743. */
  99744. export class StickValues {
  99745. /**
  99746. * The x component of the control stick
  99747. */
  99748. x: number;
  99749. /**
  99750. * The y component of the control stick
  99751. */
  99752. y: number;
  99753. /**
  99754. * Initializes the gamepad x and y control stick values
  99755. * @param x The x component of the gamepad control stick value
  99756. * @param y The y component of the gamepad control stick value
  99757. */
  99758. constructor(
  99759. /**
  99760. * The x component of the control stick
  99761. */
  99762. x: number,
  99763. /**
  99764. * The y component of the control stick
  99765. */
  99766. y: number);
  99767. }
  99768. /**
  99769. * An interface which manages callbacks for gamepad button changes
  99770. */
  99771. export interface GamepadButtonChanges {
  99772. /**
  99773. * Called when a gamepad has been changed
  99774. */
  99775. changed: boolean;
  99776. /**
  99777. * Called when a gamepad press event has been triggered
  99778. */
  99779. pressChanged: boolean;
  99780. /**
  99781. * Called when a touch event has been triggered
  99782. */
  99783. touchChanged: boolean;
  99784. /**
  99785. * Called when a value has changed
  99786. */
  99787. valueChanged: boolean;
  99788. }
  99789. /**
  99790. * Represents a gamepad
  99791. */
  99792. export class Gamepad {
  99793. /**
  99794. * The id of the gamepad
  99795. */
  99796. id: string;
  99797. /**
  99798. * The index of the gamepad
  99799. */
  99800. index: number;
  99801. /**
  99802. * The browser gamepad
  99803. */
  99804. browserGamepad: any;
  99805. /**
  99806. * Specifies what type of gamepad this represents
  99807. */
  99808. type: number;
  99809. private _leftStick;
  99810. private _rightStick;
  99811. /** @hidden */
  99812. _isConnected: boolean;
  99813. private _leftStickAxisX;
  99814. private _leftStickAxisY;
  99815. private _rightStickAxisX;
  99816. private _rightStickAxisY;
  99817. /**
  99818. * Triggered when the left control stick has been changed
  99819. */
  99820. private _onleftstickchanged;
  99821. /**
  99822. * Triggered when the right control stick has been changed
  99823. */
  99824. private _onrightstickchanged;
  99825. /**
  99826. * Represents a gamepad controller
  99827. */
  99828. static GAMEPAD: number;
  99829. /**
  99830. * Represents a generic controller
  99831. */
  99832. static GENERIC: number;
  99833. /**
  99834. * Represents an XBox controller
  99835. */
  99836. static XBOX: number;
  99837. /**
  99838. * Represents a pose-enabled controller
  99839. */
  99840. static POSE_ENABLED: number;
  99841. /**
  99842. * Represents an Dual Shock controller
  99843. */
  99844. static DUALSHOCK: number;
  99845. /**
  99846. * Specifies whether the left control stick should be Y-inverted
  99847. */
  99848. protected _invertLeftStickY: boolean;
  99849. /**
  99850. * Specifies if the gamepad has been connected
  99851. */
  99852. get isConnected(): boolean;
  99853. /**
  99854. * Initializes the gamepad
  99855. * @param id The id of the gamepad
  99856. * @param index The index of the gamepad
  99857. * @param browserGamepad The browser gamepad
  99858. * @param leftStickX The x component of the left joystick
  99859. * @param leftStickY The y component of the left joystick
  99860. * @param rightStickX The x component of the right joystick
  99861. * @param rightStickY The y component of the right joystick
  99862. */
  99863. constructor(
  99864. /**
  99865. * The id of the gamepad
  99866. */
  99867. id: string,
  99868. /**
  99869. * The index of the gamepad
  99870. */
  99871. index: number,
  99872. /**
  99873. * The browser gamepad
  99874. */
  99875. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99876. /**
  99877. * Callback triggered when the left joystick has changed
  99878. * @param callback
  99879. */
  99880. onleftstickchanged(callback: (values: StickValues) => void): void;
  99881. /**
  99882. * Callback triggered when the right joystick has changed
  99883. * @param callback
  99884. */
  99885. onrightstickchanged(callback: (values: StickValues) => void): void;
  99886. /**
  99887. * Gets the left joystick
  99888. */
  99889. get leftStick(): StickValues;
  99890. /**
  99891. * Sets the left joystick values
  99892. */
  99893. set leftStick(newValues: StickValues);
  99894. /**
  99895. * Gets the right joystick
  99896. */
  99897. get rightStick(): StickValues;
  99898. /**
  99899. * Sets the right joystick value
  99900. */
  99901. set rightStick(newValues: StickValues);
  99902. /**
  99903. * Updates the gamepad joystick positions
  99904. */
  99905. update(): void;
  99906. /**
  99907. * Disposes the gamepad
  99908. */
  99909. dispose(): void;
  99910. }
  99911. /**
  99912. * Represents a generic gamepad
  99913. */
  99914. export class GenericPad extends Gamepad {
  99915. private _buttons;
  99916. private _onbuttondown;
  99917. private _onbuttonup;
  99918. /**
  99919. * Observable triggered when a button has been pressed
  99920. */
  99921. onButtonDownObservable: Observable<number>;
  99922. /**
  99923. * Observable triggered when a button has been released
  99924. */
  99925. onButtonUpObservable: Observable<number>;
  99926. /**
  99927. * Callback triggered when a button has been pressed
  99928. * @param callback Called when a button has been pressed
  99929. */
  99930. onbuttondown(callback: (buttonPressed: number) => void): void;
  99931. /**
  99932. * Callback triggered when a button has been released
  99933. * @param callback Called when a button has been released
  99934. */
  99935. onbuttonup(callback: (buttonReleased: number) => void): void;
  99936. /**
  99937. * Initializes the generic gamepad
  99938. * @param id The id of the generic gamepad
  99939. * @param index The index of the generic gamepad
  99940. * @param browserGamepad The browser gamepad
  99941. */
  99942. constructor(id: string, index: number, browserGamepad: any);
  99943. private _setButtonValue;
  99944. /**
  99945. * Updates the generic gamepad
  99946. */
  99947. update(): void;
  99948. /**
  99949. * Disposes the generic gamepad
  99950. */
  99951. dispose(): void;
  99952. }
  99953. }
  99954. declare module BABYLON {
  99955. /**
  99956. * Defines the types of pose enabled controllers that are supported
  99957. */
  99958. export enum PoseEnabledControllerType {
  99959. /**
  99960. * HTC Vive
  99961. */
  99962. VIVE = 0,
  99963. /**
  99964. * Oculus Rift
  99965. */
  99966. OCULUS = 1,
  99967. /**
  99968. * Windows mixed reality
  99969. */
  99970. WINDOWS = 2,
  99971. /**
  99972. * Samsung gear VR
  99973. */
  99974. GEAR_VR = 3,
  99975. /**
  99976. * Google Daydream
  99977. */
  99978. DAYDREAM = 4,
  99979. /**
  99980. * Generic
  99981. */
  99982. GENERIC = 5
  99983. }
  99984. /**
  99985. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99986. */
  99987. export interface MutableGamepadButton {
  99988. /**
  99989. * Value of the button/trigger
  99990. */
  99991. value: number;
  99992. /**
  99993. * If the button/trigger is currently touched
  99994. */
  99995. touched: boolean;
  99996. /**
  99997. * If the button/trigger is currently pressed
  99998. */
  99999. pressed: boolean;
  100000. }
  100001. /**
  100002. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  100003. * @hidden
  100004. */
  100005. export interface ExtendedGamepadButton extends GamepadButton {
  100006. /**
  100007. * If the button/trigger is currently pressed
  100008. */
  100009. readonly pressed: boolean;
  100010. /**
  100011. * If the button/trigger is currently touched
  100012. */
  100013. readonly touched: boolean;
  100014. /**
  100015. * Value of the button/trigger
  100016. */
  100017. readonly value: number;
  100018. }
  100019. /** @hidden */
  100020. export interface _GamePadFactory {
  100021. /**
  100022. * Returns whether or not the current gamepad can be created for this type of controller.
  100023. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100024. * @returns true if it can be created, otherwise false
  100025. */
  100026. canCreate(gamepadInfo: any): boolean;
  100027. /**
  100028. * Creates a new instance of the Gamepad.
  100029. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100030. * @returns the new gamepad instance
  100031. */
  100032. create(gamepadInfo: any): Gamepad;
  100033. }
  100034. /**
  100035. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100036. */
  100037. export class PoseEnabledControllerHelper {
  100038. /** @hidden */
  100039. static _ControllerFactories: _GamePadFactory[];
  100040. /** @hidden */
  100041. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  100042. /**
  100043. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100044. * @param vrGamepad the gamepad to initialized
  100045. * @returns a vr controller of the type the gamepad identified as
  100046. */
  100047. static InitiateController(vrGamepad: any): Gamepad;
  100048. }
  100049. /**
  100050. * Defines the PoseEnabledController object that contains state of a vr capable controller
  100051. */
  100052. export class PoseEnabledController extends Gamepad implements PoseControlled {
  100053. /**
  100054. * If the controller is used in a webXR session
  100055. */
  100056. isXR: boolean;
  100057. private _deviceRoomPosition;
  100058. private _deviceRoomRotationQuaternion;
  100059. /**
  100060. * The device position in babylon space
  100061. */
  100062. devicePosition: Vector3;
  100063. /**
  100064. * The device rotation in babylon space
  100065. */
  100066. deviceRotationQuaternion: Quaternion;
  100067. /**
  100068. * The scale factor of the device in babylon space
  100069. */
  100070. deviceScaleFactor: number;
  100071. /**
  100072. * (Likely devicePosition should be used instead) The device position in its room space
  100073. */
  100074. position: Vector3;
  100075. /**
  100076. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  100077. */
  100078. rotationQuaternion: Quaternion;
  100079. /**
  100080. * The type of controller (Eg. Windows mixed reality)
  100081. */
  100082. controllerType: PoseEnabledControllerType;
  100083. protected _calculatedPosition: Vector3;
  100084. private _calculatedRotation;
  100085. /**
  100086. * The raw pose from the device
  100087. */
  100088. rawPose: DevicePose;
  100089. private _trackPosition;
  100090. private _maxRotationDistFromHeadset;
  100091. private _draggedRoomRotation;
  100092. /**
  100093. * @hidden
  100094. */
  100095. _disableTrackPosition(fixedPosition: Vector3): void;
  100096. /**
  100097. * Internal, the mesh attached to the controller
  100098. * @hidden
  100099. */
  100100. _mesh: Nullable<AbstractMesh>;
  100101. private _poseControlledCamera;
  100102. private _leftHandSystemQuaternion;
  100103. /**
  100104. * Internal, matrix used to convert room space to babylon space
  100105. * @hidden
  100106. */
  100107. _deviceToWorld: Matrix;
  100108. /**
  100109. * Node to be used when casting a ray from the controller
  100110. * @hidden
  100111. */
  100112. _pointingPoseNode: Nullable<TransformNode>;
  100113. /**
  100114. * Name of the child mesh that can be used to cast a ray from the controller
  100115. */
  100116. static readonly POINTING_POSE: string;
  100117. /**
  100118. * Creates a new PoseEnabledController from a gamepad
  100119. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  100120. */
  100121. constructor(browserGamepad: any);
  100122. private _workingMatrix;
  100123. /**
  100124. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  100125. */
  100126. update(): void;
  100127. /**
  100128. * Updates only the pose device and mesh without doing any button event checking
  100129. */
  100130. protected _updatePoseAndMesh(): void;
  100131. /**
  100132. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  100133. * @param poseData raw pose fromthe device
  100134. */
  100135. updateFromDevice(poseData: DevicePose): void;
  100136. /**
  100137. * @hidden
  100138. */
  100139. _meshAttachedObservable: Observable<AbstractMesh>;
  100140. /**
  100141. * Attaches a mesh to the controller
  100142. * @param mesh the mesh to be attached
  100143. */
  100144. attachToMesh(mesh: AbstractMesh): void;
  100145. /**
  100146. * Attaches the controllers mesh to a camera
  100147. * @param camera the camera the mesh should be attached to
  100148. */
  100149. attachToPoseControlledCamera(camera: TargetCamera): void;
  100150. /**
  100151. * Disposes of the controller
  100152. */
  100153. dispose(): void;
  100154. /**
  100155. * The mesh that is attached to the controller
  100156. */
  100157. get mesh(): Nullable<AbstractMesh>;
  100158. /**
  100159. * Gets the ray of the controller in the direction the controller is pointing
  100160. * @param length the length the resulting ray should be
  100161. * @returns a ray in the direction the controller is pointing
  100162. */
  100163. getForwardRay(length?: number): Ray;
  100164. }
  100165. }
  100166. declare module BABYLON {
  100167. /**
  100168. * Defines the WebVRController object that represents controllers tracked in 3D space
  100169. */
  100170. export abstract class WebVRController extends PoseEnabledController {
  100171. /**
  100172. * Internal, the default controller model for the controller
  100173. */
  100174. protected _defaultModel: Nullable<AbstractMesh>;
  100175. /**
  100176. * Fired when the trigger state has changed
  100177. */
  100178. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100179. /**
  100180. * Fired when the main button state has changed
  100181. */
  100182. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100183. /**
  100184. * Fired when the secondary button state has changed
  100185. */
  100186. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100187. /**
  100188. * Fired when the pad state has changed
  100189. */
  100190. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  100191. /**
  100192. * Fired when controllers stick values have changed
  100193. */
  100194. onPadValuesChangedObservable: Observable<StickValues>;
  100195. /**
  100196. * Array of button availible on the controller
  100197. */
  100198. protected _buttons: Array<MutableGamepadButton>;
  100199. private _onButtonStateChange;
  100200. /**
  100201. * Fired when a controller button's state has changed
  100202. * @param callback the callback containing the button that was modified
  100203. */
  100204. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  100205. /**
  100206. * X and Y axis corresponding to the controllers joystick
  100207. */
  100208. pad: StickValues;
  100209. /**
  100210. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  100211. */
  100212. hand: string;
  100213. /**
  100214. * The default controller model for the controller
  100215. */
  100216. get defaultModel(): Nullable<AbstractMesh>;
  100217. /**
  100218. * Creates a new WebVRController from a gamepad
  100219. * @param vrGamepad the gamepad that the WebVRController should be created from
  100220. */
  100221. constructor(vrGamepad: any);
  100222. /**
  100223. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  100224. */
  100225. update(): void;
  100226. /**
  100227. * Function to be called when a button is modified
  100228. */
  100229. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100230. /**
  100231. * Loads a mesh and attaches it to the controller
  100232. * @param scene the scene the mesh should be added to
  100233. * @param meshLoaded callback for when the mesh has been loaded
  100234. */
  100235. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100236. private _setButtonValue;
  100237. private _changes;
  100238. private _checkChanges;
  100239. /**
  100240. * Disposes of th webVRCOntroller
  100241. */
  100242. dispose(): void;
  100243. }
  100244. }
  100245. declare module BABYLON {
  100246. /**
  100247. * The HemisphericLight simulates the ambient environment light,
  100248. * so the passed direction is the light reflection direction, not the incoming direction.
  100249. */
  100250. export class HemisphericLight extends Light {
  100251. /**
  100252. * The groundColor is the light in the opposite direction to the one specified during creation.
  100253. * 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.
  100254. */
  100255. groundColor: Color3;
  100256. /**
  100257. * The light reflection direction, not the incoming direction.
  100258. */
  100259. direction: Vector3;
  100260. /**
  100261. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  100262. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  100263. * The HemisphericLight can't cast shadows.
  100264. * Documentation : https://doc.babylonjs.com/babylon101/lights
  100265. * @param name The friendly name of the light
  100266. * @param direction The direction of the light reflection
  100267. * @param scene The scene the light belongs to
  100268. */
  100269. constructor(name: string, direction: Vector3, scene: Scene);
  100270. protected _buildUniformLayout(): void;
  100271. /**
  100272. * Returns the string "HemisphericLight".
  100273. * @return The class name
  100274. */
  100275. getClassName(): string;
  100276. /**
  100277. * Sets the HemisphericLight direction towards the passed target (Vector3).
  100278. * Returns the updated direction.
  100279. * @param target The target the direction should point to
  100280. * @return The computed direction
  100281. */
  100282. setDirectionToTarget(target: Vector3): Vector3;
  100283. /**
  100284. * Returns the shadow generator associated to the light.
  100285. * @returns Always null for hemispheric lights because it does not support shadows.
  100286. */
  100287. getShadowGenerator(): Nullable<IShadowGenerator>;
  100288. /**
  100289. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100290. * @param effect The effect to update
  100291. * @param lightIndex The index of the light in the effect to update
  100292. * @returns The hemispheric light
  100293. */
  100294. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100295. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100296. /**
  100297. * Computes the world matrix of the node
  100298. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100299. * @param useWasUpdatedFlag defines a reserved property
  100300. * @returns the world matrix
  100301. */
  100302. computeWorldMatrix(): Matrix;
  100303. /**
  100304. * Returns the integer 3.
  100305. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100306. */
  100307. getTypeID(): number;
  100308. /**
  100309. * Prepares the list of defines specific to the light type.
  100310. * @param defines the list of defines
  100311. * @param lightIndex defines the index of the light for the effect
  100312. */
  100313. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100314. }
  100315. }
  100316. declare module BABYLON {
  100317. /** @hidden */
  100318. export var vrMultiviewToSingleviewPixelShader: {
  100319. name: string;
  100320. shader: string;
  100321. };
  100322. }
  100323. declare module BABYLON {
  100324. /**
  100325. * Renders to multiple views with a single draw call
  100326. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100327. */
  100328. export class MultiviewRenderTarget extends RenderTargetTexture {
  100329. /**
  100330. * Creates a multiview render target
  100331. * @param scene scene used with the render target
  100332. * @param size the size of the render target (used for each view)
  100333. */
  100334. constructor(scene: Scene, size?: number | {
  100335. width: number;
  100336. height: number;
  100337. } | {
  100338. ratio: number;
  100339. });
  100340. /**
  100341. * @hidden
  100342. * @param faceIndex the face index, if its a cube texture
  100343. */
  100344. _bindFrameBuffer(faceIndex?: number): void;
  100345. /**
  100346. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100347. * @returns the view count
  100348. */
  100349. getViewCount(): number;
  100350. }
  100351. }
  100352. declare module BABYLON {
  100353. interface Engine {
  100354. /**
  100355. * Creates a new multiview render target
  100356. * @param width defines the width of the texture
  100357. * @param height defines the height of the texture
  100358. * @returns the created multiview texture
  100359. */
  100360. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100361. /**
  100362. * Binds a multiview framebuffer to be drawn to
  100363. * @param multiviewTexture texture to bind
  100364. */
  100365. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100366. }
  100367. interface Camera {
  100368. /**
  100369. * @hidden
  100370. * 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)
  100371. */
  100372. _useMultiviewToSingleView: boolean;
  100373. /**
  100374. * @hidden
  100375. * 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)
  100376. */
  100377. _multiviewTexture: Nullable<RenderTargetTexture>;
  100378. /**
  100379. * @hidden
  100380. * ensures the multiview texture of the camera exists and has the specified width/height
  100381. * @param width height to set on the multiview texture
  100382. * @param height width to set on the multiview texture
  100383. */
  100384. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100385. }
  100386. interface Scene {
  100387. /** @hidden */
  100388. _transformMatrixR: Matrix;
  100389. /** @hidden */
  100390. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100391. /** @hidden */
  100392. _createMultiviewUbo(): void;
  100393. /** @hidden */
  100394. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100395. /** @hidden */
  100396. _renderMultiviewToSingleView(camera: Camera): void;
  100397. }
  100398. }
  100399. declare module BABYLON {
  100400. /**
  100401. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100402. * This will not be used for webXR as it supports displaying texture arrays directly
  100403. */
  100404. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100405. /**
  100406. * Gets a string identifying the name of the class
  100407. * @returns "VRMultiviewToSingleviewPostProcess" string
  100408. */
  100409. getClassName(): string;
  100410. /**
  100411. * Initializes a VRMultiviewToSingleview
  100412. * @param name name of the post process
  100413. * @param camera camera to be applied to
  100414. * @param scaleFactor scaling factor to the size of the output texture
  100415. */
  100416. constructor(name: string, camera: Camera, scaleFactor: number);
  100417. }
  100418. }
  100419. declare module BABYLON {
  100420. /**
  100421. * Interface used to define additional presentation attributes
  100422. */
  100423. export interface IVRPresentationAttributes {
  100424. /**
  100425. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100426. */
  100427. highRefreshRate: boolean;
  100428. /**
  100429. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100430. */
  100431. foveationLevel: number;
  100432. }
  100433. interface Engine {
  100434. /** @hidden */
  100435. _vrDisplay: any;
  100436. /** @hidden */
  100437. _vrSupported: boolean;
  100438. /** @hidden */
  100439. _oldSize: Size;
  100440. /** @hidden */
  100441. _oldHardwareScaleFactor: number;
  100442. /** @hidden */
  100443. _vrExclusivePointerMode: boolean;
  100444. /** @hidden */
  100445. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100446. /** @hidden */
  100447. _onVRDisplayPointerRestricted: () => void;
  100448. /** @hidden */
  100449. _onVRDisplayPointerUnrestricted: () => void;
  100450. /** @hidden */
  100451. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100452. /** @hidden */
  100453. _onVrDisplayDisconnect: Nullable<() => void>;
  100454. /** @hidden */
  100455. _onVrDisplayPresentChange: Nullable<() => void>;
  100456. /**
  100457. * Observable signaled when VR display mode changes
  100458. */
  100459. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100460. /**
  100461. * Observable signaled when VR request present is complete
  100462. */
  100463. onVRRequestPresentComplete: Observable<boolean>;
  100464. /**
  100465. * Observable signaled when VR request present starts
  100466. */
  100467. onVRRequestPresentStart: Observable<Engine>;
  100468. /**
  100469. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100470. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100471. */
  100472. isInVRExclusivePointerMode: boolean;
  100473. /**
  100474. * Gets a boolean indicating if a webVR device was detected
  100475. * @returns true if a webVR device was detected
  100476. */
  100477. isVRDevicePresent(): boolean;
  100478. /**
  100479. * Gets the current webVR device
  100480. * @returns the current webVR device (or null)
  100481. */
  100482. getVRDevice(): any;
  100483. /**
  100484. * Initializes a webVR display and starts listening to display change events
  100485. * The onVRDisplayChangedObservable will be notified upon these changes
  100486. * @returns A promise containing a VRDisplay and if vr is supported
  100487. */
  100488. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100489. /** @hidden */
  100490. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100491. /**
  100492. * Gets or sets the presentation attributes used to configure VR rendering
  100493. */
  100494. vrPresentationAttributes?: IVRPresentationAttributes;
  100495. /**
  100496. * Call this function to switch to webVR mode
  100497. * Will do nothing if webVR is not supported or if there is no webVR device
  100498. * @param options the webvr options provided to the camera. mainly used for multiview
  100499. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100500. */
  100501. enableVR(options: WebVROptions): void;
  100502. /** @hidden */
  100503. _onVRFullScreenTriggered(): void;
  100504. }
  100505. }
  100506. declare module BABYLON {
  100507. /**
  100508. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100509. * IMPORTANT!! The data is right-hand data.
  100510. * @export
  100511. * @interface DevicePose
  100512. */
  100513. export interface DevicePose {
  100514. /**
  100515. * The position of the device, values in array are [x,y,z].
  100516. */
  100517. readonly position: Nullable<Float32Array>;
  100518. /**
  100519. * The linearVelocity of the device, values in array are [x,y,z].
  100520. */
  100521. readonly linearVelocity: Nullable<Float32Array>;
  100522. /**
  100523. * The linearAcceleration of the device, values in array are [x,y,z].
  100524. */
  100525. readonly linearAcceleration: Nullable<Float32Array>;
  100526. /**
  100527. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100528. */
  100529. readonly orientation: Nullable<Float32Array>;
  100530. /**
  100531. * The angularVelocity of the device, values in array are [x,y,z].
  100532. */
  100533. readonly angularVelocity: Nullable<Float32Array>;
  100534. /**
  100535. * The angularAcceleration of the device, values in array are [x,y,z].
  100536. */
  100537. readonly angularAcceleration: Nullable<Float32Array>;
  100538. }
  100539. /**
  100540. * Interface representing a pose controlled object in Babylon.
  100541. * A pose controlled object has both regular pose values as well as pose values
  100542. * from an external device such as a VR head mounted display
  100543. */
  100544. export interface PoseControlled {
  100545. /**
  100546. * The position of the object in babylon space.
  100547. */
  100548. position: Vector3;
  100549. /**
  100550. * The rotation quaternion of the object in babylon space.
  100551. */
  100552. rotationQuaternion: Quaternion;
  100553. /**
  100554. * The position of the device in babylon space.
  100555. */
  100556. devicePosition?: Vector3;
  100557. /**
  100558. * The rotation quaternion of the device in babylon space.
  100559. */
  100560. deviceRotationQuaternion: Quaternion;
  100561. /**
  100562. * The raw pose coming from the device.
  100563. */
  100564. rawPose: Nullable<DevicePose>;
  100565. /**
  100566. * The scale of the device to be used when translating from device space to babylon space.
  100567. */
  100568. deviceScaleFactor: number;
  100569. /**
  100570. * Updates the poseControlled values based on the input device pose.
  100571. * @param poseData the pose data to update the object with
  100572. */
  100573. updateFromDevice(poseData: DevicePose): void;
  100574. }
  100575. /**
  100576. * Set of options to customize the webVRCamera
  100577. */
  100578. export interface WebVROptions {
  100579. /**
  100580. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100581. */
  100582. trackPosition?: boolean;
  100583. /**
  100584. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100585. */
  100586. positionScale?: number;
  100587. /**
  100588. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100589. */
  100590. displayName?: string;
  100591. /**
  100592. * Should the native controller meshes be initialized. (default: true)
  100593. */
  100594. controllerMeshes?: boolean;
  100595. /**
  100596. * Creating a default HemiLight only on controllers. (default: true)
  100597. */
  100598. defaultLightingOnControllers?: boolean;
  100599. /**
  100600. * If you don't want to use the default VR button of the helper. (default: false)
  100601. */
  100602. useCustomVRButton?: boolean;
  100603. /**
  100604. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100605. */
  100606. customVRButton?: HTMLButtonElement;
  100607. /**
  100608. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100609. */
  100610. rayLength?: number;
  100611. /**
  100612. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100613. */
  100614. defaultHeight?: number;
  100615. /**
  100616. * If multiview should be used if availible (default: false)
  100617. */
  100618. useMultiview?: boolean;
  100619. }
  100620. /**
  100621. * This represents a WebVR camera.
  100622. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100623. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100624. */
  100625. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100626. private webVROptions;
  100627. /**
  100628. * @hidden
  100629. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100630. */
  100631. _vrDevice: any;
  100632. /**
  100633. * The rawPose of the vrDevice.
  100634. */
  100635. rawPose: Nullable<DevicePose>;
  100636. private _onVREnabled;
  100637. private _specsVersion;
  100638. private _attached;
  100639. private _frameData;
  100640. protected _descendants: Array<Node>;
  100641. private _deviceRoomPosition;
  100642. /** @hidden */
  100643. _deviceRoomRotationQuaternion: Quaternion;
  100644. private _standingMatrix;
  100645. /**
  100646. * Represents device position in babylon space.
  100647. */
  100648. devicePosition: Vector3;
  100649. /**
  100650. * Represents device rotation in babylon space.
  100651. */
  100652. deviceRotationQuaternion: Quaternion;
  100653. /**
  100654. * The scale of the device to be used when translating from device space to babylon space.
  100655. */
  100656. deviceScaleFactor: number;
  100657. private _deviceToWorld;
  100658. private _worldToDevice;
  100659. /**
  100660. * References to the webVR controllers for the vrDevice.
  100661. */
  100662. controllers: Array<WebVRController>;
  100663. /**
  100664. * Emits an event when a controller is attached.
  100665. */
  100666. onControllersAttachedObservable: Observable<WebVRController[]>;
  100667. /**
  100668. * Emits an event when a controller's mesh has been loaded;
  100669. */
  100670. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100671. /**
  100672. * Emits an event when the HMD's pose has been updated.
  100673. */
  100674. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100675. private _poseSet;
  100676. /**
  100677. * If the rig cameras be used as parent instead of this camera.
  100678. */
  100679. rigParenting: boolean;
  100680. private _lightOnControllers;
  100681. private _defaultHeight?;
  100682. /**
  100683. * Instantiates a WebVRFreeCamera.
  100684. * @param name The name of the WebVRFreeCamera
  100685. * @param position The starting anchor position for the camera
  100686. * @param scene The scene the camera belongs to
  100687. * @param webVROptions a set of customizable options for the webVRCamera
  100688. */
  100689. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100690. /**
  100691. * Gets the device distance from the ground in meters.
  100692. * @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.
  100693. */
  100694. deviceDistanceToRoomGround(): number;
  100695. /**
  100696. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100697. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100698. */
  100699. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100700. /**
  100701. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100702. * @returns A promise with a boolean set to if the standing matrix is supported.
  100703. */
  100704. useStandingMatrixAsync(): Promise<boolean>;
  100705. /**
  100706. * Disposes the camera
  100707. */
  100708. dispose(): void;
  100709. /**
  100710. * Gets a vrController by name.
  100711. * @param name The name of the controller to retreive
  100712. * @returns the controller matching the name specified or null if not found
  100713. */
  100714. getControllerByName(name: string): Nullable<WebVRController>;
  100715. private _leftController;
  100716. /**
  100717. * The controller corresponding to the users left hand.
  100718. */
  100719. get leftController(): Nullable<WebVRController>;
  100720. private _rightController;
  100721. /**
  100722. * The controller corresponding to the users right hand.
  100723. */
  100724. get rightController(): Nullable<WebVRController>;
  100725. /**
  100726. * Casts a ray forward from the vrCamera's gaze.
  100727. * @param length Length of the ray (default: 100)
  100728. * @returns the ray corresponding to the gaze
  100729. */
  100730. getForwardRay(length?: number): Ray;
  100731. /**
  100732. * @hidden
  100733. * Updates the camera based on device's frame data
  100734. */
  100735. _checkInputs(): void;
  100736. /**
  100737. * Updates the poseControlled values based on the input device pose.
  100738. * @param poseData Pose coming from the device
  100739. */
  100740. updateFromDevice(poseData: DevicePose): void;
  100741. private _htmlElementAttached;
  100742. private _detachIfAttached;
  100743. /**
  100744. * WebVR's attach control will start broadcasting frames to the device.
  100745. * Note that in certain browsers (chrome for example) this function must be called
  100746. * within a user-interaction callback. Example:
  100747. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100748. *
  100749. * @param element html element to attach the vrDevice to
  100750. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100751. */
  100752. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100753. /**
  100754. * Detaches the camera from the html element and disables VR
  100755. *
  100756. * @param element html element to detach from
  100757. */
  100758. detachControl(element: HTMLElement): void;
  100759. /**
  100760. * @returns the name of this class
  100761. */
  100762. getClassName(): string;
  100763. /**
  100764. * Calls resetPose on the vrDisplay
  100765. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100766. */
  100767. resetToCurrentRotation(): void;
  100768. /**
  100769. * @hidden
  100770. * Updates the rig cameras (left and right eye)
  100771. */
  100772. _updateRigCameras(): void;
  100773. private _workingVector;
  100774. private _oneVector;
  100775. private _workingMatrix;
  100776. private updateCacheCalled;
  100777. private _correctPositionIfNotTrackPosition;
  100778. /**
  100779. * @hidden
  100780. * Updates the cached values of the camera
  100781. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100782. */
  100783. _updateCache(ignoreParentClass?: boolean): void;
  100784. /**
  100785. * @hidden
  100786. * Get current device position in babylon world
  100787. */
  100788. _computeDevicePosition(): void;
  100789. /**
  100790. * Updates the current device position and rotation in the babylon world
  100791. */
  100792. update(): void;
  100793. /**
  100794. * @hidden
  100795. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100796. * @returns an identity matrix
  100797. */
  100798. _getViewMatrix(): Matrix;
  100799. private _tmpMatrix;
  100800. /**
  100801. * This function is called by the two RIG cameras.
  100802. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100803. * @hidden
  100804. */
  100805. _getWebVRViewMatrix(): Matrix;
  100806. /** @hidden */
  100807. _getWebVRProjectionMatrix(): Matrix;
  100808. private _onGamepadConnectedObserver;
  100809. private _onGamepadDisconnectedObserver;
  100810. private _updateCacheWhenTrackingDisabledObserver;
  100811. /**
  100812. * Initializes the controllers and their meshes
  100813. */
  100814. initControllers(): void;
  100815. }
  100816. }
  100817. declare module BABYLON {
  100818. /**
  100819. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100820. *
  100821. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100822. *
  100823. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100824. */
  100825. export class MaterialHelper {
  100826. /**
  100827. * Bind the current view position to an effect.
  100828. * @param effect The effect to be bound
  100829. * @param scene The scene the eyes position is used from
  100830. * @param variableName name of the shader variable that will hold the eye position
  100831. */
  100832. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100833. /**
  100834. * Helps preparing the defines values about the UVs in used in the effect.
  100835. * UVs are shared as much as we can accross channels in the shaders.
  100836. * @param texture The texture we are preparing the UVs for
  100837. * @param defines The defines to update
  100838. * @param key The channel key "diffuse", "specular"... used in the shader
  100839. */
  100840. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100841. /**
  100842. * Binds a texture matrix value to its corrsponding uniform
  100843. * @param texture The texture to bind the matrix for
  100844. * @param uniformBuffer The uniform buffer receivin the data
  100845. * @param key The channel key "diffuse", "specular"... used in the shader
  100846. */
  100847. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100848. /**
  100849. * Gets the current status of the fog (should it be enabled?)
  100850. * @param mesh defines the mesh to evaluate for fog support
  100851. * @param scene defines the hosting scene
  100852. * @returns true if fog must be enabled
  100853. */
  100854. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100855. /**
  100856. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100857. * @param mesh defines the current mesh
  100858. * @param scene defines the current scene
  100859. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100860. * @param pointsCloud defines if point cloud rendering has to be turned on
  100861. * @param fogEnabled defines if fog has to be turned on
  100862. * @param alphaTest defines if alpha testing has to be turned on
  100863. * @param defines defines the current list of defines
  100864. */
  100865. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100866. /**
  100867. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100868. * @param scene defines the current scene
  100869. * @param engine defines the current engine
  100870. * @param defines specifies the list of active defines
  100871. * @param useInstances defines if instances have to be turned on
  100872. * @param useClipPlane defines if clip plane have to be turned on
  100873. * @param useInstances defines if instances have to be turned on
  100874. * @param useThinInstances defines if thin instances have to be turned on
  100875. */
  100876. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100877. /**
  100878. * Prepares the defines for bones
  100879. * @param mesh The mesh containing the geometry data we will draw
  100880. * @param defines The defines to update
  100881. */
  100882. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100883. /**
  100884. * Prepares the defines for morph targets
  100885. * @param mesh The mesh containing the geometry data we will draw
  100886. * @param defines The defines to update
  100887. */
  100888. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100889. /**
  100890. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100891. * @param mesh The mesh containing the geometry data we will draw
  100892. * @param defines The defines to update
  100893. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100894. * @param useBones Precise whether bones should be used or not (override mesh info)
  100895. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100896. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100897. * @returns false if defines are considered not dirty and have not been checked
  100898. */
  100899. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100900. /**
  100901. * Prepares the defines related to multiview
  100902. * @param scene The scene we are intending to draw
  100903. * @param defines The defines to update
  100904. */
  100905. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100906. /**
  100907. * Prepares the defines related to the prepass
  100908. * @param scene The scene we are intending to draw
  100909. * @param defines The defines to update
  100910. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100911. */
  100912. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100913. /**
  100914. * Prepares the defines related to the light information passed in parameter
  100915. * @param scene The scene we are intending to draw
  100916. * @param mesh The mesh the effect is compiling for
  100917. * @param light The light the effect is compiling for
  100918. * @param lightIndex The index of the light
  100919. * @param defines The defines to update
  100920. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100921. * @param state Defines the current state regarding what is needed (normals, etc...)
  100922. */
  100923. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100924. needNormals: boolean;
  100925. needRebuild: boolean;
  100926. shadowEnabled: boolean;
  100927. specularEnabled: boolean;
  100928. lightmapMode: boolean;
  100929. }): void;
  100930. /**
  100931. * Prepares the defines related to the light information passed in parameter
  100932. * @param scene The scene we are intending to draw
  100933. * @param mesh The mesh the effect is compiling for
  100934. * @param defines The defines to update
  100935. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100936. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100937. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100938. * @returns true if normals will be required for the rest of the effect
  100939. */
  100940. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100941. /**
  100942. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100943. * @param lightIndex defines the light index
  100944. * @param uniformsList The uniform list
  100945. * @param samplersList The sampler list
  100946. * @param projectedLightTexture defines if projected texture must be used
  100947. * @param uniformBuffersList defines an optional list of uniform buffers
  100948. */
  100949. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100950. /**
  100951. * Prepares the uniforms and samplers list to be used in the effect
  100952. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100953. * @param samplersList The sampler list
  100954. * @param defines The defines helping in the list generation
  100955. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100956. */
  100957. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100958. /**
  100959. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100960. * @param defines The defines to update while falling back
  100961. * @param fallbacks The authorized effect fallbacks
  100962. * @param maxSimultaneousLights The maximum number of lights allowed
  100963. * @param rank the current rank of the Effect
  100964. * @returns The newly affected rank
  100965. */
  100966. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100967. private static _TmpMorphInfluencers;
  100968. /**
  100969. * Prepares the list of attributes required for morph targets according to the effect defines.
  100970. * @param attribs The current list of supported attribs
  100971. * @param mesh The mesh to prepare the morph targets attributes for
  100972. * @param influencers The number of influencers
  100973. */
  100974. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100975. /**
  100976. * Prepares the list of attributes required for morph targets according to the effect defines.
  100977. * @param attribs The current list of supported attribs
  100978. * @param mesh The mesh to prepare the morph targets attributes for
  100979. * @param defines The current Defines of the effect
  100980. */
  100981. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100982. /**
  100983. * Prepares the list of attributes required for bones according to the effect defines.
  100984. * @param attribs The current list of supported attribs
  100985. * @param mesh The mesh to prepare the bones attributes for
  100986. * @param defines The current Defines of the effect
  100987. * @param fallbacks The current efffect fallback strategy
  100988. */
  100989. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100990. /**
  100991. * Check and prepare the list of attributes required for instances according to the effect defines.
  100992. * @param attribs The current list of supported attribs
  100993. * @param defines The current MaterialDefines of the effect
  100994. */
  100995. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100996. /**
  100997. * Add the list of attributes required for instances to the attribs array.
  100998. * @param attribs The current list of supported attribs
  100999. */
  101000. static PushAttributesForInstances(attribs: string[]): void;
  101001. /**
  101002. * Binds the light information to the effect.
  101003. * @param light The light containing the generator
  101004. * @param effect The effect we are binding the data to
  101005. * @param lightIndex The light index in the effect used to render
  101006. */
  101007. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  101008. /**
  101009. * Binds the lights information from the scene to the effect for the given mesh.
  101010. * @param light Light to bind
  101011. * @param lightIndex Light index
  101012. * @param scene The scene where the light belongs to
  101013. * @param effect The effect we are binding the data to
  101014. * @param useSpecular Defines if specular is supported
  101015. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101016. */
  101017. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  101018. /**
  101019. * Binds the lights information from the scene to the effect for the given mesh.
  101020. * @param scene The scene the lights belongs to
  101021. * @param mesh The mesh we are binding the information to render
  101022. * @param effect The effect we are binding the data to
  101023. * @param defines The generated defines for the effect
  101024. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  101025. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101026. */
  101027. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  101028. private static _tempFogColor;
  101029. /**
  101030. * Binds the fog information from the scene to the effect for the given mesh.
  101031. * @param scene The scene the lights belongs to
  101032. * @param mesh The mesh we are binding the information to render
  101033. * @param effect The effect we are binding the data to
  101034. * @param linearSpace Defines if the fog effect is applied in linear space
  101035. */
  101036. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  101037. /**
  101038. * Binds the bones information from the mesh to the effect.
  101039. * @param mesh The mesh we are binding the information to render
  101040. * @param effect The effect we are binding the data to
  101041. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  101042. */
  101043. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  101044. private static _CopyBonesTransformationMatrices;
  101045. /**
  101046. * Binds the morph targets information from the mesh to the effect.
  101047. * @param abstractMesh The mesh we are binding the information to render
  101048. * @param effect The effect we are binding the data to
  101049. */
  101050. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  101051. /**
  101052. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  101053. * @param defines The generated defines used in the effect
  101054. * @param effect The effect we are binding the data to
  101055. * @param scene The scene we are willing to render with logarithmic scale for
  101056. */
  101057. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  101058. /**
  101059. * Binds the clip plane information from the scene to the effect.
  101060. * @param scene The scene the clip plane information are extracted from
  101061. * @param effect The effect we are binding the data to
  101062. */
  101063. static BindClipPlane(effect: Effect, scene: Scene): void;
  101064. }
  101065. }
  101066. declare module BABYLON {
  101067. /**
  101068. * Block used to expose an input value
  101069. */
  101070. export class InputBlock extends NodeMaterialBlock {
  101071. private _mode;
  101072. private _associatedVariableName;
  101073. private _storedValue;
  101074. private _valueCallback;
  101075. private _type;
  101076. private _animationType;
  101077. /** Gets or set a value used to limit the range of float values */
  101078. min: number;
  101079. /** Gets or set a value used to limit the range of float values */
  101080. max: number;
  101081. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  101082. isBoolean: boolean;
  101083. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  101084. matrixMode: number;
  101085. /** @hidden */
  101086. _systemValue: Nullable<NodeMaterialSystemValues>;
  101087. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  101088. isConstant: boolean;
  101089. /** Gets or sets the group to use to display this block in the Inspector */
  101090. groupInInspector: string;
  101091. /** Gets an observable raised when the value is changed */
  101092. onValueChangedObservable: Observable<InputBlock>;
  101093. /**
  101094. * Gets or sets the connection point type (default is float)
  101095. */
  101096. get type(): NodeMaterialBlockConnectionPointTypes;
  101097. /**
  101098. * Creates a new InputBlock
  101099. * @param name defines the block name
  101100. * @param target defines the target of that block (Vertex by default)
  101101. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  101102. */
  101103. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  101104. /**
  101105. * Validates if a name is a reserve word.
  101106. * @param newName the new name to be given to the node.
  101107. * @returns false if the name is a reserve word, else true.
  101108. */
  101109. validateBlockName(newName: string): boolean;
  101110. /**
  101111. * Gets the output component
  101112. */
  101113. get output(): NodeMaterialConnectionPoint;
  101114. /**
  101115. * Set the source of this connection point to a vertex attribute
  101116. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  101117. * @returns the current connection point
  101118. */
  101119. setAsAttribute(attributeName?: string): InputBlock;
  101120. /**
  101121. * Set the source of this connection point to a system value
  101122. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  101123. * @returns the current connection point
  101124. */
  101125. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  101126. /**
  101127. * Gets or sets the value of that point.
  101128. * Please note that this value will be ignored if valueCallback is defined
  101129. */
  101130. get value(): any;
  101131. set value(value: any);
  101132. /**
  101133. * Gets or sets a callback used to get the value of that point.
  101134. * Please note that setting this value will force the connection point to ignore the value property
  101135. */
  101136. get valueCallback(): () => any;
  101137. set valueCallback(value: () => any);
  101138. /**
  101139. * Gets or sets the associated variable name in the shader
  101140. */
  101141. get associatedVariableName(): string;
  101142. set associatedVariableName(value: string);
  101143. /** Gets or sets the type of animation applied to the input */
  101144. get animationType(): AnimatedInputBlockTypes;
  101145. set animationType(value: AnimatedInputBlockTypes);
  101146. /**
  101147. * Gets a boolean indicating that this connection point not defined yet
  101148. */
  101149. get isUndefined(): boolean;
  101150. /**
  101151. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  101152. * In this case the connection point name must be the name of the uniform to use.
  101153. * Can only be set on inputs
  101154. */
  101155. get isUniform(): boolean;
  101156. set isUniform(value: boolean);
  101157. /**
  101158. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  101159. * In this case the connection point name must be the name of the attribute to use
  101160. * Can only be set on inputs
  101161. */
  101162. get isAttribute(): boolean;
  101163. set isAttribute(value: boolean);
  101164. /**
  101165. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  101166. * Can only be set on exit points
  101167. */
  101168. get isVarying(): boolean;
  101169. set isVarying(value: boolean);
  101170. /**
  101171. * Gets a boolean indicating that the current connection point is a system value
  101172. */
  101173. get isSystemValue(): boolean;
  101174. /**
  101175. * Gets or sets the current well known value or null if not defined as a system value
  101176. */
  101177. get systemValue(): Nullable<NodeMaterialSystemValues>;
  101178. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  101179. /**
  101180. * Gets the current class name
  101181. * @returns the class name
  101182. */
  101183. getClassName(): string;
  101184. /**
  101185. * Animate the input if animationType !== None
  101186. * @param scene defines the rendering scene
  101187. */
  101188. animate(scene: Scene): void;
  101189. private _emitDefine;
  101190. initialize(state: NodeMaterialBuildState): void;
  101191. /**
  101192. * Set the input block to its default value (based on its type)
  101193. */
  101194. setDefaultValue(): void;
  101195. private _emitConstant;
  101196. /** @hidden */
  101197. get _noContextSwitch(): boolean;
  101198. private _emit;
  101199. /** @hidden */
  101200. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  101201. /** @hidden */
  101202. _transmit(effect: Effect, scene: Scene): void;
  101203. protected _buildBlock(state: NodeMaterialBuildState): void;
  101204. protected _dumpPropertiesCode(): string;
  101205. dispose(): void;
  101206. serialize(): any;
  101207. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101208. }
  101209. }
  101210. declare module BABYLON {
  101211. /**
  101212. * Enum used to define the compatibility state between two connection points
  101213. */
  101214. export enum NodeMaterialConnectionPointCompatibilityStates {
  101215. /** Points are compatibles */
  101216. Compatible = 0,
  101217. /** Points are incompatible because of their types */
  101218. TypeIncompatible = 1,
  101219. /** Points are incompatible because of their targets (vertex vs fragment) */
  101220. TargetIncompatible = 2
  101221. }
  101222. /**
  101223. * Defines the direction of a connection point
  101224. */
  101225. export enum NodeMaterialConnectionPointDirection {
  101226. /** Input */
  101227. Input = 0,
  101228. /** Output */
  101229. Output = 1
  101230. }
  101231. /**
  101232. * Defines a connection point for a block
  101233. */
  101234. export class NodeMaterialConnectionPoint {
  101235. /** @hidden */
  101236. _ownerBlock: NodeMaterialBlock;
  101237. /** @hidden */
  101238. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  101239. private _endpoints;
  101240. private _associatedVariableName;
  101241. private _direction;
  101242. /** @hidden */
  101243. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101244. /** @hidden */
  101245. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101246. private _type;
  101247. /** @hidden */
  101248. _enforceAssociatedVariableName: boolean;
  101249. /** Gets the direction of the point */
  101250. get direction(): NodeMaterialConnectionPointDirection;
  101251. /** Indicates that this connection point needs dual validation before being connected to another point */
  101252. needDualDirectionValidation: boolean;
  101253. /**
  101254. * Gets or sets the additional types supported by this connection point
  101255. */
  101256. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101257. /**
  101258. * Gets or sets the additional types excluded by this connection point
  101259. */
  101260. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101261. /**
  101262. * Observable triggered when this point is connected
  101263. */
  101264. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  101265. /**
  101266. * Gets or sets the associated variable name in the shader
  101267. */
  101268. get associatedVariableName(): string;
  101269. set associatedVariableName(value: string);
  101270. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  101271. get innerType(): NodeMaterialBlockConnectionPointTypes;
  101272. /**
  101273. * Gets or sets the connection point type (default is float)
  101274. */
  101275. get type(): NodeMaterialBlockConnectionPointTypes;
  101276. set type(value: NodeMaterialBlockConnectionPointTypes);
  101277. /**
  101278. * Gets or sets the connection point name
  101279. */
  101280. name: string;
  101281. /**
  101282. * Gets or sets the connection point name
  101283. */
  101284. displayName: string;
  101285. /**
  101286. * Gets or sets a boolean indicating that this connection point can be omitted
  101287. */
  101288. isOptional: boolean;
  101289. /**
  101290. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101291. */
  101292. isExposedOnFrame: boolean;
  101293. /**
  101294. * Gets or sets number indicating the position that the port is exposed to on a frame
  101295. */
  101296. exposedPortPosition: number;
  101297. /**
  101298. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101299. */
  101300. define: string;
  101301. /** @hidden */
  101302. _prioritizeVertex: boolean;
  101303. private _target;
  101304. /** Gets or sets the target of that connection point */
  101305. get target(): NodeMaterialBlockTargets;
  101306. set target(value: NodeMaterialBlockTargets);
  101307. /**
  101308. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101309. */
  101310. get isConnected(): boolean;
  101311. /**
  101312. * Gets a boolean indicating that the current point is connected to an input block
  101313. */
  101314. get isConnectedToInputBlock(): boolean;
  101315. /**
  101316. * Gets a the connected input block (if any)
  101317. */
  101318. get connectInputBlock(): Nullable<InputBlock>;
  101319. /** Get the other side of the connection (if any) */
  101320. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101321. /** Get the block that owns this connection point */
  101322. get ownerBlock(): NodeMaterialBlock;
  101323. /** Get the block connected on the other side of this connection (if any) */
  101324. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101325. /** Get the block connected on the endpoints of this connection (if any) */
  101326. get connectedBlocks(): Array<NodeMaterialBlock>;
  101327. /** Gets the list of connected endpoints */
  101328. get endpoints(): NodeMaterialConnectionPoint[];
  101329. /** Gets a boolean indicating if that output point is connected to at least one input */
  101330. get hasEndpoints(): boolean;
  101331. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101332. get isConnectedInVertexShader(): boolean;
  101333. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101334. get isConnectedInFragmentShader(): boolean;
  101335. /**
  101336. * Creates a block suitable to be used as an input for this input point.
  101337. * If null is returned, a block based on the point type will be created.
  101338. * @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
  101339. */
  101340. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101341. /**
  101342. * Creates a new connection point
  101343. * @param name defines the connection point name
  101344. * @param ownerBlock defines the block hosting this connection point
  101345. * @param direction defines the direction of the connection point
  101346. */
  101347. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101348. /**
  101349. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101350. * @returns the class name
  101351. */
  101352. getClassName(): string;
  101353. /**
  101354. * Gets a boolean indicating if the current point can be connected to another point
  101355. * @param connectionPoint defines the other connection point
  101356. * @returns a boolean
  101357. */
  101358. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101359. /**
  101360. * Gets a number indicating if the current point can be connected to another point
  101361. * @param connectionPoint defines the other connection point
  101362. * @returns a number defining the compatibility state
  101363. */
  101364. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101365. /**
  101366. * Connect this point to another connection point
  101367. * @param connectionPoint defines the other connection point
  101368. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101369. * @returns the current connection point
  101370. */
  101371. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101372. /**
  101373. * Disconnect this point from one of his endpoint
  101374. * @param endpoint defines the other connection point
  101375. * @returns the current connection point
  101376. */
  101377. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101378. /**
  101379. * Serializes this point in a JSON representation
  101380. * @param isInput defines if the connection point is an input (default is true)
  101381. * @returns the serialized point object
  101382. */
  101383. serialize(isInput?: boolean): any;
  101384. /**
  101385. * Release resources
  101386. */
  101387. dispose(): void;
  101388. }
  101389. }
  101390. declare module BABYLON {
  101391. /**
  101392. * Enum used to define the material modes
  101393. */
  101394. export enum NodeMaterialModes {
  101395. /** Regular material */
  101396. Material = 0,
  101397. /** For post process */
  101398. PostProcess = 1,
  101399. /** For particle system */
  101400. Particle = 2,
  101401. /** For procedural texture */
  101402. ProceduralTexture = 3
  101403. }
  101404. }
  101405. declare module BABYLON {
  101406. /**
  101407. * Block used to read a texture from a sampler
  101408. */
  101409. export class TextureBlock extends NodeMaterialBlock {
  101410. private _defineName;
  101411. private _linearDefineName;
  101412. private _gammaDefineName;
  101413. private _tempTextureRead;
  101414. private _samplerName;
  101415. private _transformedUVName;
  101416. private _textureTransformName;
  101417. private _textureInfoName;
  101418. private _mainUVName;
  101419. private _mainUVDefineName;
  101420. private _fragmentOnly;
  101421. /**
  101422. * Gets or sets the texture associated with the node
  101423. */
  101424. texture: Nullable<Texture>;
  101425. /**
  101426. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101427. */
  101428. convertToGammaSpace: boolean;
  101429. /**
  101430. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101431. */
  101432. convertToLinearSpace: boolean;
  101433. /**
  101434. * Create a new TextureBlock
  101435. * @param name defines the block name
  101436. */
  101437. constructor(name: string, fragmentOnly?: boolean);
  101438. /**
  101439. * Gets the current class name
  101440. * @returns the class name
  101441. */
  101442. getClassName(): string;
  101443. /**
  101444. * Gets the uv input component
  101445. */
  101446. get uv(): NodeMaterialConnectionPoint;
  101447. /**
  101448. * Gets the rgba output component
  101449. */
  101450. get rgba(): NodeMaterialConnectionPoint;
  101451. /**
  101452. * Gets the rgb output component
  101453. */
  101454. get rgb(): NodeMaterialConnectionPoint;
  101455. /**
  101456. * Gets the r output component
  101457. */
  101458. get r(): NodeMaterialConnectionPoint;
  101459. /**
  101460. * Gets the g output component
  101461. */
  101462. get g(): NodeMaterialConnectionPoint;
  101463. /**
  101464. * Gets the b output component
  101465. */
  101466. get b(): NodeMaterialConnectionPoint;
  101467. /**
  101468. * Gets the a output component
  101469. */
  101470. get a(): NodeMaterialConnectionPoint;
  101471. get target(): NodeMaterialBlockTargets;
  101472. autoConfigure(material: NodeMaterial): void;
  101473. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101474. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101475. isReady(): boolean;
  101476. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101477. private get _isMixed();
  101478. private _injectVertexCode;
  101479. private _writeTextureRead;
  101480. private _writeOutput;
  101481. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101482. protected _dumpPropertiesCode(): string;
  101483. serialize(): any;
  101484. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101485. }
  101486. }
  101487. declare module BABYLON {
  101488. /** @hidden */
  101489. export var reflectionFunction: {
  101490. name: string;
  101491. shader: string;
  101492. };
  101493. }
  101494. declare module BABYLON {
  101495. /**
  101496. * Base block used to read a reflection texture from a sampler
  101497. */
  101498. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101499. /** @hidden */
  101500. _define3DName: string;
  101501. /** @hidden */
  101502. _defineCubicName: string;
  101503. /** @hidden */
  101504. _defineExplicitName: string;
  101505. /** @hidden */
  101506. _defineProjectionName: string;
  101507. /** @hidden */
  101508. _defineLocalCubicName: string;
  101509. /** @hidden */
  101510. _defineSphericalName: string;
  101511. /** @hidden */
  101512. _definePlanarName: string;
  101513. /** @hidden */
  101514. _defineEquirectangularName: string;
  101515. /** @hidden */
  101516. _defineMirroredEquirectangularFixedName: string;
  101517. /** @hidden */
  101518. _defineEquirectangularFixedName: string;
  101519. /** @hidden */
  101520. _defineSkyboxName: string;
  101521. /** @hidden */
  101522. _defineOppositeZ: string;
  101523. /** @hidden */
  101524. _cubeSamplerName: string;
  101525. /** @hidden */
  101526. _2DSamplerName: string;
  101527. protected _positionUVWName: string;
  101528. protected _directionWName: string;
  101529. protected _reflectionVectorName: string;
  101530. /** @hidden */
  101531. _reflectionCoordsName: string;
  101532. /** @hidden */
  101533. _reflectionMatrixName: string;
  101534. protected _reflectionColorName: string;
  101535. /**
  101536. * Gets or sets the texture associated with the node
  101537. */
  101538. texture: Nullable<BaseTexture>;
  101539. /**
  101540. * Create a new ReflectionTextureBaseBlock
  101541. * @param name defines the block name
  101542. */
  101543. constructor(name: string);
  101544. /**
  101545. * Gets the current class name
  101546. * @returns the class name
  101547. */
  101548. getClassName(): string;
  101549. /**
  101550. * Gets the world position input component
  101551. */
  101552. abstract get position(): NodeMaterialConnectionPoint;
  101553. /**
  101554. * Gets the world position input component
  101555. */
  101556. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101557. /**
  101558. * Gets the world normal input component
  101559. */
  101560. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101561. /**
  101562. * Gets the world input component
  101563. */
  101564. abstract get world(): NodeMaterialConnectionPoint;
  101565. /**
  101566. * Gets the camera (or eye) position component
  101567. */
  101568. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101569. /**
  101570. * Gets the view input component
  101571. */
  101572. abstract get view(): NodeMaterialConnectionPoint;
  101573. protected _getTexture(): Nullable<BaseTexture>;
  101574. autoConfigure(material: NodeMaterial): void;
  101575. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101576. isReady(): boolean;
  101577. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101578. /**
  101579. * Gets the code to inject in the vertex shader
  101580. * @param state current state of the node material building
  101581. * @returns the shader code
  101582. */
  101583. handleVertexSide(state: NodeMaterialBuildState): string;
  101584. /**
  101585. * Handles the inits for the fragment code path
  101586. * @param state node material build state
  101587. */
  101588. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101589. /**
  101590. * Generates the reflection coords code for the fragment code path
  101591. * @param worldNormalVarName name of the world normal variable
  101592. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101593. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101594. * @returns the shader code
  101595. */
  101596. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101597. /**
  101598. * Generates the reflection color code for the fragment code path
  101599. * @param lodVarName name of the lod variable
  101600. * @param swizzleLookupTexture swizzle to use for the final color variable
  101601. * @returns the shader code
  101602. */
  101603. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101604. /**
  101605. * Generates the code corresponding to the connected output points
  101606. * @param state node material build state
  101607. * @param varName name of the variable to output
  101608. * @returns the shader code
  101609. */
  101610. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101611. protected _buildBlock(state: NodeMaterialBuildState): this;
  101612. protected _dumpPropertiesCode(): string;
  101613. serialize(): any;
  101614. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101615. }
  101616. }
  101617. declare module BABYLON {
  101618. /**
  101619. * Defines a connection point to be used for points with a custom object type
  101620. */
  101621. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101622. private _blockType;
  101623. private _blockName;
  101624. private _nameForCheking?;
  101625. /**
  101626. * Creates a new connection point
  101627. * @param name defines the connection point name
  101628. * @param ownerBlock defines the block hosting this connection point
  101629. * @param direction defines the direction of the connection point
  101630. */
  101631. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101632. /**
  101633. * Gets a number indicating if the current point can be connected to another point
  101634. * @param connectionPoint defines the other connection point
  101635. * @returns a number defining the compatibility state
  101636. */
  101637. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101638. /**
  101639. * Creates a block suitable to be used as an input for this input point.
  101640. * If null is returned, a block based on the point type will be created.
  101641. * @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
  101642. */
  101643. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101644. }
  101645. }
  101646. declare module BABYLON {
  101647. /**
  101648. * Enum defining the type of properties that can be edited in the property pages in the NME
  101649. */
  101650. export enum PropertyTypeForEdition {
  101651. /** property is a boolean */
  101652. Boolean = 0,
  101653. /** property is a float */
  101654. Float = 1,
  101655. /** property is a Vector2 */
  101656. Vector2 = 2,
  101657. /** property is a list of values */
  101658. List = 3
  101659. }
  101660. /**
  101661. * Interface that defines an option in a variable of type list
  101662. */
  101663. export interface IEditablePropertyListOption {
  101664. /** label of the option */
  101665. "label": string;
  101666. /** value of the option */
  101667. "value": number;
  101668. }
  101669. /**
  101670. * Interface that defines the options available for an editable property
  101671. */
  101672. export interface IEditablePropertyOption {
  101673. /** min value */
  101674. "min"?: number;
  101675. /** max value */
  101676. "max"?: number;
  101677. /** notifiers: indicates which actions to take when the property is changed */
  101678. "notifiers"?: {
  101679. /** the material should be rebuilt */
  101680. "rebuild"?: boolean;
  101681. /** the preview should be updated */
  101682. "update"?: boolean;
  101683. };
  101684. /** list of the options for a variable of type list */
  101685. "options"?: IEditablePropertyListOption[];
  101686. }
  101687. /**
  101688. * Interface that describes an editable property
  101689. */
  101690. export interface IPropertyDescriptionForEdition {
  101691. /** name of the property */
  101692. "propertyName": string;
  101693. /** display name of the property */
  101694. "displayName": string;
  101695. /** type of the property */
  101696. "type": PropertyTypeForEdition;
  101697. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101698. "groupName": string;
  101699. /** options for the property */
  101700. "options": IEditablePropertyOption;
  101701. }
  101702. /**
  101703. * Decorator that flags a property in a node material block as being editable
  101704. */
  101705. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101706. }
  101707. declare module BABYLON {
  101708. /**
  101709. * Block used to implement the refraction part of the sub surface module of the PBR material
  101710. */
  101711. export class RefractionBlock extends NodeMaterialBlock {
  101712. /** @hidden */
  101713. _define3DName: string;
  101714. /** @hidden */
  101715. _refractionMatrixName: string;
  101716. /** @hidden */
  101717. _defineLODRefractionAlpha: string;
  101718. /** @hidden */
  101719. _defineLinearSpecularRefraction: string;
  101720. /** @hidden */
  101721. _defineOppositeZ: string;
  101722. /** @hidden */
  101723. _cubeSamplerName: string;
  101724. /** @hidden */
  101725. _2DSamplerName: string;
  101726. /** @hidden */
  101727. _vRefractionMicrosurfaceInfosName: string;
  101728. /** @hidden */
  101729. _vRefractionInfosName: string;
  101730. private _scene;
  101731. /**
  101732. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101733. * Materials half opaque for instance using refraction could benefit from this control.
  101734. */
  101735. linkRefractionWithTransparency: boolean;
  101736. /**
  101737. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101738. */
  101739. invertRefractionY: boolean;
  101740. /**
  101741. * Gets or sets the texture associated with the node
  101742. */
  101743. texture: Nullable<BaseTexture>;
  101744. /**
  101745. * Create a new RefractionBlock
  101746. * @param name defines the block name
  101747. */
  101748. constructor(name: string);
  101749. /**
  101750. * Gets the current class name
  101751. * @returns the class name
  101752. */
  101753. getClassName(): string;
  101754. /**
  101755. * Gets the intensity input component
  101756. */
  101757. get intensity(): NodeMaterialConnectionPoint;
  101758. /**
  101759. * Gets the index of refraction input component
  101760. */
  101761. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101762. /**
  101763. * Gets the tint at distance input component
  101764. */
  101765. get tintAtDistance(): NodeMaterialConnectionPoint;
  101766. /**
  101767. * Gets the view input component
  101768. */
  101769. get view(): NodeMaterialConnectionPoint;
  101770. /**
  101771. * Gets the refraction object output component
  101772. */
  101773. get refraction(): NodeMaterialConnectionPoint;
  101774. /**
  101775. * Returns true if the block has a texture
  101776. */
  101777. get hasTexture(): boolean;
  101778. protected _getTexture(): Nullable<BaseTexture>;
  101779. autoConfigure(material: NodeMaterial): void;
  101780. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101781. isReady(): boolean;
  101782. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101783. /**
  101784. * Gets the main code of the block (fragment side)
  101785. * @param state current state of the node material building
  101786. * @returns the shader code
  101787. */
  101788. getCode(state: NodeMaterialBuildState): string;
  101789. protected _buildBlock(state: NodeMaterialBuildState): this;
  101790. protected _dumpPropertiesCode(): string;
  101791. serialize(): any;
  101792. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101793. }
  101794. }
  101795. declare module BABYLON {
  101796. /**
  101797. * Base block used as input for post process
  101798. */
  101799. export class CurrentScreenBlock extends NodeMaterialBlock {
  101800. private _samplerName;
  101801. private _linearDefineName;
  101802. private _gammaDefineName;
  101803. private _mainUVName;
  101804. private _tempTextureRead;
  101805. /**
  101806. * Gets or sets the texture associated with the node
  101807. */
  101808. texture: Nullable<BaseTexture>;
  101809. /**
  101810. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101811. */
  101812. convertToGammaSpace: boolean;
  101813. /**
  101814. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101815. */
  101816. convertToLinearSpace: boolean;
  101817. /**
  101818. * Create a new CurrentScreenBlock
  101819. * @param name defines the block name
  101820. */
  101821. constructor(name: string);
  101822. /**
  101823. * Gets the current class name
  101824. * @returns the class name
  101825. */
  101826. getClassName(): string;
  101827. /**
  101828. * Gets the uv input component
  101829. */
  101830. get uv(): NodeMaterialConnectionPoint;
  101831. /**
  101832. * Gets the rgba output component
  101833. */
  101834. get rgba(): NodeMaterialConnectionPoint;
  101835. /**
  101836. * Gets the rgb output component
  101837. */
  101838. get rgb(): NodeMaterialConnectionPoint;
  101839. /**
  101840. * Gets the r output component
  101841. */
  101842. get r(): NodeMaterialConnectionPoint;
  101843. /**
  101844. * Gets the g output component
  101845. */
  101846. get g(): NodeMaterialConnectionPoint;
  101847. /**
  101848. * Gets the b output component
  101849. */
  101850. get b(): NodeMaterialConnectionPoint;
  101851. /**
  101852. * Gets the a output component
  101853. */
  101854. get a(): NodeMaterialConnectionPoint;
  101855. /**
  101856. * Initialize the block and prepare the context for build
  101857. * @param state defines the state that will be used for the build
  101858. */
  101859. initialize(state: NodeMaterialBuildState): void;
  101860. get target(): NodeMaterialBlockTargets;
  101861. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101862. isReady(): boolean;
  101863. private _injectVertexCode;
  101864. private _writeTextureRead;
  101865. private _writeOutput;
  101866. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101867. serialize(): any;
  101868. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101869. }
  101870. }
  101871. declare module BABYLON {
  101872. /**
  101873. * Base block used for the particle texture
  101874. */
  101875. export class ParticleTextureBlock extends NodeMaterialBlock {
  101876. private _samplerName;
  101877. private _linearDefineName;
  101878. private _gammaDefineName;
  101879. private _tempTextureRead;
  101880. /**
  101881. * Gets or sets the texture associated with the node
  101882. */
  101883. texture: Nullable<BaseTexture>;
  101884. /**
  101885. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101886. */
  101887. convertToGammaSpace: boolean;
  101888. /**
  101889. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101890. */
  101891. convertToLinearSpace: boolean;
  101892. /**
  101893. * Create a new ParticleTextureBlock
  101894. * @param name defines the block name
  101895. */
  101896. constructor(name: string);
  101897. /**
  101898. * Gets the current class name
  101899. * @returns the class name
  101900. */
  101901. getClassName(): string;
  101902. /**
  101903. * Gets the uv input component
  101904. */
  101905. get uv(): NodeMaterialConnectionPoint;
  101906. /**
  101907. * Gets the rgba output component
  101908. */
  101909. get rgba(): NodeMaterialConnectionPoint;
  101910. /**
  101911. * Gets the rgb output component
  101912. */
  101913. get rgb(): NodeMaterialConnectionPoint;
  101914. /**
  101915. * Gets the r output component
  101916. */
  101917. get r(): NodeMaterialConnectionPoint;
  101918. /**
  101919. * Gets the g output component
  101920. */
  101921. get g(): NodeMaterialConnectionPoint;
  101922. /**
  101923. * Gets the b output component
  101924. */
  101925. get b(): NodeMaterialConnectionPoint;
  101926. /**
  101927. * Gets the a output component
  101928. */
  101929. get a(): NodeMaterialConnectionPoint;
  101930. /**
  101931. * Initialize the block and prepare the context for build
  101932. * @param state defines the state that will be used for the build
  101933. */
  101934. initialize(state: NodeMaterialBuildState): void;
  101935. autoConfigure(material: NodeMaterial): void;
  101936. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101937. isReady(): boolean;
  101938. private _writeOutput;
  101939. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101940. serialize(): any;
  101941. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101942. }
  101943. }
  101944. declare module BABYLON {
  101945. /**
  101946. * Class used to store shared data between 2 NodeMaterialBuildState
  101947. */
  101948. export class NodeMaterialBuildStateSharedData {
  101949. /**
  101950. * Gets the list of emitted varyings
  101951. */
  101952. temps: string[];
  101953. /**
  101954. * Gets the list of emitted varyings
  101955. */
  101956. varyings: string[];
  101957. /**
  101958. * Gets the varying declaration string
  101959. */
  101960. varyingDeclaration: string;
  101961. /**
  101962. * Input blocks
  101963. */
  101964. inputBlocks: InputBlock[];
  101965. /**
  101966. * Input blocks
  101967. */
  101968. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101969. /**
  101970. * Bindable blocks (Blocks that need to set data to the effect)
  101971. */
  101972. bindableBlocks: NodeMaterialBlock[];
  101973. /**
  101974. * List of blocks that can provide a compilation fallback
  101975. */
  101976. blocksWithFallbacks: NodeMaterialBlock[];
  101977. /**
  101978. * List of blocks that can provide a define update
  101979. */
  101980. blocksWithDefines: NodeMaterialBlock[];
  101981. /**
  101982. * List of blocks that can provide a repeatable content
  101983. */
  101984. repeatableContentBlocks: NodeMaterialBlock[];
  101985. /**
  101986. * List of blocks that can provide a dynamic list of uniforms
  101987. */
  101988. dynamicUniformBlocks: NodeMaterialBlock[];
  101989. /**
  101990. * List of blocks that can block the isReady function for the material
  101991. */
  101992. blockingBlocks: NodeMaterialBlock[];
  101993. /**
  101994. * Gets the list of animated inputs
  101995. */
  101996. animatedInputs: InputBlock[];
  101997. /**
  101998. * Build Id used to avoid multiple recompilations
  101999. */
  102000. buildId: number;
  102001. /** List of emitted variables */
  102002. variableNames: {
  102003. [key: string]: number;
  102004. };
  102005. /** List of emitted defines */
  102006. defineNames: {
  102007. [key: string]: number;
  102008. };
  102009. /** Should emit comments? */
  102010. emitComments: boolean;
  102011. /** Emit build activity */
  102012. verbose: boolean;
  102013. /** Gets or sets the hosting scene */
  102014. scene: Scene;
  102015. /**
  102016. * Gets the compilation hints emitted at compilation time
  102017. */
  102018. hints: {
  102019. needWorldViewMatrix: boolean;
  102020. needWorldViewProjectionMatrix: boolean;
  102021. needAlphaBlending: boolean;
  102022. needAlphaTesting: boolean;
  102023. };
  102024. /**
  102025. * List of compilation checks
  102026. */
  102027. checks: {
  102028. emitVertex: boolean;
  102029. emitFragment: boolean;
  102030. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  102031. };
  102032. /**
  102033. * Is vertex program allowed to be empty?
  102034. */
  102035. allowEmptyVertexProgram: boolean;
  102036. /** Creates a new shared data */
  102037. constructor();
  102038. /**
  102039. * Emits console errors and exceptions if there is a failing check
  102040. */
  102041. emitErrors(): void;
  102042. }
  102043. }
  102044. declare module BABYLON {
  102045. /**
  102046. * Class used to store node based material build state
  102047. */
  102048. export class NodeMaterialBuildState {
  102049. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  102050. supportUniformBuffers: boolean;
  102051. /**
  102052. * Gets the list of emitted attributes
  102053. */
  102054. attributes: string[];
  102055. /**
  102056. * Gets the list of emitted uniforms
  102057. */
  102058. uniforms: string[];
  102059. /**
  102060. * Gets the list of emitted constants
  102061. */
  102062. constants: string[];
  102063. /**
  102064. * Gets the list of emitted samplers
  102065. */
  102066. samplers: string[];
  102067. /**
  102068. * Gets the list of emitted functions
  102069. */
  102070. functions: {
  102071. [key: string]: string;
  102072. };
  102073. /**
  102074. * Gets the list of emitted extensions
  102075. */
  102076. extensions: {
  102077. [key: string]: string;
  102078. };
  102079. /**
  102080. * Gets the target of the compilation state
  102081. */
  102082. target: NodeMaterialBlockTargets;
  102083. /**
  102084. * Gets the list of emitted counters
  102085. */
  102086. counters: {
  102087. [key: string]: number;
  102088. };
  102089. /**
  102090. * Shared data between multiple NodeMaterialBuildState instances
  102091. */
  102092. sharedData: NodeMaterialBuildStateSharedData;
  102093. /** @hidden */
  102094. _vertexState: NodeMaterialBuildState;
  102095. /** @hidden */
  102096. _attributeDeclaration: string;
  102097. /** @hidden */
  102098. _uniformDeclaration: string;
  102099. /** @hidden */
  102100. _constantDeclaration: string;
  102101. /** @hidden */
  102102. _samplerDeclaration: string;
  102103. /** @hidden */
  102104. _varyingTransfer: string;
  102105. /** @hidden */
  102106. _injectAtEnd: string;
  102107. private _repeatableContentAnchorIndex;
  102108. /** @hidden */
  102109. _builtCompilationString: string;
  102110. /**
  102111. * Gets the emitted compilation strings
  102112. */
  102113. compilationString: string;
  102114. /**
  102115. * Finalize the compilation strings
  102116. * @param state defines the current compilation state
  102117. */
  102118. finalize(state: NodeMaterialBuildState): void;
  102119. /** @hidden */
  102120. get _repeatableContentAnchor(): string;
  102121. /** @hidden */
  102122. _getFreeVariableName(prefix: string): string;
  102123. /** @hidden */
  102124. _getFreeDefineName(prefix: string): string;
  102125. /** @hidden */
  102126. _excludeVariableName(name: string): void;
  102127. /** @hidden */
  102128. _emit2DSampler(name: string): void;
  102129. /** @hidden */
  102130. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  102131. /** @hidden */
  102132. _emitExtension(name: string, extension: string, define?: string): void;
  102133. /** @hidden */
  102134. _emitFunction(name: string, code: string, comments: string): void;
  102135. /** @hidden */
  102136. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  102137. replaceStrings?: {
  102138. search: RegExp;
  102139. replace: string;
  102140. }[];
  102141. repeatKey?: string;
  102142. }): string;
  102143. /** @hidden */
  102144. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  102145. repeatKey?: string;
  102146. removeAttributes?: boolean;
  102147. removeUniforms?: boolean;
  102148. removeVaryings?: boolean;
  102149. removeIfDef?: boolean;
  102150. replaceStrings?: {
  102151. search: RegExp;
  102152. replace: string;
  102153. }[];
  102154. }, storeKey?: string): void;
  102155. /** @hidden */
  102156. _registerTempVariable(name: string): boolean;
  102157. /** @hidden */
  102158. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  102159. /** @hidden */
  102160. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  102161. /** @hidden */
  102162. _emitFloat(value: number): string;
  102163. }
  102164. }
  102165. declare module BABYLON {
  102166. /**
  102167. * Helper class used to generate session unique ID
  102168. */
  102169. export class UniqueIdGenerator {
  102170. private static _UniqueIdCounter;
  102171. /**
  102172. * Gets an unique (relatively to the current scene) Id
  102173. */
  102174. static get UniqueId(): number;
  102175. }
  102176. }
  102177. declare module BABYLON {
  102178. /**
  102179. * Defines a block that can be used inside a node based material
  102180. */
  102181. export class NodeMaterialBlock {
  102182. private _buildId;
  102183. private _buildTarget;
  102184. private _target;
  102185. private _isFinalMerger;
  102186. private _isInput;
  102187. private _name;
  102188. protected _isUnique: boolean;
  102189. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  102190. inputsAreExclusive: boolean;
  102191. /** @hidden */
  102192. _codeVariableName: string;
  102193. /** @hidden */
  102194. _inputs: NodeMaterialConnectionPoint[];
  102195. /** @hidden */
  102196. _outputs: NodeMaterialConnectionPoint[];
  102197. /** @hidden */
  102198. _preparationId: number;
  102199. /**
  102200. * Gets the name of the block
  102201. */
  102202. get name(): string;
  102203. /**
  102204. * Sets the name of the block. Will check if the name is valid.
  102205. */
  102206. set name(newName: string);
  102207. /**
  102208. * Gets or sets the unique id of the node
  102209. */
  102210. uniqueId: number;
  102211. /**
  102212. * Gets or sets the comments associated with this block
  102213. */
  102214. comments: string;
  102215. /**
  102216. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  102217. */
  102218. get isUnique(): boolean;
  102219. /**
  102220. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  102221. */
  102222. get isFinalMerger(): boolean;
  102223. /**
  102224. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  102225. */
  102226. get isInput(): boolean;
  102227. /**
  102228. * Gets or sets the build Id
  102229. */
  102230. get buildId(): number;
  102231. set buildId(value: number);
  102232. /**
  102233. * Gets or sets the target of the block
  102234. */
  102235. get target(): NodeMaterialBlockTargets;
  102236. set target(value: NodeMaterialBlockTargets);
  102237. /**
  102238. * Gets the list of input points
  102239. */
  102240. get inputs(): NodeMaterialConnectionPoint[];
  102241. /** Gets the list of output points */
  102242. get outputs(): NodeMaterialConnectionPoint[];
  102243. /**
  102244. * Find an input by its name
  102245. * @param name defines the name of the input to look for
  102246. * @returns the input or null if not found
  102247. */
  102248. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102249. /**
  102250. * Find an output by its name
  102251. * @param name defines the name of the outputto look for
  102252. * @returns the output or null if not found
  102253. */
  102254. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102255. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  102256. visibleInInspector: boolean;
  102257. /**
  102258. * Creates a new NodeMaterialBlock
  102259. * @param name defines the block name
  102260. * @param target defines the target of that block (Vertex by default)
  102261. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  102262. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  102263. */
  102264. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  102265. /**
  102266. * Initialize the block and prepare the context for build
  102267. * @param state defines the state that will be used for the build
  102268. */
  102269. initialize(state: NodeMaterialBuildState): void;
  102270. /**
  102271. * Bind data to effect. Will only be called for blocks with isBindable === true
  102272. * @param effect defines the effect to bind data to
  102273. * @param nodeMaterial defines the hosting NodeMaterial
  102274. * @param mesh defines the mesh that will be rendered
  102275. * @param subMesh defines the submesh that will be rendered
  102276. */
  102277. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102278. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  102279. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  102280. protected _writeFloat(value: number): string;
  102281. /**
  102282. * Gets the current class name e.g. "NodeMaterialBlock"
  102283. * @returns the class name
  102284. */
  102285. getClassName(): string;
  102286. /**
  102287. * Register a new input. Must be called inside a block constructor
  102288. * @param name defines the connection point name
  102289. * @param type defines the connection point type
  102290. * @param isOptional defines a boolean indicating that this input can be omitted
  102291. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102292. * @param point an already created connection point. If not provided, create a new one
  102293. * @returns the current block
  102294. */
  102295. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102296. /**
  102297. * Register a new output. Must be called inside a block constructor
  102298. * @param name defines the connection point name
  102299. * @param type defines the connection point type
  102300. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102301. * @param point an already created connection point. If not provided, create a new one
  102302. * @returns the current block
  102303. */
  102304. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102305. /**
  102306. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102307. * @param forOutput defines an optional connection point to check compatibility with
  102308. * @returns the first available input or null
  102309. */
  102310. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102311. /**
  102312. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102313. * @param forBlock defines an optional block to check compatibility with
  102314. * @returns the first available input or null
  102315. */
  102316. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102317. /**
  102318. * Gets the sibling of the given output
  102319. * @param current defines the current output
  102320. * @returns the next output in the list or null
  102321. */
  102322. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102323. /**
  102324. * Connect current block with another block
  102325. * @param other defines the block to connect with
  102326. * @param options define the various options to help pick the right connections
  102327. * @returns the current block
  102328. */
  102329. connectTo(other: NodeMaterialBlock, options?: {
  102330. input?: string;
  102331. output?: string;
  102332. outputSwizzle?: string;
  102333. }): this | undefined;
  102334. protected _buildBlock(state: NodeMaterialBuildState): void;
  102335. /**
  102336. * Add uniforms, samplers and uniform buffers at compilation time
  102337. * @param state defines the state to update
  102338. * @param nodeMaterial defines the node material requesting the update
  102339. * @param defines defines the material defines to update
  102340. * @param uniformBuffers defines the list of uniform buffer names
  102341. */
  102342. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102343. /**
  102344. * Add potential fallbacks if shader compilation fails
  102345. * @param mesh defines the mesh to be rendered
  102346. * @param fallbacks defines the current prioritized list of fallbacks
  102347. */
  102348. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102349. /**
  102350. * Initialize defines for shader compilation
  102351. * @param mesh defines the mesh to be rendered
  102352. * @param nodeMaterial defines the node material requesting the update
  102353. * @param defines defines the material defines to update
  102354. * @param useInstances specifies that instances should be used
  102355. */
  102356. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102357. /**
  102358. * Update defines for shader compilation
  102359. * @param mesh defines the mesh to be rendered
  102360. * @param nodeMaterial defines the node material requesting the update
  102361. * @param defines defines the material defines to update
  102362. * @param useInstances specifies that instances should be used
  102363. * @param subMesh defines which submesh to render
  102364. */
  102365. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102366. /**
  102367. * Lets the block try to connect some inputs automatically
  102368. * @param material defines the hosting NodeMaterial
  102369. */
  102370. autoConfigure(material: NodeMaterial): void;
  102371. /**
  102372. * Function called when a block is declared as repeatable content generator
  102373. * @param vertexShaderState defines the current compilation state for the vertex shader
  102374. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102375. * @param mesh defines the mesh to be rendered
  102376. * @param defines defines the material defines to update
  102377. */
  102378. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102379. /**
  102380. * Checks if the block is ready
  102381. * @param mesh defines the mesh to be rendered
  102382. * @param nodeMaterial defines the node material requesting the update
  102383. * @param defines defines the material defines to update
  102384. * @param useInstances specifies that instances should be used
  102385. * @returns true if the block is ready
  102386. */
  102387. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102388. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102389. private _processBuild;
  102390. /**
  102391. * Validates the new name for the block node.
  102392. * @param newName the new name to be given to the node.
  102393. * @returns false if the name is a reserve word, else true.
  102394. */
  102395. validateBlockName(newName: string): boolean;
  102396. /**
  102397. * Compile the current node and generate the shader code
  102398. * @param state defines the current compilation state (uniforms, samplers, current string)
  102399. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102400. * @returns true if already built
  102401. */
  102402. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102403. protected _inputRename(name: string): string;
  102404. protected _outputRename(name: string): string;
  102405. protected _dumpPropertiesCode(): string;
  102406. /** @hidden */
  102407. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102408. /** @hidden */
  102409. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102410. /**
  102411. * Clone the current block to a new identical block
  102412. * @param scene defines the hosting scene
  102413. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102414. * @returns a copy of the current block
  102415. */
  102416. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102417. /**
  102418. * Serializes this block in a JSON representation
  102419. * @returns the serialized block object
  102420. */
  102421. serialize(): any;
  102422. /** @hidden */
  102423. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102424. private _deserializePortDisplayNamesAndExposedOnFrame;
  102425. /**
  102426. * Release resources
  102427. */
  102428. dispose(): void;
  102429. }
  102430. }
  102431. declare module BABYLON {
  102432. /**
  102433. * Base class of materials working in push mode in babylon JS
  102434. * @hidden
  102435. */
  102436. export class PushMaterial extends Material {
  102437. protected _activeEffect: Effect;
  102438. protected _normalMatrix: Matrix;
  102439. constructor(name: string, scene: Scene);
  102440. getEffect(): Effect;
  102441. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102442. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102443. /**
  102444. * Binds the given world matrix to the active effect
  102445. *
  102446. * @param world the matrix to bind
  102447. */
  102448. bindOnlyWorldMatrix(world: Matrix): void;
  102449. /**
  102450. * Binds the given normal matrix to the active effect
  102451. *
  102452. * @param normalMatrix the matrix to bind
  102453. */
  102454. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102455. bind(world: Matrix, mesh?: Mesh): void;
  102456. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102457. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102458. }
  102459. }
  102460. declare module BABYLON {
  102461. /**
  102462. * Root class for all node material optimizers
  102463. */
  102464. export class NodeMaterialOptimizer {
  102465. /**
  102466. * Function used to optimize a NodeMaterial graph
  102467. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102468. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102469. */
  102470. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102471. }
  102472. }
  102473. declare module BABYLON {
  102474. /**
  102475. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102476. */
  102477. export class TransformBlock extends NodeMaterialBlock {
  102478. /**
  102479. * Defines the value to use to complement W value to transform it to a Vector4
  102480. */
  102481. complementW: number;
  102482. /**
  102483. * Defines the value to use to complement z value to transform it to a Vector4
  102484. */
  102485. complementZ: number;
  102486. /**
  102487. * Creates a new TransformBlock
  102488. * @param name defines the block name
  102489. */
  102490. constructor(name: string);
  102491. /**
  102492. * Gets the current class name
  102493. * @returns the class name
  102494. */
  102495. getClassName(): string;
  102496. /**
  102497. * Gets the vector input
  102498. */
  102499. get vector(): NodeMaterialConnectionPoint;
  102500. /**
  102501. * Gets the output component
  102502. */
  102503. get output(): NodeMaterialConnectionPoint;
  102504. /**
  102505. * Gets the xyz output component
  102506. */
  102507. get xyz(): NodeMaterialConnectionPoint;
  102508. /**
  102509. * Gets the matrix transform input
  102510. */
  102511. get transform(): NodeMaterialConnectionPoint;
  102512. protected _buildBlock(state: NodeMaterialBuildState): this;
  102513. /**
  102514. * Update defines for shader compilation
  102515. * @param mesh defines the mesh to be rendered
  102516. * @param nodeMaterial defines the node material requesting the update
  102517. * @param defines defines the material defines to update
  102518. * @param useInstances specifies that instances should be used
  102519. * @param subMesh defines which submesh to render
  102520. */
  102521. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102522. serialize(): any;
  102523. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102524. protected _dumpPropertiesCode(): string;
  102525. }
  102526. }
  102527. declare module BABYLON {
  102528. /**
  102529. * Block used to output the vertex position
  102530. */
  102531. export class VertexOutputBlock extends NodeMaterialBlock {
  102532. /**
  102533. * Creates a new VertexOutputBlock
  102534. * @param name defines the block name
  102535. */
  102536. constructor(name: string);
  102537. /**
  102538. * Gets the current class name
  102539. * @returns the class name
  102540. */
  102541. getClassName(): string;
  102542. /**
  102543. * Gets the vector input component
  102544. */
  102545. get vector(): NodeMaterialConnectionPoint;
  102546. protected _buildBlock(state: NodeMaterialBuildState): this;
  102547. }
  102548. }
  102549. declare module BABYLON {
  102550. /**
  102551. * Block used to output the final color
  102552. */
  102553. export class FragmentOutputBlock extends NodeMaterialBlock {
  102554. /**
  102555. * Create a new FragmentOutputBlock
  102556. * @param name defines the block name
  102557. */
  102558. constructor(name: string);
  102559. /**
  102560. * Gets the current class name
  102561. * @returns the class name
  102562. */
  102563. getClassName(): string;
  102564. /**
  102565. * Gets the rgba input component
  102566. */
  102567. get rgba(): NodeMaterialConnectionPoint;
  102568. /**
  102569. * Gets the rgb input component
  102570. */
  102571. get rgb(): NodeMaterialConnectionPoint;
  102572. /**
  102573. * Gets the a input component
  102574. */
  102575. get a(): NodeMaterialConnectionPoint;
  102576. protected _buildBlock(state: NodeMaterialBuildState): this;
  102577. }
  102578. }
  102579. declare module BABYLON {
  102580. /**
  102581. * Block used for the particle ramp gradient section
  102582. */
  102583. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102584. /**
  102585. * Create a new ParticleRampGradientBlock
  102586. * @param name defines the block name
  102587. */
  102588. constructor(name: string);
  102589. /**
  102590. * Gets the current class name
  102591. * @returns the class name
  102592. */
  102593. getClassName(): string;
  102594. /**
  102595. * Gets the color input component
  102596. */
  102597. get color(): NodeMaterialConnectionPoint;
  102598. /**
  102599. * Gets the rampColor output component
  102600. */
  102601. get rampColor(): NodeMaterialConnectionPoint;
  102602. /**
  102603. * Initialize the block and prepare the context for build
  102604. * @param state defines the state that will be used for the build
  102605. */
  102606. initialize(state: NodeMaterialBuildState): void;
  102607. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102608. }
  102609. }
  102610. declare module BABYLON {
  102611. /**
  102612. * Block used for the particle blend multiply section
  102613. */
  102614. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102615. /**
  102616. * Create a new ParticleBlendMultiplyBlock
  102617. * @param name defines the block name
  102618. */
  102619. constructor(name: string);
  102620. /**
  102621. * Gets the current class name
  102622. * @returns the class name
  102623. */
  102624. getClassName(): string;
  102625. /**
  102626. * Gets the color input component
  102627. */
  102628. get color(): NodeMaterialConnectionPoint;
  102629. /**
  102630. * Gets the alphaTexture input component
  102631. */
  102632. get alphaTexture(): NodeMaterialConnectionPoint;
  102633. /**
  102634. * Gets the alphaColor input component
  102635. */
  102636. get alphaColor(): NodeMaterialConnectionPoint;
  102637. /**
  102638. * Gets the blendColor output component
  102639. */
  102640. get blendColor(): NodeMaterialConnectionPoint;
  102641. /**
  102642. * Initialize the block and prepare the context for build
  102643. * @param state defines the state that will be used for the build
  102644. */
  102645. initialize(state: NodeMaterialBuildState): void;
  102646. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102647. }
  102648. }
  102649. declare module BABYLON {
  102650. /**
  102651. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102652. */
  102653. export class VectorMergerBlock extends NodeMaterialBlock {
  102654. /**
  102655. * Create a new VectorMergerBlock
  102656. * @param name defines the block name
  102657. */
  102658. constructor(name: string);
  102659. /**
  102660. * Gets the current class name
  102661. * @returns the class name
  102662. */
  102663. getClassName(): string;
  102664. /**
  102665. * Gets the xyz component (input)
  102666. */
  102667. get xyzIn(): NodeMaterialConnectionPoint;
  102668. /**
  102669. * Gets the xy component (input)
  102670. */
  102671. get xyIn(): NodeMaterialConnectionPoint;
  102672. /**
  102673. * Gets the x component (input)
  102674. */
  102675. get x(): NodeMaterialConnectionPoint;
  102676. /**
  102677. * Gets the y component (input)
  102678. */
  102679. get y(): NodeMaterialConnectionPoint;
  102680. /**
  102681. * Gets the z component (input)
  102682. */
  102683. get z(): NodeMaterialConnectionPoint;
  102684. /**
  102685. * Gets the w component (input)
  102686. */
  102687. get w(): NodeMaterialConnectionPoint;
  102688. /**
  102689. * Gets the xyzw component (output)
  102690. */
  102691. get xyzw(): NodeMaterialConnectionPoint;
  102692. /**
  102693. * Gets the xyz component (output)
  102694. */
  102695. get xyzOut(): NodeMaterialConnectionPoint;
  102696. /**
  102697. * Gets the xy component (output)
  102698. */
  102699. get xyOut(): NodeMaterialConnectionPoint;
  102700. /**
  102701. * Gets the xy component (output)
  102702. * @deprecated Please use xyOut instead.
  102703. */
  102704. get xy(): NodeMaterialConnectionPoint;
  102705. /**
  102706. * Gets the xyz component (output)
  102707. * @deprecated Please use xyzOut instead.
  102708. */
  102709. get xyz(): NodeMaterialConnectionPoint;
  102710. protected _buildBlock(state: NodeMaterialBuildState): this;
  102711. }
  102712. }
  102713. declare module BABYLON {
  102714. /**
  102715. * Block used to remap a float from a range to a new one
  102716. */
  102717. export class RemapBlock extends NodeMaterialBlock {
  102718. /**
  102719. * Gets or sets the source range
  102720. */
  102721. sourceRange: Vector2;
  102722. /**
  102723. * Gets or sets the target range
  102724. */
  102725. targetRange: Vector2;
  102726. /**
  102727. * Creates a new RemapBlock
  102728. * @param name defines the block name
  102729. */
  102730. constructor(name: string);
  102731. /**
  102732. * Gets the current class name
  102733. * @returns the class name
  102734. */
  102735. getClassName(): string;
  102736. /**
  102737. * Gets the input component
  102738. */
  102739. get input(): NodeMaterialConnectionPoint;
  102740. /**
  102741. * Gets the source min input component
  102742. */
  102743. get sourceMin(): NodeMaterialConnectionPoint;
  102744. /**
  102745. * Gets the source max input component
  102746. */
  102747. get sourceMax(): NodeMaterialConnectionPoint;
  102748. /**
  102749. * Gets the target min input component
  102750. */
  102751. get targetMin(): NodeMaterialConnectionPoint;
  102752. /**
  102753. * Gets the target max input component
  102754. */
  102755. get targetMax(): NodeMaterialConnectionPoint;
  102756. /**
  102757. * Gets the output component
  102758. */
  102759. get output(): NodeMaterialConnectionPoint;
  102760. protected _buildBlock(state: NodeMaterialBuildState): this;
  102761. protected _dumpPropertiesCode(): string;
  102762. serialize(): any;
  102763. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102764. }
  102765. }
  102766. declare module BABYLON {
  102767. /**
  102768. * Block used to multiply 2 values
  102769. */
  102770. export class MultiplyBlock extends NodeMaterialBlock {
  102771. /**
  102772. * Creates a new MultiplyBlock
  102773. * @param name defines the block name
  102774. */
  102775. constructor(name: string);
  102776. /**
  102777. * Gets the current class name
  102778. * @returns the class name
  102779. */
  102780. getClassName(): string;
  102781. /**
  102782. * Gets the left operand input component
  102783. */
  102784. get left(): NodeMaterialConnectionPoint;
  102785. /**
  102786. * Gets the right operand input component
  102787. */
  102788. get right(): NodeMaterialConnectionPoint;
  102789. /**
  102790. * Gets the output component
  102791. */
  102792. get output(): NodeMaterialConnectionPoint;
  102793. protected _buildBlock(state: NodeMaterialBuildState): this;
  102794. }
  102795. }
  102796. declare module BABYLON {
  102797. /**
  102798. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102799. */
  102800. export class ColorSplitterBlock extends NodeMaterialBlock {
  102801. /**
  102802. * Create a new ColorSplitterBlock
  102803. * @param name defines the block name
  102804. */
  102805. constructor(name: string);
  102806. /**
  102807. * Gets the current class name
  102808. * @returns the class name
  102809. */
  102810. getClassName(): string;
  102811. /**
  102812. * Gets the rgba component (input)
  102813. */
  102814. get rgba(): NodeMaterialConnectionPoint;
  102815. /**
  102816. * Gets the rgb component (input)
  102817. */
  102818. get rgbIn(): NodeMaterialConnectionPoint;
  102819. /**
  102820. * Gets the rgb component (output)
  102821. */
  102822. get rgbOut(): NodeMaterialConnectionPoint;
  102823. /**
  102824. * Gets the r component (output)
  102825. */
  102826. get r(): NodeMaterialConnectionPoint;
  102827. /**
  102828. * Gets the g component (output)
  102829. */
  102830. get g(): NodeMaterialConnectionPoint;
  102831. /**
  102832. * Gets the b component (output)
  102833. */
  102834. get b(): NodeMaterialConnectionPoint;
  102835. /**
  102836. * Gets the a component (output)
  102837. */
  102838. get a(): NodeMaterialConnectionPoint;
  102839. protected _inputRename(name: string): string;
  102840. protected _outputRename(name: string): string;
  102841. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102842. }
  102843. }
  102844. declare module BABYLON {
  102845. /**
  102846. * Operations supported by the Trigonometry block
  102847. */
  102848. export enum TrigonometryBlockOperations {
  102849. /** Cos */
  102850. Cos = 0,
  102851. /** Sin */
  102852. Sin = 1,
  102853. /** Abs */
  102854. Abs = 2,
  102855. /** Exp */
  102856. Exp = 3,
  102857. /** Exp2 */
  102858. Exp2 = 4,
  102859. /** Round */
  102860. Round = 5,
  102861. /** Floor */
  102862. Floor = 6,
  102863. /** Ceiling */
  102864. Ceiling = 7,
  102865. /** Square root */
  102866. Sqrt = 8,
  102867. /** Log */
  102868. Log = 9,
  102869. /** Tangent */
  102870. Tan = 10,
  102871. /** Arc tangent */
  102872. ArcTan = 11,
  102873. /** Arc cosinus */
  102874. ArcCos = 12,
  102875. /** Arc sinus */
  102876. ArcSin = 13,
  102877. /** Fraction */
  102878. Fract = 14,
  102879. /** Sign */
  102880. Sign = 15,
  102881. /** To radians (from degrees) */
  102882. Radians = 16,
  102883. /** To degrees (from radians) */
  102884. Degrees = 17
  102885. }
  102886. /**
  102887. * Block used to apply trigonometry operation to floats
  102888. */
  102889. export class TrigonometryBlock extends NodeMaterialBlock {
  102890. /**
  102891. * Gets or sets the operation applied by the block
  102892. */
  102893. operation: TrigonometryBlockOperations;
  102894. /**
  102895. * Creates a new TrigonometryBlock
  102896. * @param name defines the block name
  102897. */
  102898. constructor(name: string);
  102899. /**
  102900. * Gets the current class name
  102901. * @returns the class name
  102902. */
  102903. getClassName(): string;
  102904. /**
  102905. * Gets the input component
  102906. */
  102907. get input(): NodeMaterialConnectionPoint;
  102908. /**
  102909. * Gets the output component
  102910. */
  102911. get output(): NodeMaterialConnectionPoint;
  102912. protected _buildBlock(state: NodeMaterialBuildState): this;
  102913. serialize(): any;
  102914. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102915. protected _dumpPropertiesCode(): string;
  102916. }
  102917. }
  102918. declare module BABYLON {
  102919. /**
  102920. * Interface used to configure the node material editor
  102921. */
  102922. export interface INodeMaterialEditorOptions {
  102923. /** Define the URl to load node editor script */
  102924. editorURL?: string;
  102925. }
  102926. /** @hidden */
  102927. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102928. NORMAL: boolean;
  102929. TANGENT: boolean;
  102930. UV1: boolean;
  102931. /** BONES */
  102932. NUM_BONE_INFLUENCERS: number;
  102933. BonesPerMesh: number;
  102934. BONETEXTURE: boolean;
  102935. /** MORPH TARGETS */
  102936. MORPHTARGETS: boolean;
  102937. MORPHTARGETS_NORMAL: boolean;
  102938. MORPHTARGETS_TANGENT: boolean;
  102939. MORPHTARGETS_UV: boolean;
  102940. NUM_MORPH_INFLUENCERS: number;
  102941. /** IMAGE PROCESSING */
  102942. IMAGEPROCESSING: boolean;
  102943. VIGNETTE: boolean;
  102944. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102945. VIGNETTEBLENDMODEOPAQUE: boolean;
  102946. TONEMAPPING: boolean;
  102947. TONEMAPPING_ACES: boolean;
  102948. CONTRAST: boolean;
  102949. EXPOSURE: boolean;
  102950. COLORCURVES: boolean;
  102951. COLORGRADING: boolean;
  102952. COLORGRADING3D: boolean;
  102953. SAMPLER3DGREENDEPTH: boolean;
  102954. SAMPLER3DBGRMAP: boolean;
  102955. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102956. /** MISC. */
  102957. BUMPDIRECTUV: number;
  102958. constructor();
  102959. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102960. }
  102961. /**
  102962. * Class used to configure NodeMaterial
  102963. */
  102964. export interface INodeMaterialOptions {
  102965. /**
  102966. * Defines if blocks should emit comments
  102967. */
  102968. emitComments: boolean;
  102969. }
  102970. /**
  102971. * Class used to create a node based material built by assembling shader blocks
  102972. */
  102973. export class NodeMaterial extends PushMaterial {
  102974. private static _BuildIdGenerator;
  102975. private _options;
  102976. private _vertexCompilationState;
  102977. private _fragmentCompilationState;
  102978. private _sharedData;
  102979. private _buildId;
  102980. private _buildWasSuccessful;
  102981. private _cachedWorldViewMatrix;
  102982. private _cachedWorldViewProjectionMatrix;
  102983. private _optimizers;
  102984. private _animationFrame;
  102985. /** Define the Url to load node editor script */
  102986. static EditorURL: string;
  102987. /** Define the Url to load snippets */
  102988. static SnippetUrl: string;
  102989. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102990. static IgnoreTexturesAtLoadTime: boolean;
  102991. private BJSNODEMATERIALEDITOR;
  102992. /** Get the inspector from bundle or global */
  102993. private _getGlobalNodeMaterialEditor;
  102994. /**
  102995. * Snippet ID if the material was created from the snippet server
  102996. */
  102997. snippetId: string;
  102998. /**
  102999. * Gets or sets data used by visual editor
  103000. * @see https://nme.babylonjs.com
  103001. */
  103002. editorData: any;
  103003. /**
  103004. * 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)
  103005. */
  103006. ignoreAlpha: boolean;
  103007. /**
  103008. * Defines the maximum number of lights that can be used in the material
  103009. */
  103010. maxSimultaneousLights: number;
  103011. /**
  103012. * Observable raised when the material is built
  103013. */
  103014. onBuildObservable: Observable<NodeMaterial>;
  103015. /**
  103016. * Gets or sets the root nodes of the material vertex shader
  103017. */
  103018. _vertexOutputNodes: NodeMaterialBlock[];
  103019. /**
  103020. * Gets or sets the root nodes of the material fragment (pixel) shader
  103021. */
  103022. _fragmentOutputNodes: NodeMaterialBlock[];
  103023. /** Gets or sets options to control the node material overall behavior */
  103024. get options(): INodeMaterialOptions;
  103025. set options(options: INodeMaterialOptions);
  103026. /**
  103027. * Default configuration related to image processing available in the standard Material.
  103028. */
  103029. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103030. /**
  103031. * Gets the image processing configuration used either in this material.
  103032. */
  103033. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103034. /**
  103035. * Sets the Default image processing configuration used either in the this material.
  103036. *
  103037. * If sets to null, the scene one is in use.
  103038. */
  103039. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103040. /**
  103041. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103042. */
  103043. attachedBlocks: NodeMaterialBlock[];
  103044. /**
  103045. * Specifies the mode of the node material
  103046. * @hidden
  103047. */
  103048. _mode: NodeMaterialModes;
  103049. /**
  103050. * Gets the mode property
  103051. */
  103052. get mode(): NodeMaterialModes;
  103053. /**
  103054. * Create a new node based material
  103055. * @param name defines the material name
  103056. * @param scene defines the hosting scene
  103057. * @param options defines creation option
  103058. */
  103059. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  103060. /**
  103061. * Gets the current class name of the material e.g. "NodeMaterial"
  103062. * @returns the class name
  103063. */
  103064. getClassName(): string;
  103065. /**
  103066. * Keep track of the image processing observer to allow dispose and replace.
  103067. */
  103068. private _imageProcessingObserver;
  103069. /**
  103070. * Attaches a new image processing configuration to the Standard Material.
  103071. * @param configuration
  103072. */
  103073. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103074. /**
  103075. * Get a block by its name
  103076. * @param name defines the name of the block to retrieve
  103077. * @returns the required block or null if not found
  103078. */
  103079. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  103080. /**
  103081. * Get a block by its name
  103082. * @param predicate defines the predicate used to find the good candidate
  103083. * @returns the required block or null if not found
  103084. */
  103085. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  103086. /**
  103087. * Get an input block by its name
  103088. * @param predicate defines the predicate used to find the good candidate
  103089. * @returns the required input block or null if not found
  103090. */
  103091. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  103092. /**
  103093. * Gets the list of input blocks attached to this material
  103094. * @returns an array of InputBlocks
  103095. */
  103096. getInputBlocks(): InputBlock[];
  103097. /**
  103098. * Adds a new optimizer to the list of optimizers
  103099. * @param optimizer defines the optimizers to add
  103100. * @returns the current material
  103101. */
  103102. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103103. /**
  103104. * Remove an optimizer from the list of optimizers
  103105. * @param optimizer defines the optimizers to remove
  103106. * @returns the current material
  103107. */
  103108. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103109. /**
  103110. * Add a new block to the list of output nodes
  103111. * @param node defines the node to add
  103112. * @returns the current material
  103113. */
  103114. addOutputNode(node: NodeMaterialBlock): this;
  103115. /**
  103116. * Remove a block from the list of root nodes
  103117. * @param node defines the node to remove
  103118. * @returns the current material
  103119. */
  103120. removeOutputNode(node: NodeMaterialBlock): this;
  103121. private _addVertexOutputNode;
  103122. private _removeVertexOutputNode;
  103123. private _addFragmentOutputNode;
  103124. private _removeFragmentOutputNode;
  103125. /**
  103126. * Specifies if the material will require alpha blending
  103127. * @returns a boolean specifying if alpha blending is needed
  103128. */
  103129. needAlphaBlending(): boolean;
  103130. /**
  103131. * Specifies if this material should be rendered in alpha test mode
  103132. * @returns a boolean specifying if an alpha test is needed.
  103133. */
  103134. needAlphaTesting(): boolean;
  103135. private _initializeBlock;
  103136. private _resetDualBlocks;
  103137. /**
  103138. * Remove a block from the current node material
  103139. * @param block defines the block to remove
  103140. */
  103141. removeBlock(block: NodeMaterialBlock): void;
  103142. /**
  103143. * Build the material and generates the inner effect
  103144. * @param verbose defines if the build should log activity
  103145. */
  103146. build(verbose?: boolean): void;
  103147. /**
  103148. * Runs an otpimization phase to try to improve the shader code
  103149. */
  103150. optimize(): void;
  103151. private _prepareDefinesForAttributes;
  103152. /**
  103153. * Create a post process from the material
  103154. * @param camera The camera to apply the render pass to.
  103155. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103157. * @param engine The engine which the post process will be applied. (default: current engine)
  103158. * @param reusable If the post process can be reused on the same frame. (default: false)
  103159. * @param textureType Type of textures used when performing the post process. (default: 0)
  103160. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103161. * @returns the post process created
  103162. */
  103163. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  103164. /**
  103165. * Create the post process effect from the material
  103166. * @param postProcess The post process to create the effect for
  103167. */
  103168. createEffectForPostProcess(postProcess: PostProcess): void;
  103169. private _createEffectForPostProcess;
  103170. /**
  103171. * Create a new procedural texture based on this node material
  103172. * @param size defines the size of the texture
  103173. * @param scene defines the hosting scene
  103174. * @returns the new procedural texture attached to this node material
  103175. */
  103176. createProceduralTexture(size: number | {
  103177. width: number;
  103178. height: number;
  103179. layers?: number;
  103180. }, scene: Scene): Nullable<ProceduralTexture>;
  103181. private _createEffectForParticles;
  103182. private _checkInternals;
  103183. /**
  103184. * Create the effect to be used as the custom effect for a particle system
  103185. * @param particleSystem Particle system to create the effect for
  103186. * @param onCompiled defines a function to call when the effect creation is successful
  103187. * @param onError defines a function to call when the effect creation has failed
  103188. */
  103189. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103190. private _processDefines;
  103191. /**
  103192. * Get if the submesh is ready to be used and all its information available.
  103193. * Child classes can use it to update shaders
  103194. * @param mesh defines the mesh to check
  103195. * @param subMesh defines which submesh to check
  103196. * @param useInstances specifies that instances should be used
  103197. * @returns a boolean indicating that the submesh is ready or not
  103198. */
  103199. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103200. /**
  103201. * Get a string representing the shaders built by the current node graph
  103202. */
  103203. get compiledShaders(): string;
  103204. /**
  103205. * Binds the world matrix to the material
  103206. * @param world defines the world transformation matrix
  103207. */
  103208. bindOnlyWorldMatrix(world: Matrix): void;
  103209. /**
  103210. * Binds the submesh to this material by preparing the effect and shader to draw
  103211. * @param world defines the world transformation matrix
  103212. * @param mesh defines the mesh containing the submesh
  103213. * @param subMesh defines the submesh to bind the material to
  103214. */
  103215. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103216. /**
  103217. * Gets the active textures from the material
  103218. * @returns an array of textures
  103219. */
  103220. getActiveTextures(): BaseTexture[];
  103221. /**
  103222. * Gets the list of texture blocks
  103223. * @returns an array of texture blocks
  103224. */
  103225. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  103226. /**
  103227. * Specifies if the material uses a texture
  103228. * @param texture defines the texture to check against the material
  103229. * @returns a boolean specifying if the material uses the texture
  103230. */
  103231. hasTexture(texture: BaseTexture): boolean;
  103232. /**
  103233. * Disposes the material
  103234. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103235. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103236. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103237. */
  103238. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103239. /** Creates the node editor window. */
  103240. private _createNodeEditor;
  103241. /**
  103242. * Launch the node material editor
  103243. * @param config Define the configuration of the editor
  103244. * @return a promise fulfilled when the node editor is visible
  103245. */
  103246. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103247. /**
  103248. * Clear the current material
  103249. */
  103250. clear(): void;
  103251. /**
  103252. * Clear the current material and set it to a default state
  103253. */
  103254. setToDefault(): void;
  103255. /**
  103256. * Clear the current material and set it to a default state for post process
  103257. */
  103258. setToDefaultPostProcess(): void;
  103259. /**
  103260. * Clear the current material and set it to a default state for procedural texture
  103261. */
  103262. setToDefaultProceduralTexture(): void;
  103263. /**
  103264. * Clear the current material and set it to a default state for particle
  103265. */
  103266. setToDefaultParticle(): void;
  103267. /**
  103268. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103269. * @param url defines the url to load from
  103270. * @returns a promise that will fullfil when the material is fully loaded
  103271. */
  103272. loadAsync(url: string): Promise<void>;
  103273. private _gatherBlocks;
  103274. /**
  103275. * Generate a string containing the code declaration required to create an equivalent of this material
  103276. * @returns a string
  103277. */
  103278. generateCode(): string;
  103279. /**
  103280. * Serializes this material in a JSON representation
  103281. * @returns the serialized material object
  103282. */
  103283. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103284. private _restoreConnections;
  103285. /**
  103286. * Clear the current graph and load a new one from a serialization object
  103287. * @param source defines the JSON representation of the material
  103288. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103289. * @param merge defines whether or not the source must be merged or replace the current content
  103290. */
  103291. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103292. /**
  103293. * Makes a duplicate of the current material.
  103294. * @param name - name to use for the new material.
  103295. */
  103296. clone(name: string): NodeMaterial;
  103297. /**
  103298. * Creates a node material from parsed material data
  103299. * @param source defines the JSON representation of the material
  103300. * @param scene defines the hosting scene
  103301. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103302. * @returns a new node material
  103303. */
  103304. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103305. /**
  103306. * Creates a node material from a snippet saved in a remote file
  103307. * @param name defines the name of the material to create
  103308. * @param url defines the url to load from
  103309. * @param scene defines the hosting scene
  103310. * @returns a promise that will resolve to the new node material
  103311. */
  103312. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103313. /**
  103314. * Creates a node material from a snippet saved by the node material editor
  103315. * @param snippetId defines the snippet to load
  103316. * @param scene defines the hosting scene
  103317. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103318. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103319. * @returns a promise that will resolve to the new node material
  103320. */
  103321. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103322. /**
  103323. * Creates a new node material set to default basic configuration
  103324. * @param name defines the name of the material
  103325. * @param scene defines the hosting scene
  103326. * @returns a new NodeMaterial
  103327. */
  103328. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103329. }
  103330. }
  103331. declare module BABYLON {
  103332. interface ThinEngine {
  103333. /**
  103334. * Unbind a list of render target textures from the webGL context
  103335. * This is used only when drawBuffer extension or webGL2 are active
  103336. * @param textures defines the render target textures to unbind
  103337. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103338. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103339. */
  103340. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103341. /**
  103342. * Create a multi render target texture
  103343. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103344. * @param size defines the size of the texture
  103345. * @param options defines the creation options
  103346. * @returns the cube texture as an InternalTexture
  103347. */
  103348. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103349. /**
  103350. * Update the sample count for a given multiple render target texture
  103351. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103352. * @param textures defines the textures to update
  103353. * @param samples defines the sample count to set
  103354. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103355. */
  103356. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103357. /**
  103358. * Select a subsets of attachments to draw to.
  103359. * @param attachments gl attachments
  103360. */
  103361. bindAttachments(attachments: number[]): void;
  103362. }
  103363. }
  103364. declare module BABYLON {
  103365. /**
  103366. * Creation options of the multi render target texture.
  103367. */
  103368. export interface IMultiRenderTargetOptions {
  103369. /**
  103370. * Define if the texture needs to create mip maps after render.
  103371. */
  103372. generateMipMaps?: boolean;
  103373. /**
  103374. * Define the types of all the draw buffers we want to create
  103375. */
  103376. types?: number[];
  103377. /**
  103378. * Define the sampling modes of all the draw buffers we want to create
  103379. */
  103380. samplingModes?: number[];
  103381. /**
  103382. * Define if a depth buffer is required
  103383. */
  103384. generateDepthBuffer?: boolean;
  103385. /**
  103386. * Define if a stencil buffer is required
  103387. */
  103388. generateStencilBuffer?: boolean;
  103389. /**
  103390. * Define if a depth texture is required instead of a depth buffer
  103391. */
  103392. generateDepthTexture?: boolean;
  103393. /**
  103394. * Define the number of desired draw buffers
  103395. */
  103396. textureCount?: number;
  103397. /**
  103398. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103399. */
  103400. doNotChangeAspectRatio?: boolean;
  103401. /**
  103402. * Define the default type of the buffers we are creating
  103403. */
  103404. defaultType?: number;
  103405. }
  103406. /**
  103407. * A multi render target, like a render target provides the ability to render to a texture.
  103408. * Unlike the render target, it can render to several draw buffers in one draw.
  103409. * This is specially interesting in deferred rendering or for any effects requiring more than
  103410. * just one color from a single pass.
  103411. */
  103412. export class MultiRenderTarget extends RenderTargetTexture {
  103413. private _internalTextures;
  103414. private _textures;
  103415. private _multiRenderTargetOptions;
  103416. private _count;
  103417. /**
  103418. * Get if draw buffers are currently supported by the used hardware and browser.
  103419. */
  103420. get isSupported(): boolean;
  103421. /**
  103422. * Get the list of textures generated by the multi render target.
  103423. */
  103424. get textures(): Texture[];
  103425. /**
  103426. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103427. */
  103428. get count(): number;
  103429. /**
  103430. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103431. */
  103432. get depthTexture(): Texture;
  103433. /**
  103434. * Set the wrapping mode on U of all the textures we are rendering to.
  103435. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103436. */
  103437. set wrapU(wrap: number);
  103438. /**
  103439. * Set the wrapping mode on V of all the textures we are rendering to.
  103440. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103441. */
  103442. set wrapV(wrap: number);
  103443. /**
  103444. * Instantiate a new multi render target texture.
  103445. * A multi render target, like a render target provides the ability to render to a texture.
  103446. * Unlike the render target, it can render to several draw buffers in one draw.
  103447. * This is specially interesting in deferred rendering or for any effects requiring more than
  103448. * just one color from a single pass.
  103449. * @param name Define the name of the texture
  103450. * @param size Define the size of the buffers to render to
  103451. * @param count Define the number of target we are rendering into
  103452. * @param scene Define the scene the texture belongs to
  103453. * @param options Define the options used to create the multi render target
  103454. */
  103455. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103456. private _initTypes;
  103457. /** @hidden */
  103458. _rebuild(forceFullRebuild?: boolean): void;
  103459. private _createInternalTextures;
  103460. private _createTextures;
  103461. /**
  103462. * Define the number of samples used if MSAA is enabled.
  103463. */
  103464. get samples(): number;
  103465. set samples(value: number);
  103466. /**
  103467. * Resize all the textures in the multi render target.
  103468. * Be careful as it will recreate all the data in the new texture.
  103469. * @param size Define the new size
  103470. */
  103471. resize(size: any): void;
  103472. /**
  103473. * Changes the number of render targets in this MRT
  103474. * Be careful as it will recreate all the data in the new texture.
  103475. * @param count new texture count
  103476. * @param options Specifies texture types and sampling modes for new textures
  103477. */
  103478. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103479. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103480. /**
  103481. * Dispose the render targets and their associated resources
  103482. */
  103483. dispose(): void;
  103484. /**
  103485. * Release all the underlying texture used as draw buffers.
  103486. */
  103487. releaseInternalTextures(): void;
  103488. }
  103489. }
  103490. declare module BABYLON {
  103491. /** @hidden */
  103492. export var imageProcessingPixelShader: {
  103493. name: string;
  103494. shader: string;
  103495. };
  103496. }
  103497. declare module BABYLON {
  103498. /**
  103499. * ImageProcessingPostProcess
  103500. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103501. */
  103502. export class ImageProcessingPostProcess extends PostProcess {
  103503. /**
  103504. * Default configuration related to image processing available in the PBR Material.
  103505. */
  103506. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103507. /**
  103508. * Gets the image processing configuration used either in this material.
  103509. */
  103510. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103511. /**
  103512. * Sets the Default image processing configuration used either in the this material.
  103513. *
  103514. * If sets to null, the scene one is in use.
  103515. */
  103516. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103517. /**
  103518. * Keep track of the image processing observer to allow dispose and replace.
  103519. */
  103520. private _imageProcessingObserver;
  103521. /**
  103522. * Attaches a new image processing configuration to the PBR Material.
  103523. * @param configuration
  103524. */
  103525. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103526. /**
  103527. * If the post process is supported.
  103528. */
  103529. get isSupported(): boolean;
  103530. /**
  103531. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103532. */
  103533. get colorCurves(): Nullable<ColorCurves>;
  103534. /**
  103535. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103536. */
  103537. set colorCurves(value: Nullable<ColorCurves>);
  103538. /**
  103539. * Gets wether the color curves effect is enabled.
  103540. */
  103541. get colorCurvesEnabled(): boolean;
  103542. /**
  103543. * Sets wether the color curves effect is enabled.
  103544. */
  103545. set colorCurvesEnabled(value: boolean);
  103546. /**
  103547. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103548. */
  103549. get colorGradingTexture(): Nullable<BaseTexture>;
  103550. /**
  103551. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103552. */
  103553. set colorGradingTexture(value: Nullable<BaseTexture>);
  103554. /**
  103555. * Gets wether the color grading effect is enabled.
  103556. */
  103557. get colorGradingEnabled(): boolean;
  103558. /**
  103559. * Gets wether the color grading effect is enabled.
  103560. */
  103561. set colorGradingEnabled(value: boolean);
  103562. /**
  103563. * Gets exposure used in the effect.
  103564. */
  103565. get exposure(): number;
  103566. /**
  103567. * Sets exposure used in the effect.
  103568. */
  103569. set exposure(value: number);
  103570. /**
  103571. * Gets wether tonemapping is enabled or not.
  103572. */
  103573. get toneMappingEnabled(): boolean;
  103574. /**
  103575. * Sets wether tonemapping is enabled or not
  103576. */
  103577. set toneMappingEnabled(value: boolean);
  103578. /**
  103579. * Gets the type of tone mapping effect.
  103580. */
  103581. get toneMappingType(): number;
  103582. /**
  103583. * Sets the type of tone mapping effect.
  103584. */
  103585. set toneMappingType(value: number);
  103586. /**
  103587. * Gets contrast used in the effect.
  103588. */
  103589. get contrast(): number;
  103590. /**
  103591. * Sets contrast used in the effect.
  103592. */
  103593. set contrast(value: number);
  103594. /**
  103595. * Gets Vignette stretch size.
  103596. */
  103597. get vignetteStretch(): number;
  103598. /**
  103599. * Sets Vignette stretch size.
  103600. */
  103601. set vignetteStretch(value: number);
  103602. /**
  103603. * Gets Vignette centre X Offset.
  103604. */
  103605. get vignetteCentreX(): number;
  103606. /**
  103607. * Sets Vignette centre X Offset.
  103608. */
  103609. set vignetteCentreX(value: number);
  103610. /**
  103611. * Gets Vignette centre Y Offset.
  103612. */
  103613. get vignetteCentreY(): number;
  103614. /**
  103615. * Sets Vignette centre Y Offset.
  103616. */
  103617. set vignetteCentreY(value: number);
  103618. /**
  103619. * Gets Vignette weight or intensity of the vignette effect.
  103620. */
  103621. get vignetteWeight(): number;
  103622. /**
  103623. * Sets Vignette weight or intensity of the vignette effect.
  103624. */
  103625. set vignetteWeight(value: number);
  103626. /**
  103627. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103628. * if vignetteEnabled is set to true.
  103629. */
  103630. get vignetteColor(): Color4;
  103631. /**
  103632. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103633. * if vignetteEnabled is set to true.
  103634. */
  103635. set vignetteColor(value: Color4);
  103636. /**
  103637. * Gets Camera field of view used by the Vignette effect.
  103638. */
  103639. get vignetteCameraFov(): number;
  103640. /**
  103641. * Sets Camera field of view used by the Vignette effect.
  103642. */
  103643. set vignetteCameraFov(value: number);
  103644. /**
  103645. * Gets the vignette blend mode allowing different kind of effect.
  103646. */
  103647. get vignetteBlendMode(): number;
  103648. /**
  103649. * Sets the vignette blend mode allowing different kind of effect.
  103650. */
  103651. set vignetteBlendMode(value: number);
  103652. /**
  103653. * Gets wether the vignette effect is enabled.
  103654. */
  103655. get vignetteEnabled(): boolean;
  103656. /**
  103657. * Sets wether the vignette effect is enabled.
  103658. */
  103659. set vignetteEnabled(value: boolean);
  103660. private _fromLinearSpace;
  103661. /**
  103662. * Gets wether the input of the processing is in Gamma or Linear Space.
  103663. */
  103664. get fromLinearSpace(): boolean;
  103665. /**
  103666. * Sets wether the input of the processing is in Gamma or Linear Space.
  103667. */
  103668. set fromLinearSpace(value: boolean);
  103669. /**
  103670. * Defines cache preventing GC.
  103671. */
  103672. private _defines;
  103673. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103674. /**
  103675. * "ImageProcessingPostProcess"
  103676. * @returns "ImageProcessingPostProcess"
  103677. */
  103678. getClassName(): string;
  103679. /**
  103680. * @hidden
  103681. */
  103682. _updateParameters(): void;
  103683. dispose(camera?: Camera): void;
  103684. }
  103685. }
  103686. declare module BABYLON {
  103687. /**
  103688. * Interface for defining prepass effects in the prepass post-process pipeline
  103689. */
  103690. export interface PrePassEffectConfiguration {
  103691. /**
  103692. * Name of the effect
  103693. */
  103694. name: string;
  103695. /**
  103696. * Post process to attach for this effect
  103697. */
  103698. postProcess?: PostProcess;
  103699. /**
  103700. * Textures required in the MRT
  103701. */
  103702. texturesRequired: number[];
  103703. /**
  103704. * Is the effect enabled
  103705. */
  103706. enabled: boolean;
  103707. /**
  103708. * Disposes the effect configuration
  103709. */
  103710. dispose?: () => void;
  103711. /**
  103712. * Creates the associated post process
  103713. */
  103714. createPostProcess?: () => PostProcess;
  103715. }
  103716. }
  103717. declare module BABYLON {
  103718. /**
  103719. * Renders a pre pass of the scene
  103720. * This means every mesh in the scene will be rendered to a render target texture
  103721. * And then this texture will be composited to the rendering canvas with post processes
  103722. * It is necessary for effects like subsurface scattering or deferred shading
  103723. */
  103724. export class PrePassRenderer {
  103725. /** @hidden */
  103726. static _SceneComponentInitialization: (scene: Scene) => void;
  103727. private _textureFormats;
  103728. /**
  103729. * To save performance, we can excluded skinned meshes from the prepass
  103730. */
  103731. excludedSkinnedMesh: AbstractMesh[];
  103732. private _textureIndices;
  103733. private _scene;
  103734. private _engine;
  103735. private _isDirty;
  103736. /**
  103737. * Number of textures in the multi render target texture where the scene is directly rendered
  103738. */
  103739. mrtCount: number;
  103740. /**
  103741. * The render target where the scene is directly rendered
  103742. */
  103743. prePassRT: MultiRenderTarget;
  103744. private _multiRenderAttachments;
  103745. private _defaultAttachments;
  103746. private _clearAttachments;
  103747. private _postProcesses;
  103748. private readonly _clearColor;
  103749. /**
  103750. * Image processing post process for composition
  103751. */
  103752. imageProcessingPostProcess: ImageProcessingPostProcess;
  103753. /**
  103754. * Configuration for prepass effects
  103755. */
  103756. private _effectConfigurations;
  103757. private _mrtFormats;
  103758. private _mrtLayout;
  103759. private _enabled;
  103760. /**
  103761. * Indicates if the prepass is enabled
  103762. */
  103763. get enabled(): boolean;
  103764. /**
  103765. * How many samples are used for MSAA of the scene render target
  103766. */
  103767. get samples(): number;
  103768. set samples(n: number);
  103769. /**
  103770. * Instanciates a prepass renderer
  103771. * @param scene The scene
  103772. */
  103773. constructor(scene: Scene);
  103774. private _initializeAttachments;
  103775. private _createCompositionEffect;
  103776. /**
  103777. * Indicates if rendering a prepass is supported
  103778. */
  103779. get isSupported(): boolean;
  103780. /**
  103781. * Sets the proper output textures to draw in the engine.
  103782. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103783. */
  103784. bindAttachmentsForEffect(effect: Effect): void;
  103785. /**
  103786. * @hidden
  103787. */
  103788. _beforeCameraDraw(): void;
  103789. /**
  103790. * @hidden
  103791. */
  103792. _afterCameraDraw(): void;
  103793. private _checkRTSize;
  103794. private _bindFrameBuffer;
  103795. /**
  103796. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103797. */
  103798. clear(): void;
  103799. private _setState;
  103800. /**
  103801. * Adds an effect configuration to the prepass.
  103802. * If an effect has already been added, it won't add it twice and will return the configuration
  103803. * already present.
  103804. * @param cfg the effect configuration
  103805. * @return the effect configuration now used by the prepass
  103806. */
  103807. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  103808. /**
  103809. * Returns the index of a texture in the multi render target texture array.
  103810. * @param type Texture type
  103811. * @return The index
  103812. */
  103813. getIndex(type: number): number;
  103814. private _enable;
  103815. private _disable;
  103816. private _resetLayout;
  103817. private _resetPostProcessChain;
  103818. private _bindPostProcessChain;
  103819. /**
  103820. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103821. */
  103822. markAsDirty(): void;
  103823. /**
  103824. * Enables a texture on the MultiRenderTarget for prepass
  103825. */
  103826. private _enableTextures;
  103827. private _update;
  103828. private _markAllMaterialsAsPrePassDirty;
  103829. /**
  103830. * Disposes the prepass renderer.
  103831. */
  103832. dispose(): void;
  103833. }
  103834. }
  103835. declare module BABYLON {
  103836. /**
  103837. * Size options for a post process
  103838. */
  103839. export type PostProcessOptions = {
  103840. width: number;
  103841. height: number;
  103842. };
  103843. /**
  103844. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103845. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103846. */
  103847. export class PostProcess {
  103848. /**
  103849. * Gets or sets the unique id of the post process
  103850. */
  103851. uniqueId: number;
  103852. /** Name of the PostProcess. */
  103853. name: string;
  103854. /**
  103855. * Width of the texture to apply the post process on
  103856. */
  103857. width: number;
  103858. /**
  103859. * Height of the texture to apply the post process on
  103860. */
  103861. height: number;
  103862. /**
  103863. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103864. */
  103865. nodeMaterialSource: Nullable<NodeMaterial>;
  103866. /**
  103867. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103868. * @hidden
  103869. */
  103870. _outputTexture: Nullable<InternalTexture>;
  103871. /**
  103872. * Sampling mode used by the shader
  103873. * See https://doc.babylonjs.com/classes/3.1/texture
  103874. */
  103875. renderTargetSamplingMode: number;
  103876. /**
  103877. * Clear color to use when screen clearing
  103878. */
  103879. clearColor: Color4;
  103880. /**
  103881. * If the buffer needs to be cleared before applying the post process. (default: true)
  103882. * Should be set to false if shader will overwrite all previous pixels.
  103883. */
  103884. autoClear: boolean;
  103885. /**
  103886. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  103887. */
  103888. alphaMode: number;
  103889. /**
  103890. * Sets the setAlphaBlendConstants of the babylon engine
  103891. */
  103892. alphaConstants: Color4;
  103893. /**
  103894. * Animations to be used for the post processing
  103895. */
  103896. animations: Animation[];
  103897. /**
  103898. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  103899. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  103900. */
  103901. enablePixelPerfectMode: boolean;
  103902. /**
  103903. * Force the postprocess to be applied without taking in account viewport
  103904. */
  103905. forceFullscreenViewport: boolean;
  103906. /**
  103907. * List of inspectable custom properties (used by the Inspector)
  103908. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103909. */
  103910. inspectableCustomProperties: IInspectable[];
  103911. /**
  103912. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  103913. *
  103914. * | Value | Type | Description |
  103915. * | ----- | ----------------------------------- | ----------- |
  103916. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  103917. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  103918. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  103919. *
  103920. */
  103921. scaleMode: number;
  103922. /**
  103923. * Force textures to be a power of two (default: false)
  103924. */
  103925. alwaysForcePOT: boolean;
  103926. private _samples;
  103927. /**
  103928. * Number of sample textures (default: 1)
  103929. */
  103930. get samples(): number;
  103931. set samples(n: number);
  103932. /**
  103933. * Modify the scale of the post process to be the same as the viewport (default: false)
  103934. */
  103935. adaptScaleToCurrentViewport: boolean;
  103936. private _camera;
  103937. protected _scene: Scene;
  103938. private _engine;
  103939. private _options;
  103940. private _reusable;
  103941. private _textureType;
  103942. private _textureFormat;
  103943. /**
  103944. * Smart array of input and output textures for the post process.
  103945. * @hidden
  103946. */
  103947. _textures: SmartArray<InternalTexture>;
  103948. /**
  103949. * The index in _textures that corresponds to the output texture.
  103950. * @hidden
  103951. */
  103952. _currentRenderTextureInd: number;
  103953. private _effect;
  103954. private _samplers;
  103955. private _fragmentUrl;
  103956. private _vertexUrl;
  103957. private _parameters;
  103958. private _scaleRatio;
  103959. protected _indexParameters: any;
  103960. private _shareOutputWithPostProcess;
  103961. private _texelSize;
  103962. private _forcedOutputTexture;
  103963. /**
  103964. * Prepass configuration in case this post process needs a texture from prepass
  103965. * @hidden
  103966. */
  103967. _prePassEffectConfiguration: PrePassEffectConfiguration;
  103968. /**
  103969. * Returns the fragment url or shader name used in the post process.
  103970. * @returns the fragment url or name in the shader store.
  103971. */
  103972. getEffectName(): string;
  103973. /**
  103974. * An event triggered when the postprocess is activated.
  103975. */
  103976. onActivateObservable: Observable<Camera>;
  103977. private _onActivateObserver;
  103978. /**
  103979. * A function that is added to the onActivateObservable
  103980. */
  103981. set onActivate(callback: Nullable<(camera: Camera) => void>);
  103982. /**
  103983. * An event triggered when the postprocess changes its size.
  103984. */
  103985. onSizeChangedObservable: Observable<PostProcess>;
  103986. private _onSizeChangedObserver;
  103987. /**
  103988. * A function that is added to the onSizeChangedObservable
  103989. */
  103990. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  103991. /**
  103992. * An event triggered when the postprocess applies its effect.
  103993. */
  103994. onApplyObservable: Observable<Effect>;
  103995. private _onApplyObserver;
  103996. /**
  103997. * A function that is added to the onApplyObservable
  103998. */
  103999. set onApply(callback: (effect: Effect) => void);
  104000. /**
  104001. * An event triggered before rendering the postprocess
  104002. */
  104003. onBeforeRenderObservable: Observable<Effect>;
  104004. private _onBeforeRenderObserver;
  104005. /**
  104006. * A function that is added to the onBeforeRenderObservable
  104007. */
  104008. set onBeforeRender(callback: (effect: Effect) => void);
  104009. /**
  104010. * An event triggered after rendering the postprocess
  104011. */
  104012. onAfterRenderObservable: Observable<Effect>;
  104013. private _onAfterRenderObserver;
  104014. /**
  104015. * A function that is added to the onAfterRenderObservable
  104016. */
  104017. set onAfterRender(callback: (efect: Effect) => void);
  104018. /**
  104019. * 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
  104020. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  104021. */
  104022. get inputTexture(): InternalTexture;
  104023. set inputTexture(value: InternalTexture);
  104024. /**
  104025. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  104026. * the only way to unset it is to use this function to restore its internal state
  104027. */
  104028. restoreDefaultInputTexture(): void;
  104029. /**
  104030. * Gets the camera which post process is applied to.
  104031. * @returns The camera the post process is applied to.
  104032. */
  104033. getCamera(): Camera;
  104034. /**
  104035. * Gets the texel size of the postprocess.
  104036. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  104037. */
  104038. get texelSize(): Vector2;
  104039. /**
  104040. * Creates a new instance PostProcess
  104041. * @param name The name of the PostProcess.
  104042. * @param fragmentUrl The url of the fragment shader to be used.
  104043. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  104044. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  104045. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104046. * @param camera The camera to apply the render pass to.
  104047. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104048. * @param engine The engine which the post process will be applied. (default: current engine)
  104049. * @param reusable If the post process can be reused on the same frame. (default: false)
  104050. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  104051. * @param textureType Type of textures used when performing the post process. (default: 0)
  104052. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  104053. * @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
  104054. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  104055. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  104056. */
  104057. 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);
  104058. /**
  104059. * Gets a string identifying the name of the class
  104060. * @returns "PostProcess" string
  104061. */
  104062. getClassName(): string;
  104063. /**
  104064. * Gets the engine which this post process belongs to.
  104065. * @returns The engine the post process was enabled with.
  104066. */
  104067. getEngine(): Engine;
  104068. /**
  104069. * The effect that is created when initializing the post process.
  104070. * @returns The created effect corresponding the the postprocess.
  104071. */
  104072. getEffect(): Effect;
  104073. /**
  104074. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  104075. * @param postProcess The post process to share the output with.
  104076. * @returns This post process.
  104077. */
  104078. shareOutputWith(postProcess: PostProcess): PostProcess;
  104079. /**
  104080. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  104081. * This should be called if the post process that shares output with this post process is disabled/disposed.
  104082. */
  104083. useOwnOutput(): void;
  104084. /**
  104085. * Updates the effect with the current post process compile time values and recompiles the shader.
  104086. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104087. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104088. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104089. * @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
  104090. * @param onCompiled Called when the shader has been compiled.
  104091. * @param onError Called if there is an error when compiling a shader.
  104092. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  104093. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  104094. */
  104095. 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;
  104096. /**
  104097. * The post process is reusable if it can be used multiple times within one frame.
  104098. * @returns If the post process is reusable
  104099. */
  104100. isReusable(): boolean;
  104101. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  104102. markTextureDirty(): void;
  104103. /**
  104104. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  104105. * 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.
  104106. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  104107. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  104108. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  104109. * @returns The target texture that was bound to be written to.
  104110. */
  104111. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  104112. /**
  104113. * If the post process is supported.
  104114. */
  104115. get isSupported(): boolean;
  104116. /**
  104117. * The aspect ratio of the output texture.
  104118. */
  104119. get aspectRatio(): number;
  104120. /**
  104121. * Get a value indicating if the post-process is ready to be used
  104122. * @returns true if the post-process is ready (shader is compiled)
  104123. */
  104124. isReady(): boolean;
  104125. /**
  104126. * Binds all textures and uniforms to the shader, this will be run on every pass.
  104127. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  104128. */
  104129. apply(): Nullable<Effect>;
  104130. private _disposeTextures;
  104131. /**
  104132. * Sets the required values to the prepass renderer.
  104133. * @param prePassRenderer defines the prepass renderer to setup.
  104134. * @returns true if the pre pass is needed.
  104135. */
  104136. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104137. /**
  104138. * Disposes the post process.
  104139. * @param camera The camera to dispose the post process on.
  104140. */
  104141. dispose(camera?: Camera): void;
  104142. /**
  104143. * Serializes the particle system to a JSON object
  104144. * @returns the JSON object
  104145. */
  104146. serialize(): any;
  104147. /**
  104148. * Creates a material from parsed material data
  104149. * @param parsedPostProcess defines parsed post process data
  104150. * @param scene defines the hosting scene
  104151. * @param rootUrl defines the root URL to use to load textures
  104152. * @returns a new post process
  104153. */
  104154. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  104155. }
  104156. }
  104157. declare module BABYLON {
  104158. /** @hidden */
  104159. export var kernelBlurVaryingDeclaration: {
  104160. name: string;
  104161. shader: string;
  104162. };
  104163. }
  104164. declare module BABYLON {
  104165. /** @hidden */
  104166. export var kernelBlurFragment: {
  104167. name: string;
  104168. shader: string;
  104169. };
  104170. }
  104171. declare module BABYLON {
  104172. /** @hidden */
  104173. export var kernelBlurFragment2: {
  104174. name: string;
  104175. shader: string;
  104176. };
  104177. }
  104178. declare module BABYLON {
  104179. /** @hidden */
  104180. export var kernelBlurPixelShader: {
  104181. name: string;
  104182. shader: string;
  104183. };
  104184. }
  104185. declare module BABYLON {
  104186. /** @hidden */
  104187. export var kernelBlurVertex: {
  104188. name: string;
  104189. shader: string;
  104190. };
  104191. }
  104192. declare module BABYLON {
  104193. /** @hidden */
  104194. export var kernelBlurVertexShader: {
  104195. name: string;
  104196. shader: string;
  104197. };
  104198. }
  104199. declare module BABYLON {
  104200. /**
  104201. * The Blur Post Process which blurs an image based on a kernel and direction.
  104202. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  104203. */
  104204. export class BlurPostProcess extends PostProcess {
  104205. private blockCompilation;
  104206. protected _kernel: number;
  104207. protected _idealKernel: number;
  104208. protected _packedFloat: boolean;
  104209. private _staticDefines;
  104210. /** The direction in which to blur the image. */
  104211. direction: Vector2;
  104212. /**
  104213. * Sets the length in pixels of the blur sample region
  104214. */
  104215. set kernel(v: number);
  104216. /**
  104217. * Gets the length in pixels of the blur sample region
  104218. */
  104219. get kernel(): number;
  104220. /**
  104221. * Sets wether or not the blur needs to unpack/repack floats
  104222. */
  104223. set packedFloat(v: boolean);
  104224. /**
  104225. * Gets wether or not the blur is unpacking/repacking floats
  104226. */
  104227. get packedFloat(): boolean;
  104228. /**
  104229. * Gets a string identifying the name of the class
  104230. * @returns "BlurPostProcess" string
  104231. */
  104232. getClassName(): string;
  104233. /**
  104234. * Creates a new instance BlurPostProcess
  104235. * @param name The name of the effect.
  104236. * @param direction The direction in which to blur the image.
  104237. * @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.
  104238. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104239. * @param camera The camera to apply the render pass to.
  104240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104241. * @param engine The engine which the post process will be applied. (default: current engine)
  104242. * @param reusable If the post process can be reused on the same frame. (default: false)
  104243. * @param textureType Type of textures used when performing the post process. (default: 0)
  104244. * @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)
  104245. */
  104246. 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);
  104247. /**
  104248. * Updates the effect with the current post process compile time values and recompiles the shader.
  104249. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104250. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104251. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104252. * @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
  104253. * @param onCompiled Called when the shader has been compiled.
  104254. * @param onError Called if there is an error when compiling a shader.
  104255. */
  104256. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104257. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104258. /**
  104259. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  104260. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  104261. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  104262. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  104263. * The gaps between physical kernels are compensated for in the weighting of the samples
  104264. * @param idealKernel Ideal blur kernel.
  104265. * @return Nearest best kernel.
  104266. */
  104267. protected _nearestBestKernel(idealKernel: number): number;
  104268. /**
  104269. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  104270. * @param x The point on the Gaussian distribution to sample.
  104271. * @return the value of the Gaussian function at x.
  104272. */
  104273. protected _gaussianWeight(x: number): number;
  104274. /**
  104275. * Generates a string that can be used as a floating point number in GLSL.
  104276. * @param x Value to print.
  104277. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  104278. * @return GLSL float string.
  104279. */
  104280. protected _glslFloat(x: number, decimalFigures?: number): string;
  104281. /** @hidden */
  104282. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  104283. }
  104284. }
  104285. declare module BABYLON {
  104286. /**
  104287. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104288. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104289. * You can then easily use it as a reflectionTexture on a flat surface.
  104290. * In case the surface is not a plane, please consider relying on reflection probes.
  104291. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104292. */
  104293. export class MirrorTexture extends RenderTargetTexture {
  104294. private scene;
  104295. /**
  104296. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  104297. * 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.
  104298. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104299. */
  104300. mirrorPlane: Plane;
  104301. /**
  104302. * Define the blur ratio used to blur the reflection if needed.
  104303. */
  104304. set blurRatio(value: number);
  104305. get blurRatio(): number;
  104306. /**
  104307. * Define the adaptive blur kernel used to blur the reflection if needed.
  104308. * This will autocompute the closest best match for the `blurKernel`
  104309. */
  104310. set adaptiveBlurKernel(value: number);
  104311. /**
  104312. * Define the blur kernel used to blur the reflection if needed.
  104313. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104314. */
  104315. set blurKernel(value: number);
  104316. /**
  104317. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  104318. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104319. */
  104320. set blurKernelX(value: number);
  104321. get blurKernelX(): number;
  104322. /**
  104323. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  104324. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104325. */
  104326. set blurKernelY(value: number);
  104327. get blurKernelY(): number;
  104328. private _autoComputeBlurKernel;
  104329. protected _onRatioRescale(): void;
  104330. private _updateGammaSpace;
  104331. private _imageProcessingConfigChangeObserver;
  104332. private _transformMatrix;
  104333. private _mirrorMatrix;
  104334. private _savedViewMatrix;
  104335. private _blurX;
  104336. private _blurY;
  104337. private _adaptiveBlurKernel;
  104338. private _blurKernelX;
  104339. private _blurKernelY;
  104340. private _blurRatio;
  104341. /**
  104342. * Instantiates a Mirror Texture.
  104343. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104344. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104345. * You can then easily use it as a reflectionTexture on a flat surface.
  104346. * In case the surface is not a plane, please consider relying on reflection probes.
  104347. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104348. * @param name
  104349. * @param size
  104350. * @param scene
  104351. * @param generateMipMaps
  104352. * @param type
  104353. * @param samplingMode
  104354. * @param generateDepthBuffer
  104355. */
  104356. constructor(name: string, size: number | {
  104357. width: number;
  104358. height: number;
  104359. } | {
  104360. ratio: number;
  104361. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  104362. private _preparePostProcesses;
  104363. /**
  104364. * Clone the mirror texture.
  104365. * @returns the cloned texture
  104366. */
  104367. clone(): MirrorTexture;
  104368. /**
  104369. * Serialize the texture to a JSON representation you could use in Parse later on
  104370. * @returns the serialized JSON representation
  104371. */
  104372. serialize(): any;
  104373. /**
  104374. * Dispose the texture and release its associated resources.
  104375. */
  104376. dispose(): void;
  104377. }
  104378. }
  104379. declare module BABYLON {
  104380. /**
  104381. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104382. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104383. */
  104384. export class Texture extends BaseTexture {
  104385. /**
  104386. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  104387. */
  104388. static SerializeBuffers: boolean;
  104389. /** @hidden */
  104390. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  104391. /** @hidden */
  104392. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  104393. /** @hidden */
  104394. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  104395. /** nearest is mag = nearest and min = nearest and mip = linear */
  104396. static readonly NEAREST_SAMPLINGMODE: number;
  104397. /** nearest is mag = nearest and min = nearest and mip = linear */
  104398. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  104399. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104400. static readonly BILINEAR_SAMPLINGMODE: number;
  104401. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104402. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  104403. /** Trilinear is mag = linear and min = linear and mip = linear */
  104404. static readonly TRILINEAR_SAMPLINGMODE: number;
  104405. /** Trilinear is mag = linear and min = linear and mip = linear */
  104406. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  104407. /** mag = nearest and min = nearest and mip = nearest */
  104408. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  104409. /** mag = nearest and min = linear and mip = nearest */
  104410. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  104411. /** mag = nearest and min = linear and mip = linear */
  104412. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  104413. /** mag = nearest and min = linear and mip = none */
  104414. static readonly NEAREST_LINEAR: number;
  104415. /** mag = nearest and min = nearest and mip = none */
  104416. static readonly NEAREST_NEAREST: number;
  104417. /** mag = linear and min = nearest and mip = nearest */
  104418. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  104419. /** mag = linear and min = nearest and mip = linear */
  104420. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  104421. /** mag = linear and min = linear and mip = none */
  104422. static readonly LINEAR_LINEAR: number;
  104423. /** mag = linear and min = nearest and mip = none */
  104424. static readonly LINEAR_NEAREST: number;
  104425. /** Explicit coordinates mode */
  104426. static readonly EXPLICIT_MODE: number;
  104427. /** Spherical coordinates mode */
  104428. static readonly SPHERICAL_MODE: number;
  104429. /** Planar coordinates mode */
  104430. static readonly PLANAR_MODE: number;
  104431. /** Cubic coordinates mode */
  104432. static readonly CUBIC_MODE: number;
  104433. /** Projection coordinates mode */
  104434. static readonly PROJECTION_MODE: number;
  104435. /** Inverse Cubic coordinates mode */
  104436. static readonly SKYBOX_MODE: number;
  104437. /** Inverse Cubic coordinates mode */
  104438. static readonly INVCUBIC_MODE: number;
  104439. /** Equirectangular coordinates mode */
  104440. static readonly EQUIRECTANGULAR_MODE: number;
  104441. /** Equirectangular Fixed coordinates mode */
  104442. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  104443. /** Equirectangular Fixed Mirrored coordinates mode */
  104444. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  104445. /** Texture is not repeating outside of 0..1 UVs */
  104446. static readonly CLAMP_ADDRESSMODE: number;
  104447. /** Texture is repeating outside of 0..1 UVs */
  104448. static readonly WRAP_ADDRESSMODE: number;
  104449. /** Texture is repeating and mirrored */
  104450. static readonly MIRROR_ADDRESSMODE: number;
  104451. /**
  104452. * 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
  104453. */
  104454. static UseSerializedUrlIfAny: boolean;
  104455. /**
  104456. * Define the url of the texture.
  104457. */
  104458. url: Nullable<string>;
  104459. /**
  104460. * Define an offset on the texture to offset the u coordinates of the UVs
  104461. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104462. */
  104463. uOffset: number;
  104464. /**
  104465. * Define an offset on the texture to offset the v coordinates of the UVs
  104466. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104467. */
  104468. vOffset: number;
  104469. /**
  104470. * Define an offset on the texture to scale the u coordinates of the UVs
  104471. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104472. */
  104473. uScale: number;
  104474. /**
  104475. * Define an offset on the texture to scale the v coordinates of the UVs
  104476. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104477. */
  104478. vScale: number;
  104479. /**
  104480. * Define an offset on the texture to rotate around the u coordinates of the UVs
  104481. * @see https://doc.babylonjs.com/how_to/more_materials
  104482. */
  104483. uAng: number;
  104484. /**
  104485. * Define an offset on the texture to rotate around the v coordinates of the UVs
  104486. * @see https://doc.babylonjs.com/how_to/more_materials
  104487. */
  104488. vAng: number;
  104489. /**
  104490. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  104491. * @see https://doc.babylonjs.com/how_to/more_materials
  104492. */
  104493. wAng: number;
  104494. /**
  104495. * Defines the center of rotation (U)
  104496. */
  104497. uRotationCenter: number;
  104498. /**
  104499. * Defines the center of rotation (V)
  104500. */
  104501. vRotationCenter: number;
  104502. /**
  104503. * Defines the center of rotation (W)
  104504. */
  104505. wRotationCenter: number;
  104506. /**
  104507. * Are mip maps generated for this texture or not.
  104508. */
  104509. get noMipmap(): boolean;
  104510. /**
  104511. * List of inspectable custom properties (used by the Inspector)
  104512. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104513. */
  104514. inspectableCustomProperties: Nullable<IInspectable[]>;
  104515. private _noMipmap;
  104516. /** @hidden */
  104517. _invertY: boolean;
  104518. private _rowGenerationMatrix;
  104519. private _cachedTextureMatrix;
  104520. private _projectionModeMatrix;
  104521. private _t0;
  104522. private _t1;
  104523. private _t2;
  104524. private _cachedUOffset;
  104525. private _cachedVOffset;
  104526. private _cachedUScale;
  104527. private _cachedVScale;
  104528. private _cachedUAng;
  104529. private _cachedVAng;
  104530. private _cachedWAng;
  104531. private _cachedProjectionMatrixId;
  104532. private _cachedCoordinatesMode;
  104533. /** @hidden */
  104534. protected _initialSamplingMode: number;
  104535. /** @hidden */
  104536. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  104537. private _deleteBuffer;
  104538. protected _format: Nullable<number>;
  104539. private _delayedOnLoad;
  104540. private _delayedOnError;
  104541. private _mimeType?;
  104542. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  104543. get mimeType(): string | undefined;
  104544. /**
  104545. * Observable triggered once the texture has been loaded.
  104546. */
  104547. onLoadObservable: Observable<Texture>;
  104548. protected _isBlocking: boolean;
  104549. /**
  104550. * Is the texture preventing material to render while loading.
  104551. * If false, a default texture will be used instead of the loading one during the preparation step.
  104552. */
  104553. set isBlocking(value: boolean);
  104554. get isBlocking(): boolean;
  104555. /**
  104556. * Get the current sampling mode associated with the texture.
  104557. */
  104558. get samplingMode(): number;
  104559. /**
  104560. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  104561. */
  104562. get invertY(): boolean;
  104563. /**
  104564. * Instantiates a new texture.
  104565. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104566. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104567. * @param url defines the url of the picture to load as a texture
  104568. * @param sceneOrEngine defines the scene or engine the texture will belong to
  104569. * @param noMipmap defines if the texture will require mip maps or not
  104570. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  104571. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104572. * @param onLoad defines a callback triggered when the texture has been loaded
  104573. * @param onError defines a callback triggered when an error occurred during the loading session
  104574. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  104575. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  104576. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104577. * @param mimeType defines an optional mime type information
  104578. */
  104579. 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);
  104580. /**
  104581. * Update the url (and optional buffer) of this texture if url was null during construction.
  104582. * @param url the url of the texture
  104583. * @param buffer the buffer of the texture (defaults to null)
  104584. * @param onLoad callback called when the texture is loaded (defaults to null)
  104585. */
  104586. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  104587. /**
  104588. * Finish the loading sequence of a texture flagged as delayed load.
  104589. * @hidden
  104590. */
  104591. delayLoad(): void;
  104592. private _prepareRowForTextureGeneration;
  104593. /**
  104594. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  104595. * @returns the transform matrix of the texture.
  104596. */
  104597. getTextureMatrix(uBase?: number): Matrix;
  104598. /**
  104599. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  104600. * @returns The reflection texture transform
  104601. */
  104602. getReflectionTextureMatrix(): Matrix;
  104603. /**
  104604. * Clones the texture.
  104605. * @returns the cloned texture
  104606. */
  104607. clone(): Texture;
  104608. /**
  104609. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104610. * @returns The JSON representation of the texture
  104611. */
  104612. serialize(): any;
  104613. /**
  104614. * Get the current class name of the texture useful for serialization or dynamic coding.
  104615. * @returns "Texture"
  104616. */
  104617. getClassName(): string;
  104618. /**
  104619. * Dispose the texture and release its associated resources.
  104620. */
  104621. dispose(): void;
  104622. /**
  104623. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  104624. * @param parsedTexture Define the JSON representation of the texture
  104625. * @param scene Define the scene the parsed texture should be instantiated in
  104626. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104627. * @returns The parsed texture if successful
  104628. */
  104629. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  104630. /**
  104631. * Creates a texture from its base 64 representation.
  104632. * @param data Define the base64 payload without the data: prefix
  104633. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104634. * @param scene Define the scene the texture should belong to
  104635. * @param noMipmap Forces the texture to not create mip map information if true
  104636. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104637. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104638. * @param onLoad define a callback triggered when the texture has been loaded
  104639. * @param onError define a callback triggered when an error occurred during the loading session
  104640. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104641. * @returns the created texture
  104642. */
  104643. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  104644. /**
  104645. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  104646. * @param data Define the base64 payload without the data: prefix
  104647. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104648. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  104649. * @param scene Define the scene the texture should belong to
  104650. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  104651. * @param noMipmap Forces the texture to not create mip map information if true
  104652. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104653. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104654. * @param onLoad define a callback triggered when the texture has been loaded
  104655. * @param onError define a callback triggered when an error occurred during the loading session
  104656. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104657. * @returns the created texture
  104658. */
  104659. 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;
  104660. }
  104661. }
  104662. declare module BABYLON {
  104663. /**
  104664. * PostProcessManager is used to manage one or more post processes or post process pipelines
  104665. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  104666. */
  104667. export class PostProcessManager {
  104668. private _scene;
  104669. private _indexBuffer;
  104670. private _vertexBuffers;
  104671. /**
  104672. * Creates a new instance PostProcess
  104673. * @param scene The scene that the post process is associated with.
  104674. */
  104675. constructor(scene: Scene);
  104676. private _prepareBuffers;
  104677. private _buildIndexBuffer;
  104678. /**
  104679. * Rebuilds the vertex buffers of the manager.
  104680. * @hidden
  104681. */
  104682. _rebuild(): void;
  104683. /**
  104684. * Prepares a frame to be run through a post process.
  104685. * @param sourceTexture The input texture to the post procesess. (default: null)
  104686. * @param postProcesses An array of post processes to be run. (default: null)
  104687. * @returns True if the post processes were able to be run.
  104688. * @hidden
  104689. */
  104690. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  104691. /**
  104692. * Manually render a set of post processes to a texture.
  104693. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  104694. * @param postProcesses An array of post processes to be run.
  104695. * @param targetTexture The target texture to render to.
  104696. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  104697. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  104698. * @param lodLevel defines which lod of the texture to render to
  104699. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  104700. */
  104701. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  104702. /**
  104703. * Finalize the result of the output of the postprocesses.
  104704. * @param doNotPresent If true the result will not be displayed to the screen.
  104705. * @param targetTexture The target texture to render to.
  104706. * @param faceIndex The index of the face to bind the target texture to.
  104707. * @param postProcesses The array of post processes to render.
  104708. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  104709. * @hidden
  104710. */
  104711. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  104712. /**
  104713. * Disposes of the post process manager.
  104714. */
  104715. dispose(): void;
  104716. }
  104717. }
  104718. declare module BABYLON {
  104719. /**
  104720. * This Helps creating a texture that will be created from a camera in your scene.
  104721. * It is basically a dynamic texture that could be used to create special effects for instance.
  104722. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  104723. */
  104724. export class RenderTargetTexture extends Texture {
  104725. /**
  104726. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  104727. */
  104728. static readonly REFRESHRATE_RENDER_ONCE: number;
  104729. /**
  104730. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  104731. */
  104732. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  104733. /**
  104734. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  104735. * the central point of your effect and can save a lot of performances.
  104736. */
  104737. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  104738. /**
  104739. * Use this predicate to dynamically define the list of mesh you want to render.
  104740. * If set, the renderList property will be overwritten.
  104741. */
  104742. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  104743. private _renderList;
  104744. /**
  104745. * Use this list to define the list of mesh you want to render.
  104746. */
  104747. get renderList(): Nullable<Array<AbstractMesh>>;
  104748. set renderList(value: Nullable<Array<AbstractMesh>>);
  104749. /**
  104750. * Use this function to overload the renderList array at rendering time.
  104751. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  104752. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  104753. * the cube (if the RTT is a cube, else layerOrFace=0).
  104754. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  104755. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  104756. * hold dummy elements!
  104757. */
  104758. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  104759. private _hookArray;
  104760. /**
  104761. * Define if particles should be rendered in your texture.
  104762. */
  104763. renderParticles: boolean;
  104764. /**
  104765. * Define if sprites should be rendered in your texture.
  104766. */
  104767. renderSprites: boolean;
  104768. /**
  104769. * Define the camera used to render the texture.
  104770. */
  104771. activeCamera: Nullable<Camera>;
  104772. /**
  104773. * Override the mesh isReady function with your own one.
  104774. */
  104775. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  104776. /**
  104777. * Override the render function of the texture with your own one.
  104778. */
  104779. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  104780. /**
  104781. * Define if camera post processes should be use while rendering the texture.
  104782. */
  104783. useCameraPostProcesses: boolean;
  104784. /**
  104785. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  104786. */
  104787. ignoreCameraViewport: boolean;
  104788. private _postProcessManager;
  104789. private _postProcesses;
  104790. private _resizeObserver;
  104791. /**
  104792. * An event triggered when the texture is unbind.
  104793. */
  104794. onBeforeBindObservable: Observable<RenderTargetTexture>;
  104795. /**
  104796. * An event triggered when the texture is unbind.
  104797. */
  104798. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  104799. private _onAfterUnbindObserver;
  104800. /**
  104801. * Set a after unbind callback in the texture.
  104802. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  104803. */
  104804. set onAfterUnbind(callback: () => void);
  104805. /**
  104806. * An event triggered before rendering the texture
  104807. */
  104808. onBeforeRenderObservable: Observable<number>;
  104809. private _onBeforeRenderObserver;
  104810. /**
  104811. * Set a before render callback in the texture.
  104812. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  104813. */
  104814. set onBeforeRender(callback: (faceIndex: number) => void);
  104815. /**
  104816. * An event triggered after rendering the texture
  104817. */
  104818. onAfterRenderObservable: Observable<number>;
  104819. private _onAfterRenderObserver;
  104820. /**
  104821. * Set a after render callback in the texture.
  104822. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  104823. */
  104824. set onAfterRender(callback: (faceIndex: number) => void);
  104825. /**
  104826. * An event triggered after the texture clear
  104827. */
  104828. onClearObservable: Observable<Engine>;
  104829. private _onClearObserver;
  104830. /**
  104831. * Set a clear callback in the texture.
  104832. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  104833. */
  104834. set onClear(callback: (Engine: Engine) => void);
  104835. /**
  104836. * An event triggered when the texture is resized.
  104837. */
  104838. onResizeObservable: Observable<RenderTargetTexture>;
  104839. /**
  104840. * Define the clear color of the Render Target if it should be different from the scene.
  104841. */
  104842. clearColor: Color4;
  104843. protected _size: number | {
  104844. width: number;
  104845. height: number;
  104846. layers?: number;
  104847. };
  104848. protected _initialSizeParameter: number | {
  104849. width: number;
  104850. height: number;
  104851. } | {
  104852. ratio: number;
  104853. };
  104854. protected _sizeRatio: Nullable<number>;
  104855. /** @hidden */
  104856. _generateMipMaps: boolean;
  104857. protected _renderingManager: RenderingManager;
  104858. /** @hidden */
  104859. _waitingRenderList?: string[];
  104860. protected _doNotChangeAspectRatio: boolean;
  104861. protected _currentRefreshId: number;
  104862. protected _refreshRate: number;
  104863. protected _textureMatrix: Matrix;
  104864. protected _samples: number;
  104865. protected _renderTargetOptions: RenderTargetCreationOptions;
  104866. /**
  104867. * Gets render target creation options that were used.
  104868. */
  104869. get renderTargetOptions(): RenderTargetCreationOptions;
  104870. protected _onRatioRescale(): void;
  104871. /**
  104872. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  104873. * It must define where the camera used to render the texture is set
  104874. */
  104875. boundingBoxPosition: Vector3;
  104876. private _boundingBoxSize;
  104877. /**
  104878. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  104879. * When defined, the cubemap will switch to local mode
  104880. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104881. * @example https://www.babylonjs-playground.com/#RNASML
  104882. */
  104883. set boundingBoxSize(value: Vector3);
  104884. get boundingBoxSize(): Vector3;
  104885. /**
  104886. * In case the RTT has been created with a depth texture, get the associated
  104887. * depth texture.
  104888. * Otherwise, return null.
  104889. */
  104890. get depthStencilTexture(): Nullable<InternalTexture>;
  104891. /**
  104892. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  104893. * or used a shadow, depth texture...
  104894. * @param name The friendly name of the texture
  104895. * @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)
  104896. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  104897. * @param generateMipMaps True if mip maps need to be generated after render.
  104898. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  104899. * @param type The type of the buffer in the RTT (int, half float, float...)
  104900. * @param isCube True if a cube texture needs to be created
  104901. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  104902. * @param generateDepthBuffer True to generate a depth buffer
  104903. * @param generateStencilBuffer True to generate a stencil buffer
  104904. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  104905. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  104906. * @param delayAllocation if the texture allocation should be delayed (default: false)
  104907. */
  104908. constructor(name: string, size: number | {
  104909. width: number;
  104910. height: number;
  104911. layers?: number;
  104912. } | {
  104913. ratio: number;
  104914. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  104915. /**
  104916. * Creates a depth stencil texture.
  104917. * This is only available in WebGL 2 or with the depth texture extension available.
  104918. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  104919. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  104920. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  104921. */
  104922. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  104923. private _processSizeParameter;
  104924. /**
  104925. * Define the number of samples to use in case of MSAA.
  104926. * It defaults to one meaning no MSAA has been enabled.
  104927. */
  104928. get samples(): number;
  104929. set samples(value: number);
  104930. /**
  104931. * Resets the refresh counter of the texture and start bak from scratch.
  104932. * Could be useful to regenerate the texture if it is setup to render only once.
  104933. */
  104934. resetRefreshCounter(): void;
  104935. /**
  104936. * Define the refresh rate of the texture or the rendering frequency.
  104937. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  104938. */
  104939. get refreshRate(): number;
  104940. set refreshRate(value: number);
  104941. /**
  104942. * Adds a post process to the render target rendering passes.
  104943. * @param postProcess define the post process to add
  104944. */
  104945. addPostProcess(postProcess: PostProcess): void;
  104946. /**
  104947. * Clear all the post processes attached to the render target
  104948. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  104949. */
  104950. clearPostProcesses(dispose?: boolean): void;
  104951. /**
  104952. * Remove one of the post process from the list of attached post processes to the texture
  104953. * @param postProcess define the post process to remove from the list
  104954. */
  104955. removePostProcess(postProcess: PostProcess): void;
  104956. /** @hidden */
  104957. _shouldRender(): boolean;
  104958. /**
  104959. * Gets the actual render size of the texture.
  104960. * @returns the width of the render size
  104961. */
  104962. getRenderSize(): number;
  104963. /**
  104964. * Gets the actual render width of the texture.
  104965. * @returns the width of the render size
  104966. */
  104967. getRenderWidth(): number;
  104968. /**
  104969. * Gets the actual render height of the texture.
  104970. * @returns the height of the render size
  104971. */
  104972. getRenderHeight(): number;
  104973. /**
  104974. * Gets the actual number of layers of the texture.
  104975. * @returns the number of layers
  104976. */
  104977. getRenderLayers(): number;
  104978. /**
  104979. * Get if the texture can be rescaled or not.
  104980. */
  104981. get canRescale(): boolean;
  104982. /**
  104983. * Resize the texture using a ratio.
  104984. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  104985. */
  104986. scale(ratio: number): void;
  104987. /**
  104988. * Get the texture reflection matrix used to rotate/transform the reflection.
  104989. * @returns the reflection matrix
  104990. */
  104991. getReflectionTextureMatrix(): Matrix;
  104992. /**
  104993. * Resize the texture to a new desired size.
  104994. * Be carrefull as it will recreate all the data in the new texture.
  104995. * @param size Define the new size. It can be:
  104996. * - a number for squared texture,
  104997. * - an object containing { width: number, height: number }
  104998. * - or an object containing a ratio { ratio: number }
  104999. */
  105000. resize(size: number | {
  105001. width: number;
  105002. height: number;
  105003. } | {
  105004. ratio: number;
  105005. }): void;
  105006. private _defaultRenderListPrepared;
  105007. /**
  105008. * Renders all the objects from the render list into the texture.
  105009. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  105010. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  105011. */
  105012. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  105013. private _bestReflectionRenderTargetDimension;
  105014. private _prepareRenderingManager;
  105015. /**
  105016. * @hidden
  105017. * @param faceIndex face index to bind to if this is a cubetexture
  105018. * @param layer defines the index of the texture to bind in the array
  105019. */
  105020. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  105021. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  105022. private renderToTarget;
  105023. /**
  105024. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  105025. * This allowed control for front to back rendering or reversly depending of the special needs.
  105026. *
  105027. * @param renderingGroupId The rendering group id corresponding to its index
  105028. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  105029. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  105030. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  105031. */
  105032. 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;
  105033. /**
  105034. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  105035. *
  105036. * @param renderingGroupId The rendering group id corresponding to its index
  105037. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105038. */
  105039. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  105040. /**
  105041. * Clones the texture.
  105042. * @returns the cloned texture
  105043. */
  105044. clone(): RenderTargetTexture;
  105045. /**
  105046. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  105047. * @returns The JSON representation of the texture
  105048. */
  105049. serialize(): any;
  105050. /**
  105051. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  105052. */
  105053. disposeFramebufferObjects(): void;
  105054. /**
  105055. * Dispose the texture and release its associated resources.
  105056. */
  105057. dispose(): void;
  105058. /** @hidden */
  105059. _rebuild(): void;
  105060. /**
  105061. * Clear the info related to rendering groups preventing retention point in material dispose.
  105062. */
  105063. freeRenderingGroups(): void;
  105064. /**
  105065. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  105066. * @returns the view count
  105067. */
  105068. getViewCount(): number;
  105069. }
  105070. }
  105071. declare module BABYLON {
  105072. /**
  105073. * Class used to manipulate GUIDs
  105074. */
  105075. export class GUID {
  105076. /**
  105077. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105078. * Be aware Math.random() could cause collisions, but:
  105079. * "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"
  105080. * @returns a pseudo random id
  105081. */
  105082. static RandomId(): string;
  105083. }
  105084. }
  105085. declare module BABYLON {
  105086. /**
  105087. * Options to be used when creating a shadow depth material
  105088. */
  105089. export interface IIOptionShadowDepthMaterial {
  105090. /** Variables in the vertex shader code that need to have their names remapped.
  105091. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  105092. * "var_name" should be either: worldPos or vNormalW
  105093. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  105094. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  105095. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  105096. */
  105097. remappedVariables?: string[];
  105098. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  105099. standalone?: boolean;
  105100. }
  105101. /**
  105102. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  105103. */
  105104. export class ShadowDepthWrapper {
  105105. private _scene;
  105106. private _options?;
  105107. private _baseMaterial;
  105108. private _onEffectCreatedObserver;
  105109. private _subMeshToEffect;
  105110. private _subMeshToDepthEffect;
  105111. private _meshes;
  105112. /** @hidden */
  105113. _matriceNames: any;
  105114. /** Gets the standalone status of the wrapper */
  105115. get standalone(): boolean;
  105116. /** Gets the base material the wrapper is built upon */
  105117. get baseMaterial(): Material;
  105118. /**
  105119. * Instantiate a new shadow depth wrapper.
  105120. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  105121. * generate the shadow depth map. For more information, please refer to the documentation:
  105122. * https://doc.babylonjs.com/babylon101/shadows
  105123. * @param baseMaterial Material to wrap
  105124. * @param scene Define the scene the material belongs to
  105125. * @param options Options used to create the wrapper
  105126. */
  105127. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  105128. /**
  105129. * Gets the effect to use to generate the depth map
  105130. * @param subMesh subMesh to get the effect for
  105131. * @param shadowGenerator shadow generator to get the effect for
  105132. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  105133. */
  105134. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  105135. /**
  105136. * Specifies that the submesh is ready to be used for depth rendering
  105137. * @param subMesh submesh to check
  105138. * @param defines the list of defines to take into account when checking the effect
  105139. * @param shadowGenerator combined with subMesh, it defines the effect to check
  105140. * @param useInstances specifies that instances should be used
  105141. * @returns a boolean indicating that the submesh is ready or not
  105142. */
  105143. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  105144. /**
  105145. * Disposes the resources
  105146. */
  105147. dispose(): void;
  105148. private _makeEffect;
  105149. }
  105150. }
  105151. declare module BABYLON {
  105152. /**
  105153. * Options for compiling materials.
  105154. */
  105155. export interface IMaterialCompilationOptions {
  105156. /**
  105157. * Defines whether clip planes are enabled.
  105158. */
  105159. clipPlane: boolean;
  105160. /**
  105161. * Defines whether instances are enabled.
  105162. */
  105163. useInstances: boolean;
  105164. }
  105165. /**
  105166. * Options passed when calling customShaderNameResolve
  105167. */
  105168. export interface ICustomShaderNameResolveOptions {
  105169. /**
  105170. * 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
  105171. */
  105172. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  105173. }
  105174. /**
  105175. * Base class for the main features of a material in Babylon.js
  105176. */
  105177. export class Material implements IAnimatable {
  105178. /**
  105179. * Returns the triangle fill mode
  105180. */
  105181. static readonly TriangleFillMode: number;
  105182. /**
  105183. * Returns the wireframe mode
  105184. */
  105185. static readonly WireFrameFillMode: number;
  105186. /**
  105187. * Returns the point fill mode
  105188. */
  105189. static readonly PointFillMode: number;
  105190. /**
  105191. * Returns the point list draw mode
  105192. */
  105193. static readonly PointListDrawMode: number;
  105194. /**
  105195. * Returns the line list draw mode
  105196. */
  105197. static readonly LineListDrawMode: number;
  105198. /**
  105199. * Returns the line loop draw mode
  105200. */
  105201. static readonly LineLoopDrawMode: number;
  105202. /**
  105203. * Returns the line strip draw mode
  105204. */
  105205. static readonly LineStripDrawMode: number;
  105206. /**
  105207. * Returns the triangle strip draw mode
  105208. */
  105209. static readonly TriangleStripDrawMode: number;
  105210. /**
  105211. * Returns the triangle fan draw mode
  105212. */
  105213. static readonly TriangleFanDrawMode: number;
  105214. /**
  105215. * Stores the clock-wise side orientation
  105216. */
  105217. static readonly ClockWiseSideOrientation: number;
  105218. /**
  105219. * Stores the counter clock-wise side orientation
  105220. */
  105221. static readonly CounterClockWiseSideOrientation: number;
  105222. /**
  105223. * The dirty texture flag value
  105224. */
  105225. static readonly TextureDirtyFlag: number;
  105226. /**
  105227. * The dirty light flag value
  105228. */
  105229. static readonly LightDirtyFlag: number;
  105230. /**
  105231. * The dirty fresnel flag value
  105232. */
  105233. static readonly FresnelDirtyFlag: number;
  105234. /**
  105235. * The dirty attribute flag value
  105236. */
  105237. static readonly AttributesDirtyFlag: number;
  105238. /**
  105239. * The dirty misc flag value
  105240. */
  105241. static readonly MiscDirtyFlag: number;
  105242. /**
  105243. * The dirty prepass flag value
  105244. */
  105245. static readonly PrePassDirtyFlag: number;
  105246. /**
  105247. * The all dirty flag value
  105248. */
  105249. static readonly AllDirtyFlag: number;
  105250. /**
  105251. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105252. */
  105253. static readonly MATERIAL_OPAQUE: number;
  105254. /**
  105255. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105256. */
  105257. static readonly MATERIAL_ALPHATEST: number;
  105258. /**
  105259. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105260. */
  105261. static readonly MATERIAL_ALPHABLEND: number;
  105262. /**
  105263. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105264. * They are also discarded below the alpha cutoff threshold to improve performances.
  105265. */
  105266. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  105267. /**
  105268. * The Whiteout method is used to blend normals.
  105269. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  105270. */
  105271. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  105272. /**
  105273. * The Reoriented Normal Mapping method is used to blend normals.
  105274. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  105275. */
  105276. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  105277. /**
  105278. * Custom callback helping to override the default shader used in the material.
  105279. */
  105280. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  105281. /**
  105282. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  105283. */
  105284. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  105285. /**
  105286. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  105287. * This means that the material can keep using a previous shader while a new one is being compiled.
  105288. * This is mostly used when shader parallel compilation is supported (true by default)
  105289. */
  105290. allowShaderHotSwapping: boolean;
  105291. /**
  105292. * The ID of the material
  105293. */
  105294. id: string;
  105295. /**
  105296. * Gets or sets the unique id of the material
  105297. */
  105298. uniqueId: number;
  105299. /**
  105300. * The name of the material
  105301. */
  105302. name: string;
  105303. /**
  105304. * Gets or sets user defined metadata
  105305. */
  105306. metadata: any;
  105307. /**
  105308. * For internal use only. Please do not use.
  105309. */
  105310. reservedDataStore: any;
  105311. /**
  105312. * Specifies if the ready state should be checked on each call
  105313. */
  105314. checkReadyOnEveryCall: boolean;
  105315. /**
  105316. * Specifies if the ready state should be checked once
  105317. */
  105318. checkReadyOnlyOnce: boolean;
  105319. /**
  105320. * The state of the material
  105321. */
  105322. state: string;
  105323. /**
  105324. * If the material can be rendered to several textures with MRT extension
  105325. */
  105326. get canRenderToMRT(): boolean;
  105327. /**
  105328. * The alpha value of the material
  105329. */
  105330. protected _alpha: number;
  105331. /**
  105332. * List of inspectable custom properties (used by the Inspector)
  105333. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105334. */
  105335. inspectableCustomProperties: IInspectable[];
  105336. /**
  105337. * Sets the alpha value of the material
  105338. */
  105339. set alpha(value: number);
  105340. /**
  105341. * Gets the alpha value of the material
  105342. */
  105343. get alpha(): number;
  105344. /**
  105345. * Specifies if back face culling is enabled
  105346. */
  105347. protected _backFaceCulling: boolean;
  105348. /**
  105349. * Sets the back-face culling state
  105350. */
  105351. set backFaceCulling(value: boolean);
  105352. /**
  105353. * Gets the back-face culling state
  105354. */
  105355. get backFaceCulling(): boolean;
  105356. /**
  105357. * Stores the value for side orientation
  105358. */
  105359. sideOrientation: number;
  105360. /**
  105361. * Callback triggered when the material is compiled
  105362. */
  105363. onCompiled: Nullable<(effect: Effect) => void>;
  105364. /**
  105365. * Callback triggered when an error occurs
  105366. */
  105367. onError: Nullable<(effect: Effect, errors: string) => void>;
  105368. /**
  105369. * Callback triggered to get the render target textures
  105370. */
  105371. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  105372. /**
  105373. * Gets a boolean indicating that current material needs to register RTT
  105374. */
  105375. get hasRenderTargetTextures(): boolean;
  105376. /**
  105377. * Specifies if the material should be serialized
  105378. */
  105379. doNotSerialize: boolean;
  105380. /**
  105381. * @hidden
  105382. */
  105383. _storeEffectOnSubMeshes: boolean;
  105384. /**
  105385. * Stores the animations for the material
  105386. */
  105387. animations: Nullable<Array<Animation>>;
  105388. /**
  105389. * An event triggered when the material is disposed
  105390. */
  105391. onDisposeObservable: Observable<Material>;
  105392. /**
  105393. * An observer which watches for dispose events
  105394. */
  105395. private _onDisposeObserver;
  105396. private _onUnBindObservable;
  105397. /**
  105398. * Called during a dispose event
  105399. */
  105400. set onDispose(callback: () => void);
  105401. private _onBindObservable;
  105402. /**
  105403. * An event triggered when the material is bound
  105404. */
  105405. get onBindObservable(): Observable<AbstractMesh>;
  105406. /**
  105407. * An observer which watches for bind events
  105408. */
  105409. private _onBindObserver;
  105410. /**
  105411. * Called during a bind event
  105412. */
  105413. set onBind(callback: (Mesh: AbstractMesh) => void);
  105414. /**
  105415. * An event triggered when the material is unbound
  105416. */
  105417. get onUnBindObservable(): Observable<Material>;
  105418. protected _onEffectCreatedObservable: Nullable<Observable<{
  105419. effect: Effect;
  105420. subMesh: Nullable<SubMesh>;
  105421. }>>;
  105422. /**
  105423. * An event triggered when the effect is (re)created
  105424. */
  105425. get onEffectCreatedObservable(): Observable<{
  105426. effect: Effect;
  105427. subMesh: Nullable<SubMesh>;
  105428. }>;
  105429. /**
  105430. * Stores the value of the alpha mode
  105431. */
  105432. private _alphaMode;
  105433. /**
  105434. * Sets the value of the alpha mode.
  105435. *
  105436. * | Value | Type | Description |
  105437. * | --- | --- | --- |
  105438. * | 0 | ALPHA_DISABLE | |
  105439. * | 1 | ALPHA_ADD | |
  105440. * | 2 | ALPHA_COMBINE | |
  105441. * | 3 | ALPHA_SUBTRACT | |
  105442. * | 4 | ALPHA_MULTIPLY | |
  105443. * | 5 | ALPHA_MAXIMIZED | |
  105444. * | 6 | ALPHA_ONEONE | |
  105445. * | 7 | ALPHA_PREMULTIPLIED | |
  105446. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  105447. * | 9 | ALPHA_INTERPOLATE | |
  105448. * | 10 | ALPHA_SCREENMODE | |
  105449. *
  105450. */
  105451. set alphaMode(value: number);
  105452. /**
  105453. * Gets the value of the alpha mode
  105454. */
  105455. get alphaMode(): number;
  105456. /**
  105457. * Stores the state of the need depth pre-pass value
  105458. */
  105459. private _needDepthPrePass;
  105460. /**
  105461. * Sets the need depth pre-pass value
  105462. */
  105463. set needDepthPrePass(value: boolean);
  105464. /**
  105465. * Gets the depth pre-pass value
  105466. */
  105467. get needDepthPrePass(): boolean;
  105468. /**
  105469. * Specifies if depth writing should be disabled
  105470. */
  105471. disableDepthWrite: boolean;
  105472. /**
  105473. * Specifies if color writing should be disabled
  105474. */
  105475. disableColorWrite: boolean;
  105476. /**
  105477. * Specifies if depth writing should be forced
  105478. */
  105479. forceDepthWrite: boolean;
  105480. /**
  105481. * Specifies the depth function that should be used. 0 means the default engine function
  105482. */
  105483. depthFunction: number;
  105484. /**
  105485. * Specifies if there should be a separate pass for culling
  105486. */
  105487. separateCullingPass: boolean;
  105488. /**
  105489. * Stores the state specifing if fog should be enabled
  105490. */
  105491. private _fogEnabled;
  105492. /**
  105493. * Sets the state for enabling fog
  105494. */
  105495. set fogEnabled(value: boolean);
  105496. /**
  105497. * Gets the value of the fog enabled state
  105498. */
  105499. get fogEnabled(): boolean;
  105500. /**
  105501. * Stores the size of points
  105502. */
  105503. pointSize: number;
  105504. /**
  105505. * Stores the z offset value
  105506. */
  105507. zOffset: number;
  105508. get wireframe(): boolean;
  105509. /**
  105510. * Sets the state of wireframe mode
  105511. */
  105512. set wireframe(value: boolean);
  105513. /**
  105514. * Gets the value specifying if point clouds are enabled
  105515. */
  105516. get pointsCloud(): boolean;
  105517. /**
  105518. * Sets the state of point cloud mode
  105519. */
  105520. set pointsCloud(value: boolean);
  105521. /**
  105522. * Gets the material fill mode
  105523. */
  105524. get fillMode(): number;
  105525. /**
  105526. * Sets the material fill mode
  105527. */
  105528. set fillMode(value: number);
  105529. /**
  105530. * @hidden
  105531. * Stores the effects for the material
  105532. */
  105533. _effect: Nullable<Effect>;
  105534. /**
  105535. * Specifies if uniform buffers should be used
  105536. */
  105537. private _useUBO;
  105538. /**
  105539. * Stores a reference to the scene
  105540. */
  105541. private _scene;
  105542. /**
  105543. * Stores the fill mode state
  105544. */
  105545. private _fillMode;
  105546. /**
  105547. * Specifies if the depth write state should be cached
  105548. */
  105549. private _cachedDepthWriteState;
  105550. /**
  105551. * Specifies if the color write state should be cached
  105552. */
  105553. private _cachedColorWriteState;
  105554. /**
  105555. * Specifies if the depth function state should be cached
  105556. */
  105557. private _cachedDepthFunctionState;
  105558. /**
  105559. * Stores the uniform buffer
  105560. */
  105561. protected _uniformBuffer: UniformBuffer;
  105562. /** @hidden */
  105563. _indexInSceneMaterialArray: number;
  105564. /** @hidden */
  105565. meshMap: Nullable<{
  105566. [id: string]: AbstractMesh | undefined;
  105567. }>;
  105568. /**
  105569. * Creates a material instance
  105570. * @param name defines the name of the material
  105571. * @param scene defines the scene to reference
  105572. * @param doNotAdd specifies if the material should be added to the scene
  105573. */
  105574. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  105575. /**
  105576. * Returns a string representation of the current material
  105577. * @param fullDetails defines a boolean indicating which levels of logging is desired
  105578. * @returns a string with material information
  105579. */
  105580. toString(fullDetails?: boolean): string;
  105581. /**
  105582. * Gets the class name of the material
  105583. * @returns a string with the class name of the material
  105584. */
  105585. getClassName(): string;
  105586. /**
  105587. * Specifies if updates for the material been locked
  105588. */
  105589. get isFrozen(): boolean;
  105590. /**
  105591. * Locks updates for the material
  105592. */
  105593. freeze(): void;
  105594. /**
  105595. * Unlocks updates for the material
  105596. */
  105597. unfreeze(): void;
  105598. /**
  105599. * Specifies if the material is ready to be used
  105600. * @param mesh defines the mesh to check
  105601. * @param useInstances specifies if instances should be used
  105602. * @returns a boolean indicating if the material is ready to be used
  105603. */
  105604. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105605. /**
  105606. * Specifies that the submesh is ready to be used
  105607. * @param mesh defines the mesh to check
  105608. * @param subMesh defines which submesh to check
  105609. * @param useInstances specifies that instances should be used
  105610. * @returns a boolean indicating that the submesh is ready or not
  105611. */
  105612. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105613. /**
  105614. * Returns the material effect
  105615. * @returns the effect associated with the material
  105616. */
  105617. getEffect(): Nullable<Effect>;
  105618. /**
  105619. * Returns the current scene
  105620. * @returns a Scene
  105621. */
  105622. getScene(): Scene;
  105623. /**
  105624. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105625. */
  105626. protected _forceAlphaTest: boolean;
  105627. /**
  105628. * The transparency mode of the material.
  105629. */
  105630. protected _transparencyMode: Nullable<number>;
  105631. /**
  105632. * Gets the current transparency mode.
  105633. */
  105634. get transparencyMode(): Nullable<number>;
  105635. /**
  105636. * Sets the transparency mode of the material.
  105637. *
  105638. * | Value | Type | Description |
  105639. * | ----- | ----------------------------------- | ----------- |
  105640. * | 0 | OPAQUE | |
  105641. * | 1 | ALPHATEST | |
  105642. * | 2 | ALPHABLEND | |
  105643. * | 3 | ALPHATESTANDBLEND | |
  105644. *
  105645. */
  105646. set transparencyMode(value: Nullable<number>);
  105647. /**
  105648. * Returns true if alpha blending should be disabled.
  105649. */
  105650. protected get _disableAlphaBlending(): boolean;
  105651. /**
  105652. * Specifies whether or not this material should be rendered in alpha blend mode.
  105653. * @returns a boolean specifying if alpha blending is needed
  105654. */
  105655. needAlphaBlending(): boolean;
  105656. /**
  105657. * Specifies if the mesh will require alpha blending
  105658. * @param mesh defines the mesh to check
  105659. * @returns a boolean specifying if alpha blending is needed for the mesh
  105660. */
  105661. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105662. /**
  105663. * Specifies whether or not this material should be rendered in alpha test mode.
  105664. * @returns a boolean specifying if an alpha test is needed.
  105665. */
  105666. needAlphaTesting(): boolean;
  105667. /**
  105668. * Specifies if material alpha testing should be turned on for the mesh
  105669. * @param mesh defines the mesh to check
  105670. */
  105671. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  105672. /**
  105673. * Gets the texture used for the alpha test
  105674. * @returns the texture to use for alpha testing
  105675. */
  105676. getAlphaTestTexture(): Nullable<BaseTexture>;
  105677. /**
  105678. * Marks the material to indicate that it needs to be re-calculated
  105679. */
  105680. markDirty(): void;
  105681. /** @hidden */
  105682. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  105683. /**
  105684. * Binds the material to the mesh
  105685. * @param world defines the world transformation matrix
  105686. * @param mesh defines the mesh to bind the material to
  105687. */
  105688. bind(world: Matrix, mesh?: Mesh): void;
  105689. /**
  105690. * Binds the submesh to the material
  105691. * @param world defines the world transformation matrix
  105692. * @param mesh defines the mesh containing the submesh
  105693. * @param subMesh defines the submesh to bind the material to
  105694. */
  105695. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105696. /**
  105697. * Binds the world matrix to the material
  105698. * @param world defines the world transformation matrix
  105699. */
  105700. bindOnlyWorldMatrix(world: Matrix): void;
  105701. /**
  105702. * Binds the scene's uniform buffer to the effect.
  105703. * @param effect defines the effect to bind to the scene uniform buffer
  105704. * @param sceneUbo defines the uniform buffer storing scene data
  105705. */
  105706. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  105707. /**
  105708. * Binds the view matrix to the effect
  105709. * @param effect defines the effect to bind the view matrix to
  105710. */
  105711. bindView(effect: Effect): void;
  105712. /**
  105713. * Binds the view projection matrix to the effect
  105714. * @param effect defines the effect to bind the view projection matrix to
  105715. */
  105716. bindViewProjection(effect: Effect): void;
  105717. /**
  105718. * Processes to execute after binding the material to a mesh
  105719. * @param mesh defines the rendered mesh
  105720. */
  105721. protected _afterBind(mesh?: Mesh): void;
  105722. /**
  105723. * Unbinds the material from the mesh
  105724. */
  105725. unbind(): void;
  105726. /**
  105727. * Gets the active textures from the material
  105728. * @returns an array of textures
  105729. */
  105730. getActiveTextures(): BaseTexture[];
  105731. /**
  105732. * Specifies if the material uses a texture
  105733. * @param texture defines the texture to check against the material
  105734. * @returns a boolean specifying if the material uses the texture
  105735. */
  105736. hasTexture(texture: BaseTexture): boolean;
  105737. /**
  105738. * Makes a duplicate of the material, and gives it a new name
  105739. * @param name defines the new name for the duplicated material
  105740. * @returns the cloned material
  105741. */
  105742. clone(name: string): Nullable<Material>;
  105743. /**
  105744. * Gets the meshes bound to the material
  105745. * @returns an array of meshes bound to the material
  105746. */
  105747. getBindedMeshes(): AbstractMesh[];
  105748. /**
  105749. * Force shader compilation
  105750. * @param mesh defines the mesh associated with this material
  105751. * @param onCompiled defines a function to execute once the material is compiled
  105752. * @param options defines the options to configure the compilation
  105753. * @param onError defines a function to execute if the material fails compiling
  105754. */
  105755. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  105756. /**
  105757. * Force shader compilation
  105758. * @param mesh defines the mesh that will use this material
  105759. * @param options defines additional options for compiling the shaders
  105760. * @returns a promise that resolves when the compilation completes
  105761. */
  105762. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  105763. private static readonly _AllDirtyCallBack;
  105764. private static readonly _ImageProcessingDirtyCallBack;
  105765. private static readonly _TextureDirtyCallBack;
  105766. private static readonly _FresnelDirtyCallBack;
  105767. private static readonly _MiscDirtyCallBack;
  105768. private static readonly _PrePassDirtyCallBack;
  105769. private static readonly _LightsDirtyCallBack;
  105770. private static readonly _AttributeDirtyCallBack;
  105771. private static _FresnelAndMiscDirtyCallBack;
  105772. private static _TextureAndMiscDirtyCallBack;
  105773. private static readonly _DirtyCallbackArray;
  105774. private static readonly _RunDirtyCallBacks;
  105775. /**
  105776. * Marks a define in the material to indicate that it needs to be re-computed
  105777. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  105778. */
  105779. markAsDirty(flag: number): void;
  105780. /**
  105781. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  105782. * @param func defines a function which checks material defines against the submeshes
  105783. */
  105784. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  105785. /**
  105786. * Indicates that the scene should check if the rendering now needs a prepass
  105787. */
  105788. protected _markScenePrePassDirty(): void;
  105789. /**
  105790. * Indicates that we need to re-calculated for all submeshes
  105791. */
  105792. protected _markAllSubMeshesAsAllDirty(): void;
  105793. /**
  105794. * Indicates that image processing needs to be re-calculated for all submeshes
  105795. */
  105796. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  105797. /**
  105798. * Indicates that textures need to be re-calculated for all submeshes
  105799. */
  105800. protected _markAllSubMeshesAsTexturesDirty(): void;
  105801. /**
  105802. * Indicates that fresnel needs to be re-calculated for all submeshes
  105803. */
  105804. protected _markAllSubMeshesAsFresnelDirty(): void;
  105805. /**
  105806. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  105807. */
  105808. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  105809. /**
  105810. * Indicates that lights need to be re-calculated for all submeshes
  105811. */
  105812. protected _markAllSubMeshesAsLightsDirty(): void;
  105813. /**
  105814. * Indicates that attributes need to be re-calculated for all submeshes
  105815. */
  105816. protected _markAllSubMeshesAsAttributesDirty(): void;
  105817. /**
  105818. * Indicates that misc needs to be re-calculated for all submeshes
  105819. */
  105820. protected _markAllSubMeshesAsMiscDirty(): void;
  105821. /**
  105822. * Indicates that prepass needs to be re-calculated for all submeshes
  105823. */
  105824. protected _markAllSubMeshesAsPrePassDirty(): void;
  105825. /**
  105826. * Indicates that textures and misc need to be re-calculated for all submeshes
  105827. */
  105828. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  105829. /**
  105830. * Sets the required values to the prepass renderer.
  105831. * @param prePassRenderer defines the prepass renderer to setup.
  105832. * @returns true if the pre pass is needed.
  105833. */
  105834. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  105835. /**
  105836. * Disposes the material
  105837. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105838. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105839. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  105840. */
  105841. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  105842. /** @hidden */
  105843. private releaseVertexArrayObject;
  105844. /**
  105845. * Serializes this material
  105846. * @returns the serialized material object
  105847. */
  105848. serialize(): any;
  105849. /**
  105850. * Creates a material from parsed material data
  105851. * @param parsedMaterial defines parsed material data
  105852. * @param scene defines the hosting scene
  105853. * @param rootUrl defines the root URL to use to load textures
  105854. * @returns a new material
  105855. */
  105856. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  105857. }
  105858. }
  105859. declare module BABYLON {
  105860. /**
  105861. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105862. * separate meshes. This can be use to improve performances.
  105863. * @see https://doc.babylonjs.com/how_to/multi_materials
  105864. */
  105865. export class MultiMaterial extends Material {
  105866. private _subMaterials;
  105867. /**
  105868. * Gets or Sets the list of Materials used within the multi material.
  105869. * They need to be ordered according to the submeshes order in the associated mesh
  105870. */
  105871. get subMaterials(): Nullable<Material>[];
  105872. set subMaterials(value: Nullable<Material>[]);
  105873. /**
  105874. * Function used to align with Node.getChildren()
  105875. * @returns the list of Materials used within the multi material
  105876. */
  105877. getChildren(): Nullable<Material>[];
  105878. /**
  105879. * Instantiates a new Multi Material
  105880. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105881. * separate meshes. This can be use to improve performances.
  105882. * @see https://doc.babylonjs.com/how_to/multi_materials
  105883. * @param name Define the name in the scene
  105884. * @param scene Define the scene the material belongs to
  105885. */
  105886. constructor(name: string, scene: Scene);
  105887. private _hookArray;
  105888. /**
  105889. * Get one of the submaterial by its index in the submaterials array
  105890. * @param index The index to look the sub material at
  105891. * @returns The Material if the index has been defined
  105892. */
  105893. getSubMaterial(index: number): Nullable<Material>;
  105894. /**
  105895. * Get the list of active textures for the whole sub materials list.
  105896. * @returns All the textures that will be used during the rendering
  105897. */
  105898. getActiveTextures(): BaseTexture[];
  105899. /**
  105900. * Gets the current class name of the material e.g. "MultiMaterial"
  105901. * Mainly use in serialization.
  105902. * @returns the class name
  105903. */
  105904. getClassName(): string;
  105905. /**
  105906. * Checks if the material is ready to render the requested sub mesh
  105907. * @param mesh Define the mesh the submesh belongs to
  105908. * @param subMesh Define the sub mesh to look readyness for
  105909. * @param useInstances Define whether or not the material is used with instances
  105910. * @returns true if ready, otherwise false
  105911. */
  105912. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105913. /**
  105914. * Clones the current material and its related sub materials
  105915. * @param name Define the name of the newly cloned material
  105916. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105917. * @returns the cloned material
  105918. */
  105919. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105920. /**
  105921. * Serializes the materials into a JSON representation.
  105922. * @returns the JSON representation
  105923. */
  105924. serialize(): any;
  105925. /**
  105926. * Dispose the material and release its associated resources
  105927. * @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)
  105928. * @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)
  105929. * @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)
  105930. */
  105931. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105932. /**
  105933. * Creates a MultiMaterial from parsed MultiMaterial data.
  105934. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105935. * @param scene defines the hosting scene
  105936. * @returns a new MultiMaterial
  105937. */
  105938. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105939. }
  105940. }
  105941. declare module BABYLON {
  105942. /**
  105943. * Defines a subdivision inside a mesh
  105944. */
  105945. export class SubMesh implements ICullable {
  105946. /** the material index to use */
  105947. materialIndex: number;
  105948. /** vertex index start */
  105949. verticesStart: number;
  105950. /** vertices count */
  105951. verticesCount: number;
  105952. /** index start */
  105953. indexStart: number;
  105954. /** indices count */
  105955. indexCount: number;
  105956. /** @hidden */
  105957. _materialDefines: Nullable<MaterialDefines>;
  105958. /** @hidden */
  105959. _materialEffect: Nullable<Effect>;
  105960. /** @hidden */
  105961. _effectOverride: Nullable<Effect>;
  105962. /**
  105963. * Gets material defines used by the effect associated to the sub mesh
  105964. */
  105965. get materialDefines(): Nullable<MaterialDefines>;
  105966. /**
  105967. * Sets material defines used by the effect associated to the sub mesh
  105968. */
  105969. set materialDefines(defines: Nullable<MaterialDefines>);
  105970. /**
  105971. * Gets associated effect
  105972. */
  105973. get effect(): Nullable<Effect>;
  105974. /**
  105975. * Sets associated effect (effect used to render this submesh)
  105976. * @param effect defines the effect to associate with
  105977. * @param defines defines the set of defines used to compile this effect
  105978. */
  105979. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105980. /** @hidden */
  105981. _linesIndexCount: number;
  105982. private _mesh;
  105983. private _renderingMesh;
  105984. private _boundingInfo;
  105985. private _linesIndexBuffer;
  105986. /** @hidden */
  105987. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105988. /** @hidden */
  105989. _trianglePlanes: Plane[];
  105990. /** @hidden */
  105991. _lastColliderTransformMatrix: Nullable<Matrix>;
  105992. /** @hidden */
  105993. _renderId: number;
  105994. /** @hidden */
  105995. _alphaIndex: number;
  105996. /** @hidden */
  105997. _distanceToCamera: number;
  105998. /** @hidden */
  105999. _id: number;
  106000. private _currentMaterial;
  106001. /**
  106002. * Add a new submesh to a mesh
  106003. * @param materialIndex defines the material index to use
  106004. * @param verticesStart defines vertex index start
  106005. * @param verticesCount defines vertices count
  106006. * @param indexStart defines index start
  106007. * @param indexCount defines indices count
  106008. * @param mesh defines the parent mesh
  106009. * @param renderingMesh defines an optional rendering mesh
  106010. * @param createBoundingBox defines if bounding box should be created for this submesh
  106011. * @returns the new submesh
  106012. */
  106013. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  106014. /**
  106015. * Creates a new submesh
  106016. * @param materialIndex defines the material index to use
  106017. * @param verticesStart defines vertex index start
  106018. * @param verticesCount defines vertices count
  106019. * @param indexStart defines index start
  106020. * @param indexCount defines indices count
  106021. * @param mesh defines the parent mesh
  106022. * @param renderingMesh defines an optional rendering mesh
  106023. * @param createBoundingBox defines if bounding box should be created for this submesh
  106024. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  106025. */
  106026. constructor(
  106027. /** the material index to use */
  106028. materialIndex: number,
  106029. /** vertex index start */
  106030. verticesStart: number,
  106031. /** vertices count */
  106032. verticesCount: number,
  106033. /** index start */
  106034. indexStart: number,
  106035. /** indices count */
  106036. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  106037. /**
  106038. * Returns true if this submesh covers the entire parent mesh
  106039. * @ignorenaming
  106040. */
  106041. get IsGlobal(): boolean;
  106042. /**
  106043. * Returns the submesh BoudingInfo object
  106044. * @returns current bounding info (or mesh's one if the submesh is global)
  106045. */
  106046. getBoundingInfo(): BoundingInfo;
  106047. /**
  106048. * Sets the submesh BoundingInfo
  106049. * @param boundingInfo defines the new bounding info to use
  106050. * @returns the SubMesh
  106051. */
  106052. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  106053. /**
  106054. * Returns the mesh of the current submesh
  106055. * @return the parent mesh
  106056. */
  106057. getMesh(): AbstractMesh;
  106058. /**
  106059. * Returns the rendering mesh of the submesh
  106060. * @returns the rendering mesh (could be different from parent mesh)
  106061. */
  106062. getRenderingMesh(): Mesh;
  106063. /**
  106064. * Returns the replacement mesh of the submesh
  106065. * @returns the replacement mesh (could be different from parent mesh)
  106066. */
  106067. getReplacementMesh(): Nullable<AbstractMesh>;
  106068. /**
  106069. * Returns the effective mesh of the submesh
  106070. * @returns the effective mesh (could be different from parent mesh)
  106071. */
  106072. getEffectiveMesh(): AbstractMesh;
  106073. /**
  106074. * Returns the submesh material
  106075. * @returns null or the current material
  106076. */
  106077. getMaterial(): Nullable<Material>;
  106078. private _IsMultiMaterial;
  106079. /**
  106080. * Sets a new updated BoundingInfo object to the submesh
  106081. * @param data defines an optional position array to use to determine the bounding info
  106082. * @returns the SubMesh
  106083. */
  106084. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  106085. /** @hidden */
  106086. _checkCollision(collider: Collider): boolean;
  106087. /**
  106088. * Updates the submesh BoundingInfo
  106089. * @param world defines the world matrix to use to update the bounding info
  106090. * @returns the submesh
  106091. */
  106092. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  106093. /**
  106094. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  106095. * @param frustumPlanes defines the frustum planes
  106096. * @returns true if the submesh is intersecting with the frustum
  106097. */
  106098. isInFrustum(frustumPlanes: Plane[]): boolean;
  106099. /**
  106100. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  106101. * @param frustumPlanes defines the frustum planes
  106102. * @returns true if the submesh is inside the frustum
  106103. */
  106104. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  106105. /**
  106106. * Renders the submesh
  106107. * @param enableAlphaMode defines if alpha needs to be used
  106108. * @returns the submesh
  106109. */
  106110. render(enableAlphaMode: boolean): SubMesh;
  106111. /**
  106112. * @hidden
  106113. */
  106114. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  106115. /**
  106116. * Checks if the submesh intersects with a ray
  106117. * @param ray defines the ray to test
  106118. * @returns true is the passed ray intersects the submesh bounding box
  106119. */
  106120. canIntersects(ray: Ray): boolean;
  106121. /**
  106122. * Intersects current submesh with a ray
  106123. * @param ray defines the ray to test
  106124. * @param positions defines mesh's positions array
  106125. * @param indices defines mesh's indices array
  106126. * @param fastCheck defines if the first intersection will be used (and not the closest)
  106127. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  106128. * @returns intersection info or null if no intersection
  106129. */
  106130. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  106131. /** @hidden */
  106132. private _intersectLines;
  106133. /** @hidden */
  106134. private _intersectUnIndexedLines;
  106135. /** @hidden */
  106136. private _intersectTriangles;
  106137. /** @hidden */
  106138. private _intersectUnIndexedTriangles;
  106139. /** @hidden */
  106140. _rebuild(): void;
  106141. /**
  106142. * Creates a new submesh from the passed mesh
  106143. * @param newMesh defines the new hosting mesh
  106144. * @param newRenderingMesh defines an optional rendering mesh
  106145. * @returns the new submesh
  106146. */
  106147. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  106148. /**
  106149. * Release associated resources
  106150. */
  106151. dispose(): void;
  106152. /**
  106153. * Gets the class name
  106154. * @returns the string "SubMesh".
  106155. */
  106156. getClassName(): string;
  106157. /**
  106158. * Creates a new submesh from indices data
  106159. * @param materialIndex the index of the main mesh material
  106160. * @param startIndex the index where to start the copy in the mesh indices array
  106161. * @param indexCount the number of indices to copy then from the startIndex
  106162. * @param mesh the main mesh to create the submesh from
  106163. * @param renderingMesh the optional rendering mesh
  106164. * @returns a new submesh
  106165. */
  106166. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  106167. }
  106168. }
  106169. declare module BABYLON {
  106170. /**
  106171. * Class used to represent data loading progression
  106172. */
  106173. export class SceneLoaderFlags {
  106174. private static _ForceFullSceneLoadingForIncremental;
  106175. private static _ShowLoadingScreen;
  106176. private static _CleanBoneMatrixWeights;
  106177. private static _loggingLevel;
  106178. /**
  106179. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  106180. */
  106181. static get ForceFullSceneLoadingForIncremental(): boolean;
  106182. static set ForceFullSceneLoadingForIncremental(value: boolean);
  106183. /**
  106184. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  106185. */
  106186. static get ShowLoadingScreen(): boolean;
  106187. static set ShowLoadingScreen(value: boolean);
  106188. /**
  106189. * Defines the current logging level (while loading the scene)
  106190. * @ignorenaming
  106191. */
  106192. static get loggingLevel(): number;
  106193. static set loggingLevel(value: number);
  106194. /**
  106195. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  106196. */
  106197. static get CleanBoneMatrixWeights(): boolean;
  106198. static set CleanBoneMatrixWeights(value: boolean);
  106199. }
  106200. }
  106201. declare module BABYLON {
  106202. /**
  106203. * Class used to store geometry data (vertex buffers + index buffer)
  106204. */
  106205. export class Geometry implements IGetSetVerticesData {
  106206. /**
  106207. * Gets or sets the ID of the geometry
  106208. */
  106209. id: string;
  106210. /**
  106211. * Gets or sets the unique ID of the geometry
  106212. */
  106213. uniqueId: number;
  106214. /**
  106215. * Gets the delay loading state of the geometry (none by default which means not delayed)
  106216. */
  106217. delayLoadState: number;
  106218. /**
  106219. * Gets the file containing the data to load when running in delay load state
  106220. */
  106221. delayLoadingFile: Nullable<string>;
  106222. /**
  106223. * Callback called when the geometry is updated
  106224. */
  106225. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  106226. private _scene;
  106227. private _engine;
  106228. private _meshes;
  106229. private _totalVertices;
  106230. /** @hidden */
  106231. _indices: IndicesArray;
  106232. /** @hidden */
  106233. _vertexBuffers: {
  106234. [key: string]: VertexBuffer;
  106235. };
  106236. private _isDisposed;
  106237. private _extend;
  106238. private _boundingBias;
  106239. /** @hidden */
  106240. _delayInfo: Array<string>;
  106241. private _indexBuffer;
  106242. private _indexBufferIsUpdatable;
  106243. /** @hidden */
  106244. _boundingInfo: Nullable<BoundingInfo>;
  106245. /** @hidden */
  106246. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  106247. /** @hidden */
  106248. _softwareSkinningFrameId: number;
  106249. private _vertexArrayObjects;
  106250. private _updatable;
  106251. /** @hidden */
  106252. _positions: Nullable<Vector3[]>;
  106253. /**
  106254. * 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
  106255. */
  106256. get boundingBias(): Vector2;
  106257. /**
  106258. * 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
  106259. */
  106260. set boundingBias(value: Vector2);
  106261. /**
  106262. * Static function used to attach a new empty geometry to a mesh
  106263. * @param mesh defines the mesh to attach the geometry to
  106264. * @returns the new Geometry
  106265. */
  106266. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  106267. /** Get the list of meshes using this geometry */
  106268. get meshes(): Mesh[];
  106269. /**
  106270. * 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
  106271. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  106272. */
  106273. useBoundingInfoFromGeometry: boolean;
  106274. /**
  106275. * Creates a new geometry
  106276. * @param id defines the unique ID
  106277. * @param scene defines the hosting scene
  106278. * @param vertexData defines the VertexData used to get geometry data
  106279. * @param updatable defines if geometry must be updatable (false by default)
  106280. * @param mesh defines the mesh that will be associated with the geometry
  106281. */
  106282. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  106283. /**
  106284. * Gets the current extend of the geometry
  106285. */
  106286. get extend(): {
  106287. minimum: Vector3;
  106288. maximum: Vector3;
  106289. };
  106290. /**
  106291. * Gets the hosting scene
  106292. * @returns the hosting Scene
  106293. */
  106294. getScene(): Scene;
  106295. /**
  106296. * Gets the hosting engine
  106297. * @returns the hosting Engine
  106298. */
  106299. getEngine(): Engine;
  106300. /**
  106301. * Defines if the geometry is ready to use
  106302. * @returns true if the geometry is ready to be used
  106303. */
  106304. isReady(): boolean;
  106305. /**
  106306. * Gets a value indicating that the geometry should not be serialized
  106307. */
  106308. get doNotSerialize(): boolean;
  106309. /** @hidden */
  106310. _rebuild(): void;
  106311. /**
  106312. * Affects all geometry data in one call
  106313. * @param vertexData defines the geometry data
  106314. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  106315. */
  106316. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  106317. /**
  106318. * Set specific vertex data
  106319. * @param kind defines the data kind (Position, normal, etc...)
  106320. * @param data defines the vertex data to use
  106321. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106322. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106323. */
  106324. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  106325. /**
  106326. * Removes a specific vertex data
  106327. * @param kind defines the data kind (Position, normal, etc...)
  106328. */
  106329. removeVerticesData(kind: string): void;
  106330. /**
  106331. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  106332. * @param buffer defines the vertex buffer to use
  106333. * @param totalVertices defines the total number of vertices for position kind (could be null)
  106334. */
  106335. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  106336. /**
  106337. * Update a specific vertex buffer
  106338. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  106339. * It will do nothing if the buffer is not updatable
  106340. * @param kind defines the data kind (Position, normal, etc...)
  106341. * @param data defines the data to use
  106342. * @param offset defines the offset in the target buffer where to store the data
  106343. * @param useBytes set to true if the offset is in bytes
  106344. */
  106345. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  106346. /**
  106347. * Update a specific vertex buffer
  106348. * This function will create a new buffer if the current one is not updatable
  106349. * @param kind defines the data kind (Position, normal, etc...)
  106350. * @param data defines the data to use
  106351. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  106352. */
  106353. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  106354. private _updateBoundingInfo;
  106355. /** @hidden */
  106356. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  106357. /**
  106358. * Gets total number of vertices
  106359. * @returns the total number of vertices
  106360. */
  106361. getTotalVertices(): number;
  106362. /**
  106363. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106364. * @param kind defines the data kind (Position, normal, etc...)
  106365. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106366. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106367. * @returns a float array containing vertex data
  106368. */
  106369. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106370. /**
  106371. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  106372. * @param kind defines the data kind (Position, normal, etc...)
  106373. * @returns true if the vertex buffer with the specified kind is updatable
  106374. */
  106375. isVertexBufferUpdatable(kind: string): boolean;
  106376. /**
  106377. * Gets a specific vertex buffer
  106378. * @param kind defines the data kind (Position, normal, etc...)
  106379. * @returns a VertexBuffer
  106380. */
  106381. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  106382. /**
  106383. * Returns all vertex buffers
  106384. * @return an object holding all vertex buffers indexed by kind
  106385. */
  106386. getVertexBuffers(): Nullable<{
  106387. [key: string]: VertexBuffer;
  106388. }>;
  106389. /**
  106390. * Gets a boolean indicating if specific vertex buffer is present
  106391. * @param kind defines the data kind (Position, normal, etc...)
  106392. * @returns true if data is present
  106393. */
  106394. isVerticesDataPresent(kind: string): boolean;
  106395. /**
  106396. * Gets a list of all attached data kinds (Position, normal, etc...)
  106397. * @returns a list of string containing all kinds
  106398. */
  106399. getVerticesDataKinds(): string[];
  106400. /**
  106401. * Update index buffer
  106402. * @param indices defines the indices to store in the index buffer
  106403. * @param offset defines the offset in the target buffer where to store the data
  106404. * @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)
  106405. */
  106406. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  106407. /**
  106408. * Creates a new index buffer
  106409. * @param indices defines the indices to store in the index buffer
  106410. * @param totalVertices defines the total number of vertices (could be null)
  106411. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106412. */
  106413. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  106414. /**
  106415. * Return the total number of indices
  106416. * @returns the total number of indices
  106417. */
  106418. getTotalIndices(): number;
  106419. /**
  106420. * Gets the index buffer array
  106421. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106422. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106423. * @returns the index buffer array
  106424. */
  106425. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106426. /**
  106427. * Gets the index buffer
  106428. * @return the index buffer
  106429. */
  106430. getIndexBuffer(): Nullable<DataBuffer>;
  106431. /** @hidden */
  106432. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  106433. /**
  106434. * Release the associated resources for a specific mesh
  106435. * @param mesh defines the source mesh
  106436. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  106437. */
  106438. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  106439. /**
  106440. * Apply current geometry to a given mesh
  106441. * @param mesh defines the mesh to apply geometry to
  106442. */
  106443. applyToMesh(mesh: Mesh): void;
  106444. private _updateExtend;
  106445. private _applyToMesh;
  106446. private notifyUpdate;
  106447. /**
  106448. * Load the geometry if it was flagged as delay loaded
  106449. * @param scene defines the hosting scene
  106450. * @param onLoaded defines a callback called when the geometry is loaded
  106451. */
  106452. load(scene: Scene, onLoaded?: () => void): void;
  106453. private _queueLoad;
  106454. /**
  106455. * Invert the geometry to move from a right handed system to a left handed one.
  106456. */
  106457. toLeftHanded(): void;
  106458. /** @hidden */
  106459. _resetPointsArrayCache(): void;
  106460. /** @hidden */
  106461. _generatePointsArray(): boolean;
  106462. /**
  106463. * Gets a value indicating if the geometry is disposed
  106464. * @returns true if the geometry was disposed
  106465. */
  106466. isDisposed(): boolean;
  106467. private _disposeVertexArrayObjects;
  106468. /**
  106469. * Free all associated resources
  106470. */
  106471. dispose(): void;
  106472. /**
  106473. * Clone the current geometry into a new geometry
  106474. * @param id defines the unique ID of the new geometry
  106475. * @returns a new geometry object
  106476. */
  106477. copy(id: string): Geometry;
  106478. /**
  106479. * Serialize the current geometry info (and not the vertices data) into a JSON object
  106480. * @return a JSON representation of the current geometry data (without the vertices data)
  106481. */
  106482. serialize(): any;
  106483. private toNumberArray;
  106484. /**
  106485. * Serialize all vertices data into a JSON oject
  106486. * @returns a JSON representation of the current geometry data
  106487. */
  106488. serializeVerticeData(): any;
  106489. /**
  106490. * Extracts a clone of a mesh geometry
  106491. * @param mesh defines the source mesh
  106492. * @param id defines the unique ID of the new geometry object
  106493. * @returns the new geometry object
  106494. */
  106495. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  106496. /**
  106497. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  106498. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106499. * Be aware Math.random() could cause collisions, but:
  106500. * "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"
  106501. * @returns a string containing a new GUID
  106502. */
  106503. static RandomId(): string;
  106504. /** @hidden */
  106505. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  106506. private static _CleanMatricesWeights;
  106507. /**
  106508. * Create a new geometry from persisted data (Using .babylon file format)
  106509. * @param parsedVertexData defines the persisted data
  106510. * @param scene defines the hosting scene
  106511. * @param rootUrl defines the root url to use to load assets (like delayed data)
  106512. * @returns the new geometry object
  106513. */
  106514. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  106515. }
  106516. }
  106517. declare module BABYLON {
  106518. /**
  106519. * Define an interface for all classes that will get and set the data on vertices
  106520. */
  106521. export interface IGetSetVerticesData {
  106522. /**
  106523. * Gets a boolean indicating if specific vertex data is present
  106524. * @param kind defines the vertex data kind to use
  106525. * @returns true is data kind is present
  106526. */
  106527. isVerticesDataPresent(kind: string): boolean;
  106528. /**
  106529. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106530. * @param kind defines the data kind (Position, normal, etc...)
  106531. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106532. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106533. * @returns a float array containing vertex data
  106534. */
  106535. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106536. /**
  106537. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  106538. * @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.
  106539. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106540. * @returns the indices array or an empty array if the mesh has no geometry
  106541. */
  106542. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106543. /**
  106544. * Set specific vertex data
  106545. * @param kind defines the data kind (Position, normal, etc...)
  106546. * @param data defines the vertex data to use
  106547. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106548. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106549. */
  106550. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  106551. /**
  106552. * Update a specific associated vertex buffer
  106553. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106554. * - VertexBuffer.PositionKind
  106555. * - VertexBuffer.UVKind
  106556. * - VertexBuffer.UV2Kind
  106557. * - VertexBuffer.UV3Kind
  106558. * - VertexBuffer.UV4Kind
  106559. * - VertexBuffer.UV5Kind
  106560. * - VertexBuffer.UV6Kind
  106561. * - VertexBuffer.ColorKind
  106562. * - VertexBuffer.MatricesIndicesKind
  106563. * - VertexBuffer.MatricesIndicesExtraKind
  106564. * - VertexBuffer.MatricesWeightsKind
  106565. * - VertexBuffer.MatricesWeightsExtraKind
  106566. * @param data defines the data source
  106567. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  106568. * @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)
  106569. */
  106570. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  106571. /**
  106572. * Creates a new index buffer
  106573. * @param indices defines the indices to store in the index buffer
  106574. * @param totalVertices defines the total number of vertices (could be null)
  106575. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106576. */
  106577. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  106578. }
  106579. /**
  106580. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  106581. */
  106582. export class VertexData {
  106583. /**
  106584. * Mesh side orientation : usually the external or front surface
  106585. */
  106586. static readonly FRONTSIDE: number;
  106587. /**
  106588. * Mesh side orientation : usually the internal or back surface
  106589. */
  106590. static readonly BACKSIDE: number;
  106591. /**
  106592. * Mesh side orientation : both internal and external or front and back surfaces
  106593. */
  106594. static readonly DOUBLESIDE: number;
  106595. /**
  106596. * Mesh side orientation : by default, `FRONTSIDE`
  106597. */
  106598. static readonly DEFAULTSIDE: number;
  106599. /**
  106600. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  106601. */
  106602. positions: Nullable<FloatArray>;
  106603. /**
  106604. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  106605. */
  106606. normals: Nullable<FloatArray>;
  106607. /**
  106608. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  106609. */
  106610. tangents: Nullable<FloatArray>;
  106611. /**
  106612. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106613. */
  106614. uvs: Nullable<FloatArray>;
  106615. /**
  106616. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106617. */
  106618. uvs2: Nullable<FloatArray>;
  106619. /**
  106620. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106621. */
  106622. uvs3: Nullable<FloatArray>;
  106623. /**
  106624. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106625. */
  106626. uvs4: Nullable<FloatArray>;
  106627. /**
  106628. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106629. */
  106630. uvs5: Nullable<FloatArray>;
  106631. /**
  106632. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106633. */
  106634. uvs6: Nullable<FloatArray>;
  106635. /**
  106636. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  106637. */
  106638. colors: Nullable<FloatArray>;
  106639. /**
  106640. * 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).
  106641. */
  106642. matricesIndices: Nullable<FloatArray>;
  106643. /**
  106644. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  106645. */
  106646. matricesWeights: Nullable<FloatArray>;
  106647. /**
  106648. * An array extending the number of possible indices
  106649. */
  106650. matricesIndicesExtra: Nullable<FloatArray>;
  106651. /**
  106652. * An array extending the number of possible weights when the number of indices is extended
  106653. */
  106654. matricesWeightsExtra: Nullable<FloatArray>;
  106655. /**
  106656. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  106657. */
  106658. indices: Nullable<IndicesArray>;
  106659. /**
  106660. * Uses the passed data array to set the set the values for the specified kind of data
  106661. * @param data a linear array of floating numbers
  106662. * @param kind the type of data that is being set, eg positions, colors etc
  106663. */
  106664. set(data: FloatArray, kind: string): void;
  106665. /**
  106666. * Associates the vertexData to the passed Mesh.
  106667. * Sets it as updatable or not (default `false`)
  106668. * @param mesh the mesh the vertexData is applied to
  106669. * @param updatable when used and having the value true allows new data to update the vertexData
  106670. * @returns the VertexData
  106671. */
  106672. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  106673. /**
  106674. * Associates the vertexData to the passed Geometry.
  106675. * Sets it as updatable or not (default `false`)
  106676. * @param geometry the geometry the vertexData is applied to
  106677. * @param updatable when used and having the value true allows new data to update the vertexData
  106678. * @returns VertexData
  106679. */
  106680. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  106681. /**
  106682. * Updates the associated mesh
  106683. * @param mesh the mesh to be updated
  106684. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106685. * @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
  106686. * @returns VertexData
  106687. */
  106688. updateMesh(mesh: Mesh): VertexData;
  106689. /**
  106690. * Updates the associated geometry
  106691. * @param geometry the geometry to be updated
  106692. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106693. * @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
  106694. * @returns VertexData.
  106695. */
  106696. updateGeometry(geometry: Geometry): VertexData;
  106697. private _applyTo;
  106698. private _update;
  106699. /**
  106700. * Transforms each position and each normal of the vertexData according to the passed Matrix
  106701. * @param matrix the transforming matrix
  106702. * @returns the VertexData
  106703. */
  106704. transform(matrix: Matrix): VertexData;
  106705. /**
  106706. * Merges the passed VertexData into the current one
  106707. * @param other the VertexData to be merged into the current one
  106708. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  106709. * @returns the modified VertexData
  106710. */
  106711. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  106712. private _mergeElement;
  106713. private _validate;
  106714. /**
  106715. * Serializes the VertexData
  106716. * @returns a serialized object
  106717. */
  106718. serialize(): any;
  106719. /**
  106720. * Extracts the vertexData from a mesh
  106721. * @param mesh the mesh from which to extract the VertexData
  106722. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  106723. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106724. * @returns the object VertexData associated to the passed mesh
  106725. */
  106726. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106727. /**
  106728. * Extracts the vertexData from the geometry
  106729. * @param geometry the geometry from which to extract the VertexData
  106730. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  106731. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106732. * @returns the object VertexData associated to the passed mesh
  106733. */
  106734. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106735. private static _ExtractFrom;
  106736. /**
  106737. * Creates the VertexData for a Ribbon
  106738. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  106739. * * pathArray array of paths, each of which an array of successive Vector3
  106740. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  106741. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  106742. * * 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
  106743. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106744. * * 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)
  106745. * * 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)
  106746. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  106747. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  106748. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  106749. * @returns the VertexData of the ribbon
  106750. */
  106751. static CreateRibbon(options: {
  106752. pathArray: Vector3[][];
  106753. closeArray?: boolean;
  106754. closePath?: boolean;
  106755. offset?: number;
  106756. sideOrientation?: number;
  106757. frontUVs?: Vector4;
  106758. backUVs?: Vector4;
  106759. invertUV?: boolean;
  106760. uvs?: Vector2[];
  106761. colors?: Color4[];
  106762. }): VertexData;
  106763. /**
  106764. * Creates the VertexData for a box
  106765. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106766. * * size sets the width, height and depth of the box to the value of size, optional default 1
  106767. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  106768. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  106769. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  106770. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106771. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106773. * * 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)
  106774. * * 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)
  106775. * @returns the VertexData of the box
  106776. */
  106777. static CreateBox(options: {
  106778. size?: number;
  106779. width?: number;
  106780. height?: number;
  106781. depth?: number;
  106782. faceUV?: Vector4[];
  106783. faceColors?: Color4[];
  106784. sideOrientation?: number;
  106785. frontUVs?: Vector4;
  106786. backUVs?: Vector4;
  106787. }): VertexData;
  106788. /**
  106789. * Creates the VertexData for a tiled box
  106790. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106791. * * faceTiles sets the pattern, tile size and number of tiles for a face
  106792. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106793. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106794. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106795. * @returns the VertexData of the box
  106796. */
  106797. static CreateTiledBox(options: {
  106798. pattern?: number;
  106799. width?: number;
  106800. height?: number;
  106801. depth?: number;
  106802. tileSize?: number;
  106803. tileWidth?: number;
  106804. tileHeight?: number;
  106805. alignHorizontal?: number;
  106806. alignVertical?: number;
  106807. faceUV?: Vector4[];
  106808. faceColors?: Color4[];
  106809. sideOrientation?: number;
  106810. }): VertexData;
  106811. /**
  106812. * Creates the VertexData for a tiled plane
  106813. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106814. * * pattern a limited pattern arrangement depending on the number
  106815. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  106816. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  106817. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  106818. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106819. * * 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)
  106820. * * 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)
  106821. * @returns the VertexData of the tiled plane
  106822. */
  106823. static CreateTiledPlane(options: {
  106824. pattern?: number;
  106825. tileSize?: number;
  106826. tileWidth?: number;
  106827. tileHeight?: number;
  106828. size?: number;
  106829. width?: number;
  106830. height?: number;
  106831. alignHorizontal?: number;
  106832. alignVertical?: number;
  106833. sideOrientation?: number;
  106834. frontUVs?: Vector4;
  106835. backUVs?: Vector4;
  106836. }): VertexData;
  106837. /**
  106838. * Creates the VertexData for an ellipsoid, defaults to a sphere
  106839. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106840. * * segments sets the number of horizontal strips optional, default 32
  106841. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  106842. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  106843. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  106844. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  106845. * * 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
  106846. * * 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
  106847. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106848. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  106849. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  106850. * @returns the VertexData of the ellipsoid
  106851. */
  106852. static CreateSphere(options: {
  106853. segments?: number;
  106854. diameter?: number;
  106855. diameterX?: number;
  106856. diameterY?: number;
  106857. diameterZ?: number;
  106858. arc?: number;
  106859. slice?: number;
  106860. sideOrientation?: number;
  106861. frontUVs?: Vector4;
  106862. backUVs?: Vector4;
  106863. }): VertexData;
  106864. /**
  106865. * Creates the VertexData for a cylinder, cone or prism
  106866. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106867. * * height sets the height (y direction) of the cylinder, optional, default 2
  106868. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  106869. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  106870. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  106871. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106872. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  106873. * * 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
  106874. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106875. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106876. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  106877. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  106878. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106879. * * 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)
  106880. * * 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)
  106881. * @returns the VertexData of the cylinder, cone or prism
  106882. */
  106883. static CreateCylinder(options: {
  106884. height?: number;
  106885. diameterTop?: number;
  106886. diameterBottom?: number;
  106887. diameter?: number;
  106888. tessellation?: number;
  106889. subdivisions?: number;
  106890. arc?: number;
  106891. faceColors?: Color4[];
  106892. faceUV?: Vector4[];
  106893. hasRings?: boolean;
  106894. enclose?: boolean;
  106895. sideOrientation?: number;
  106896. frontUVs?: Vector4;
  106897. backUVs?: Vector4;
  106898. }): VertexData;
  106899. /**
  106900. * Creates the VertexData for a torus
  106901. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106902. * * diameter the diameter of the torus, optional default 1
  106903. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106904. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106905. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106906. * * 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)
  106907. * * 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)
  106908. * @returns the VertexData of the torus
  106909. */
  106910. static CreateTorus(options: {
  106911. diameter?: number;
  106912. thickness?: number;
  106913. tessellation?: number;
  106914. sideOrientation?: number;
  106915. frontUVs?: Vector4;
  106916. backUVs?: Vector4;
  106917. }): VertexData;
  106918. /**
  106919. * Creates the VertexData of the LineSystem
  106920. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106921. * - lines an array of lines, each line being an array of successive Vector3
  106922. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106923. * @returns the VertexData of the LineSystem
  106924. */
  106925. static CreateLineSystem(options: {
  106926. lines: Vector3[][];
  106927. colors?: Nullable<Color4[][]>;
  106928. }): VertexData;
  106929. /**
  106930. * Create the VertexData for a DashedLines
  106931. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106932. * - points an array successive Vector3
  106933. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106934. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106935. * - dashNb the intended total number of dashes, optional, default 200
  106936. * @returns the VertexData for the DashedLines
  106937. */
  106938. static CreateDashedLines(options: {
  106939. points: Vector3[];
  106940. dashSize?: number;
  106941. gapSize?: number;
  106942. dashNb?: number;
  106943. }): VertexData;
  106944. /**
  106945. * Creates the VertexData for a Ground
  106946. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106947. * - width the width (x direction) of the ground, optional, default 1
  106948. * - height the height (z direction) of the ground, optional, default 1
  106949. * - subdivisions the number of subdivisions per side, optional, default 1
  106950. * @returns the VertexData of the Ground
  106951. */
  106952. static CreateGround(options: {
  106953. width?: number;
  106954. height?: number;
  106955. subdivisions?: number;
  106956. subdivisionsX?: number;
  106957. subdivisionsY?: number;
  106958. }): VertexData;
  106959. /**
  106960. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106961. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106962. * * xmin the ground minimum X coordinate, optional, default -1
  106963. * * zmin the ground minimum Z coordinate, optional, default -1
  106964. * * xmax the ground maximum X coordinate, optional, default 1
  106965. * * zmax the ground maximum Z coordinate, optional, default 1
  106966. * * 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}
  106967. * * 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}
  106968. * @returns the VertexData of the TiledGround
  106969. */
  106970. static CreateTiledGround(options: {
  106971. xmin: number;
  106972. zmin: number;
  106973. xmax: number;
  106974. zmax: number;
  106975. subdivisions?: {
  106976. w: number;
  106977. h: number;
  106978. };
  106979. precision?: {
  106980. w: number;
  106981. h: number;
  106982. };
  106983. }): VertexData;
  106984. /**
  106985. * Creates the VertexData of the Ground designed from a heightmap
  106986. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106987. * * width the width (x direction) of the ground
  106988. * * height the height (z direction) of the ground
  106989. * * subdivisions the number of subdivisions per side
  106990. * * minHeight the minimum altitude on the ground, optional, default 0
  106991. * * maxHeight the maximum altitude on the ground, optional default 1
  106992. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106993. * * buffer the array holding the image color data
  106994. * * bufferWidth the width of image
  106995. * * bufferHeight the height of image
  106996. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106997. * @returns the VertexData of the Ground designed from a heightmap
  106998. */
  106999. static CreateGroundFromHeightMap(options: {
  107000. width: number;
  107001. height: number;
  107002. subdivisions: number;
  107003. minHeight: number;
  107004. maxHeight: number;
  107005. colorFilter: Color3;
  107006. buffer: Uint8Array;
  107007. bufferWidth: number;
  107008. bufferHeight: number;
  107009. alphaFilter: number;
  107010. }): VertexData;
  107011. /**
  107012. * Creates the VertexData for a Plane
  107013. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  107014. * * size sets the width and height of the plane to the value of size, optional default 1
  107015. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  107016. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  107017. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107018. * * 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)
  107019. * * 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)
  107020. * @returns the VertexData of the box
  107021. */
  107022. static CreatePlane(options: {
  107023. size?: number;
  107024. width?: number;
  107025. height?: number;
  107026. sideOrientation?: number;
  107027. frontUVs?: Vector4;
  107028. backUVs?: Vector4;
  107029. }): VertexData;
  107030. /**
  107031. * Creates the VertexData of the Disc or regular Polygon
  107032. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  107033. * * radius the radius of the disc, optional default 0.5
  107034. * * tessellation the number of polygon sides, optional, default 64
  107035. * * 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
  107036. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107037. * * 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)
  107038. * * 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)
  107039. * @returns the VertexData of the box
  107040. */
  107041. static CreateDisc(options: {
  107042. radius?: number;
  107043. tessellation?: number;
  107044. arc?: number;
  107045. sideOrientation?: number;
  107046. frontUVs?: Vector4;
  107047. backUVs?: Vector4;
  107048. }): VertexData;
  107049. /**
  107050. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  107051. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  107052. * @param polygon a mesh built from polygonTriangulation.build()
  107053. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107054. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  107055. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  107056. * @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)
  107057. * @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)
  107058. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  107059. * @returns the VertexData of the Polygon
  107060. */
  107061. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  107062. /**
  107063. * Creates the VertexData of the IcoSphere
  107064. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  107065. * * radius the radius of the IcoSphere, optional default 1
  107066. * * radiusX allows stretching in the x direction, optional, default radius
  107067. * * radiusY allows stretching in the y direction, optional, default radius
  107068. * * radiusZ allows stretching in the z direction, optional, default radius
  107069. * * flat when true creates a flat shaded mesh, optional, default true
  107070. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  107071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107072. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  107073. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  107074. * @returns the VertexData of the IcoSphere
  107075. */
  107076. static CreateIcoSphere(options: {
  107077. radius?: number;
  107078. radiusX?: number;
  107079. radiusY?: number;
  107080. radiusZ?: number;
  107081. flat?: boolean;
  107082. subdivisions?: number;
  107083. sideOrientation?: number;
  107084. frontUVs?: Vector4;
  107085. backUVs?: Vector4;
  107086. }): VertexData;
  107087. /**
  107088. * Creates the VertexData for a Polyhedron
  107089. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  107090. * * type provided types are:
  107091. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  107092. * * 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)
  107093. * * size the size of the IcoSphere, optional default 1
  107094. * * sizeX allows stretching in the x direction, optional, default size
  107095. * * sizeY allows stretching in the y direction, optional, default size
  107096. * * sizeZ allows stretching in the z direction, optional, default size
  107097. * * 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
  107098. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  107099. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  107100. * * flat when true creates a flat shaded mesh, optional, default true
  107101. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  107102. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107103. * * 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)
  107104. * * 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)
  107105. * @returns the VertexData of the Polyhedron
  107106. */
  107107. static CreatePolyhedron(options: {
  107108. type?: number;
  107109. size?: number;
  107110. sizeX?: number;
  107111. sizeY?: number;
  107112. sizeZ?: number;
  107113. custom?: any;
  107114. faceUV?: Vector4[];
  107115. faceColors?: Color4[];
  107116. flat?: boolean;
  107117. sideOrientation?: number;
  107118. frontUVs?: Vector4;
  107119. backUVs?: Vector4;
  107120. }): VertexData;
  107121. /**
  107122. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  107123. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  107124. * @returns the VertexData of the Capsule
  107125. */
  107126. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  107127. /**
  107128. * Creates the VertexData for a TorusKnot
  107129. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  107130. * * radius the radius of the torus knot, optional, default 2
  107131. * * tube the thickness of the tube, optional, default 0.5
  107132. * * radialSegments the number of sides on each tube segments, optional, default 32
  107133. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  107134. * * p the number of windings around the z axis, optional, default 2
  107135. * * q the number of windings around the x axis, optional, default 3
  107136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107137. * * 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)
  107138. * * 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)
  107139. * @returns the VertexData of the Torus Knot
  107140. */
  107141. static CreateTorusKnot(options: {
  107142. radius?: number;
  107143. tube?: number;
  107144. radialSegments?: number;
  107145. tubularSegments?: number;
  107146. p?: number;
  107147. q?: number;
  107148. sideOrientation?: number;
  107149. frontUVs?: Vector4;
  107150. backUVs?: Vector4;
  107151. }): VertexData;
  107152. /**
  107153. * Compute normals for given positions and indices
  107154. * @param positions an array of vertex positions, [...., x, y, z, ......]
  107155. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  107156. * @param normals an array of vertex normals, [...., x, y, z, ......]
  107157. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  107158. * * facetNormals : optional array of facet normals (vector3)
  107159. * * facetPositions : optional array of facet positions (vector3)
  107160. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  107161. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  107162. * * bInfo : optional bounding info, required for facetPartitioning computation
  107163. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  107164. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  107165. * * useRightHandedSystem: optional boolean to for right handed system computation
  107166. * * depthSort : optional boolean to enable the facet depth sort computation
  107167. * * distanceTo : optional Vector3 to compute the facet depth from this location
  107168. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  107169. */
  107170. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  107171. facetNormals?: any;
  107172. facetPositions?: any;
  107173. facetPartitioning?: any;
  107174. ratio?: number;
  107175. bInfo?: any;
  107176. bbSize?: Vector3;
  107177. subDiv?: any;
  107178. useRightHandedSystem?: boolean;
  107179. depthSort?: boolean;
  107180. distanceTo?: Vector3;
  107181. depthSortedFacets?: any;
  107182. }): void;
  107183. /** @hidden */
  107184. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  107185. /**
  107186. * Applies VertexData created from the imported parameters to the geometry
  107187. * @param parsedVertexData the parsed data from an imported file
  107188. * @param geometry the geometry to apply the VertexData to
  107189. */
  107190. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  107191. }
  107192. }
  107193. declare module BABYLON {
  107194. /**
  107195. * Defines a target to use with MorphTargetManager
  107196. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107197. */
  107198. export class MorphTarget implements IAnimatable {
  107199. /** defines the name of the target */
  107200. name: string;
  107201. /**
  107202. * Gets or sets the list of animations
  107203. */
  107204. animations: Animation[];
  107205. private _scene;
  107206. private _positions;
  107207. private _normals;
  107208. private _tangents;
  107209. private _uvs;
  107210. private _influence;
  107211. private _uniqueId;
  107212. /**
  107213. * Observable raised when the influence changes
  107214. */
  107215. onInfluenceChanged: Observable<boolean>;
  107216. /** @hidden */
  107217. _onDataLayoutChanged: Observable<void>;
  107218. /**
  107219. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  107220. */
  107221. get influence(): number;
  107222. set influence(influence: number);
  107223. /**
  107224. * Gets or sets the id of the morph Target
  107225. */
  107226. id: string;
  107227. private _animationPropertiesOverride;
  107228. /**
  107229. * Gets or sets the animation properties override
  107230. */
  107231. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  107232. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  107233. /**
  107234. * Creates a new MorphTarget
  107235. * @param name defines the name of the target
  107236. * @param influence defines the influence to use
  107237. * @param scene defines the scene the morphtarget belongs to
  107238. */
  107239. constructor(
  107240. /** defines the name of the target */
  107241. name: string, influence?: number, scene?: Nullable<Scene>);
  107242. /**
  107243. * Gets the unique ID of this manager
  107244. */
  107245. get uniqueId(): number;
  107246. /**
  107247. * Gets a boolean defining if the target contains position data
  107248. */
  107249. get hasPositions(): boolean;
  107250. /**
  107251. * Gets a boolean defining if the target contains normal data
  107252. */
  107253. get hasNormals(): boolean;
  107254. /**
  107255. * Gets a boolean defining if the target contains tangent data
  107256. */
  107257. get hasTangents(): boolean;
  107258. /**
  107259. * Gets a boolean defining if the target contains texture coordinates data
  107260. */
  107261. get hasUVs(): boolean;
  107262. /**
  107263. * Affects position data to this target
  107264. * @param data defines the position data to use
  107265. */
  107266. setPositions(data: Nullable<FloatArray>): void;
  107267. /**
  107268. * Gets the position data stored in this target
  107269. * @returns a FloatArray containing the position data (or null if not present)
  107270. */
  107271. getPositions(): Nullable<FloatArray>;
  107272. /**
  107273. * Affects normal data to this target
  107274. * @param data defines the normal data to use
  107275. */
  107276. setNormals(data: Nullable<FloatArray>): void;
  107277. /**
  107278. * Gets the normal data stored in this target
  107279. * @returns a FloatArray containing the normal data (or null if not present)
  107280. */
  107281. getNormals(): Nullable<FloatArray>;
  107282. /**
  107283. * Affects tangent data to this target
  107284. * @param data defines the tangent data to use
  107285. */
  107286. setTangents(data: Nullable<FloatArray>): void;
  107287. /**
  107288. * Gets the tangent data stored in this target
  107289. * @returns a FloatArray containing the tangent data (or null if not present)
  107290. */
  107291. getTangents(): Nullable<FloatArray>;
  107292. /**
  107293. * Affects texture coordinates data to this target
  107294. * @param data defines the texture coordinates data to use
  107295. */
  107296. setUVs(data: Nullable<FloatArray>): void;
  107297. /**
  107298. * Gets the texture coordinates data stored in this target
  107299. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  107300. */
  107301. getUVs(): Nullable<FloatArray>;
  107302. /**
  107303. * Clone the current target
  107304. * @returns a new MorphTarget
  107305. */
  107306. clone(): MorphTarget;
  107307. /**
  107308. * Serializes the current target into a Serialization object
  107309. * @returns the serialized object
  107310. */
  107311. serialize(): any;
  107312. /**
  107313. * Returns the string "MorphTarget"
  107314. * @returns "MorphTarget"
  107315. */
  107316. getClassName(): string;
  107317. /**
  107318. * Creates a new target from serialized data
  107319. * @param serializationObject defines the serialized data to use
  107320. * @returns a new MorphTarget
  107321. */
  107322. static Parse(serializationObject: any): MorphTarget;
  107323. /**
  107324. * Creates a MorphTarget from mesh data
  107325. * @param mesh defines the source mesh
  107326. * @param name defines the name to use for the new target
  107327. * @param influence defines the influence to attach to the target
  107328. * @returns a new MorphTarget
  107329. */
  107330. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  107331. }
  107332. }
  107333. declare module BABYLON {
  107334. /**
  107335. * This class is used to deform meshes using morphing between different targets
  107336. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107337. */
  107338. export class MorphTargetManager {
  107339. private _targets;
  107340. private _targetInfluenceChangedObservers;
  107341. private _targetDataLayoutChangedObservers;
  107342. private _activeTargets;
  107343. private _scene;
  107344. private _influences;
  107345. private _supportsNormals;
  107346. private _supportsTangents;
  107347. private _supportsUVs;
  107348. private _vertexCount;
  107349. private _uniqueId;
  107350. private _tempInfluences;
  107351. /**
  107352. * Gets or sets a boolean indicating if normals must be morphed
  107353. */
  107354. enableNormalMorphing: boolean;
  107355. /**
  107356. * Gets or sets a boolean indicating if tangents must be morphed
  107357. */
  107358. enableTangentMorphing: boolean;
  107359. /**
  107360. * Gets or sets a boolean indicating if UV must be morphed
  107361. */
  107362. enableUVMorphing: boolean;
  107363. /**
  107364. * Creates a new MorphTargetManager
  107365. * @param scene defines the current scene
  107366. */
  107367. constructor(scene?: Nullable<Scene>);
  107368. /**
  107369. * Gets the unique ID of this manager
  107370. */
  107371. get uniqueId(): number;
  107372. /**
  107373. * Gets the number of vertices handled by this manager
  107374. */
  107375. get vertexCount(): number;
  107376. /**
  107377. * Gets a boolean indicating if this manager supports morphing of normals
  107378. */
  107379. get supportsNormals(): boolean;
  107380. /**
  107381. * Gets a boolean indicating if this manager supports morphing of tangents
  107382. */
  107383. get supportsTangents(): boolean;
  107384. /**
  107385. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  107386. */
  107387. get supportsUVs(): boolean;
  107388. /**
  107389. * Gets the number of targets stored in this manager
  107390. */
  107391. get numTargets(): number;
  107392. /**
  107393. * Gets the number of influencers (ie. the number of targets with influences > 0)
  107394. */
  107395. get numInfluencers(): number;
  107396. /**
  107397. * Gets the list of influences (one per target)
  107398. */
  107399. get influences(): Float32Array;
  107400. /**
  107401. * Gets the active target at specified index. An active target is a target with an influence > 0
  107402. * @param index defines the index to check
  107403. * @returns the requested target
  107404. */
  107405. getActiveTarget(index: number): MorphTarget;
  107406. /**
  107407. * Gets the target at specified index
  107408. * @param index defines the index to check
  107409. * @returns the requested target
  107410. */
  107411. getTarget(index: number): MorphTarget;
  107412. /**
  107413. * Add a new target to this manager
  107414. * @param target defines the target to add
  107415. */
  107416. addTarget(target: MorphTarget): void;
  107417. /**
  107418. * Removes a target from the manager
  107419. * @param target defines the target to remove
  107420. */
  107421. removeTarget(target: MorphTarget): void;
  107422. /**
  107423. * Clone the current manager
  107424. * @returns a new MorphTargetManager
  107425. */
  107426. clone(): MorphTargetManager;
  107427. /**
  107428. * Serializes the current manager into a Serialization object
  107429. * @returns the serialized object
  107430. */
  107431. serialize(): any;
  107432. private _syncActiveTargets;
  107433. /**
  107434. * Syncrhonize the targets with all the meshes using this morph target manager
  107435. */
  107436. synchronize(): void;
  107437. /**
  107438. * Creates a new MorphTargetManager from serialized data
  107439. * @param serializationObject defines the serialized data
  107440. * @param scene defines the hosting scene
  107441. * @returns the new MorphTargetManager
  107442. */
  107443. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  107444. }
  107445. }
  107446. declare module BABYLON {
  107447. /**
  107448. * Class used to represent a specific level of detail of a mesh
  107449. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107450. */
  107451. export class MeshLODLevel {
  107452. /** Defines the distance where this level should start being displayed */
  107453. distance: number;
  107454. /** Defines the mesh to use to render this level */
  107455. mesh: Nullable<Mesh>;
  107456. /**
  107457. * Creates a new LOD level
  107458. * @param distance defines the distance where this level should star being displayed
  107459. * @param mesh defines the mesh to use to render this level
  107460. */
  107461. constructor(
  107462. /** Defines the distance where this level should start being displayed */
  107463. distance: number,
  107464. /** Defines the mesh to use to render this level */
  107465. mesh: Nullable<Mesh>);
  107466. }
  107467. }
  107468. declare module BABYLON {
  107469. /**
  107470. * Helper class used to generate a canvas to manipulate images
  107471. */
  107472. export class CanvasGenerator {
  107473. /**
  107474. * Create a new canvas (or offscreen canvas depending on the context)
  107475. * @param width defines the expected width
  107476. * @param height defines the expected height
  107477. * @return a new canvas or offscreen canvas
  107478. */
  107479. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  107480. }
  107481. }
  107482. declare module BABYLON {
  107483. /**
  107484. * Mesh representing the gorund
  107485. */
  107486. export class GroundMesh extends Mesh {
  107487. /** If octree should be generated */
  107488. generateOctree: boolean;
  107489. private _heightQuads;
  107490. /** @hidden */
  107491. _subdivisionsX: number;
  107492. /** @hidden */
  107493. _subdivisionsY: number;
  107494. /** @hidden */
  107495. _width: number;
  107496. /** @hidden */
  107497. _height: number;
  107498. /** @hidden */
  107499. _minX: number;
  107500. /** @hidden */
  107501. _maxX: number;
  107502. /** @hidden */
  107503. _minZ: number;
  107504. /** @hidden */
  107505. _maxZ: number;
  107506. constructor(name: string, scene: Scene);
  107507. /**
  107508. * "GroundMesh"
  107509. * @returns "GroundMesh"
  107510. */
  107511. getClassName(): string;
  107512. /**
  107513. * The minimum of x and y subdivisions
  107514. */
  107515. get subdivisions(): number;
  107516. /**
  107517. * X subdivisions
  107518. */
  107519. get subdivisionsX(): number;
  107520. /**
  107521. * Y subdivisions
  107522. */
  107523. get subdivisionsY(): number;
  107524. /**
  107525. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  107526. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107527. * @param chunksCount the number of subdivisions for x and y
  107528. * @param octreeBlocksSize (Default: 32)
  107529. */
  107530. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  107531. /**
  107532. * Returns a height (y) value in the Worl system :
  107533. * the ground altitude at the coordinates (x, z) expressed in the World system.
  107534. * @param x x coordinate
  107535. * @param z z coordinate
  107536. * @returns the ground y position if (x, z) are outside the ground surface.
  107537. */
  107538. getHeightAtCoordinates(x: number, z: number): number;
  107539. /**
  107540. * Returns a normalized vector (Vector3) orthogonal to the ground
  107541. * at the ground coordinates (x, z) expressed in the World system.
  107542. * @param x x coordinate
  107543. * @param z z coordinate
  107544. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  107545. */
  107546. getNormalAtCoordinates(x: number, z: number): Vector3;
  107547. /**
  107548. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  107549. * at the ground coordinates (x, z) expressed in the World system.
  107550. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  107551. * @param x x coordinate
  107552. * @param z z coordinate
  107553. * @param ref vector to store the result
  107554. * @returns the GroundMesh.
  107555. */
  107556. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  107557. /**
  107558. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  107559. * if the ground has been updated.
  107560. * This can be used in the render loop.
  107561. * @returns the GroundMesh.
  107562. */
  107563. updateCoordinateHeights(): GroundMesh;
  107564. private _getFacetAt;
  107565. private _initHeightQuads;
  107566. private _computeHeightQuads;
  107567. /**
  107568. * Serializes this ground mesh
  107569. * @param serializationObject object to write serialization to
  107570. */
  107571. serialize(serializationObject: any): void;
  107572. /**
  107573. * Parses a serialized ground mesh
  107574. * @param parsedMesh the serialized mesh
  107575. * @param scene the scene to create the ground mesh in
  107576. * @returns the created ground mesh
  107577. */
  107578. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  107579. }
  107580. }
  107581. declare module BABYLON {
  107582. /**
  107583. * Interface for Physics-Joint data
  107584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107585. */
  107586. export interface PhysicsJointData {
  107587. /**
  107588. * The main pivot of the joint
  107589. */
  107590. mainPivot?: Vector3;
  107591. /**
  107592. * The connected pivot of the joint
  107593. */
  107594. connectedPivot?: Vector3;
  107595. /**
  107596. * The main axis of the joint
  107597. */
  107598. mainAxis?: Vector3;
  107599. /**
  107600. * The connected axis of the joint
  107601. */
  107602. connectedAxis?: Vector3;
  107603. /**
  107604. * The collision of the joint
  107605. */
  107606. collision?: boolean;
  107607. /**
  107608. * Native Oimo/Cannon/Energy data
  107609. */
  107610. nativeParams?: any;
  107611. }
  107612. /**
  107613. * This is a holder class for the physics joint created by the physics plugin
  107614. * It holds a set of functions to control the underlying joint
  107615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107616. */
  107617. export class PhysicsJoint {
  107618. /**
  107619. * The type of the physics joint
  107620. */
  107621. type: number;
  107622. /**
  107623. * The data for the physics joint
  107624. */
  107625. jointData: PhysicsJointData;
  107626. private _physicsJoint;
  107627. protected _physicsPlugin: IPhysicsEnginePlugin;
  107628. /**
  107629. * Initializes the physics joint
  107630. * @param type The type of the physics joint
  107631. * @param jointData The data for the physics joint
  107632. */
  107633. constructor(
  107634. /**
  107635. * The type of the physics joint
  107636. */
  107637. type: number,
  107638. /**
  107639. * The data for the physics joint
  107640. */
  107641. jointData: PhysicsJointData);
  107642. /**
  107643. * Gets the physics joint
  107644. */
  107645. get physicsJoint(): any;
  107646. /**
  107647. * Sets the physics joint
  107648. */
  107649. set physicsJoint(newJoint: any);
  107650. /**
  107651. * Sets the physics plugin
  107652. */
  107653. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  107654. /**
  107655. * Execute a function that is physics-plugin specific.
  107656. * @param {Function} func the function that will be executed.
  107657. * It accepts two parameters: the physics world and the physics joint
  107658. */
  107659. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  107660. /**
  107661. * Distance-Joint type
  107662. */
  107663. static DistanceJoint: number;
  107664. /**
  107665. * Hinge-Joint type
  107666. */
  107667. static HingeJoint: number;
  107668. /**
  107669. * Ball-and-Socket joint type
  107670. */
  107671. static BallAndSocketJoint: number;
  107672. /**
  107673. * Wheel-Joint type
  107674. */
  107675. static WheelJoint: number;
  107676. /**
  107677. * Slider-Joint type
  107678. */
  107679. static SliderJoint: number;
  107680. /**
  107681. * Prismatic-Joint type
  107682. */
  107683. static PrismaticJoint: number;
  107684. /**
  107685. * Universal-Joint type
  107686. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  107687. */
  107688. static UniversalJoint: number;
  107689. /**
  107690. * Hinge-Joint 2 type
  107691. */
  107692. static Hinge2Joint: number;
  107693. /**
  107694. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  107695. */
  107696. static PointToPointJoint: number;
  107697. /**
  107698. * Spring-Joint type
  107699. */
  107700. static SpringJoint: number;
  107701. /**
  107702. * Lock-Joint type
  107703. */
  107704. static LockJoint: number;
  107705. }
  107706. /**
  107707. * A class representing a physics distance joint
  107708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107709. */
  107710. export class DistanceJoint extends PhysicsJoint {
  107711. /**
  107712. *
  107713. * @param jointData The data for the Distance-Joint
  107714. */
  107715. constructor(jointData: DistanceJointData);
  107716. /**
  107717. * Update the predefined distance.
  107718. * @param maxDistance The maximum preferred distance
  107719. * @param minDistance The minimum preferred distance
  107720. */
  107721. updateDistance(maxDistance: number, minDistance?: number): void;
  107722. }
  107723. /**
  107724. * Represents a Motor-Enabled Joint
  107725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107726. */
  107727. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  107728. /**
  107729. * Initializes the Motor-Enabled Joint
  107730. * @param type The type of the joint
  107731. * @param jointData The physica joint data for the joint
  107732. */
  107733. constructor(type: number, jointData: PhysicsJointData);
  107734. /**
  107735. * Set the motor values.
  107736. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107737. * @param force the force to apply
  107738. * @param maxForce max force for this motor.
  107739. */
  107740. setMotor(force?: number, maxForce?: number): void;
  107741. /**
  107742. * Set the motor's limits.
  107743. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107744. * @param upperLimit The upper limit of the motor
  107745. * @param lowerLimit The lower limit of the motor
  107746. */
  107747. setLimit(upperLimit: number, lowerLimit?: number): void;
  107748. }
  107749. /**
  107750. * This class represents a single physics Hinge-Joint
  107751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107752. */
  107753. export class HingeJoint extends MotorEnabledJoint {
  107754. /**
  107755. * Initializes the Hinge-Joint
  107756. * @param jointData The joint data for the Hinge-Joint
  107757. */
  107758. constructor(jointData: PhysicsJointData);
  107759. /**
  107760. * Set the motor values.
  107761. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107762. * @param {number} force the force to apply
  107763. * @param {number} maxForce max force for this motor.
  107764. */
  107765. setMotor(force?: number, maxForce?: number): void;
  107766. /**
  107767. * Set the motor's limits.
  107768. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107769. * @param upperLimit The upper limit of the motor
  107770. * @param lowerLimit The lower limit of the motor
  107771. */
  107772. setLimit(upperLimit: number, lowerLimit?: number): void;
  107773. }
  107774. /**
  107775. * This class represents a dual hinge physics joint (same as wheel joint)
  107776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107777. */
  107778. export class Hinge2Joint extends MotorEnabledJoint {
  107779. /**
  107780. * Initializes the Hinge2-Joint
  107781. * @param jointData The joint data for the Hinge2-Joint
  107782. */
  107783. constructor(jointData: PhysicsJointData);
  107784. /**
  107785. * Set the motor values.
  107786. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107787. * @param {number} targetSpeed the speed the motor is to reach
  107788. * @param {number} maxForce max force for this motor.
  107789. * @param {motorIndex} the motor's index, 0 or 1.
  107790. */
  107791. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  107792. /**
  107793. * Set the motor limits.
  107794. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107795. * @param {number} upperLimit the upper limit
  107796. * @param {number} lowerLimit lower limit
  107797. * @param {motorIndex} the motor's index, 0 or 1.
  107798. */
  107799. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107800. }
  107801. /**
  107802. * Interface for a motor enabled joint
  107803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107804. */
  107805. export interface IMotorEnabledJoint {
  107806. /**
  107807. * Physics joint
  107808. */
  107809. physicsJoint: any;
  107810. /**
  107811. * Sets the motor of the motor-enabled joint
  107812. * @param force The force of the motor
  107813. * @param maxForce The maximum force of the motor
  107814. * @param motorIndex The index of the motor
  107815. */
  107816. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  107817. /**
  107818. * Sets the limit of the motor
  107819. * @param upperLimit The upper limit of the motor
  107820. * @param lowerLimit The lower limit of the motor
  107821. * @param motorIndex The index of the motor
  107822. */
  107823. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107824. }
  107825. /**
  107826. * Joint data for a Distance-Joint
  107827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107828. */
  107829. export interface DistanceJointData extends PhysicsJointData {
  107830. /**
  107831. * Max distance the 2 joint objects can be apart
  107832. */
  107833. maxDistance: number;
  107834. }
  107835. /**
  107836. * Joint data from a spring joint
  107837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107838. */
  107839. export interface SpringJointData extends PhysicsJointData {
  107840. /**
  107841. * Length of the spring
  107842. */
  107843. length: number;
  107844. /**
  107845. * Stiffness of the spring
  107846. */
  107847. stiffness: number;
  107848. /**
  107849. * Damping of the spring
  107850. */
  107851. damping: number;
  107852. /** this callback will be called when applying the force to the impostors. */
  107853. forceApplicationCallback: () => void;
  107854. }
  107855. }
  107856. declare module BABYLON {
  107857. /**
  107858. * Holds the data for the raycast result
  107859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107860. */
  107861. export class PhysicsRaycastResult {
  107862. private _hasHit;
  107863. private _hitDistance;
  107864. private _hitNormalWorld;
  107865. private _hitPointWorld;
  107866. private _rayFromWorld;
  107867. private _rayToWorld;
  107868. /**
  107869. * Gets if there was a hit
  107870. */
  107871. get hasHit(): boolean;
  107872. /**
  107873. * Gets the distance from the hit
  107874. */
  107875. get hitDistance(): number;
  107876. /**
  107877. * Gets the hit normal/direction in the world
  107878. */
  107879. get hitNormalWorld(): Vector3;
  107880. /**
  107881. * Gets the hit point in the world
  107882. */
  107883. get hitPointWorld(): Vector3;
  107884. /**
  107885. * Gets the ray "start point" of the ray in the world
  107886. */
  107887. get rayFromWorld(): Vector3;
  107888. /**
  107889. * Gets the ray "end point" of the ray in the world
  107890. */
  107891. get rayToWorld(): Vector3;
  107892. /**
  107893. * Sets the hit data (normal & point in world space)
  107894. * @param hitNormalWorld defines the normal in world space
  107895. * @param hitPointWorld defines the point in world space
  107896. */
  107897. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107898. /**
  107899. * Sets the distance from the start point to the hit point
  107900. * @param distance
  107901. */
  107902. setHitDistance(distance: number): void;
  107903. /**
  107904. * Calculates the distance manually
  107905. */
  107906. calculateHitDistance(): void;
  107907. /**
  107908. * Resets all the values to default
  107909. * @param from The from point on world space
  107910. * @param to The to point on world space
  107911. */
  107912. reset(from?: Vector3, to?: Vector3): void;
  107913. }
  107914. /**
  107915. * Interface for the size containing width and height
  107916. */
  107917. interface IXYZ {
  107918. /**
  107919. * X
  107920. */
  107921. x: number;
  107922. /**
  107923. * Y
  107924. */
  107925. y: number;
  107926. /**
  107927. * Z
  107928. */
  107929. z: number;
  107930. }
  107931. }
  107932. declare module BABYLON {
  107933. /**
  107934. * Interface used to describe a physics joint
  107935. */
  107936. export interface PhysicsImpostorJoint {
  107937. /** Defines the main impostor to which the joint is linked */
  107938. mainImpostor: PhysicsImpostor;
  107939. /** Defines the impostor that is connected to the main impostor using this joint */
  107940. connectedImpostor: PhysicsImpostor;
  107941. /** Defines the joint itself */
  107942. joint: PhysicsJoint;
  107943. }
  107944. /** @hidden */
  107945. export interface IPhysicsEnginePlugin {
  107946. world: any;
  107947. name: string;
  107948. setGravity(gravity: Vector3): void;
  107949. setTimeStep(timeStep: number): void;
  107950. getTimeStep(): number;
  107951. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107952. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107953. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107954. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107955. removePhysicsBody(impostor: PhysicsImpostor): void;
  107956. generateJoint(joint: PhysicsImpostorJoint): void;
  107957. removeJoint(joint: PhysicsImpostorJoint): void;
  107958. isSupported(): boolean;
  107959. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107960. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107961. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107962. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107963. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107964. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107965. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107966. getBodyMass(impostor: PhysicsImpostor): number;
  107967. getBodyFriction(impostor: PhysicsImpostor): number;
  107968. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107969. getBodyRestitution(impostor: PhysicsImpostor): number;
  107970. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107971. getBodyPressure?(impostor: PhysicsImpostor): number;
  107972. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107973. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107974. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107975. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107976. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107977. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107978. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107979. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107980. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107981. sleepBody(impostor: PhysicsImpostor): void;
  107982. wakeUpBody(impostor: PhysicsImpostor): void;
  107983. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107984. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107985. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107986. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107987. getRadius(impostor: PhysicsImpostor): number;
  107988. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107989. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107990. dispose(): void;
  107991. }
  107992. /**
  107993. * Interface used to define a physics engine
  107994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107995. */
  107996. export interface IPhysicsEngine {
  107997. /**
  107998. * Gets the gravity vector used by the simulation
  107999. */
  108000. gravity: Vector3;
  108001. /**
  108002. * Sets the gravity vector used by the simulation
  108003. * @param gravity defines the gravity vector to use
  108004. */
  108005. setGravity(gravity: Vector3): void;
  108006. /**
  108007. * Set the time step of the physics engine.
  108008. * Default is 1/60.
  108009. * To slow it down, enter 1/600 for example.
  108010. * To speed it up, 1/30
  108011. * @param newTimeStep the new timestep to apply to this world.
  108012. */
  108013. setTimeStep(newTimeStep: number): void;
  108014. /**
  108015. * Get the time step of the physics engine.
  108016. * @returns the current time step
  108017. */
  108018. getTimeStep(): number;
  108019. /**
  108020. * Set the sub time step of the physics engine.
  108021. * Default is 0 meaning there is no sub steps
  108022. * To increase physics resolution precision, set a small value (like 1 ms)
  108023. * @param subTimeStep defines the new sub timestep used for physics resolution.
  108024. */
  108025. setSubTimeStep(subTimeStep: number): void;
  108026. /**
  108027. * Get the sub time step of the physics engine.
  108028. * @returns the current sub time step
  108029. */
  108030. getSubTimeStep(): number;
  108031. /**
  108032. * Release all resources
  108033. */
  108034. dispose(): void;
  108035. /**
  108036. * Gets the name of the current physics plugin
  108037. * @returns the name of the plugin
  108038. */
  108039. getPhysicsPluginName(): string;
  108040. /**
  108041. * Adding a new impostor for the impostor tracking.
  108042. * This will be done by the impostor itself.
  108043. * @param impostor the impostor to add
  108044. */
  108045. addImpostor(impostor: PhysicsImpostor): void;
  108046. /**
  108047. * Remove an impostor from the engine.
  108048. * This impostor and its mesh will not longer be updated by the physics engine.
  108049. * @param impostor the impostor to remove
  108050. */
  108051. removeImpostor(impostor: PhysicsImpostor): void;
  108052. /**
  108053. * Add a joint to the physics engine
  108054. * @param mainImpostor defines the main impostor to which the joint is added.
  108055. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108056. * @param joint defines the joint that will connect both impostors.
  108057. */
  108058. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108059. /**
  108060. * Removes a joint from the simulation
  108061. * @param mainImpostor defines the impostor used with the joint
  108062. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108063. * @param joint defines the joint to remove
  108064. */
  108065. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108066. /**
  108067. * Gets the current plugin used to run the simulation
  108068. * @returns current plugin
  108069. */
  108070. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108071. /**
  108072. * Gets the list of physic impostors
  108073. * @returns an array of PhysicsImpostor
  108074. */
  108075. getImpostors(): Array<PhysicsImpostor>;
  108076. /**
  108077. * Gets the impostor for a physics enabled object
  108078. * @param object defines the object impersonated by the impostor
  108079. * @returns the PhysicsImpostor or null if not found
  108080. */
  108081. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108082. /**
  108083. * Gets the impostor for a physics body object
  108084. * @param body defines physics body used by the impostor
  108085. * @returns the PhysicsImpostor or null if not found
  108086. */
  108087. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108088. /**
  108089. * Does a raycast in the physics world
  108090. * @param from when should the ray start?
  108091. * @param to when should the ray end?
  108092. * @returns PhysicsRaycastResult
  108093. */
  108094. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108095. /**
  108096. * Called by the scene. No need to call it.
  108097. * @param delta defines the timespam between frames
  108098. */
  108099. _step(delta: number): void;
  108100. }
  108101. }
  108102. declare module BABYLON {
  108103. /**
  108104. * The interface for the physics imposter parameters
  108105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108106. */
  108107. export interface PhysicsImpostorParameters {
  108108. /**
  108109. * The mass of the physics imposter
  108110. */
  108111. mass: number;
  108112. /**
  108113. * The friction of the physics imposter
  108114. */
  108115. friction?: number;
  108116. /**
  108117. * The coefficient of restitution of the physics imposter
  108118. */
  108119. restitution?: number;
  108120. /**
  108121. * The native options of the physics imposter
  108122. */
  108123. nativeOptions?: any;
  108124. /**
  108125. * Specifies if the parent should be ignored
  108126. */
  108127. ignoreParent?: boolean;
  108128. /**
  108129. * Specifies if bi-directional transformations should be disabled
  108130. */
  108131. disableBidirectionalTransformation?: boolean;
  108132. /**
  108133. * The pressure inside the physics imposter, soft object only
  108134. */
  108135. pressure?: number;
  108136. /**
  108137. * The stiffness the physics imposter, soft object only
  108138. */
  108139. stiffness?: number;
  108140. /**
  108141. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  108142. */
  108143. velocityIterations?: number;
  108144. /**
  108145. * The number of iterations used in maintaining consistent vertex positions, soft object only
  108146. */
  108147. positionIterations?: number;
  108148. /**
  108149. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  108150. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  108151. * Add to fix multiple points
  108152. */
  108153. fixedPoints?: number;
  108154. /**
  108155. * The collision margin around a soft object
  108156. */
  108157. margin?: number;
  108158. /**
  108159. * The collision margin around a soft object
  108160. */
  108161. damping?: number;
  108162. /**
  108163. * The path for a rope based on an extrusion
  108164. */
  108165. path?: any;
  108166. /**
  108167. * The shape of an extrusion used for a rope based on an extrusion
  108168. */
  108169. shape?: any;
  108170. }
  108171. /**
  108172. * Interface for a physics-enabled object
  108173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108174. */
  108175. export interface IPhysicsEnabledObject {
  108176. /**
  108177. * The position of the physics-enabled object
  108178. */
  108179. position: Vector3;
  108180. /**
  108181. * The rotation of the physics-enabled object
  108182. */
  108183. rotationQuaternion: Nullable<Quaternion>;
  108184. /**
  108185. * The scale of the physics-enabled object
  108186. */
  108187. scaling: Vector3;
  108188. /**
  108189. * The rotation of the physics-enabled object
  108190. */
  108191. rotation?: Vector3;
  108192. /**
  108193. * The parent of the physics-enabled object
  108194. */
  108195. parent?: any;
  108196. /**
  108197. * The bounding info of the physics-enabled object
  108198. * @returns The bounding info of the physics-enabled object
  108199. */
  108200. getBoundingInfo(): BoundingInfo;
  108201. /**
  108202. * Computes the world matrix
  108203. * @param force Specifies if the world matrix should be computed by force
  108204. * @returns A world matrix
  108205. */
  108206. computeWorldMatrix(force: boolean): Matrix;
  108207. /**
  108208. * Gets the world matrix
  108209. * @returns A world matrix
  108210. */
  108211. getWorldMatrix?(): Matrix;
  108212. /**
  108213. * Gets the child meshes
  108214. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  108215. * @returns An array of abstract meshes
  108216. */
  108217. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  108218. /**
  108219. * Gets the vertex data
  108220. * @param kind The type of vertex data
  108221. * @returns A nullable array of numbers, or a float32 array
  108222. */
  108223. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  108224. /**
  108225. * Gets the indices from the mesh
  108226. * @returns A nullable array of index arrays
  108227. */
  108228. getIndices?(): Nullable<IndicesArray>;
  108229. /**
  108230. * Gets the scene from the mesh
  108231. * @returns the indices array or null
  108232. */
  108233. getScene?(): Scene;
  108234. /**
  108235. * Gets the absolute position from the mesh
  108236. * @returns the absolute position
  108237. */
  108238. getAbsolutePosition(): Vector3;
  108239. /**
  108240. * Gets the absolute pivot point from the mesh
  108241. * @returns the absolute pivot point
  108242. */
  108243. getAbsolutePivotPoint(): Vector3;
  108244. /**
  108245. * Rotates the mesh
  108246. * @param axis The axis of rotation
  108247. * @param amount The amount of rotation
  108248. * @param space The space of the rotation
  108249. * @returns The rotation transform node
  108250. */
  108251. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  108252. /**
  108253. * Translates the mesh
  108254. * @param axis The axis of translation
  108255. * @param distance The distance of translation
  108256. * @param space The space of the translation
  108257. * @returns The transform node
  108258. */
  108259. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  108260. /**
  108261. * Sets the absolute position of the mesh
  108262. * @param absolutePosition The absolute position of the mesh
  108263. * @returns The transform node
  108264. */
  108265. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  108266. /**
  108267. * Gets the class name of the mesh
  108268. * @returns The class name
  108269. */
  108270. getClassName(): string;
  108271. }
  108272. /**
  108273. * Represents a physics imposter
  108274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108275. */
  108276. export class PhysicsImpostor {
  108277. /**
  108278. * The physics-enabled object used as the physics imposter
  108279. */
  108280. object: IPhysicsEnabledObject;
  108281. /**
  108282. * The type of the physics imposter
  108283. */
  108284. type: number;
  108285. private _options;
  108286. private _scene?;
  108287. /**
  108288. * The default object size of the imposter
  108289. */
  108290. static DEFAULT_OBJECT_SIZE: Vector3;
  108291. /**
  108292. * The identity quaternion of the imposter
  108293. */
  108294. static IDENTITY_QUATERNION: Quaternion;
  108295. /** @hidden */
  108296. _pluginData: any;
  108297. private _physicsEngine;
  108298. private _physicsBody;
  108299. private _bodyUpdateRequired;
  108300. private _onBeforePhysicsStepCallbacks;
  108301. private _onAfterPhysicsStepCallbacks;
  108302. /** @hidden */
  108303. _onPhysicsCollideCallbacks: Array<{
  108304. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  108305. otherImpostors: Array<PhysicsImpostor>;
  108306. }>;
  108307. private _deltaPosition;
  108308. private _deltaRotation;
  108309. private _deltaRotationConjugated;
  108310. /** @hidden */
  108311. _isFromLine: boolean;
  108312. private _parent;
  108313. private _isDisposed;
  108314. private static _tmpVecs;
  108315. private static _tmpQuat;
  108316. /**
  108317. * Specifies if the physics imposter is disposed
  108318. */
  108319. get isDisposed(): boolean;
  108320. /**
  108321. * Gets the mass of the physics imposter
  108322. */
  108323. get mass(): number;
  108324. set mass(value: number);
  108325. /**
  108326. * Gets the coefficient of friction
  108327. */
  108328. get friction(): number;
  108329. /**
  108330. * Sets the coefficient of friction
  108331. */
  108332. set friction(value: number);
  108333. /**
  108334. * Gets the coefficient of restitution
  108335. */
  108336. get restitution(): number;
  108337. /**
  108338. * Sets the coefficient of restitution
  108339. */
  108340. set restitution(value: number);
  108341. /**
  108342. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  108343. */
  108344. get pressure(): number;
  108345. /**
  108346. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  108347. */
  108348. set pressure(value: number);
  108349. /**
  108350. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108351. */
  108352. get stiffness(): number;
  108353. /**
  108354. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108355. */
  108356. set stiffness(value: number);
  108357. /**
  108358. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108359. */
  108360. get velocityIterations(): number;
  108361. /**
  108362. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108363. */
  108364. set velocityIterations(value: number);
  108365. /**
  108366. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108367. */
  108368. get positionIterations(): number;
  108369. /**
  108370. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108371. */
  108372. set positionIterations(value: number);
  108373. /**
  108374. * The unique id of the physics imposter
  108375. * set by the physics engine when adding this impostor to the array
  108376. */
  108377. uniqueId: number;
  108378. /**
  108379. * @hidden
  108380. */
  108381. soft: boolean;
  108382. /**
  108383. * @hidden
  108384. */
  108385. segments: number;
  108386. private _joints;
  108387. /**
  108388. * Initializes the physics imposter
  108389. * @param object The physics-enabled object used as the physics imposter
  108390. * @param type The type of the physics imposter
  108391. * @param _options The options for the physics imposter
  108392. * @param _scene The Babylon scene
  108393. */
  108394. constructor(
  108395. /**
  108396. * The physics-enabled object used as the physics imposter
  108397. */
  108398. object: IPhysicsEnabledObject,
  108399. /**
  108400. * The type of the physics imposter
  108401. */
  108402. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  108403. /**
  108404. * This function will completly initialize this impostor.
  108405. * It will create a new body - but only if this mesh has no parent.
  108406. * If it has, this impostor will not be used other than to define the impostor
  108407. * of the child mesh.
  108408. * @hidden
  108409. */
  108410. _init(): void;
  108411. private _getPhysicsParent;
  108412. /**
  108413. * Should a new body be generated.
  108414. * @returns boolean specifying if body initialization is required
  108415. */
  108416. isBodyInitRequired(): boolean;
  108417. /**
  108418. * Sets the updated scaling
  108419. * @param updated Specifies if the scaling is updated
  108420. */
  108421. setScalingUpdated(): void;
  108422. /**
  108423. * Force a regeneration of this or the parent's impostor's body.
  108424. * Use under cautious - This will remove all joints already implemented.
  108425. */
  108426. forceUpdate(): void;
  108427. /**
  108428. * Gets the body that holds this impostor. Either its own, or its parent.
  108429. */
  108430. get physicsBody(): any;
  108431. /**
  108432. * Get the parent of the physics imposter
  108433. * @returns Physics imposter or null
  108434. */
  108435. get parent(): Nullable<PhysicsImpostor>;
  108436. /**
  108437. * Sets the parent of the physics imposter
  108438. */
  108439. set parent(value: Nullable<PhysicsImpostor>);
  108440. /**
  108441. * Set the physics body. Used mainly by the physics engine/plugin
  108442. */
  108443. set physicsBody(physicsBody: any);
  108444. /**
  108445. * Resets the update flags
  108446. */
  108447. resetUpdateFlags(): void;
  108448. /**
  108449. * Gets the object extend size
  108450. * @returns the object extend size
  108451. */
  108452. getObjectExtendSize(): Vector3;
  108453. /**
  108454. * Gets the object center
  108455. * @returns The object center
  108456. */
  108457. getObjectCenter(): Vector3;
  108458. /**
  108459. * Get a specific parameter from the options parameters
  108460. * @param paramName The object parameter name
  108461. * @returns The object parameter
  108462. */
  108463. getParam(paramName: string): any;
  108464. /**
  108465. * Sets a specific parameter in the options given to the physics plugin
  108466. * @param paramName The parameter name
  108467. * @param value The value of the parameter
  108468. */
  108469. setParam(paramName: string, value: number): void;
  108470. /**
  108471. * Specifically change the body's mass option. Won't recreate the physics body object
  108472. * @param mass The mass of the physics imposter
  108473. */
  108474. setMass(mass: number): void;
  108475. /**
  108476. * Gets the linear velocity
  108477. * @returns linear velocity or null
  108478. */
  108479. getLinearVelocity(): Nullable<Vector3>;
  108480. /**
  108481. * Sets the linear velocity
  108482. * @param velocity linear velocity or null
  108483. */
  108484. setLinearVelocity(velocity: Nullable<Vector3>): void;
  108485. /**
  108486. * Gets the angular velocity
  108487. * @returns angular velocity or null
  108488. */
  108489. getAngularVelocity(): Nullable<Vector3>;
  108490. /**
  108491. * Sets the angular velocity
  108492. * @param velocity The velocity or null
  108493. */
  108494. setAngularVelocity(velocity: Nullable<Vector3>): void;
  108495. /**
  108496. * Execute a function with the physics plugin native code
  108497. * Provide a function the will have two variables - the world object and the physics body object
  108498. * @param func The function to execute with the physics plugin native code
  108499. */
  108500. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  108501. /**
  108502. * Register a function that will be executed before the physics world is stepping forward
  108503. * @param func The function to execute before the physics world is stepped forward
  108504. */
  108505. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108506. /**
  108507. * Unregister a function that will be executed before the physics world is stepping forward
  108508. * @param func The function to execute before the physics world is stepped forward
  108509. */
  108510. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108511. /**
  108512. * Register a function that will be executed after the physics step
  108513. * @param func The function to execute after physics step
  108514. */
  108515. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108516. /**
  108517. * Unregisters a function that will be executed after the physics step
  108518. * @param func The function to execute after physics step
  108519. */
  108520. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108521. /**
  108522. * register a function that will be executed when this impostor collides against a different body
  108523. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  108524. * @param func Callback that is executed on collision
  108525. */
  108526. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  108527. /**
  108528. * Unregisters the physics imposter on contact
  108529. * @param collideAgainst The physics object to collide against
  108530. * @param func Callback to execute on collision
  108531. */
  108532. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  108533. private _tmpQuat;
  108534. private _tmpQuat2;
  108535. /**
  108536. * Get the parent rotation
  108537. * @returns The parent rotation
  108538. */
  108539. getParentsRotation(): Quaternion;
  108540. /**
  108541. * this function is executed by the physics engine.
  108542. */
  108543. beforeStep: () => void;
  108544. /**
  108545. * this function is executed by the physics engine
  108546. */
  108547. afterStep: () => void;
  108548. /**
  108549. * Legacy collision detection event support
  108550. */
  108551. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  108552. /**
  108553. * event and body object due to cannon's event-based architecture.
  108554. */
  108555. onCollide: (e: {
  108556. body: any;
  108557. }) => void;
  108558. /**
  108559. * Apply a force
  108560. * @param force The force to apply
  108561. * @param contactPoint The contact point for the force
  108562. * @returns The physics imposter
  108563. */
  108564. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108565. /**
  108566. * Apply an impulse
  108567. * @param force The impulse force
  108568. * @param contactPoint The contact point for the impulse force
  108569. * @returns The physics imposter
  108570. */
  108571. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108572. /**
  108573. * A help function to create a joint
  108574. * @param otherImpostor A physics imposter used to create a joint
  108575. * @param jointType The type of joint
  108576. * @param jointData The data for the joint
  108577. * @returns The physics imposter
  108578. */
  108579. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  108580. /**
  108581. * Add a joint to this impostor with a different impostor
  108582. * @param otherImpostor A physics imposter used to add a joint
  108583. * @param joint The joint to add
  108584. * @returns The physics imposter
  108585. */
  108586. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  108587. /**
  108588. * Add an anchor to a cloth impostor
  108589. * @param otherImpostor rigid impostor to anchor to
  108590. * @param width ratio across width from 0 to 1
  108591. * @param height ratio up height from 0 to 1
  108592. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108593. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  108594. * @returns impostor the soft imposter
  108595. */
  108596. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108597. /**
  108598. * Add a hook to a rope impostor
  108599. * @param otherImpostor rigid impostor to anchor to
  108600. * @param length ratio across rope from 0 to 1
  108601. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  108602. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108603. * @returns impostor the rope imposter
  108604. */
  108605. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108606. /**
  108607. * Will keep this body still, in a sleep mode.
  108608. * @returns the physics imposter
  108609. */
  108610. sleep(): PhysicsImpostor;
  108611. /**
  108612. * Wake the body up.
  108613. * @returns The physics imposter
  108614. */
  108615. wakeUp(): PhysicsImpostor;
  108616. /**
  108617. * Clones the physics imposter
  108618. * @param newObject The physics imposter clones to this physics-enabled object
  108619. * @returns A nullable physics imposter
  108620. */
  108621. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108622. /**
  108623. * Disposes the physics imposter
  108624. */
  108625. dispose(): void;
  108626. /**
  108627. * Sets the delta position
  108628. * @param position The delta position amount
  108629. */
  108630. setDeltaPosition(position: Vector3): void;
  108631. /**
  108632. * Sets the delta rotation
  108633. * @param rotation The delta rotation amount
  108634. */
  108635. setDeltaRotation(rotation: Quaternion): void;
  108636. /**
  108637. * Gets the box size of the physics imposter and stores the result in the input parameter
  108638. * @param result Stores the box size
  108639. * @returns The physics imposter
  108640. */
  108641. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  108642. /**
  108643. * Gets the radius of the physics imposter
  108644. * @returns Radius of the physics imposter
  108645. */
  108646. getRadius(): number;
  108647. /**
  108648. * Sync a bone with this impostor
  108649. * @param bone The bone to sync to the impostor.
  108650. * @param boneMesh The mesh that the bone is influencing.
  108651. * @param jointPivot The pivot of the joint / bone in local space.
  108652. * @param distToJoint Optional distance from the impostor to the joint.
  108653. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108654. */
  108655. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  108656. /**
  108657. * Sync impostor to a bone
  108658. * @param bone The bone that the impostor will be synced to.
  108659. * @param boneMesh The mesh that the bone is influencing.
  108660. * @param jointPivot The pivot of the joint / bone in local space.
  108661. * @param distToJoint Optional distance from the impostor to the joint.
  108662. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108663. * @param boneAxis Optional vector3 axis the bone is aligned with
  108664. */
  108665. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  108666. /**
  108667. * No-Imposter type
  108668. */
  108669. static NoImpostor: number;
  108670. /**
  108671. * Sphere-Imposter type
  108672. */
  108673. static SphereImpostor: number;
  108674. /**
  108675. * Box-Imposter type
  108676. */
  108677. static BoxImpostor: number;
  108678. /**
  108679. * Plane-Imposter type
  108680. */
  108681. static PlaneImpostor: number;
  108682. /**
  108683. * Mesh-imposter type
  108684. */
  108685. static MeshImpostor: number;
  108686. /**
  108687. * Capsule-Impostor type (Ammo.js plugin only)
  108688. */
  108689. static CapsuleImpostor: number;
  108690. /**
  108691. * Cylinder-Imposter type
  108692. */
  108693. static CylinderImpostor: number;
  108694. /**
  108695. * Particle-Imposter type
  108696. */
  108697. static ParticleImpostor: number;
  108698. /**
  108699. * Heightmap-Imposter type
  108700. */
  108701. static HeightmapImpostor: number;
  108702. /**
  108703. * ConvexHull-Impostor type (Ammo.js plugin only)
  108704. */
  108705. static ConvexHullImpostor: number;
  108706. /**
  108707. * Custom-Imposter type (Ammo.js plugin only)
  108708. */
  108709. static CustomImpostor: number;
  108710. /**
  108711. * Rope-Imposter type
  108712. */
  108713. static RopeImpostor: number;
  108714. /**
  108715. * Cloth-Imposter type
  108716. */
  108717. static ClothImpostor: number;
  108718. /**
  108719. * Softbody-Imposter type
  108720. */
  108721. static SoftbodyImpostor: number;
  108722. }
  108723. }
  108724. declare module BABYLON {
  108725. /**
  108726. * @hidden
  108727. **/
  108728. export class _CreationDataStorage {
  108729. closePath?: boolean;
  108730. closeArray?: boolean;
  108731. idx: number[];
  108732. dashSize: number;
  108733. gapSize: number;
  108734. path3D: Path3D;
  108735. pathArray: Vector3[][];
  108736. arc: number;
  108737. radius: number;
  108738. cap: number;
  108739. tessellation: number;
  108740. }
  108741. /**
  108742. * @hidden
  108743. **/
  108744. class _InstanceDataStorage {
  108745. visibleInstances: any;
  108746. batchCache: _InstancesBatch;
  108747. instancesBufferSize: number;
  108748. instancesBuffer: Nullable<Buffer>;
  108749. instancesData: Float32Array;
  108750. overridenInstanceCount: number;
  108751. isFrozen: boolean;
  108752. previousBatch: Nullable<_InstancesBatch>;
  108753. hardwareInstancedRendering: boolean;
  108754. sideOrientation: number;
  108755. manualUpdate: boolean;
  108756. previousRenderId: number;
  108757. }
  108758. /**
  108759. * @hidden
  108760. **/
  108761. export class _InstancesBatch {
  108762. mustReturn: boolean;
  108763. visibleInstances: Nullable<InstancedMesh[]>[];
  108764. renderSelf: boolean[];
  108765. hardwareInstancedRendering: boolean[];
  108766. }
  108767. /**
  108768. * @hidden
  108769. **/
  108770. class _ThinInstanceDataStorage {
  108771. instancesCount: number;
  108772. matrixBuffer: Nullable<Buffer>;
  108773. matrixBufferSize: number;
  108774. matrixData: Nullable<Float32Array>;
  108775. boundingVectors: Array<Vector3>;
  108776. worldMatrices: Nullable<Matrix[]>;
  108777. }
  108778. /**
  108779. * Class used to represent renderable models
  108780. */
  108781. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  108782. /**
  108783. * Mesh side orientation : usually the external or front surface
  108784. */
  108785. static readonly FRONTSIDE: number;
  108786. /**
  108787. * Mesh side orientation : usually the internal or back surface
  108788. */
  108789. static readonly BACKSIDE: number;
  108790. /**
  108791. * Mesh side orientation : both internal and external or front and back surfaces
  108792. */
  108793. static readonly DOUBLESIDE: number;
  108794. /**
  108795. * Mesh side orientation : by default, `FRONTSIDE`
  108796. */
  108797. static readonly DEFAULTSIDE: number;
  108798. /**
  108799. * Mesh cap setting : no cap
  108800. */
  108801. static readonly NO_CAP: number;
  108802. /**
  108803. * Mesh cap setting : one cap at the beginning of the mesh
  108804. */
  108805. static readonly CAP_START: number;
  108806. /**
  108807. * Mesh cap setting : one cap at the end of the mesh
  108808. */
  108809. static readonly CAP_END: number;
  108810. /**
  108811. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  108812. */
  108813. static readonly CAP_ALL: number;
  108814. /**
  108815. * Mesh pattern setting : no flip or rotate
  108816. */
  108817. static readonly NO_FLIP: number;
  108818. /**
  108819. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  108820. */
  108821. static readonly FLIP_TILE: number;
  108822. /**
  108823. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  108824. */
  108825. static readonly ROTATE_TILE: number;
  108826. /**
  108827. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  108828. */
  108829. static readonly FLIP_ROW: number;
  108830. /**
  108831. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  108832. */
  108833. static readonly ROTATE_ROW: number;
  108834. /**
  108835. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  108836. */
  108837. static readonly FLIP_N_ROTATE_TILE: number;
  108838. /**
  108839. * Mesh pattern setting : rotate pattern and rotate
  108840. */
  108841. static readonly FLIP_N_ROTATE_ROW: number;
  108842. /**
  108843. * Mesh tile positioning : part tiles same on left/right or top/bottom
  108844. */
  108845. static readonly CENTER: number;
  108846. /**
  108847. * Mesh tile positioning : part tiles on left
  108848. */
  108849. static readonly LEFT: number;
  108850. /**
  108851. * Mesh tile positioning : part tiles on right
  108852. */
  108853. static readonly RIGHT: number;
  108854. /**
  108855. * Mesh tile positioning : part tiles on top
  108856. */
  108857. static readonly TOP: number;
  108858. /**
  108859. * Mesh tile positioning : part tiles on bottom
  108860. */
  108861. static readonly BOTTOM: number;
  108862. /**
  108863. * Gets the default side orientation.
  108864. * @param orientation the orientation to value to attempt to get
  108865. * @returns the default orientation
  108866. * @hidden
  108867. */
  108868. static _GetDefaultSideOrientation(orientation?: number): number;
  108869. private _internalMeshDataInfo;
  108870. get computeBonesUsingShaders(): boolean;
  108871. set computeBonesUsingShaders(value: boolean);
  108872. /**
  108873. * An event triggered before rendering the mesh
  108874. */
  108875. get onBeforeRenderObservable(): Observable<Mesh>;
  108876. /**
  108877. * An event triggered before binding the mesh
  108878. */
  108879. get onBeforeBindObservable(): Observable<Mesh>;
  108880. /**
  108881. * An event triggered after rendering the mesh
  108882. */
  108883. get onAfterRenderObservable(): Observable<Mesh>;
  108884. /**
  108885. * An event triggered before drawing the mesh
  108886. */
  108887. get onBeforeDrawObservable(): Observable<Mesh>;
  108888. private _onBeforeDrawObserver;
  108889. /**
  108890. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108891. */
  108892. set onBeforeDraw(callback: () => void);
  108893. get hasInstances(): boolean;
  108894. get hasThinInstances(): boolean;
  108895. /**
  108896. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108897. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108898. */
  108899. delayLoadState: number;
  108900. /**
  108901. * Gets the list of instances created from this mesh
  108902. * it is not supposed to be modified manually.
  108903. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108904. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108905. */
  108906. instances: InstancedMesh[];
  108907. /**
  108908. * Gets the file containing delay loading data for this mesh
  108909. */
  108910. delayLoadingFile: string;
  108911. /** @hidden */
  108912. _binaryInfo: any;
  108913. /**
  108914. * User defined function used to change how LOD level selection is done
  108915. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108916. */
  108917. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108918. /**
  108919. * Gets or sets the morph target manager
  108920. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108921. */
  108922. get morphTargetManager(): Nullable<MorphTargetManager>;
  108923. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108924. /** @hidden */
  108925. _creationDataStorage: Nullable<_CreationDataStorage>;
  108926. /** @hidden */
  108927. _geometry: Nullable<Geometry>;
  108928. /** @hidden */
  108929. _delayInfo: Array<string>;
  108930. /** @hidden */
  108931. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108932. /** @hidden */
  108933. _instanceDataStorage: _InstanceDataStorage;
  108934. /** @hidden */
  108935. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108936. private _effectiveMaterial;
  108937. /** @hidden */
  108938. _shouldGenerateFlatShading: boolean;
  108939. /** @hidden */
  108940. _originalBuilderSideOrientation: number;
  108941. /**
  108942. * Use this property to change the original side orientation defined at construction time
  108943. */
  108944. overrideMaterialSideOrientation: Nullable<number>;
  108945. /**
  108946. * Gets the source mesh (the one used to clone this one from)
  108947. */
  108948. get source(): Nullable<Mesh>;
  108949. /**
  108950. * Gets the list of clones of this mesh
  108951. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108952. * Note that useClonedMeshMap=true is the default setting
  108953. */
  108954. get cloneMeshMap(): Nullable<{
  108955. [id: string]: Mesh | undefined;
  108956. }>;
  108957. /**
  108958. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108959. */
  108960. get isUnIndexed(): boolean;
  108961. set isUnIndexed(value: boolean);
  108962. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108963. get worldMatrixInstancedBuffer(): Float32Array;
  108964. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108965. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108966. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108967. /**
  108968. * @constructor
  108969. * @param name The value used by scene.getMeshByName() to do a lookup.
  108970. * @param scene The scene to add this mesh to.
  108971. * @param parent The parent of this mesh, if it has one
  108972. * @param source An optional Mesh from which geometry is shared, cloned.
  108973. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108974. * When false, achieved by calling a clone(), also passing False.
  108975. * This will make creation of children, recursive.
  108976. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108977. */
  108978. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108979. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108980. doNotInstantiate: boolean;
  108981. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108982. /**
  108983. * Gets the class name
  108984. * @returns the string "Mesh".
  108985. */
  108986. getClassName(): string;
  108987. /** @hidden */
  108988. get _isMesh(): boolean;
  108989. /**
  108990. * Returns a description of this mesh
  108991. * @param fullDetails define if full details about this mesh must be used
  108992. * @returns a descriptive string representing this mesh
  108993. */
  108994. toString(fullDetails?: boolean): string;
  108995. /** @hidden */
  108996. _unBindEffect(): void;
  108997. /**
  108998. * Gets a boolean indicating if this mesh has LOD
  108999. */
  109000. get hasLODLevels(): boolean;
  109001. /**
  109002. * Gets the list of MeshLODLevel associated with the current mesh
  109003. * @returns an array of MeshLODLevel
  109004. */
  109005. getLODLevels(): MeshLODLevel[];
  109006. private _sortLODLevels;
  109007. /**
  109008. * Add a mesh as LOD level triggered at the given distance.
  109009. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  109010. * @param distance The distance from the center of the object to show this level
  109011. * @param mesh The mesh to be added as LOD level (can be null)
  109012. * @return This mesh (for chaining)
  109013. */
  109014. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  109015. /**
  109016. * Returns the LOD level mesh at the passed distance or null if not found.
  109017. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  109018. * @param distance The distance from the center of the object to show this level
  109019. * @returns a Mesh or `null`
  109020. */
  109021. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  109022. /**
  109023. * Remove a mesh from the LOD array
  109024. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  109025. * @param mesh defines the mesh to be removed
  109026. * @return This mesh (for chaining)
  109027. */
  109028. removeLODLevel(mesh: Mesh): Mesh;
  109029. /**
  109030. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  109031. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  109032. * @param camera defines the camera to use to compute distance
  109033. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  109034. * @return This mesh (for chaining)
  109035. */
  109036. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  109037. /**
  109038. * Gets the mesh internal Geometry object
  109039. */
  109040. get geometry(): Nullable<Geometry>;
  109041. /**
  109042. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  109043. * @returns the total number of vertices
  109044. */
  109045. getTotalVertices(): number;
  109046. /**
  109047. * Returns the content of an associated vertex buffer
  109048. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  109049. * - VertexBuffer.PositionKind
  109050. * - VertexBuffer.UVKind
  109051. * - VertexBuffer.UV2Kind
  109052. * - VertexBuffer.UV3Kind
  109053. * - VertexBuffer.UV4Kind
  109054. * - VertexBuffer.UV5Kind
  109055. * - VertexBuffer.UV6Kind
  109056. * - VertexBuffer.ColorKind
  109057. * - VertexBuffer.MatricesIndicesKind
  109058. * - VertexBuffer.MatricesIndicesExtraKind
  109059. * - VertexBuffer.MatricesWeightsKind
  109060. * - VertexBuffer.MatricesWeightsExtraKind
  109061. * @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
  109062. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  109063. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  109064. */
  109065. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  109066. /**
  109067. * Returns the mesh VertexBuffer object from the requested `kind`
  109068. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  109069. * - VertexBuffer.PositionKind
  109070. * - VertexBuffer.NormalKind
  109071. * - VertexBuffer.UVKind
  109072. * - VertexBuffer.UV2Kind
  109073. * - VertexBuffer.UV3Kind
  109074. * - VertexBuffer.UV4Kind
  109075. * - VertexBuffer.UV5Kind
  109076. * - VertexBuffer.UV6Kind
  109077. * - VertexBuffer.ColorKind
  109078. * - VertexBuffer.MatricesIndicesKind
  109079. * - VertexBuffer.MatricesIndicesExtraKind
  109080. * - VertexBuffer.MatricesWeightsKind
  109081. * - VertexBuffer.MatricesWeightsExtraKind
  109082. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  109083. */
  109084. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  109085. /**
  109086. * Tests if a specific vertex buffer is associated with this mesh
  109087. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  109088. * - VertexBuffer.PositionKind
  109089. * - VertexBuffer.NormalKind
  109090. * - VertexBuffer.UVKind
  109091. * - VertexBuffer.UV2Kind
  109092. * - VertexBuffer.UV3Kind
  109093. * - VertexBuffer.UV4Kind
  109094. * - VertexBuffer.UV5Kind
  109095. * - VertexBuffer.UV6Kind
  109096. * - VertexBuffer.ColorKind
  109097. * - VertexBuffer.MatricesIndicesKind
  109098. * - VertexBuffer.MatricesIndicesExtraKind
  109099. * - VertexBuffer.MatricesWeightsKind
  109100. * - VertexBuffer.MatricesWeightsExtraKind
  109101. * @returns a boolean
  109102. */
  109103. isVerticesDataPresent(kind: string): boolean;
  109104. /**
  109105. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  109106. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  109107. * - VertexBuffer.PositionKind
  109108. * - VertexBuffer.UVKind
  109109. * - VertexBuffer.UV2Kind
  109110. * - VertexBuffer.UV3Kind
  109111. * - VertexBuffer.UV4Kind
  109112. * - VertexBuffer.UV5Kind
  109113. * - VertexBuffer.UV6Kind
  109114. * - VertexBuffer.ColorKind
  109115. * - VertexBuffer.MatricesIndicesKind
  109116. * - VertexBuffer.MatricesIndicesExtraKind
  109117. * - VertexBuffer.MatricesWeightsKind
  109118. * - VertexBuffer.MatricesWeightsExtraKind
  109119. * @returns a boolean
  109120. */
  109121. isVertexBufferUpdatable(kind: string): boolean;
  109122. /**
  109123. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  109124. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  109125. * - VertexBuffer.PositionKind
  109126. * - VertexBuffer.NormalKind
  109127. * - VertexBuffer.UVKind
  109128. * - VertexBuffer.UV2Kind
  109129. * - VertexBuffer.UV3Kind
  109130. * - VertexBuffer.UV4Kind
  109131. * - VertexBuffer.UV5Kind
  109132. * - VertexBuffer.UV6Kind
  109133. * - VertexBuffer.ColorKind
  109134. * - VertexBuffer.MatricesIndicesKind
  109135. * - VertexBuffer.MatricesIndicesExtraKind
  109136. * - VertexBuffer.MatricesWeightsKind
  109137. * - VertexBuffer.MatricesWeightsExtraKind
  109138. * @returns an array of strings
  109139. */
  109140. getVerticesDataKinds(): string[];
  109141. /**
  109142. * Returns a positive integer : the total number of indices in this mesh geometry.
  109143. * @returns the numner of indices or zero if the mesh has no geometry.
  109144. */
  109145. getTotalIndices(): number;
  109146. /**
  109147. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  109148. * @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.
  109149. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  109150. * @returns the indices array or an empty array if the mesh has no geometry
  109151. */
  109152. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  109153. get isBlocked(): boolean;
  109154. /**
  109155. * Determine if the current mesh is ready to be rendered
  109156. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109157. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  109158. * @returns true if all associated assets are ready (material, textures, shaders)
  109159. */
  109160. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  109161. /**
  109162. * 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.
  109163. */
  109164. get areNormalsFrozen(): boolean;
  109165. /**
  109166. * 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.
  109167. * @returns the current mesh
  109168. */
  109169. freezeNormals(): Mesh;
  109170. /**
  109171. * 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
  109172. * @returns the current mesh
  109173. */
  109174. unfreezeNormals(): Mesh;
  109175. /**
  109176. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  109177. */
  109178. set overridenInstanceCount(count: number);
  109179. /** @hidden */
  109180. _preActivate(): Mesh;
  109181. /** @hidden */
  109182. _preActivateForIntermediateRendering(renderId: number): Mesh;
  109183. /** @hidden */
  109184. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  109185. protected _afterComputeWorldMatrix(): void;
  109186. /** @hidden */
  109187. _postActivate(): void;
  109188. /**
  109189. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109190. * This means the mesh underlying bounding box and sphere are recomputed.
  109191. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109192. * @returns the current mesh
  109193. */
  109194. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  109195. /** @hidden */
  109196. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  109197. /**
  109198. * This function will subdivide the mesh into multiple submeshes
  109199. * @param count defines the expected number of submeshes
  109200. */
  109201. subdivide(count: number): void;
  109202. /**
  109203. * Copy a FloatArray into a specific associated vertex buffer
  109204. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  109205. * - VertexBuffer.PositionKind
  109206. * - VertexBuffer.UVKind
  109207. * - VertexBuffer.UV2Kind
  109208. * - VertexBuffer.UV3Kind
  109209. * - VertexBuffer.UV4Kind
  109210. * - VertexBuffer.UV5Kind
  109211. * - VertexBuffer.UV6Kind
  109212. * - VertexBuffer.ColorKind
  109213. * - VertexBuffer.MatricesIndicesKind
  109214. * - VertexBuffer.MatricesIndicesExtraKind
  109215. * - VertexBuffer.MatricesWeightsKind
  109216. * - VertexBuffer.MatricesWeightsExtraKind
  109217. * @param data defines the data source
  109218. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  109219. * @param stride defines the data stride size (can be null)
  109220. * @returns the current mesh
  109221. */
  109222. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109223. /**
  109224. * Delete a vertex buffer associated with this mesh
  109225. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  109226. * - VertexBuffer.PositionKind
  109227. * - VertexBuffer.UVKind
  109228. * - VertexBuffer.UV2Kind
  109229. * - VertexBuffer.UV3Kind
  109230. * - VertexBuffer.UV4Kind
  109231. * - VertexBuffer.UV5Kind
  109232. * - VertexBuffer.UV6Kind
  109233. * - VertexBuffer.ColorKind
  109234. * - VertexBuffer.MatricesIndicesKind
  109235. * - VertexBuffer.MatricesIndicesExtraKind
  109236. * - VertexBuffer.MatricesWeightsKind
  109237. * - VertexBuffer.MatricesWeightsExtraKind
  109238. */
  109239. removeVerticesData(kind: string): void;
  109240. /**
  109241. * Flags an associated vertex buffer as updatable
  109242. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  109243. * - VertexBuffer.PositionKind
  109244. * - VertexBuffer.UVKind
  109245. * - VertexBuffer.UV2Kind
  109246. * - VertexBuffer.UV3Kind
  109247. * - VertexBuffer.UV4Kind
  109248. * - VertexBuffer.UV5Kind
  109249. * - VertexBuffer.UV6Kind
  109250. * - VertexBuffer.ColorKind
  109251. * - VertexBuffer.MatricesIndicesKind
  109252. * - VertexBuffer.MatricesIndicesExtraKind
  109253. * - VertexBuffer.MatricesWeightsKind
  109254. * - VertexBuffer.MatricesWeightsExtraKind
  109255. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  109256. */
  109257. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  109258. /**
  109259. * Sets the mesh global Vertex Buffer
  109260. * @param buffer defines the buffer to use
  109261. * @returns the current mesh
  109262. */
  109263. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  109264. /**
  109265. * Update a specific associated vertex buffer
  109266. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  109267. * - VertexBuffer.PositionKind
  109268. * - VertexBuffer.UVKind
  109269. * - VertexBuffer.UV2Kind
  109270. * - VertexBuffer.UV3Kind
  109271. * - VertexBuffer.UV4Kind
  109272. * - VertexBuffer.UV5Kind
  109273. * - VertexBuffer.UV6Kind
  109274. * - VertexBuffer.ColorKind
  109275. * - VertexBuffer.MatricesIndicesKind
  109276. * - VertexBuffer.MatricesIndicesExtraKind
  109277. * - VertexBuffer.MatricesWeightsKind
  109278. * - VertexBuffer.MatricesWeightsExtraKind
  109279. * @param data defines the data source
  109280. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  109281. * @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)
  109282. * @returns the current mesh
  109283. */
  109284. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109285. /**
  109286. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  109287. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  109288. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  109289. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  109290. * @returns the current mesh
  109291. */
  109292. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  109293. /**
  109294. * Creates a un-shared specific occurence of the geometry for the mesh.
  109295. * @returns the current mesh
  109296. */
  109297. makeGeometryUnique(): Mesh;
  109298. /**
  109299. * Set the index buffer of this mesh
  109300. * @param indices defines the source data
  109301. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  109302. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  109303. * @returns the current mesh
  109304. */
  109305. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  109306. /**
  109307. * Update the current index buffer
  109308. * @param indices defines the source data
  109309. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109310. * @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)
  109311. * @returns the current mesh
  109312. */
  109313. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109314. /**
  109315. * Invert the geometry to move from a right handed system to a left handed one.
  109316. * @returns the current mesh
  109317. */
  109318. toLeftHanded(): Mesh;
  109319. /** @hidden */
  109320. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  109321. /** @hidden */
  109322. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  109323. /**
  109324. * Registers for this mesh a javascript function called just before the rendering process
  109325. * @param func defines the function to call before rendering this mesh
  109326. * @returns the current mesh
  109327. */
  109328. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109329. /**
  109330. * Disposes a previously registered javascript function called before the rendering
  109331. * @param func defines the function to remove
  109332. * @returns the current mesh
  109333. */
  109334. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109335. /**
  109336. * Registers for this mesh a javascript function called just after the rendering is complete
  109337. * @param func defines the function to call after rendering this mesh
  109338. * @returns the current mesh
  109339. */
  109340. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109341. /**
  109342. * Disposes a previously registered javascript function called after the rendering.
  109343. * @param func defines the function to remove
  109344. * @returns the current mesh
  109345. */
  109346. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109347. /** @hidden */
  109348. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  109349. /** @hidden */
  109350. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  109351. /** @hidden */
  109352. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  109353. /** @hidden */
  109354. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  109355. /** @hidden */
  109356. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  109357. /** @hidden */
  109358. _rebuild(): void;
  109359. /** @hidden */
  109360. _freeze(): void;
  109361. /** @hidden */
  109362. _unFreeze(): void;
  109363. /**
  109364. * 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
  109365. * @param subMesh defines the subMesh to render
  109366. * @param enableAlphaMode defines if alpha mode can be changed
  109367. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  109368. * @returns the current mesh
  109369. */
  109370. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  109371. private _onBeforeDraw;
  109372. /**
  109373. * Renormalize the mesh and patch it up if there are no weights
  109374. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  109375. * However in the case of zero weights then we set just a single influence to 1.
  109376. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  109377. */
  109378. cleanMatrixWeights(): void;
  109379. private normalizeSkinFourWeights;
  109380. private normalizeSkinWeightsAndExtra;
  109381. /**
  109382. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  109383. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  109384. * the user know there was an issue with importing the mesh
  109385. * @returns a validation object with skinned, valid and report string
  109386. */
  109387. validateSkinning(): {
  109388. skinned: boolean;
  109389. valid: boolean;
  109390. report: string;
  109391. };
  109392. /** @hidden */
  109393. _checkDelayState(): Mesh;
  109394. private _queueLoad;
  109395. /**
  109396. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109397. * A mesh is in the frustum if its bounding box intersects the frustum
  109398. * @param frustumPlanes defines the frustum to test
  109399. * @returns true if the mesh is in the frustum planes
  109400. */
  109401. isInFrustum(frustumPlanes: Plane[]): boolean;
  109402. /**
  109403. * Sets the mesh material by the material or multiMaterial `id` property
  109404. * @param id is a string identifying the material or the multiMaterial
  109405. * @returns the current mesh
  109406. */
  109407. setMaterialByID(id: string): Mesh;
  109408. /**
  109409. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  109410. * @returns an array of IAnimatable
  109411. */
  109412. getAnimatables(): IAnimatable[];
  109413. /**
  109414. * Modifies the mesh geometry according to the passed transformation matrix.
  109415. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  109416. * The mesh normals are modified using the same transformation.
  109417. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109418. * @param transform defines the transform matrix to use
  109419. * @see https://doc.babylonjs.com/resources/baking_transformations
  109420. * @returns the current mesh
  109421. */
  109422. bakeTransformIntoVertices(transform: Matrix): Mesh;
  109423. /**
  109424. * Modifies the mesh geometry according to its own current World Matrix.
  109425. * The mesh World Matrix is then reset.
  109426. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  109427. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109428. * @see https://doc.babylonjs.com/resources/baking_transformations
  109429. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  109430. * @returns the current mesh
  109431. */
  109432. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  109433. /** @hidden */
  109434. get _positions(): Nullable<Vector3[]>;
  109435. /** @hidden */
  109436. _resetPointsArrayCache(): Mesh;
  109437. /** @hidden */
  109438. _generatePointsArray(): boolean;
  109439. /**
  109440. * Returns a new Mesh object generated from the current mesh properties.
  109441. * This method must not get confused with createInstance()
  109442. * @param name is a string, the name given to the new mesh
  109443. * @param newParent can be any Node object (default `null`)
  109444. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  109445. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  109446. * @returns a new mesh
  109447. */
  109448. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  109449. /**
  109450. * Releases resources associated with this mesh.
  109451. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109452. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109453. */
  109454. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109455. /** @hidden */
  109456. _disposeInstanceSpecificData(): void;
  109457. /** @hidden */
  109458. _disposeThinInstanceSpecificData(): void;
  109459. /**
  109460. * Modifies the mesh geometry according to a displacement map.
  109461. * 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.
  109462. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109463. * @param url is a string, the URL from the image file is to be downloaded.
  109464. * @param minHeight is the lower limit of the displacement.
  109465. * @param maxHeight is the upper limit of the displacement.
  109466. * @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.
  109467. * @param uvOffset is an optional vector2 used to offset UV.
  109468. * @param uvScale is an optional vector2 used to scale UV.
  109469. * @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.
  109470. * @returns the Mesh.
  109471. */
  109472. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109473. /**
  109474. * Modifies the mesh geometry according to a displacementMap buffer.
  109475. * 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.
  109476. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109477. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  109478. * @param heightMapWidth is the width of the buffer image.
  109479. * @param heightMapHeight is the height of the buffer image.
  109480. * @param minHeight is the lower limit of the displacement.
  109481. * @param maxHeight is the upper limit of the displacement.
  109482. * @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.
  109483. * @param uvOffset is an optional vector2 used to offset UV.
  109484. * @param uvScale is an optional vector2 used to scale UV.
  109485. * @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.
  109486. * @returns the Mesh.
  109487. */
  109488. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109489. /**
  109490. * Modify the mesh to get a flat shading rendering.
  109491. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  109492. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  109493. * @returns current mesh
  109494. */
  109495. convertToFlatShadedMesh(): Mesh;
  109496. /**
  109497. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  109498. * In other words, more vertices, no more indices and a single bigger VBO.
  109499. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  109500. * @returns current mesh
  109501. */
  109502. convertToUnIndexedMesh(): Mesh;
  109503. /**
  109504. * Inverses facet orientations.
  109505. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109506. * @param flipNormals will also inverts the normals
  109507. * @returns current mesh
  109508. */
  109509. flipFaces(flipNormals?: boolean): Mesh;
  109510. /**
  109511. * Increase the number of facets and hence vertices in a mesh
  109512. * Vertex normals are interpolated from existing vertex normals
  109513. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109514. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  109515. */
  109516. increaseVertices(numberPerEdge: number): void;
  109517. /**
  109518. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  109519. * This will undo any application of covertToFlatShadedMesh
  109520. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109521. */
  109522. forceSharedVertices(): void;
  109523. /** @hidden */
  109524. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  109525. /** @hidden */
  109526. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  109527. /**
  109528. * Creates a new InstancedMesh object from the mesh model.
  109529. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109530. * @param name defines the name of the new instance
  109531. * @returns a new InstancedMesh
  109532. */
  109533. createInstance(name: string): InstancedMesh;
  109534. /**
  109535. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  109536. * After this call, all the mesh instances have the same submeshes than the current mesh.
  109537. * @returns the current mesh
  109538. */
  109539. synchronizeInstances(): Mesh;
  109540. /**
  109541. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  109542. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  109543. * This should be used together with the simplification to avoid disappearing triangles.
  109544. * @param successCallback an optional success callback to be called after the optimization finished.
  109545. * @returns the current mesh
  109546. */
  109547. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  109548. /**
  109549. * Serialize current mesh
  109550. * @param serializationObject defines the object which will receive the serialization data
  109551. */
  109552. serialize(serializationObject: any): void;
  109553. /** @hidden */
  109554. _syncGeometryWithMorphTargetManager(): void;
  109555. /** @hidden */
  109556. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  109557. /**
  109558. * Returns a new Mesh object parsed from the source provided.
  109559. * @param parsedMesh is the source
  109560. * @param scene defines the hosting scene
  109561. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  109562. * @returns a new Mesh
  109563. */
  109564. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  109565. /**
  109566. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  109567. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109568. * @param name defines the name of the mesh to create
  109569. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  109570. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  109571. * @param closePath creates a seam between the first and the last points of each path of the path array
  109572. * @param offset is taken in account only if the `pathArray` is containing a single path
  109573. * @param scene defines the hosting scene
  109574. * @param updatable defines if the mesh must be flagged as updatable
  109575. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109576. * @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)
  109577. * @returns a new Mesh
  109578. */
  109579. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109580. /**
  109581. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  109582. * @param name defines the name of the mesh to create
  109583. * @param radius sets the radius size (float) of the polygon (default 0.5)
  109584. * @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
  109585. * @param scene defines the hosting scene
  109586. * @param updatable defines if the mesh must be flagged as updatable
  109587. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109588. * @returns a new Mesh
  109589. */
  109590. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109591. /**
  109592. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  109593. * @param name defines the name of the mesh to create
  109594. * @param size sets the size (float) of each box side (default 1)
  109595. * @param scene defines the hosting scene
  109596. * @param updatable defines if the mesh must be flagged as updatable
  109597. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109598. * @returns a new Mesh
  109599. */
  109600. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109601. /**
  109602. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  109603. * @param name defines the name of the mesh to create
  109604. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109605. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109606. * @param scene defines the hosting scene
  109607. * @param updatable defines if the mesh must be flagged as updatable
  109608. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109609. * @returns a new Mesh
  109610. */
  109611. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109612. /**
  109613. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  109614. * @param name defines the name of the mesh to create
  109615. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109616. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109617. * @param scene defines the hosting scene
  109618. * @returns a new Mesh
  109619. */
  109620. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  109621. /**
  109622. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  109623. * @param name defines the name of the mesh to create
  109624. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  109625. * @param diameterTop set the top cap diameter (floats, default 1)
  109626. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  109627. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  109628. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  109629. * @param scene defines the hosting scene
  109630. * @param updatable defines if the mesh must be flagged as updatable
  109631. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109632. * @returns a new Mesh
  109633. */
  109634. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  109635. /**
  109636. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  109637. * @param name defines the name of the mesh to create
  109638. * @param diameter sets the diameter size (float) of the torus (default 1)
  109639. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  109640. * @param tessellation sets the number of torus sides (postive integer, default 16)
  109641. * @param scene defines the hosting scene
  109642. * @param updatable defines if the mesh must be flagged as updatable
  109643. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109644. * @returns a new Mesh
  109645. */
  109646. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109647. /**
  109648. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  109649. * @param name defines the name of the mesh to create
  109650. * @param radius sets the global radius size (float) of the torus knot (default 2)
  109651. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  109652. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  109653. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  109654. * @param p the number of windings on X axis (positive integers, default 2)
  109655. * @param q the number of windings on Y axis (positive integers, default 3)
  109656. * @param scene defines the hosting scene
  109657. * @param updatable defines if the mesh must be flagged as updatable
  109658. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109659. * @returns a new Mesh
  109660. */
  109661. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109662. /**
  109663. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  109664. * @param name defines the name of the mesh to create
  109665. * @param points is an array successive Vector3
  109666. * @param scene defines the hosting scene
  109667. * @param updatable defines if the mesh must be flagged as updatable
  109668. * @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).
  109669. * @returns a new Mesh
  109670. */
  109671. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  109672. /**
  109673. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  109674. * @param name defines the name of the mesh to create
  109675. * @param points is an array successive Vector3
  109676. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  109677. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109678. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  109679. * @param scene defines the hosting scene
  109680. * @param updatable defines if the mesh must be flagged as updatable
  109681. * @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)
  109682. * @returns a new Mesh
  109683. */
  109684. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  109685. /**
  109686. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  109687. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  109688. * 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.
  109689. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109690. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109691. * Remember you can only change the shape positions, not their number when updating a polygon.
  109692. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109693. * @param name defines the name of the mesh to create
  109694. * @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
  109695. * @param scene defines the hosting scene
  109696. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109697. * @param updatable defines if the mesh must be flagged as updatable
  109698. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109699. * @param earcutInjection can be used to inject your own earcut reference
  109700. * @returns a new Mesh
  109701. */
  109702. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109703. /**
  109704. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  109705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  109706. * @param name defines the name of the mesh to create
  109707. * @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
  109708. * @param depth defines the height of extrusion
  109709. * @param scene defines the hosting scene
  109710. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109711. * @param updatable defines if the mesh must be flagged as updatable
  109712. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109713. * @param earcutInjection can be used to inject your own earcut reference
  109714. * @returns a new Mesh
  109715. */
  109716. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109717. /**
  109718. * Creates an extruded shape mesh.
  109719. * 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
  109720. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109721. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109722. * @param name defines the name of the mesh to create
  109723. * @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
  109724. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109725. * @param scale is the value to scale the shape
  109726. * @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
  109727. * @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
  109728. * @param scene defines the hosting scene
  109729. * @param updatable defines if the mesh must be flagged as updatable
  109730. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109731. * @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)
  109732. * @returns a new Mesh
  109733. */
  109734. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109735. /**
  109736. * Creates an custom extruded shape mesh.
  109737. * The custom extrusion is a parametric shape.
  109738. * It has no predefined shape. Its final shape will depend on the input parameters.
  109739. * Please consider using the same method from the MeshBuilder class instead
  109740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109741. * @param name defines the name of the mesh to create
  109742. * @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
  109743. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109744. * @param scaleFunction is a custom Javascript function called on each path point
  109745. * @param rotationFunction is a custom Javascript function called on each path point
  109746. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109747. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  109748. * @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
  109749. * @param scene defines the hosting scene
  109750. * @param updatable defines if the mesh must be flagged as updatable
  109751. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109752. * @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)
  109753. * @returns a new Mesh
  109754. */
  109755. 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;
  109756. /**
  109757. * Creates lathe mesh.
  109758. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  109759. * Please consider using the same method from the MeshBuilder class instead
  109760. * @param name defines the name of the mesh to create
  109761. * @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
  109762. * @param radius is the radius value of the lathe
  109763. * @param tessellation is the side number of the lathe.
  109764. * @param scene defines the hosting scene
  109765. * @param updatable defines if the mesh must be flagged as updatable
  109766. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109767. * @returns a new Mesh
  109768. */
  109769. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109770. /**
  109771. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  109772. * @param name defines the name of the mesh to create
  109773. * @param size sets the size (float) of both sides of the plane at once (default 1)
  109774. * @param scene defines the hosting scene
  109775. * @param updatable defines if the mesh must be flagged as updatable
  109776. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109777. * @returns a new Mesh
  109778. */
  109779. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109780. /**
  109781. * Creates a ground mesh.
  109782. * Please consider using the same method from the MeshBuilder class instead
  109783. * @param name defines the name of the mesh to create
  109784. * @param width set the width of the ground
  109785. * @param height set the height of the ground
  109786. * @param subdivisions sets the number of subdivisions per side
  109787. * @param scene defines the hosting scene
  109788. * @param updatable defines if the mesh must be flagged as updatable
  109789. * @returns a new Mesh
  109790. */
  109791. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  109792. /**
  109793. * Creates a tiled ground mesh.
  109794. * Please consider using the same method from the MeshBuilder class instead
  109795. * @param name defines the name of the mesh to create
  109796. * @param xmin set the ground minimum X coordinate
  109797. * @param zmin set the ground minimum Y coordinate
  109798. * @param xmax set the ground maximum X coordinate
  109799. * @param zmax set the ground maximum Z coordinate
  109800. * @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
  109801. * @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
  109802. * @param scene defines the hosting scene
  109803. * @param updatable defines if the mesh must be flagged as updatable
  109804. * @returns a new Mesh
  109805. */
  109806. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  109807. w: number;
  109808. h: number;
  109809. }, precision: {
  109810. w: number;
  109811. h: number;
  109812. }, scene: Scene, updatable?: boolean): Mesh;
  109813. /**
  109814. * Creates a ground mesh from a height map.
  109815. * Please consider using the same method from the MeshBuilder class instead
  109816. * @see https://doc.babylonjs.com/babylon101/height_map
  109817. * @param name defines the name of the mesh to create
  109818. * @param url sets the URL of the height map image resource
  109819. * @param width set the ground width size
  109820. * @param height set the ground height size
  109821. * @param subdivisions sets the number of subdivision per side
  109822. * @param minHeight is the minimum altitude on the ground
  109823. * @param maxHeight is the maximum altitude on the ground
  109824. * @param scene defines the hosting scene
  109825. * @param updatable defines if the mesh must be flagged as updatable
  109826. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  109827. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109828. * @returns a new Mesh
  109829. */
  109830. 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;
  109831. /**
  109832. * Creates a tube mesh.
  109833. * The tube is a parametric shape.
  109834. * It has no predefined shape. Its final shape will depend on the input parameters.
  109835. * Please consider using the same method from the MeshBuilder class instead
  109836. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109837. * @param name defines the name of the mesh to create
  109838. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  109839. * @param radius sets the tube radius size
  109840. * @param tessellation is the number of sides on the tubular surface
  109841. * @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
  109842. * @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
  109843. * @param scene defines the hosting scene
  109844. * @param updatable defines if the mesh must be flagged as updatable
  109845. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109846. * @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)
  109847. * @returns a new Mesh
  109848. */
  109849. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  109850. (i: number, distance: number): number;
  109851. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109852. /**
  109853. * Creates a polyhedron mesh.
  109854. * Please consider using the same method from the MeshBuilder class instead.
  109855. * * 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
  109856. * * The parameter `size` (positive float, default 1) sets the polygon size
  109857. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109858. * * 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`
  109859. * * 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
  109860. * * 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)`)
  109861. * * 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
  109862. * * 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
  109863. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109866. * @param name defines the name of the mesh to create
  109867. * @param options defines the options used to create the mesh
  109868. * @param scene defines the hosting scene
  109869. * @returns a new Mesh
  109870. */
  109871. static CreatePolyhedron(name: string, options: {
  109872. type?: number;
  109873. size?: number;
  109874. sizeX?: number;
  109875. sizeY?: number;
  109876. sizeZ?: number;
  109877. custom?: any;
  109878. faceUV?: Vector4[];
  109879. faceColors?: Color4[];
  109880. updatable?: boolean;
  109881. sideOrientation?: number;
  109882. }, scene: Scene): Mesh;
  109883. /**
  109884. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109885. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109886. * * 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`)
  109887. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109888. * * 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
  109889. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109892. * @param name defines the name of the mesh
  109893. * @param options defines the options used to create the mesh
  109894. * @param scene defines the hosting scene
  109895. * @returns a new Mesh
  109896. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109897. */
  109898. static CreateIcoSphere(name: string, options: {
  109899. radius?: number;
  109900. flat?: boolean;
  109901. subdivisions?: number;
  109902. sideOrientation?: number;
  109903. updatable?: boolean;
  109904. }, scene: Scene): Mesh;
  109905. /**
  109906. * Creates a decal mesh.
  109907. * Please consider using the same method from the MeshBuilder class instead.
  109908. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109909. * @param name defines the name of the mesh
  109910. * @param sourceMesh defines the mesh receiving the decal
  109911. * @param position sets the position of the decal in world coordinates
  109912. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109913. * @param size sets the decal scaling
  109914. * @param angle sets the angle to rotate the decal
  109915. * @returns a new Mesh
  109916. */
  109917. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109918. /** Creates a Capsule Mesh
  109919. * @param name defines the name of the mesh.
  109920. * @param options the constructors options used to shape the mesh.
  109921. * @param scene defines the scene the mesh is scoped to.
  109922. * @returns the capsule mesh
  109923. * @see https://doc.babylonjs.com/how_to/capsule_shape
  109924. */
  109925. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  109926. /**
  109927. * Prepare internal position array for software CPU skinning
  109928. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109929. */
  109930. setPositionsForCPUSkinning(): Float32Array;
  109931. /**
  109932. * Prepare internal normal array for software CPU skinning
  109933. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109934. */
  109935. setNormalsForCPUSkinning(): Float32Array;
  109936. /**
  109937. * Updates the vertex buffer by applying transformation from the bones
  109938. * @param skeleton defines the skeleton to apply to current mesh
  109939. * @returns the current mesh
  109940. */
  109941. applySkeleton(skeleton: Skeleton): Mesh;
  109942. /**
  109943. * 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
  109944. * @param meshes defines the list of meshes to scan
  109945. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109946. */
  109947. static MinMax(meshes: AbstractMesh[]): {
  109948. min: Vector3;
  109949. max: Vector3;
  109950. };
  109951. /**
  109952. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109953. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109954. * @returns a vector3
  109955. */
  109956. static Center(meshesOrMinMaxVector: {
  109957. min: Vector3;
  109958. max: Vector3;
  109959. } | AbstractMesh[]): Vector3;
  109960. /**
  109961. * Merge the array of meshes into a single mesh for performance reasons.
  109962. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109963. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109964. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109965. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109966. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109967. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109968. * @returns a new mesh
  109969. */
  109970. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109971. /** @hidden */
  109972. addInstance(instance: InstancedMesh): void;
  109973. /** @hidden */
  109974. removeInstance(instance: InstancedMesh): void;
  109975. }
  109976. }
  109977. declare module BABYLON {
  109978. /**
  109979. * This is the base class of all the camera used in the application.
  109980. * @see https://doc.babylonjs.com/features/cameras
  109981. */
  109982. export class Camera extends Node {
  109983. /** @hidden */
  109984. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109985. /**
  109986. * This is the default projection mode used by the cameras.
  109987. * It helps recreating a feeling of perspective and better appreciate depth.
  109988. * This is the best way to simulate real life cameras.
  109989. */
  109990. static readonly PERSPECTIVE_CAMERA: number;
  109991. /**
  109992. * This helps creating camera with an orthographic mode.
  109993. * 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.
  109994. */
  109995. static readonly ORTHOGRAPHIC_CAMERA: number;
  109996. /**
  109997. * This is the default FOV mode for perspective cameras.
  109998. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109999. */
  110000. static readonly FOVMODE_VERTICAL_FIXED: number;
  110001. /**
  110002. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  110003. */
  110004. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  110005. /**
  110006. * This specifies ther is no need for a camera rig.
  110007. * Basically only one eye is rendered corresponding to the camera.
  110008. */
  110009. static readonly RIG_MODE_NONE: number;
  110010. /**
  110011. * Simulates a camera Rig with one blue eye and one red eye.
  110012. * This can be use with 3d blue and red glasses.
  110013. */
  110014. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  110015. /**
  110016. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  110017. */
  110018. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  110019. /**
  110020. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  110021. */
  110022. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  110023. /**
  110024. * Defines that both eyes of the camera will be rendered over under each other.
  110025. */
  110026. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  110027. /**
  110028. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  110029. */
  110030. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  110031. /**
  110032. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  110033. */
  110034. static readonly RIG_MODE_VR: number;
  110035. /**
  110036. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  110037. */
  110038. static readonly RIG_MODE_WEBVR: number;
  110039. /**
  110040. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  110041. */
  110042. static readonly RIG_MODE_CUSTOM: number;
  110043. /**
  110044. * Defines if by default attaching controls should prevent the default javascript event to continue.
  110045. */
  110046. static ForceAttachControlToAlwaysPreventDefault: boolean;
  110047. /**
  110048. * Define the input manager associated with the camera.
  110049. */
  110050. inputs: CameraInputsManager<Camera>;
  110051. /** @hidden */
  110052. _position: Vector3;
  110053. /**
  110054. * Define the current local position of the camera in the scene
  110055. */
  110056. get position(): Vector3;
  110057. set position(newPosition: Vector3);
  110058. protected _upVector: Vector3;
  110059. /**
  110060. * The vector the camera should consider as up.
  110061. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  110062. */
  110063. set upVector(vec: Vector3);
  110064. get upVector(): Vector3;
  110065. /**
  110066. * Define the current limit on the left side for an orthographic camera
  110067. * In scene unit
  110068. */
  110069. orthoLeft: Nullable<number>;
  110070. /**
  110071. * Define the current limit on the right side for an orthographic camera
  110072. * In scene unit
  110073. */
  110074. orthoRight: Nullable<number>;
  110075. /**
  110076. * Define the current limit on the bottom side for an orthographic camera
  110077. * In scene unit
  110078. */
  110079. orthoBottom: Nullable<number>;
  110080. /**
  110081. * Define the current limit on the top side for an orthographic camera
  110082. * In scene unit
  110083. */
  110084. orthoTop: Nullable<number>;
  110085. /**
  110086. * Field Of View is set in Radians. (default is 0.8)
  110087. */
  110088. fov: number;
  110089. /**
  110090. * Define the minimum distance the camera can see from.
  110091. * This is important to note that the depth buffer are not infinite and the closer it starts
  110092. * the more your scene might encounter depth fighting issue.
  110093. */
  110094. minZ: number;
  110095. /**
  110096. * Define the maximum distance the camera can see to.
  110097. * This is important to note that the depth buffer are not infinite and the further it end
  110098. * the more your scene might encounter depth fighting issue.
  110099. */
  110100. maxZ: number;
  110101. /**
  110102. * Define the default inertia of the camera.
  110103. * This helps giving a smooth feeling to the camera movement.
  110104. */
  110105. inertia: number;
  110106. /**
  110107. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  110108. */
  110109. mode: number;
  110110. /**
  110111. * Define whether the camera is intermediate.
  110112. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  110113. */
  110114. isIntermediate: boolean;
  110115. /**
  110116. * Define the viewport of the camera.
  110117. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  110118. */
  110119. viewport: Viewport;
  110120. /**
  110121. * Restricts the camera to viewing objects with the same layerMask.
  110122. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  110123. */
  110124. layerMask: number;
  110125. /**
  110126. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  110127. */
  110128. fovMode: number;
  110129. /**
  110130. * Rig mode of the camera.
  110131. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  110132. * This is normally controlled byt the camera themselves as internal use.
  110133. */
  110134. cameraRigMode: number;
  110135. /**
  110136. * Defines the distance between both "eyes" in case of a RIG
  110137. */
  110138. interaxialDistance: number;
  110139. /**
  110140. * Defines if stereoscopic rendering is done side by side or over under.
  110141. */
  110142. isStereoscopicSideBySide: boolean;
  110143. /**
  110144. * 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
  110145. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  110146. * else in the scene. (Eg. security camera)
  110147. *
  110148. * 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)
  110149. */
  110150. customRenderTargets: RenderTargetTexture[];
  110151. /**
  110152. * When set, the camera will render to this render target instead of the default canvas
  110153. *
  110154. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  110155. */
  110156. outputRenderTarget: Nullable<RenderTargetTexture>;
  110157. /**
  110158. * Observable triggered when the camera view matrix has changed.
  110159. */
  110160. onViewMatrixChangedObservable: Observable<Camera>;
  110161. /**
  110162. * Observable triggered when the camera Projection matrix has changed.
  110163. */
  110164. onProjectionMatrixChangedObservable: Observable<Camera>;
  110165. /**
  110166. * Observable triggered when the inputs have been processed.
  110167. */
  110168. onAfterCheckInputsObservable: Observable<Camera>;
  110169. /**
  110170. * Observable triggered when reset has been called and applied to the camera.
  110171. */
  110172. onRestoreStateObservable: Observable<Camera>;
  110173. /**
  110174. * Is this camera a part of a rig system?
  110175. */
  110176. isRigCamera: boolean;
  110177. /**
  110178. * If isRigCamera set to true this will be set with the parent camera.
  110179. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  110180. */
  110181. rigParent?: Camera;
  110182. /** @hidden */
  110183. _cameraRigParams: any;
  110184. /** @hidden */
  110185. _rigCameras: Camera[];
  110186. /** @hidden */
  110187. _rigPostProcess: Nullable<PostProcess>;
  110188. protected _webvrViewMatrix: Matrix;
  110189. /** @hidden */
  110190. _skipRendering: boolean;
  110191. /** @hidden */
  110192. _projectionMatrix: Matrix;
  110193. /** @hidden */
  110194. _postProcesses: Nullable<PostProcess>[];
  110195. /** @hidden */
  110196. _activeMeshes: SmartArray<AbstractMesh>;
  110197. protected _globalPosition: Vector3;
  110198. /** @hidden */
  110199. _computedViewMatrix: Matrix;
  110200. private _doNotComputeProjectionMatrix;
  110201. private _transformMatrix;
  110202. private _frustumPlanes;
  110203. private _refreshFrustumPlanes;
  110204. private _storedFov;
  110205. private _stateStored;
  110206. /**
  110207. * Instantiates a new camera object.
  110208. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  110209. * @see https://doc.babylonjs.com/features/cameras
  110210. * @param name Defines the name of the camera in the scene
  110211. * @param position Defines the position of the camera
  110212. * @param scene Defines the scene the camera belongs too
  110213. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  110214. */
  110215. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110216. /**
  110217. * Store current camera state (fov, position, etc..)
  110218. * @returns the camera
  110219. */
  110220. storeState(): Camera;
  110221. /**
  110222. * Restores the camera state values if it has been stored. You must call storeState() first
  110223. */
  110224. protected _restoreStateValues(): boolean;
  110225. /**
  110226. * Restored camera state. You must call storeState() first.
  110227. * @returns true if restored and false otherwise
  110228. */
  110229. restoreState(): boolean;
  110230. /**
  110231. * Gets the class name of the camera.
  110232. * @returns the class name
  110233. */
  110234. getClassName(): string;
  110235. /** @hidden */
  110236. readonly _isCamera: boolean;
  110237. /**
  110238. * Gets a string representation of the camera useful for debug purpose.
  110239. * @param fullDetails Defines that a more verboe level of logging is required
  110240. * @returns the string representation
  110241. */
  110242. toString(fullDetails?: boolean): string;
  110243. /**
  110244. * Gets the current world space position of the camera.
  110245. */
  110246. get globalPosition(): Vector3;
  110247. /**
  110248. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  110249. * @returns the active meshe list
  110250. */
  110251. getActiveMeshes(): SmartArray<AbstractMesh>;
  110252. /**
  110253. * Check whether a mesh is part of the current active mesh list of the camera
  110254. * @param mesh Defines the mesh to check
  110255. * @returns true if active, false otherwise
  110256. */
  110257. isActiveMesh(mesh: Mesh): boolean;
  110258. /**
  110259. * Is this camera ready to be used/rendered
  110260. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  110261. * @return true if the camera is ready
  110262. */
  110263. isReady(completeCheck?: boolean): boolean;
  110264. /** @hidden */
  110265. _initCache(): void;
  110266. /** @hidden */
  110267. _updateCache(ignoreParentClass?: boolean): void;
  110268. /** @hidden */
  110269. _isSynchronized(): boolean;
  110270. /** @hidden */
  110271. _isSynchronizedViewMatrix(): boolean;
  110272. /** @hidden */
  110273. _isSynchronizedProjectionMatrix(): boolean;
  110274. /**
  110275. * Attach the input controls to a specific dom element to get the input from.
  110276. * @param element Defines the element the controls should be listened from
  110277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110278. */
  110279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110280. /**
  110281. * Detach the current controls from the specified dom element.
  110282. * @param element Defines the element to stop listening the inputs from
  110283. */
  110284. detachControl(element: HTMLElement): void;
  110285. /**
  110286. * Update the camera state according to the different inputs gathered during the frame.
  110287. */
  110288. update(): void;
  110289. /** @hidden */
  110290. _checkInputs(): void;
  110291. /** @hidden */
  110292. get rigCameras(): Camera[];
  110293. /**
  110294. * Gets the post process used by the rig cameras
  110295. */
  110296. get rigPostProcess(): Nullable<PostProcess>;
  110297. /**
  110298. * Internal, gets the first post proces.
  110299. * @returns the first post process to be run on this camera.
  110300. */
  110301. _getFirstPostProcess(): Nullable<PostProcess>;
  110302. private _cascadePostProcessesToRigCams;
  110303. /**
  110304. * Attach a post process to the camera.
  110305. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110306. * @param postProcess The post process to attach to the camera
  110307. * @param insertAt The position of the post process in case several of them are in use in the scene
  110308. * @returns the position the post process has been inserted at
  110309. */
  110310. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  110311. /**
  110312. * Detach a post process to the camera.
  110313. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110314. * @param postProcess The post process to detach from the camera
  110315. */
  110316. detachPostProcess(postProcess: PostProcess): void;
  110317. /**
  110318. * Gets the current world matrix of the camera
  110319. */
  110320. getWorldMatrix(): Matrix;
  110321. /** @hidden */
  110322. _getViewMatrix(): Matrix;
  110323. /**
  110324. * Gets the current view matrix of the camera.
  110325. * @param force forces the camera to recompute the matrix without looking at the cached state
  110326. * @returns the view matrix
  110327. */
  110328. getViewMatrix(force?: boolean): Matrix;
  110329. /**
  110330. * Freeze the projection matrix.
  110331. * It will prevent the cache check of the camera projection compute and can speed up perf
  110332. * if no parameter of the camera are meant to change
  110333. * @param projection Defines manually a projection if necessary
  110334. */
  110335. freezeProjectionMatrix(projection?: Matrix): void;
  110336. /**
  110337. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  110338. */
  110339. unfreezeProjectionMatrix(): void;
  110340. /**
  110341. * Gets the current projection matrix of the camera.
  110342. * @param force forces the camera to recompute the matrix without looking at the cached state
  110343. * @returns the projection matrix
  110344. */
  110345. getProjectionMatrix(force?: boolean): Matrix;
  110346. /**
  110347. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  110348. * @returns a Matrix
  110349. */
  110350. getTransformationMatrix(): Matrix;
  110351. private _updateFrustumPlanes;
  110352. /**
  110353. * Checks if a cullable object (mesh...) is in the camera frustum
  110354. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  110355. * @param target The object to check
  110356. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  110357. * @returns true if the object is in frustum otherwise false
  110358. */
  110359. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  110360. /**
  110361. * Checks if a cullable object (mesh...) is in the camera frustum
  110362. * Unlike isInFrustum this cheks the full bounding box
  110363. * @param target The object to check
  110364. * @returns true if the object is in frustum otherwise false
  110365. */
  110366. isCompletelyInFrustum(target: ICullable): boolean;
  110367. /**
  110368. * Gets a ray in the forward direction from the camera.
  110369. * @param length Defines the length of the ray to create
  110370. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110371. * @param origin Defines the start point of the ray which defaults to the camera position
  110372. * @returns the forward ray
  110373. */
  110374. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110375. /**
  110376. * Gets a ray in the forward direction from the camera.
  110377. * @param refRay the ray to (re)use when setting the values
  110378. * @param length Defines the length of the ray to create
  110379. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110380. * @param origin Defines the start point of the ray which defaults to the camera position
  110381. * @returns the forward ray
  110382. */
  110383. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110384. /**
  110385. * Releases resources associated with this node.
  110386. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110387. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110388. */
  110389. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110390. /** @hidden */
  110391. _isLeftCamera: boolean;
  110392. /**
  110393. * Gets the left camera of a rig setup in case of Rigged Camera
  110394. */
  110395. get isLeftCamera(): boolean;
  110396. /** @hidden */
  110397. _isRightCamera: boolean;
  110398. /**
  110399. * Gets the right camera of a rig setup in case of Rigged Camera
  110400. */
  110401. get isRightCamera(): boolean;
  110402. /**
  110403. * Gets the left camera of a rig setup in case of Rigged Camera
  110404. */
  110405. get leftCamera(): Nullable<FreeCamera>;
  110406. /**
  110407. * Gets the right camera of a rig setup in case of Rigged Camera
  110408. */
  110409. get rightCamera(): Nullable<FreeCamera>;
  110410. /**
  110411. * Gets the left camera target of a rig setup in case of Rigged Camera
  110412. * @returns the target position
  110413. */
  110414. getLeftTarget(): Nullable<Vector3>;
  110415. /**
  110416. * Gets the right camera target of a rig setup in case of Rigged Camera
  110417. * @returns the target position
  110418. */
  110419. getRightTarget(): Nullable<Vector3>;
  110420. /**
  110421. * @hidden
  110422. */
  110423. setCameraRigMode(mode: number, rigParams: any): void;
  110424. /** @hidden */
  110425. static _setStereoscopicRigMode(camera: Camera): void;
  110426. /** @hidden */
  110427. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  110428. /** @hidden */
  110429. static _setVRRigMode(camera: Camera, rigParams: any): void;
  110430. /** @hidden */
  110431. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  110432. /** @hidden */
  110433. _getVRProjectionMatrix(): Matrix;
  110434. protected _updateCameraRotationMatrix(): void;
  110435. protected _updateWebVRCameraRotationMatrix(): void;
  110436. /**
  110437. * This function MUST be overwritten by the different WebVR cameras available.
  110438. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110439. * @hidden
  110440. */
  110441. _getWebVRProjectionMatrix(): Matrix;
  110442. /**
  110443. * This function MUST be overwritten by the different WebVR cameras available.
  110444. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110445. * @hidden
  110446. */
  110447. _getWebVRViewMatrix(): Matrix;
  110448. /** @hidden */
  110449. setCameraRigParameter(name: string, value: any): void;
  110450. /**
  110451. * needs to be overridden by children so sub has required properties to be copied
  110452. * @hidden
  110453. */
  110454. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  110455. /**
  110456. * May need to be overridden by children
  110457. * @hidden
  110458. */
  110459. _updateRigCameras(): void;
  110460. /** @hidden */
  110461. _setupInputs(): void;
  110462. /**
  110463. * Serialiaze the camera setup to a json represention
  110464. * @returns the JSON representation
  110465. */
  110466. serialize(): any;
  110467. /**
  110468. * Clones the current camera.
  110469. * @param name The cloned camera name
  110470. * @returns the cloned camera
  110471. */
  110472. clone(name: string): Camera;
  110473. /**
  110474. * Gets the direction of the camera relative to a given local axis.
  110475. * @param localAxis Defines the reference axis to provide a relative direction.
  110476. * @return the direction
  110477. */
  110478. getDirection(localAxis: Vector3): Vector3;
  110479. /**
  110480. * Returns the current camera absolute rotation
  110481. */
  110482. get absoluteRotation(): Quaternion;
  110483. /**
  110484. * Gets the direction of the camera relative to a given local axis into a passed vector.
  110485. * @param localAxis Defines the reference axis to provide a relative direction.
  110486. * @param result Defines the vector to store the result in
  110487. */
  110488. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  110489. /**
  110490. * Gets a camera constructor for a given camera type
  110491. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  110492. * @param name The name of the camera the result will be able to instantiate
  110493. * @param scene The scene the result will construct the camera in
  110494. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  110495. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  110496. * @returns a factory method to construc the camera
  110497. */
  110498. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  110499. /**
  110500. * Compute the world matrix of the camera.
  110501. * @returns the camera world matrix
  110502. */
  110503. computeWorldMatrix(): Matrix;
  110504. /**
  110505. * Parse a JSON and creates the camera from the parsed information
  110506. * @param parsedCamera The JSON to parse
  110507. * @param scene The scene to instantiate the camera in
  110508. * @returns the newly constructed camera
  110509. */
  110510. static Parse(parsedCamera: any, scene: Scene): Camera;
  110511. }
  110512. }
  110513. declare module BABYLON {
  110514. /**
  110515. * Class containing static functions to help procedurally build meshes
  110516. */
  110517. export class DiscBuilder {
  110518. /**
  110519. * Creates a plane polygonal mesh. By default, this is a disc
  110520. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110521. * * 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
  110522. * * 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
  110523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110526. * @param name defines the name of the mesh
  110527. * @param options defines the options used to create the mesh
  110528. * @param scene defines the hosting scene
  110529. * @returns the plane polygonal mesh
  110530. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110531. */
  110532. static CreateDisc(name: string, options: {
  110533. radius?: number;
  110534. tessellation?: number;
  110535. arc?: number;
  110536. updatable?: boolean;
  110537. sideOrientation?: number;
  110538. frontUVs?: Vector4;
  110539. backUVs?: Vector4;
  110540. }, scene?: Nullable<Scene>): Mesh;
  110541. }
  110542. }
  110543. declare module BABYLON {
  110544. /**
  110545. * Options to be used when creating a FresnelParameters.
  110546. */
  110547. export type IFresnelParametersCreationOptions = {
  110548. /**
  110549. * Define the color used on edges (grazing angle)
  110550. */
  110551. leftColor?: Color3;
  110552. /**
  110553. * Define the color used on center
  110554. */
  110555. rightColor?: Color3;
  110556. /**
  110557. * Define bias applied to computed fresnel term
  110558. */
  110559. bias?: number;
  110560. /**
  110561. * Defined the power exponent applied to fresnel term
  110562. */
  110563. power?: number;
  110564. /**
  110565. * Define if the fresnel effect is enable or not.
  110566. */
  110567. isEnabled?: boolean;
  110568. };
  110569. /**
  110570. * Serialized format for FresnelParameters.
  110571. */
  110572. export type IFresnelParametersSerialized = {
  110573. /**
  110574. * Define the color used on edges (grazing angle) [as an array]
  110575. */
  110576. leftColor: number[];
  110577. /**
  110578. * Define the color used on center [as an array]
  110579. */
  110580. rightColor: number[];
  110581. /**
  110582. * Define bias applied to computed fresnel term
  110583. */
  110584. bias: number;
  110585. /**
  110586. * Defined the power exponent applied to fresnel term
  110587. */
  110588. power?: number;
  110589. /**
  110590. * Define if the fresnel effect is enable or not.
  110591. */
  110592. isEnabled: boolean;
  110593. };
  110594. /**
  110595. * This represents all the required information to add a fresnel effect on a material:
  110596. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110597. */
  110598. export class FresnelParameters {
  110599. private _isEnabled;
  110600. /**
  110601. * Define if the fresnel effect is enable or not.
  110602. */
  110603. get isEnabled(): boolean;
  110604. set isEnabled(value: boolean);
  110605. /**
  110606. * Define the color used on edges (grazing angle)
  110607. */
  110608. leftColor: Color3;
  110609. /**
  110610. * Define the color used on center
  110611. */
  110612. rightColor: Color3;
  110613. /**
  110614. * Define bias applied to computed fresnel term
  110615. */
  110616. bias: number;
  110617. /**
  110618. * Defined the power exponent applied to fresnel term
  110619. */
  110620. power: number;
  110621. /**
  110622. * Creates a new FresnelParameters object.
  110623. *
  110624. * @param options provide your own settings to optionally to override defaults
  110625. */
  110626. constructor(options?: IFresnelParametersCreationOptions);
  110627. /**
  110628. * Clones the current fresnel and its valuues
  110629. * @returns a clone fresnel configuration
  110630. */
  110631. clone(): FresnelParameters;
  110632. /**
  110633. * Determines equality between FresnelParameters objects
  110634. * @param otherFresnelParameters defines the second operand
  110635. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  110636. */
  110637. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  110638. /**
  110639. * Serializes the current fresnel parameters to a JSON representation.
  110640. * @return the JSON serialization
  110641. */
  110642. serialize(): IFresnelParametersSerialized;
  110643. /**
  110644. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  110645. * @param parsedFresnelParameters Define the JSON representation
  110646. * @returns the parsed parameters
  110647. */
  110648. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  110649. }
  110650. }
  110651. declare module BABYLON {
  110652. /**
  110653. * This groups all the flags used to control the materials channel.
  110654. */
  110655. export class MaterialFlags {
  110656. private static _DiffuseTextureEnabled;
  110657. /**
  110658. * Are diffuse textures enabled in the application.
  110659. */
  110660. static get DiffuseTextureEnabled(): boolean;
  110661. static set DiffuseTextureEnabled(value: boolean);
  110662. private static _DetailTextureEnabled;
  110663. /**
  110664. * Are detail textures enabled in the application.
  110665. */
  110666. static get DetailTextureEnabled(): boolean;
  110667. static set DetailTextureEnabled(value: boolean);
  110668. private static _AmbientTextureEnabled;
  110669. /**
  110670. * Are ambient textures enabled in the application.
  110671. */
  110672. static get AmbientTextureEnabled(): boolean;
  110673. static set AmbientTextureEnabled(value: boolean);
  110674. private static _OpacityTextureEnabled;
  110675. /**
  110676. * Are opacity textures enabled in the application.
  110677. */
  110678. static get OpacityTextureEnabled(): boolean;
  110679. static set OpacityTextureEnabled(value: boolean);
  110680. private static _ReflectionTextureEnabled;
  110681. /**
  110682. * Are reflection textures enabled in the application.
  110683. */
  110684. static get ReflectionTextureEnabled(): boolean;
  110685. static set ReflectionTextureEnabled(value: boolean);
  110686. private static _EmissiveTextureEnabled;
  110687. /**
  110688. * Are emissive textures enabled in the application.
  110689. */
  110690. static get EmissiveTextureEnabled(): boolean;
  110691. static set EmissiveTextureEnabled(value: boolean);
  110692. private static _SpecularTextureEnabled;
  110693. /**
  110694. * Are specular textures enabled in the application.
  110695. */
  110696. static get SpecularTextureEnabled(): boolean;
  110697. static set SpecularTextureEnabled(value: boolean);
  110698. private static _BumpTextureEnabled;
  110699. /**
  110700. * Are bump textures enabled in the application.
  110701. */
  110702. static get BumpTextureEnabled(): boolean;
  110703. static set BumpTextureEnabled(value: boolean);
  110704. private static _LightmapTextureEnabled;
  110705. /**
  110706. * Are lightmap textures enabled in the application.
  110707. */
  110708. static get LightmapTextureEnabled(): boolean;
  110709. static set LightmapTextureEnabled(value: boolean);
  110710. private static _RefractionTextureEnabled;
  110711. /**
  110712. * Are refraction textures enabled in the application.
  110713. */
  110714. static get RefractionTextureEnabled(): boolean;
  110715. static set RefractionTextureEnabled(value: boolean);
  110716. private static _ColorGradingTextureEnabled;
  110717. /**
  110718. * Are color grading textures enabled in the application.
  110719. */
  110720. static get ColorGradingTextureEnabled(): boolean;
  110721. static set ColorGradingTextureEnabled(value: boolean);
  110722. private static _FresnelEnabled;
  110723. /**
  110724. * Are fresnels enabled in the application.
  110725. */
  110726. static get FresnelEnabled(): boolean;
  110727. static set FresnelEnabled(value: boolean);
  110728. private static _ClearCoatTextureEnabled;
  110729. /**
  110730. * Are clear coat textures enabled in the application.
  110731. */
  110732. static get ClearCoatTextureEnabled(): boolean;
  110733. static set ClearCoatTextureEnabled(value: boolean);
  110734. private static _ClearCoatBumpTextureEnabled;
  110735. /**
  110736. * Are clear coat bump textures enabled in the application.
  110737. */
  110738. static get ClearCoatBumpTextureEnabled(): boolean;
  110739. static set ClearCoatBumpTextureEnabled(value: boolean);
  110740. private static _ClearCoatTintTextureEnabled;
  110741. /**
  110742. * Are clear coat tint textures enabled in the application.
  110743. */
  110744. static get ClearCoatTintTextureEnabled(): boolean;
  110745. static set ClearCoatTintTextureEnabled(value: boolean);
  110746. private static _SheenTextureEnabled;
  110747. /**
  110748. * Are sheen textures enabled in the application.
  110749. */
  110750. static get SheenTextureEnabled(): boolean;
  110751. static set SheenTextureEnabled(value: boolean);
  110752. private static _AnisotropicTextureEnabled;
  110753. /**
  110754. * Are anisotropic textures enabled in the application.
  110755. */
  110756. static get AnisotropicTextureEnabled(): boolean;
  110757. static set AnisotropicTextureEnabled(value: boolean);
  110758. private static _ThicknessTextureEnabled;
  110759. /**
  110760. * Are thickness textures enabled in the application.
  110761. */
  110762. static get ThicknessTextureEnabled(): boolean;
  110763. static set ThicknessTextureEnabled(value: boolean);
  110764. }
  110765. }
  110766. declare module BABYLON {
  110767. /** @hidden */
  110768. export var defaultFragmentDeclaration: {
  110769. name: string;
  110770. shader: string;
  110771. };
  110772. }
  110773. declare module BABYLON {
  110774. /** @hidden */
  110775. export var defaultUboDeclaration: {
  110776. name: string;
  110777. shader: string;
  110778. };
  110779. }
  110780. declare module BABYLON {
  110781. /** @hidden */
  110782. export var prePassDeclaration: {
  110783. name: string;
  110784. shader: string;
  110785. };
  110786. }
  110787. declare module BABYLON {
  110788. /** @hidden */
  110789. export var lightFragmentDeclaration: {
  110790. name: string;
  110791. shader: string;
  110792. };
  110793. }
  110794. declare module BABYLON {
  110795. /** @hidden */
  110796. export var lightUboDeclaration: {
  110797. name: string;
  110798. shader: string;
  110799. };
  110800. }
  110801. declare module BABYLON {
  110802. /** @hidden */
  110803. export var lightsFragmentFunctions: {
  110804. name: string;
  110805. shader: string;
  110806. };
  110807. }
  110808. declare module BABYLON {
  110809. /** @hidden */
  110810. export var shadowsFragmentFunctions: {
  110811. name: string;
  110812. shader: string;
  110813. };
  110814. }
  110815. declare module BABYLON {
  110816. /** @hidden */
  110817. export var fresnelFunction: {
  110818. name: string;
  110819. shader: string;
  110820. };
  110821. }
  110822. declare module BABYLON {
  110823. /** @hidden */
  110824. export var bumpFragmentMainFunctions: {
  110825. name: string;
  110826. shader: string;
  110827. };
  110828. }
  110829. declare module BABYLON {
  110830. /** @hidden */
  110831. export var bumpFragmentFunctions: {
  110832. name: string;
  110833. shader: string;
  110834. };
  110835. }
  110836. declare module BABYLON {
  110837. /** @hidden */
  110838. export var logDepthDeclaration: {
  110839. name: string;
  110840. shader: string;
  110841. };
  110842. }
  110843. declare module BABYLON {
  110844. /** @hidden */
  110845. export var bumpFragment: {
  110846. name: string;
  110847. shader: string;
  110848. };
  110849. }
  110850. declare module BABYLON {
  110851. /** @hidden */
  110852. export var depthPrePass: {
  110853. name: string;
  110854. shader: string;
  110855. };
  110856. }
  110857. declare module BABYLON {
  110858. /** @hidden */
  110859. export var lightFragment: {
  110860. name: string;
  110861. shader: string;
  110862. };
  110863. }
  110864. declare module BABYLON {
  110865. /** @hidden */
  110866. export var logDepthFragment: {
  110867. name: string;
  110868. shader: string;
  110869. };
  110870. }
  110871. declare module BABYLON {
  110872. /** @hidden */
  110873. export var defaultPixelShader: {
  110874. name: string;
  110875. shader: string;
  110876. };
  110877. }
  110878. declare module BABYLON {
  110879. /** @hidden */
  110880. export var defaultVertexDeclaration: {
  110881. name: string;
  110882. shader: string;
  110883. };
  110884. }
  110885. declare module BABYLON {
  110886. /** @hidden */
  110887. export var prePassVertexDeclaration: {
  110888. name: string;
  110889. shader: string;
  110890. };
  110891. }
  110892. declare module BABYLON {
  110893. /** @hidden */
  110894. export var bumpVertexDeclaration: {
  110895. name: string;
  110896. shader: string;
  110897. };
  110898. }
  110899. declare module BABYLON {
  110900. /** @hidden */
  110901. export var prePassVertex: {
  110902. name: string;
  110903. shader: string;
  110904. };
  110905. }
  110906. declare module BABYLON {
  110907. /** @hidden */
  110908. export var bumpVertex: {
  110909. name: string;
  110910. shader: string;
  110911. };
  110912. }
  110913. declare module BABYLON {
  110914. /** @hidden */
  110915. export var fogVertex: {
  110916. name: string;
  110917. shader: string;
  110918. };
  110919. }
  110920. declare module BABYLON {
  110921. /** @hidden */
  110922. export var shadowsVertex: {
  110923. name: string;
  110924. shader: string;
  110925. };
  110926. }
  110927. declare module BABYLON {
  110928. /** @hidden */
  110929. export var pointCloudVertex: {
  110930. name: string;
  110931. shader: string;
  110932. };
  110933. }
  110934. declare module BABYLON {
  110935. /** @hidden */
  110936. export var logDepthVertex: {
  110937. name: string;
  110938. shader: string;
  110939. };
  110940. }
  110941. declare module BABYLON {
  110942. /** @hidden */
  110943. export var defaultVertexShader: {
  110944. name: string;
  110945. shader: string;
  110946. };
  110947. }
  110948. declare module BABYLON {
  110949. /**
  110950. * @hidden
  110951. */
  110952. export interface IMaterialDetailMapDefines {
  110953. DETAIL: boolean;
  110954. DETAILDIRECTUV: number;
  110955. DETAIL_NORMALBLENDMETHOD: number;
  110956. /** @hidden */
  110957. _areTexturesDirty: boolean;
  110958. }
  110959. /**
  110960. * Define the code related to the detail map parameters of a material
  110961. *
  110962. * Inspired from:
  110963. * 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
  110964. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110965. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110966. */
  110967. export class DetailMapConfiguration {
  110968. private _texture;
  110969. /**
  110970. * The detail texture of the material.
  110971. */
  110972. texture: Nullable<BaseTexture>;
  110973. /**
  110974. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110975. * Bigger values mean stronger blending
  110976. */
  110977. diffuseBlendLevel: number;
  110978. /**
  110979. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110980. * Bigger values mean stronger blending. Only used with PBR materials
  110981. */
  110982. roughnessBlendLevel: number;
  110983. /**
  110984. * Defines how strong the bump effect from the detail map is
  110985. * Bigger values mean stronger effect
  110986. */
  110987. bumpLevel: number;
  110988. private _normalBlendMethod;
  110989. /**
  110990. * The method used to blend the bump and detail normals together
  110991. */
  110992. normalBlendMethod: number;
  110993. private _isEnabled;
  110994. /**
  110995. * Enable or disable the detail map on this material
  110996. */
  110997. isEnabled: boolean;
  110998. /** @hidden */
  110999. private _internalMarkAllSubMeshesAsTexturesDirty;
  111000. /** @hidden */
  111001. _markAllSubMeshesAsTexturesDirty(): void;
  111002. /**
  111003. * Instantiate a new detail map
  111004. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111005. */
  111006. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111007. /**
  111008. * Gets whether the submesh is ready to be used or not.
  111009. * @param defines the list of "defines" to update.
  111010. * @param scene defines the scene the material belongs to.
  111011. * @returns - boolean indicating that the submesh is ready or not.
  111012. */
  111013. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  111014. /**
  111015. * Update the defines for detail map usage
  111016. * @param defines the list of "defines" to update.
  111017. * @param scene defines the scene the material belongs to.
  111018. */
  111019. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  111020. /**
  111021. * Binds the material data.
  111022. * @param uniformBuffer defines the Uniform buffer to fill in.
  111023. * @param scene defines the scene the material belongs to.
  111024. * @param isFrozen defines whether the material is frozen or not.
  111025. */
  111026. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  111027. /**
  111028. * Checks to see if a texture is used in the material.
  111029. * @param texture - Base texture to use.
  111030. * @returns - Boolean specifying if a texture is used in the material.
  111031. */
  111032. hasTexture(texture: BaseTexture): boolean;
  111033. /**
  111034. * Returns an array of the actively used textures.
  111035. * @param activeTextures Array of BaseTextures
  111036. */
  111037. getActiveTextures(activeTextures: BaseTexture[]): void;
  111038. /**
  111039. * Returns the animatable textures.
  111040. * @param animatables Array of animatable textures.
  111041. */
  111042. getAnimatables(animatables: IAnimatable[]): void;
  111043. /**
  111044. * Disposes the resources of the material.
  111045. * @param forceDisposeTextures - Forces the disposal of all textures.
  111046. */
  111047. dispose(forceDisposeTextures?: boolean): void;
  111048. /**
  111049. * Get the current class name useful for serialization or dynamic coding.
  111050. * @returns "DetailMap"
  111051. */
  111052. getClassName(): string;
  111053. /**
  111054. * Add the required uniforms to the current list.
  111055. * @param uniforms defines the current uniform list.
  111056. */
  111057. static AddUniforms(uniforms: string[]): void;
  111058. /**
  111059. * Add the required samplers to the current list.
  111060. * @param samplers defines the current sampler list.
  111061. */
  111062. static AddSamplers(samplers: string[]): void;
  111063. /**
  111064. * Add the required uniforms to the current buffer.
  111065. * @param uniformBuffer defines the current uniform buffer.
  111066. */
  111067. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111068. /**
  111069. * Makes a duplicate of the current instance into another one.
  111070. * @param detailMap define the instance where to copy the info
  111071. */
  111072. copyTo(detailMap: DetailMapConfiguration): void;
  111073. /**
  111074. * Serializes this detail map instance
  111075. * @returns - An object with the serialized instance.
  111076. */
  111077. serialize(): any;
  111078. /**
  111079. * Parses a detail map setting from a serialized object.
  111080. * @param source - Serialized object.
  111081. * @param scene Defines the scene we are parsing for
  111082. * @param rootUrl Defines the rootUrl to load from
  111083. */
  111084. parse(source: any, scene: Scene, rootUrl: string): void;
  111085. }
  111086. }
  111087. declare module BABYLON {
  111088. /** @hidden */
  111089. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  111090. MAINUV1: boolean;
  111091. MAINUV2: boolean;
  111092. DIFFUSE: boolean;
  111093. DIFFUSEDIRECTUV: number;
  111094. DETAIL: boolean;
  111095. DETAILDIRECTUV: number;
  111096. DETAIL_NORMALBLENDMETHOD: number;
  111097. AMBIENT: boolean;
  111098. AMBIENTDIRECTUV: number;
  111099. OPACITY: boolean;
  111100. OPACITYDIRECTUV: number;
  111101. OPACITYRGB: boolean;
  111102. REFLECTION: boolean;
  111103. EMISSIVE: boolean;
  111104. EMISSIVEDIRECTUV: number;
  111105. SPECULAR: boolean;
  111106. SPECULARDIRECTUV: number;
  111107. BUMP: boolean;
  111108. BUMPDIRECTUV: number;
  111109. PARALLAX: boolean;
  111110. PARALLAXOCCLUSION: boolean;
  111111. SPECULAROVERALPHA: boolean;
  111112. CLIPPLANE: boolean;
  111113. CLIPPLANE2: boolean;
  111114. CLIPPLANE3: boolean;
  111115. CLIPPLANE4: boolean;
  111116. CLIPPLANE5: boolean;
  111117. CLIPPLANE6: boolean;
  111118. ALPHATEST: boolean;
  111119. DEPTHPREPASS: boolean;
  111120. ALPHAFROMDIFFUSE: boolean;
  111121. POINTSIZE: boolean;
  111122. FOG: boolean;
  111123. SPECULARTERM: boolean;
  111124. DIFFUSEFRESNEL: boolean;
  111125. OPACITYFRESNEL: boolean;
  111126. REFLECTIONFRESNEL: boolean;
  111127. REFRACTIONFRESNEL: boolean;
  111128. EMISSIVEFRESNEL: boolean;
  111129. FRESNEL: boolean;
  111130. NORMAL: boolean;
  111131. UV1: boolean;
  111132. UV2: boolean;
  111133. VERTEXCOLOR: boolean;
  111134. VERTEXALPHA: boolean;
  111135. NUM_BONE_INFLUENCERS: number;
  111136. BonesPerMesh: number;
  111137. BONETEXTURE: boolean;
  111138. BONES_VELOCITY_ENABLED: boolean;
  111139. INSTANCES: boolean;
  111140. THIN_INSTANCES: boolean;
  111141. GLOSSINESS: boolean;
  111142. ROUGHNESS: boolean;
  111143. EMISSIVEASILLUMINATION: boolean;
  111144. LINKEMISSIVEWITHDIFFUSE: boolean;
  111145. REFLECTIONFRESNELFROMSPECULAR: boolean;
  111146. LIGHTMAP: boolean;
  111147. LIGHTMAPDIRECTUV: number;
  111148. OBJECTSPACE_NORMALMAP: boolean;
  111149. USELIGHTMAPASSHADOWMAP: boolean;
  111150. REFLECTIONMAP_3D: boolean;
  111151. REFLECTIONMAP_SPHERICAL: boolean;
  111152. REFLECTIONMAP_PLANAR: boolean;
  111153. REFLECTIONMAP_CUBIC: boolean;
  111154. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  111155. REFLECTIONMAP_PROJECTION: boolean;
  111156. REFLECTIONMAP_SKYBOX: boolean;
  111157. REFLECTIONMAP_EXPLICIT: boolean;
  111158. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  111159. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  111160. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  111161. INVERTCUBICMAP: boolean;
  111162. LOGARITHMICDEPTH: boolean;
  111163. REFRACTION: boolean;
  111164. REFRACTIONMAP_3D: boolean;
  111165. REFLECTIONOVERALPHA: boolean;
  111166. TWOSIDEDLIGHTING: boolean;
  111167. SHADOWFLOAT: boolean;
  111168. MORPHTARGETS: boolean;
  111169. MORPHTARGETS_NORMAL: boolean;
  111170. MORPHTARGETS_TANGENT: boolean;
  111171. MORPHTARGETS_UV: boolean;
  111172. NUM_MORPH_INFLUENCERS: number;
  111173. NONUNIFORMSCALING: boolean;
  111174. PREMULTIPLYALPHA: boolean;
  111175. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  111176. ALPHABLEND: boolean;
  111177. PREPASS: boolean;
  111178. PREPASS_IRRADIANCE: boolean;
  111179. PREPASS_IRRADIANCE_INDEX: number;
  111180. PREPASS_ALBEDO: boolean;
  111181. PREPASS_ALBEDO_INDEX: number;
  111182. PREPASS_DEPTHNORMAL: boolean;
  111183. PREPASS_DEPTHNORMAL_INDEX: number;
  111184. PREPASS_POSITION: boolean;
  111185. PREPASS_POSITION_INDEX: number;
  111186. PREPASS_VELOCITY: boolean;
  111187. PREPASS_VELOCITY_INDEX: number;
  111188. PREPASS_REFLECTIVITY: boolean;
  111189. PREPASS_REFLECTIVITY_INDEX: number;
  111190. SCENE_MRT_COUNT: number;
  111191. RGBDLIGHTMAP: boolean;
  111192. RGBDREFLECTION: boolean;
  111193. RGBDREFRACTION: boolean;
  111194. IMAGEPROCESSING: boolean;
  111195. VIGNETTE: boolean;
  111196. VIGNETTEBLENDMODEMULTIPLY: boolean;
  111197. VIGNETTEBLENDMODEOPAQUE: boolean;
  111198. TONEMAPPING: boolean;
  111199. TONEMAPPING_ACES: boolean;
  111200. CONTRAST: boolean;
  111201. COLORCURVES: boolean;
  111202. COLORGRADING: boolean;
  111203. COLORGRADING3D: boolean;
  111204. SAMPLER3DGREENDEPTH: boolean;
  111205. SAMPLER3DBGRMAP: boolean;
  111206. IMAGEPROCESSINGPOSTPROCESS: boolean;
  111207. MULTIVIEW: boolean;
  111208. /**
  111209. * If the reflection texture on this material is in linear color space
  111210. * @hidden
  111211. */
  111212. IS_REFLECTION_LINEAR: boolean;
  111213. /**
  111214. * If the refraction texture on this material is in linear color space
  111215. * @hidden
  111216. */
  111217. IS_REFRACTION_LINEAR: boolean;
  111218. EXPOSURE: boolean;
  111219. constructor();
  111220. setReflectionMode(modeToEnable: string): void;
  111221. }
  111222. /**
  111223. * This is the default material used in Babylon. It is the best trade off between quality
  111224. * and performances.
  111225. * @see https://doc.babylonjs.com/babylon101/materials
  111226. */
  111227. export class StandardMaterial extends PushMaterial {
  111228. private _diffuseTexture;
  111229. /**
  111230. * The basic texture of the material as viewed under a light.
  111231. */
  111232. diffuseTexture: Nullable<BaseTexture>;
  111233. private _ambientTexture;
  111234. /**
  111235. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  111236. */
  111237. ambientTexture: Nullable<BaseTexture>;
  111238. private _opacityTexture;
  111239. /**
  111240. * Define the transparency of the material from a texture.
  111241. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  111242. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  111243. */
  111244. opacityTexture: Nullable<BaseTexture>;
  111245. private _reflectionTexture;
  111246. /**
  111247. * Define the texture used to display the reflection.
  111248. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111249. */
  111250. reflectionTexture: Nullable<BaseTexture>;
  111251. private _emissiveTexture;
  111252. /**
  111253. * Define texture of the material as if self lit.
  111254. * This will be mixed in the final result even in the absence of light.
  111255. */
  111256. emissiveTexture: Nullable<BaseTexture>;
  111257. private _specularTexture;
  111258. /**
  111259. * Define how the color and intensity of the highlight given by the light in the material.
  111260. */
  111261. specularTexture: Nullable<BaseTexture>;
  111262. private _bumpTexture;
  111263. /**
  111264. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  111265. * 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.
  111266. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  111267. */
  111268. bumpTexture: Nullable<BaseTexture>;
  111269. private _lightmapTexture;
  111270. /**
  111271. * Complex lighting can be computationally expensive to compute at runtime.
  111272. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  111273. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  111274. */
  111275. lightmapTexture: Nullable<BaseTexture>;
  111276. private _refractionTexture;
  111277. /**
  111278. * Define the texture used to display the refraction.
  111279. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111280. */
  111281. refractionTexture: Nullable<BaseTexture>;
  111282. /**
  111283. * The color of the material lit by the environmental background lighting.
  111284. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  111285. */
  111286. ambientColor: Color3;
  111287. /**
  111288. * The basic color of the material as viewed under a light.
  111289. */
  111290. diffuseColor: Color3;
  111291. /**
  111292. * Define how the color and intensity of the highlight given by the light in the material.
  111293. */
  111294. specularColor: Color3;
  111295. /**
  111296. * Define the color of the material as if self lit.
  111297. * This will be mixed in the final result even in the absence of light.
  111298. */
  111299. emissiveColor: Color3;
  111300. /**
  111301. * Defines how sharp are the highlights in the material.
  111302. * The bigger the value the sharper giving a more glossy feeling to the result.
  111303. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  111304. */
  111305. specularPower: number;
  111306. private _useAlphaFromDiffuseTexture;
  111307. /**
  111308. * Does the transparency come from the diffuse texture alpha channel.
  111309. */
  111310. useAlphaFromDiffuseTexture: boolean;
  111311. private _useEmissiveAsIllumination;
  111312. /**
  111313. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  111314. */
  111315. useEmissiveAsIllumination: boolean;
  111316. private _linkEmissiveWithDiffuse;
  111317. /**
  111318. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  111319. * the emissive level when the final color is close to one.
  111320. */
  111321. linkEmissiveWithDiffuse: boolean;
  111322. private _useSpecularOverAlpha;
  111323. /**
  111324. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  111325. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111326. */
  111327. useSpecularOverAlpha: boolean;
  111328. private _useReflectionOverAlpha;
  111329. /**
  111330. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111331. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111332. */
  111333. useReflectionOverAlpha: boolean;
  111334. private _disableLighting;
  111335. /**
  111336. * Does lights from the scene impacts this material.
  111337. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  111338. */
  111339. disableLighting: boolean;
  111340. private _useObjectSpaceNormalMap;
  111341. /**
  111342. * Allows using an object space normal map (instead of tangent space).
  111343. */
  111344. useObjectSpaceNormalMap: boolean;
  111345. private _useParallax;
  111346. /**
  111347. * Is parallax enabled or not.
  111348. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111349. */
  111350. useParallax: boolean;
  111351. private _useParallaxOcclusion;
  111352. /**
  111353. * Is parallax occlusion enabled or not.
  111354. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  111355. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111356. */
  111357. useParallaxOcclusion: boolean;
  111358. /**
  111359. * 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.
  111360. */
  111361. parallaxScaleBias: number;
  111362. private _roughness;
  111363. /**
  111364. * Helps to define how blurry the reflections should appears in the material.
  111365. */
  111366. roughness: number;
  111367. /**
  111368. * In case of refraction, define the value of the index of refraction.
  111369. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111370. */
  111371. indexOfRefraction: number;
  111372. /**
  111373. * Invert the refraction texture alongside the y axis.
  111374. * It can be useful with procedural textures or probe for instance.
  111375. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111376. */
  111377. invertRefractionY: boolean;
  111378. /**
  111379. * Defines the alpha limits in alpha test mode.
  111380. */
  111381. alphaCutOff: number;
  111382. private _useLightmapAsShadowmap;
  111383. /**
  111384. * In case of light mapping, define whether the map contains light or shadow informations.
  111385. */
  111386. useLightmapAsShadowmap: boolean;
  111387. private _diffuseFresnelParameters;
  111388. /**
  111389. * Define the diffuse fresnel parameters of the material.
  111390. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111391. */
  111392. diffuseFresnelParameters: FresnelParameters;
  111393. private _opacityFresnelParameters;
  111394. /**
  111395. * Define the opacity fresnel parameters of the material.
  111396. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111397. */
  111398. opacityFresnelParameters: FresnelParameters;
  111399. private _reflectionFresnelParameters;
  111400. /**
  111401. * Define the reflection fresnel parameters of the material.
  111402. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111403. */
  111404. reflectionFresnelParameters: FresnelParameters;
  111405. private _refractionFresnelParameters;
  111406. /**
  111407. * Define the refraction fresnel parameters of the material.
  111408. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111409. */
  111410. refractionFresnelParameters: FresnelParameters;
  111411. private _emissiveFresnelParameters;
  111412. /**
  111413. * Define the emissive fresnel parameters of the material.
  111414. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111415. */
  111416. emissiveFresnelParameters: FresnelParameters;
  111417. private _useReflectionFresnelFromSpecular;
  111418. /**
  111419. * If true automatically deducts the fresnels values from the material specularity.
  111420. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111421. */
  111422. useReflectionFresnelFromSpecular: boolean;
  111423. private _useGlossinessFromSpecularMapAlpha;
  111424. /**
  111425. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  111426. */
  111427. useGlossinessFromSpecularMapAlpha: boolean;
  111428. private _maxSimultaneousLights;
  111429. /**
  111430. * Defines the maximum number of lights that can be used in the material
  111431. */
  111432. maxSimultaneousLights: number;
  111433. private _invertNormalMapX;
  111434. /**
  111435. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111436. */
  111437. invertNormalMapX: boolean;
  111438. private _invertNormalMapY;
  111439. /**
  111440. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111441. */
  111442. invertNormalMapY: boolean;
  111443. private _twoSidedLighting;
  111444. /**
  111445. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111446. */
  111447. twoSidedLighting: boolean;
  111448. /**
  111449. * Default configuration related to image processing available in the standard Material.
  111450. */
  111451. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111452. /**
  111453. * Gets the image processing configuration used either in this material.
  111454. */
  111455. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111456. /**
  111457. * Sets the Default image processing configuration used either in the this material.
  111458. *
  111459. * If sets to null, the scene one is in use.
  111460. */
  111461. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  111462. /**
  111463. * Keep track of the image processing observer to allow dispose and replace.
  111464. */
  111465. private _imageProcessingObserver;
  111466. /**
  111467. * Attaches a new image processing configuration to the Standard Material.
  111468. * @param configuration
  111469. */
  111470. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111471. /**
  111472. * Defines additionnal PrePass parameters for the material.
  111473. */
  111474. readonly prePassConfiguration: PrePassConfiguration;
  111475. /**
  111476. * Gets wether the color curves effect is enabled.
  111477. */
  111478. get cameraColorCurvesEnabled(): boolean;
  111479. /**
  111480. * Sets wether the color curves effect is enabled.
  111481. */
  111482. set cameraColorCurvesEnabled(value: boolean);
  111483. /**
  111484. * Gets wether the color grading effect is enabled.
  111485. */
  111486. get cameraColorGradingEnabled(): boolean;
  111487. /**
  111488. * Gets wether the color grading effect is enabled.
  111489. */
  111490. set cameraColorGradingEnabled(value: boolean);
  111491. /**
  111492. * Gets wether tonemapping is enabled or not.
  111493. */
  111494. get cameraToneMappingEnabled(): boolean;
  111495. /**
  111496. * Sets wether tonemapping is enabled or not
  111497. */
  111498. set cameraToneMappingEnabled(value: boolean);
  111499. /**
  111500. * The camera exposure used on this material.
  111501. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111502. * This corresponds to a photographic exposure.
  111503. */
  111504. get cameraExposure(): number;
  111505. /**
  111506. * The camera exposure used on this material.
  111507. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111508. * This corresponds to a photographic exposure.
  111509. */
  111510. set cameraExposure(value: number);
  111511. /**
  111512. * Gets The camera contrast used on this material.
  111513. */
  111514. get cameraContrast(): number;
  111515. /**
  111516. * Sets The camera contrast used on this material.
  111517. */
  111518. set cameraContrast(value: number);
  111519. /**
  111520. * Gets the Color Grading 2D Lookup Texture.
  111521. */
  111522. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  111523. /**
  111524. * Sets the Color Grading 2D Lookup Texture.
  111525. */
  111526. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  111527. /**
  111528. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111529. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111530. * 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;
  111531. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111532. */
  111533. get cameraColorCurves(): Nullable<ColorCurves>;
  111534. /**
  111535. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111536. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111537. * 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;
  111538. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111539. */
  111540. set cameraColorCurves(value: Nullable<ColorCurves>);
  111541. /**
  111542. * Can this material render to several textures at once
  111543. */
  111544. get canRenderToMRT(): boolean;
  111545. /**
  111546. * Defines the detail map parameters for the material.
  111547. */
  111548. readonly detailMap: DetailMapConfiguration;
  111549. protected _renderTargets: SmartArray<RenderTargetTexture>;
  111550. protected _worldViewProjectionMatrix: Matrix;
  111551. protected _globalAmbientColor: Color3;
  111552. protected _useLogarithmicDepth: boolean;
  111553. protected _rebuildInParallel: boolean;
  111554. /**
  111555. * Instantiates a new standard material.
  111556. * This is the default material used in Babylon. It is the best trade off between quality
  111557. * and performances.
  111558. * @see https://doc.babylonjs.com/babylon101/materials
  111559. * @param name Define the name of the material in the scene
  111560. * @param scene Define the scene the material belong to
  111561. */
  111562. constructor(name: string, scene: Scene);
  111563. /**
  111564. * Gets a boolean indicating that current material needs to register RTT
  111565. */
  111566. get hasRenderTargetTextures(): boolean;
  111567. /**
  111568. * Gets the current class name of the material e.g. "StandardMaterial"
  111569. * Mainly use in serialization.
  111570. * @returns the class name
  111571. */
  111572. getClassName(): string;
  111573. /**
  111574. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  111575. * You can try switching to logarithmic depth.
  111576. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  111577. */
  111578. get useLogarithmicDepth(): boolean;
  111579. set useLogarithmicDepth(value: boolean);
  111580. /**
  111581. * Specifies if the material will require alpha blending
  111582. * @returns a boolean specifying if alpha blending is needed
  111583. */
  111584. needAlphaBlending(): boolean;
  111585. /**
  111586. * Specifies if this material should be rendered in alpha test mode
  111587. * @returns a boolean specifying if an alpha test is needed.
  111588. */
  111589. needAlphaTesting(): boolean;
  111590. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  111591. /**
  111592. * Get the texture used for alpha test purpose.
  111593. * @returns the diffuse texture in case of the standard material.
  111594. */
  111595. getAlphaTestTexture(): Nullable<BaseTexture>;
  111596. /**
  111597. * Get if the submesh is ready to be used and all its information available.
  111598. * Child classes can use it to update shaders
  111599. * @param mesh defines the mesh to check
  111600. * @param subMesh defines which submesh to check
  111601. * @param useInstances specifies that instances should be used
  111602. * @returns a boolean indicating that the submesh is ready or not
  111603. */
  111604. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111605. /**
  111606. * Builds the material UBO layouts.
  111607. * Used internally during the effect preparation.
  111608. */
  111609. buildUniformLayout(): void;
  111610. /**
  111611. * Unbinds the material from the mesh
  111612. */
  111613. unbind(): void;
  111614. /**
  111615. * Binds the submesh to this material by preparing the effect and shader to draw
  111616. * @param world defines the world transformation matrix
  111617. * @param mesh defines the mesh containing the submesh
  111618. * @param subMesh defines the submesh to bind the material to
  111619. */
  111620. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111621. /**
  111622. * Get the list of animatables in the material.
  111623. * @returns the list of animatables object used in the material
  111624. */
  111625. getAnimatables(): IAnimatable[];
  111626. /**
  111627. * Gets the active textures from the material
  111628. * @returns an array of textures
  111629. */
  111630. getActiveTextures(): BaseTexture[];
  111631. /**
  111632. * Specifies if the material uses a texture
  111633. * @param texture defines the texture to check against the material
  111634. * @returns a boolean specifying if the material uses the texture
  111635. */
  111636. hasTexture(texture: BaseTexture): boolean;
  111637. /**
  111638. * Disposes the material
  111639. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111640. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111641. */
  111642. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111643. /**
  111644. * Makes a duplicate of the material, and gives it a new name
  111645. * @param name defines the new name for the duplicated material
  111646. * @returns the cloned material
  111647. */
  111648. clone(name: string): StandardMaterial;
  111649. /**
  111650. * Serializes this material in a JSON representation
  111651. * @returns the serialized material object
  111652. */
  111653. serialize(): any;
  111654. /**
  111655. * Creates a standard material from parsed material data
  111656. * @param source defines the JSON representation of the material
  111657. * @param scene defines the hosting scene
  111658. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  111659. * @returns a new standard material
  111660. */
  111661. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  111662. /**
  111663. * Are diffuse textures enabled in the application.
  111664. */
  111665. static get DiffuseTextureEnabled(): boolean;
  111666. static set DiffuseTextureEnabled(value: boolean);
  111667. /**
  111668. * Are detail textures enabled in the application.
  111669. */
  111670. static get DetailTextureEnabled(): boolean;
  111671. static set DetailTextureEnabled(value: boolean);
  111672. /**
  111673. * Are ambient textures enabled in the application.
  111674. */
  111675. static get AmbientTextureEnabled(): boolean;
  111676. static set AmbientTextureEnabled(value: boolean);
  111677. /**
  111678. * Are opacity textures enabled in the application.
  111679. */
  111680. static get OpacityTextureEnabled(): boolean;
  111681. static set OpacityTextureEnabled(value: boolean);
  111682. /**
  111683. * Are reflection textures enabled in the application.
  111684. */
  111685. static get ReflectionTextureEnabled(): boolean;
  111686. static set ReflectionTextureEnabled(value: boolean);
  111687. /**
  111688. * Are emissive textures enabled in the application.
  111689. */
  111690. static get EmissiveTextureEnabled(): boolean;
  111691. static set EmissiveTextureEnabled(value: boolean);
  111692. /**
  111693. * Are specular textures enabled in the application.
  111694. */
  111695. static get SpecularTextureEnabled(): boolean;
  111696. static set SpecularTextureEnabled(value: boolean);
  111697. /**
  111698. * Are bump textures enabled in the application.
  111699. */
  111700. static get BumpTextureEnabled(): boolean;
  111701. static set BumpTextureEnabled(value: boolean);
  111702. /**
  111703. * Are lightmap textures enabled in the application.
  111704. */
  111705. static get LightmapTextureEnabled(): boolean;
  111706. static set LightmapTextureEnabled(value: boolean);
  111707. /**
  111708. * Are refraction textures enabled in the application.
  111709. */
  111710. static get RefractionTextureEnabled(): boolean;
  111711. static set RefractionTextureEnabled(value: boolean);
  111712. /**
  111713. * Are color grading textures enabled in the application.
  111714. */
  111715. static get ColorGradingTextureEnabled(): boolean;
  111716. static set ColorGradingTextureEnabled(value: boolean);
  111717. /**
  111718. * Are fresnels enabled in the application.
  111719. */
  111720. static get FresnelEnabled(): boolean;
  111721. static set FresnelEnabled(value: boolean);
  111722. }
  111723. }
  111724. declare module BABYLON {
  111725. /**
  111726. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  111727. *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.
  111728. * The SPS is also a particle system. It provides some methods to manage the particles.
  111729. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  111730. *
  111731. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  111732. */
  111733. export class SolidParticleSystem implements IDisposable {
  111734. /**
  111735. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  111736. * Example : var p = SPS.particles[i];
  111737. */
  111738. particles: SolidParticle[];
  111739. /**
  111740. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  111741. */
  111742. nbParticles: number;
  111743. /**
  111744. * If the particles must ever face the camera (default false). Useful for planar particles.
  111745. */
  111746. billboard: boolean;
  111747. /**
  111748. * Recompute normals when adding a shape
  111749. */
  111750. recomputeNormals: boolean;
  111751. /**
  111752. * This a counter ofr your own usage. It's not set by any SPS functions.
  111753. */
  111754. counter: number;
  111755. /**
  111756. * The SPS name. This name is also given to the underlying mesh.
  111757. */
  111758. name: string;
  111759. /**
  111760. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  111761. */
  111762. mesh: Mesh;
  111763. /**
  111764. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  111765. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  111766. */
  111767. vars: any;
  111768. /**
  111769. * This array is populated when the SPS is set as 'pickable'.
  111770. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  111771. * Each element of this array is an object `{idx: int, faceId: int}`.
  111772. * `idx` is the picked particle index in the `SPS.particles` array
  111773. * `faceId` is the picked face index counted within this particle.
  111774. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  111775. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  111776. * Use the method SPS.pickedParticle(pickingInfo) instead.
  111777. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111778. */
  111779. pickedParticles: {
  111780. idx: number;
  111781. faceId: number;
  111782. }[];
  111783. /**
  111784. * This array is populated when the SPS is set as 'pickable'
  111785. * Each key of this array is a submesh index.
  111786. * Each element of this array is a second array defined like this :
  111787. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  111788. * Each element of this second array is an object `{idx: int, faceId: int}`.
  111789. * `idx` is the picked particle index in the `SPS.particles` array
  111790. * `faceId` is the picked face index counted within this particle.
  111791. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  111792. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111793. */
  111794. pickedBySubMesh: {
  111795. idx: number;
  111796. faceId: number;
  111797. }[][];
  111798. /**
  111799. * This array is populated when `enableDepthSort` is set to true.
  111800. * Each element of this array is an instance of the class DepthSortedParticle.
  111801. */
  111802. depthSortedParticles: DepthSortedParticle[];
  111803. /**
  111804. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111805. * @hidden
  111806. */
  111807. _bSphereOnly: boolean;
  111808. /**
  111809. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111810. * @hidden
  111811. */
  111812. _bSphereRadiusFactor: number;
  111813. private _scene;
  111814. private _positions;
  111815. private _indices;
  111816. private _normals;
  111817. private _colors;
  111818. private _uvs;
  111819. private _indices32;
  111820. private _positions32;
  111821. private _normals32;
  111822. private _fixedNormal32;
  111823. private _colors32;
  111824. private _uvs32;
  111825. private _index;
  111826. private _updatable;
  111827. private _pickable;
  111828. private _isVisibilityBoxLocked;
  111829. private _alwaysVisible;
  111830. private _depthSort;
  111831. private _expandable;
  111832. private _shapeCounter;
  111833. private _copy;
  111834. private _color;
  111835. private _computeParticleColor;
  111836. private _computeParticleTexture;
  111837. private _computeParticleRotation;
  111838. private _computeParticleVertex;
  111839. private _computeBoundingBox;
  111840. private _depthSortParticles;
  111841. private _camera;
  111842. private _mustUnrotateFixedNormals;
  111843. private _particlesIntersect;
  111844. private _needs32Bits;
  111845. private _isNotBuilt;
  111846. private _lastParticleId;
  111847. private _idxOfId;
  111848. private _multimaterialEnabled;
  111849. private _useModelMaterial;
  111850. private _indicesByMaterial;
  111851. private _materialIndexes;
  111852. private _depthSortFunction;
  111853. private _materialSortFunction;
  111854. private _materials;
  111855. private _multimaterial;
  111856. private _materialIndexesById;
  111857. private _defaultMaterial;
  111858. private _autoUpdateSubMeshes;
  111859. private _tmpVertex;
  111860. /**
  111861. * Creates a SPS (Solid Particle System) object.
  111862. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111863. * @param scene (Scene) is the scene in which the SPS is added.
  111864. * @param options defines the options of the sps e.g.
  111865. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111866. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111867. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111868. * * 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.
  111869. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  111870. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  111871. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111872. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111873. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111874. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111875. */
  111876. constructor(name: string, scene: Scene, options?: {
  111877. updatable?: boolean;
  111878. isPickable?: boolean;
  111879. enableDepthSort?: boolean;
  111880. particleIntersection?: boolean;
  111881. boundingSphereOnly?: boolean;
  111882. bSphereRadiusFactor?: number;
  111883. expandable?: boolean;
  111884. useModelMaterial?: boolean;
  111885. enableMultiMaterial?: boolean;
  111886. });
  111887. /**
  111888. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111889. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111890. * @returns the created mesh
  111891. */
  111892. buildMesh(): Mesh;
  111893. /**
  111894. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111895. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111896. * Thus the particles generated from `digest()` have their property `position` set yet.
  111897. * @param mesh ( Mesh ) is the mesh to be digested
  111898. * @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
  111899. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111900. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111901. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111902. * @returns the current SPS
  111903. */
  111904. digest(mesh: Mesh, options?: {
  111905. facetNb?: number;
  111906. number?: number;
  111907. delta?: number;
  111908. storage?: [];
  111909. }): SolidParticleSystem;
  111910. /**
  111911. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111912. * @hidden
  111913. */
  111914. private _unrotateFixedNormals;
  111915. /**
  111916. * Resets the temporary working copy particle
  111917. * @hidden
  111918. */
  111919. private _resetCopy;
  111920. /**
  111921. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  111922. * @param p the current index in the positions array to be updated
  111923. * @param ind the current index in the indices array
  111924. * @param shape a Vector3 array, the shape geometry
  111925. * @param positions the positions array to be updated
  111926. * @param meshInd the shape indices array
  111927. * @param indices the indices array to be updated
  111928. * @param meshUV the shape uv array
  111929. * @param uvs the uv array to be updated
  111930. * @param meshCol the shape color array
  111931. * @param colors the color array to be updated
  111932. * @param meshNor the shape normals array
  111933. * @param normals the normals array to be updated
  111934. * @param idx the particle index
  111935. * @param idxInShape the particle index in its shape
  111936. * @param options the addShape() method passed options
  111937. * @model the particle model
  111938. * @hidden
  111939. */
  111940. private _meshBuilder;
  111941. /**
  111942. * Returns a shape Vector3 array from positions float array
  111943. * @param positions float array
  111944. * @returns a vector3 array
  111945. * @hidden
  111946. */
  111947. private _posToShape;
  111948. /**
  111949. * Returns a shapeUV array from a float uvs (array deep copy)
  111950. * @param uvs as a float array
  111951. * @returns a shapeUV array
  111952. * @hidden
  111953. */
  111954. private _uvsToShapeUV;
  111955. /**
  111956. * Adds a new particle object in the particles array
  111957. * @param idx particle index in particles array
  111958. * @param id particle id
  111959. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111960. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111961. * @param model particle ModelShape object
  111962. * @param shapeId model shape identifier
  111963. * @param idxInShape index of the particle in the current model
  111964. * @param bInfo model bounding info object
  111965. * @param storage target storage array, if any
  111966. * @hidden
  111967. */
  111968. private _addParticle;
  111969. /**
  111970. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111971. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111972. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111973. * @param nb (positive integer) the number of particles to be created from this model
  111974. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111975. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111976. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111977. * @returns the number of shapes in the system
  111978. */
  111979. addShape(mesh: Mesh, nb: number, options?: {
  111980. positionFunction?: any;
  111981. vertexFunction?: any;
  111982. storage?: [];
  111983. }): number;
  111984. /**
  111985. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111986. * @hidden
  111987. */
  111988. private _rebuildParticle;
  111989. /**
  111990. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111991. * @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.
  111992. * @returns the SPS.
  111993. */
  111994. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111995. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111996. * Returns an array with the removed particles.
  111997. * 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.
  111998. * The SPS can't be empty so at least one particle needs to remain in place.
  111999. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  112000. * @param start index of the first particle to remove
  112001. * @param end index of the last particle to remove (included)
  112002. * @returns an array populated with the removed particles
  112003. */
  112004. removeParticles(start: number, end: number): SolidParticle[];
  112005. /**
  112006. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  112007. * @param solidParticleArray an array populated with Solid Particles objects
  112008. * @returns the SPS
  112009. */
  112010. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  112011. /**
  112012. * Creates a new particle and modifies the SPS mesh geometry :
  112013. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  112014. * - calls _addParticle() to populate the particle array
  112015. * factorized code from addShape() and insertParticlesFromArray()
  112016. * @param idx particle index in the particles array
  112017. * @param i particle index in its shape
  112018. * @param modelShape particle ModelShape object
  112019. * @param shape shape vertex array
  112020. * @param meshInd shape indices array
  112021. * @param meshUV shape uv array
  112022. * @param meshCol shape color array
  112023. * @param meshNor shape normals array
  112024. * @param bbInfo shape bounding info
  112025. * @param storage target particle storage
  112026. * @options addShape() passed options
  112027. * @hidden
  112028. */
  112029. private _insertNewParticle;
  112030. /**
  112031. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  112032. * This method calls `updateParticle()` for each particle of the SPS.
  112033. * For an animated SPS, it is usually called within the render loop.
  112034. * 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.
  112035. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  112036. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  112037. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  112038. * @returns the SPS.
  112039. */
  112040. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  112041. /**
  112042. * Disposes the SPS.
  112043. */
  112044. dispose(): void;
  112045. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  112046. * idx is the particle index in the SPS
  112047. * faceId is the picked face index counted within this particle.
  112048. * Returns null if the pickInfo can't identify a picked particle.
  112049. * @param pickingInfo (PickingInfo object)
  112050. * @returns {idx: number, faceId: number} or null
  112051. */
  112052. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  112053. idx: number;
  112054. faceId: number;
  112055. }>;
  112056. /**
  112057. * Returns a SolidParticle object from its identifier : particle.id
  112058. * @param id (integer) the particle Id
  112059. * @returns the searched particle or null if not found in the SPS.
  112060. */
  112061. getParticleById(id: number): Nullable<SolidParticle>;
  112062. /**
  112063. * Returns a new array populated with the particles having the passed shapeId.
  112064. * @param shapeId (integer) the shape identifier
  112065. * @returns a new solid particle array
  112066. */
  112067. getParticlesByShapeId(shapeId: number): SolidParticle[];
  112068. /**
  112069. * Populates the passed array "ref" with the particles having the passed shapeId.
  112070. * @param shapeId the shape identifier
  112071. * @returns the SPS
  112072. * @param ref
  112073. */
  112074. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  112075. /**
  112076. * Computes the required SubMeshes according the materials assigned to the particles.
  112077. * @returns the solid particle system.
  112078. * Does nothing if called before the SPS mesh is built.
  112079. */
  112080. computeSubMeshes(): SolidParticleSystem;
  112081. /**
  112082. * Sorts the solid particles by material when MultiMaterial is enabled.
  112083. * Updates the indices32 array.
  112084. * Updates the indicesByMaterial array.
  112085. * Updates the mesh indices array.
  112086. * @returns the SPS
  112087. * @hidden
  112088. */
  112089. private _sortParticlesByMaterial;
  112090. /**
  112091. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  112092. * @hidden
  112093. */
  112094. private _setMaterialIndexesById;
  112095. /**
  112096. * Returns an array with unique values of Materials from the passed array
  112097. * @param array the material array to be checked and filtered
  112098. * @hidden
  112099. */
  112100. private _filterUniqueMaterialId;
  112101. /**
  112102. * Sets a new Standard Material as _defaultMaterial if not already set.
  112103. * @hidden
  112104. */
  112105. private _setDefaultMaterial;
  112106. /**
  112107. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  112108. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112109. * @returns the SPS.
  112110. */
  112111. refreshVisibleSize(): SolidParticleSystem;
  112112. /**
  112113. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  112114. * @param size the size (float) of the visibility box
  112115. * note : this doesn't lock the SPS mesh bounding box.
  112116. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112117. */
  112118. setVisibilityBox(size: number): void;
  112119. /**
  112120. * Gets whether the SPS as always visible or not
  112121. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112122. */
  112123. get isAlwaysVisible(): boolean;
  112124. /**
  112125. * Sets the SPS as always visible or not
  112126. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112127. */
  112128. set isAlwaysVisible(val: boolean);
  112129. /**
  112130. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  112131. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112132. */
  112133. set isVisibilityBoxLocked(val: boolean);
  112134. /**
  112135. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  112136. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112137. */
  112138. get isVisibilityBoxLocked(): boolean;
  112139. /**
  112140. * Tells to `setParticles()` to compute the particle rotations or not.
  112141. * Default value : true. The SPS is faster when it's set to false.
  112142. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  112143. */
  112144. set computeParticleRotation(val: boolean);
  112145. /**
  112146. * Tells to `setParticles()` to compute the particle colors or not.
  112147. * Default value : true. The SPS is faster when it's set to false.
  112148. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  112149. */
  112150. set computeParticleColor(val: boolean);
  112151. set computeParticleTexture(val: boolean);
  112152. /**
  112153. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  112154. * Default value : false. The SPS is faster when it's set to false.
  112155. * Note : the particle custom vertex positions aren't stored values.
  112156. */
  112157. set computeParticleVertex(val: boolean);
  112158. /**
  112159. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  112160. */
  112161. set computeBoundingBox(val: boolean);
  112162. /**
  112163. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  112164. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  112165. * Default : `true`
  112166. */
  112167. set depthSortParticles(val: boolean);
  112168. /**
  112169. * Gets if `setParticles()` computes the particle rotations or not.
  112170. * Default value : true. The SPS is faster when it's set to false.
  112171. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  112172. */
  112173. get computeParticleRotation(): boolean;
  112174. /**
  112175. * Gets if `setParticles()` computes the particle colors or not.
  112176. * Default value : true. The SPS is faster when it's set to false.
  112177. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  112178. */
  112179. get computeParticleColor(): boolean;
  112180. /**
  112181. * Gets if `setParticles()` computes the particle textures or not.
  112182. * Default value : true. The SPS is faster when it's set to false.
  112183. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  112184. */
  112185. get computeParticleTexture(): boolean;
  112186. /**
  112187. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  112188. * Default value : false. The SPS is faster when it's set to false.
  112189. * Note : the particle custom vertex positions aren't stored values.
  112190. */
  112191. get computeParticleVertex(): boolean;
  112192. /**
  112193. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  112194. */
  112195. get computeBoundingBox(): boolean;
  112196. /**
  112197. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  112198. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  112199. * Default : `true`
  112200. */
  112201. get depthSortParticles(): boolean;
  112202. /**
  112203. * Gets if the SPS is created as expandable at construction time.
  112204. * Default : `false`
  112205. */
  112206. get expandable(): boolean;
  112207. /**
  112208. * Gets if the SPS supports the Multi Materials
  112209. */
  112210. get multimaterialEnabled(): boolean;
  112211. /**
  112212. * Gets if the SPS uses the model materials for its own multimaterial.
  112213. */
  112214. get useModelMaterial(): boolean;
  112215. /**
  112216. * The SPS used material array.
  112217. */
  112218. get materials(): Material[];
  112219. /**
  112220. * Sets the SPS MultiMaterial from the passed materials.
  112221. * Note : the passed array is internally copied and not used then by reference.
  112222. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  112223. */
  112224. setMultiMaterial(materials: Material[]): void;
  112225. /**
  112226. * The SPS computed multimaterial object
  112227. */
  112228. get multimaterial(): MultiMaterial;
  112229. set multimaterial(mm: MultiMaterial);
  112230. /**
  112231. * If the subMeshes must be updated on the next call to setParticles()
  112232. */
  112233. get autoUpdateSubMeshes(): boolean;
  112234. set autoUpdateSubMeshes(val: boolean);
  112235. /**
  112236. * This function does nothing. It may be overwritten to set all the particle first values.
  112237. * The SPS doesn't call this function, you may have to call it by your own.
  112238. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  112239. */
  112240. initParticles(): void;
  112241. /**
  112242. * This function does nothing. It may be overwritten to recycle a particle.
  112243. * The SPS doesn't call this function, you may have to call it by your own.
  112244. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  112245. * @param particle The particle to recycle
  112246. * @returns the recycled particle
  112247. */
  112248. recycleParticle(particle: SolidParticle): SolidParticle;
  112249. /**
  112250. * Updates a particle : this function should be overwritten by the user.
  112251. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  112252. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  112253. * @example : just set a particle position or velocity and recycle conditions
  112254. * @param particle The particle to update
  112255. * @returns the updated particle
  112256. */
  112257. updateParticle(particle: SolidParticle): SolidParticle;
  112258. /**
  112259. * Updates a vertex of a particle : it can be overwritten by the user.
  112260. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  112261. * @param particle the current particle
  112262. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  112263. * @param pt the index of the current vertex in the particle shape
  112264. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  112265. * @example : just set a vertex particle position or color
  112266. * @returns the sps
  112267. */
  112268. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  112269. /**
  112270. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  112271. * This does nothing and may be overwritten by the user.
  112272. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112273. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112274. * @param update the boolean update value actually passed to setParticles()
  112275. */
  112276. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  112277. /**
  112278. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  112279. * This will be passed three parameters.
  112280. * This does nothing and may be overwritten by the user.
  112281. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112282. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112283. * @param update the boolean update value actually passed to setParticles()
  112284. */
  112285. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  112286. }
  112287. }
  112288. declare module BABYLON {
  112289. /**
  112290. * Represents one particle of a solid particle system.
  112291. */
  112292. export class SolidParticle {
  112293. /**
  112294. * particle global index
  112295. */
  112296. idx: number;
  112297. /**
  112298. * particle identifier
  112299. */
  112300. id: number;
  112301. /**
  112302. * The color of the particle
  112303. */
  112304. color: Nullable<Color4>;
  112305. /**
  112306. * The world space position of the particle.
  112307. */
  112308. position: Vector3;
  112309. /**
  112310. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  112311. */
  112312. rotation: Vector3;
  112313. /**
  112314. * The world space rotation quaternion of the particle.
  112315. */
  112316. rotationQuaternion: Nullable<Quaternion>;
  112317. /**
  112318. * The scaling of the particle.
  112319. */
  112320. scaling: Vector3;
  112321. /**
  112322. * The uvs of the particle.
  112323. */
  112324. uvs: Vector4;
  112325. /**
  112326. * The current speed of the particle.
  112327. */
  112328. velocity: Vector3;
  112329. /**
  112330. * The pivot point in the particle local space.
  112331. */
  112332. pivot: Vector3;
  112333. /**
  112334. * Must the particle be translated from its pivot point in its local space ?
  112335. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  112336. * Default : false
  112337. */
  112338. translateFromPivot: boolean;
  112339. /**
  112340. * Is the particle active or not ?
  112341. */
  112342. alive: boolean;
  112343. /**
  112344. * Is the particle visible or not ?
  112345. */
  112346. isVisible: boolean;
  112347. /**
  112348. * Index of this particle in the global "positions" array (Internal use)
  112349. * @hidden
  112350. */
  112351. _pos: number;
  112352. /**
  112353. * @hidden Index of this particle in the global "indices" array (Internal use)
  112354. */
  112355. _ind: number;
  112356. /**
  112357. * @hidden ModelShape of this particle (Internal use)
  112358. */
  112359. _model: ModelShape;
  112360. /**
  112361. * ModelShape id of this particle
  112362. */
  112363. shapeId: number;
  112364. /**
  112365. * Index of the particle in its shape id
  112366. */
  112367. idxInShape: number;
  112368. /**
  112369. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  112370. */
  112371. _modelBoundingInfo: BoundingInfo;
  112372. /**
  112373. * @hidden Particle BoundingInfo object (Internal use)
  112374. */
  112375. _boundingInfo: BoundingInfo;
  112376. /**
  112377. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  112378. */
  112379. _sps: SolidParticleSystem;
  112380. /**
  112381. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  112382. */
  112383. _stillInvisible: boolean;
  112384. /**
  112385. * @hidden Last computed particle rotation matrix
  112386. */
  112387. _rotationMatrix: number[];
  112388. /**
  112389. * Parent particle Id, if any.
  112390. * Default null.
  112391. */
  112392. parentId: Nullable<number>;
  112393. /**
  112394. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  112395. */
  112396. materialIndex: Nullable<number>;
  112397. /**
  112398. * Custom object or properties.
  112399. */
  112400. props: Nullable<any>;
  112401. /**
  112402. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  112403. * The possible values are :
  112404. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112405. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112406. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112407. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112408. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112409. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  112410. * */
  112411. cullingStrategy: number;
  112412. /**
  112413. * @hidden Internal global position in the SPS.
  112414. */
  112415. _globalPosition: Vector3;
  112416. /**
  112417. * Creates a Solid Particle object.
  112418. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  112419. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  112420. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  112421. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  112422. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  112423. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  112424. * @param shapeId (integer) is the model shape identifier in the SPS.
  112425. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  112426. * @param sps defines the sps it is associated to
  112427. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  112428. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  112429. */
  112430. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  112431. /**
  112432. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  112433. * @param target the particle target
  112434. * @returns the current particle
  112435. */
  112436. copyToRef(target: SolidParticle): SolidParticle;
  112437. /**
  112438. * Legacy support, changed scale to scaling
  112439. */
  112440. get scale(): Vector3;
  112441. /**
  112442. * Legacy support, changed scale to scaling
  112443. */
  112444. set scale(scale: Vector3);
  112445. /**
  112446. * Legacy support, changed quaternion to rotationQuaternion
  112447. */
  112448. get quaternion(): Nullable<Quaternion>;
  112449. /**
  112450. * Legacy support, changed quaternion to rotationQuaternion
  112451. */
  112452. set quaternion(q: Nullable<Quaternion>);
  112453. /**
  112454. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  112455. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  112456. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  112457. * @returns true if it intersects
  112458. */
  112459. intersectsMesh(target: Mesh | SolidParticle): boolean;
  112460. /**
  112461. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  112462. * A particle is in the frustum if its bounding box intersects the frustum
  112463. * @param frustumPlanes defines the frustum to test
  112464. * @returns true if the particle is in the frustum planes
  112465. */
  112466. isInFrustum(frustumPlanes: Plane[]): boolean;
  112467. /**
  112468. * get the rotation matrix of the particle
  112469. * @hidden
  112470. */
  112471. getRotationMatrix(m: Matrix): void;
  112472. }
  112473. /**
  112474. * Represents the shape of the model used by one particle of a solid particle system.
  112475. * SPS internal tool, don't use it manually.
  112476. */
  112477. export class ModelShape {
  112478. /**
  112479. * The shape id
  112480. * @hidden
  112481. */
  112482. shapeID: number;
  112483. /**
  112484. * flat array of model positions (internal use)
  112485. * @hidden
  112486. */
  112487. _shape: Vector3[];
  112488. /**
  112489. * flat array of model UVs (internal use)
  112490. * @hidden
  112491. */
  112492. _shapeUV: number[];
  112493. /**
  112494. * color array of the model
  112495. * @hidden
  112496. */
  112497. _shapeColors: number[];
  112498. /**
  112499. * indices array of the model
  112500. * @hidden
  112501. */
  112502. _indices: number[];
  112503. /**
  112504. * normals array of the model
  112505. * @hidden
  112506. */
  112507. _normals: number[];
  112508. /**
  112509. * length of the shape in the model indices array (internal use)
  112510. * @hidden
  112511. */
  112512. _indicesLength: number;
  112513. /**
  112514. * Custom position function (internal use)
  112515. * @hidden
  112516. */
  112517. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  112518. /**
  112519. * Custom vertex function (internal use)
  112520. * @hidden
  112521. */
  112522. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  112523. /**
  112524. * Model material (internal use)
  112525. * @hidden
  112526. */
  112527. _material: Nullable<Material>;
  112528. /**
  112529. * 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.
  112530. * SPS internal tool, don't use it manually.
  112531. * @hidden
  112532. */
  112533. 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>);
  112534. }
  112535. /**
  112536. * Represents a Depth Sorted Particle in the solid particle system.
  112537. * @hidden
  112538. */
  112539. export class DepthSortedParticle {
  112540. /**
  112541. * Particle index
  112542. */
  112543. idx: number;
  112544. /**
  112545. * Index of the particle in the "indices" array
  112546. */
  112547. ind: number;
  112548. /**
  112549. * Length of the particle shape in the "indices" array
  112550. */
  112551. indicesLength: number;
  112552. /**
  112553. * Squared distance from the particle to the camera
  112554. */
  112555. sqDistance: number;
  112556. /**
  112557. * Material index when used with MultiMaterials
  112558. */
  112559. materialIndex: number;
  112560. /**
  112561. * Creates a new sorted particle
  112562. * @param materialIndex
  112563. */
  112564. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  112565. }
  112566. /**
  112567. * Represents a solid particle vertex
  112568. */
  112569. export class SolidParticleVertex {
  112570. /**
  112571. * Vertex position
  112572. */
  112573. position: Vector3;
  112574. /**
  112575. * Vertex color
  112576. */
  112577. color: Color4;
  112578. /**
  112579. * Vertex UV
  112580. */
  112581. uv: Vector2;
  112582. /**
  112583. * Creates a new solid particle vertex
  112584. */
  112585. constructor();
  112586. /** Vertex x coordinate */
  112587. get x(): number;
  112588. set x(val: number);
  112589. /** Vertex y coordinate */
  112590. get y(): number;
  112591. set y(val: number);
  112592. /** Vertex z coordinate */
  112593. get z(): number;
  112594. set z(val: number);
  112595. }
  112596. }
  112597. declare module BABYLON {
  112598. /**
  112599. * @hidden
  112600. */
  112601. export class _MeshCollisionData {
  112602. _checkCollisions: boolean;
  112603. _collisionMask: number;
  112604. _collisionGroup: number;
  112605. _surroundingMeshes: Nullable<AbstractMesh[]>;
  112606. _collider: Nullable<Collider>;
  112607. _oldPositionForCollisions: Vector3;
  112608. _diffPositionForCollisions: Vector3;
  112609. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  112610. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  112611. _collisionResponse: boolean;
  112612. }
  112613. }
  112614. declare module BABYLON {
  112615. /** @hidden */
  112616. class _FacetDataStorage {
  112617. facetPositions: Vector3[];
  112618. facetNormals: Vector3[];
  112619. facetPartitioning: number[][];
  112620. facetNb: number;
  112621. partitioningSubdivisions: number;
  112622. partitioningBBoxRatio: number;
  112623. facetDataEnabled: boolean;
  112624. facetParameters: any;
  112625. bbSize: Vector3;
  112626. subDiv: {
  112627. max: number;
  112628. X: number;
  112629. Y: number;
  112630. Z: number;
  112631. };
  112632. facetDepthSort: boolean;
  112633. facetDepthSortEnabled: boolean;
  112634. depthSortedIndices: IndicesArray;
  112635. depthSortedFacets: {
  112636. ind: number;
  112637. sqDistance: number;
  112638. }[];
  112639. facetDepthSortFunction: (f1: {
  112640. ind: number;
  112641. sqDistance: number;
  112642. }, f2: {
  112643. ind: number;
  112644. sqDistance: number;
  112645. }) => number;
  112646. facetDepthSortFrom: Vector3;
  112647. facetDepthSortOrigin: Vector3;
  112648. invertedMatrix: Matrix;
  112649. }
  112650. /**
  112651. * @hidden
  112652. **/
  112653. class _InternalAbstractMeshDataInfo {
  112654. _hasVertexAlpha: boolean;
  112655. _useVertexColors: boolean;
  112656. _numBoneInfluencers: number;
  112657. _applyFog: boolean;
  112658. _receiveShadows: boolean;
  112659. _facetData: _FacetDataStorage;
  112660. _visibility: number;
  112661. _skeleton: Nullable<Skeleton>;
  112662. _layerMask: number;
  112663. _computeBonesUsingShaders: boolean;
  112664. _isActive: boolean;
  112665. _onlyForInstances: boolean;
  112666. _isActiveIntermediate: boolean;
  112667. _onlyForInstancesIntermediate: boolean;
  112668. _actAsRegularMesh: boolean;
  112669. }
  112670. /**
  112671. * Class used to store all common mesh properties
  112672. */
  112673. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  112674. /** No occlusion */
  112675. static OCCLUSION_TYPE_NONE: number;
  112676. /** Occlusion set to optimisitic */
  112677. static OCCLUSION_TYPE_OPTIMISTIC: number;
  112678. /** Occlusion set to strict */
  112679. static OCCLUSION_TYPE_STRICT: number;
  112680. /** Use an accurante occlusion algorithm */
  112681. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  112682. /** Use a conservative occlusion algorithm */
  112683. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  112684. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  112685. * Test order :
  112686. * Is the bounding sphere outside the frustum ?
  112687. * If not, are the bounding box vertices outside the frustum ?
  112688. * It not, then the cullable object is in the frustum.
  112689. */
  112690. static readonly CULLINGSTRATEGY_STANDARD: number;
  112691. /** Culling strategy : Bounding Sphere Only.
  112692. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  112693. * It's also less accurate than the standard because some not visible objects can still be selected.
  112694. * Test : is the bounding sphere outside the frustum ?
  112695. * If not, then the cullable object is in the frustum.
  112696. */
  112697. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  112698. /** Culling strategy : Optimistic Inclusion.
  112699. * This in an inclusion test first, then the standard exclusion test.
  112700. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  112701. * 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.
  112702. * Anyway, it's as accurate as the standard strategy.
  112703. * Test :
  112704. * Is the cullable object bounding sphere center in the frustum ?
  112705. * If not, apply the default culling strategy.
  112706. */
  112707. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  112708. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  112709. * This in an inclusion test first, then the bounding sphere only exclusion test.
  112710. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  112711. * 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.
  112712. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  112713. * Test :
  112714. * Is the cullable object bounding sphere center in the frustum ?
  112715. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  112716. */
  112717. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  112718. /**
  112719. * No billboard
  112720. */
  112721. static get BILLBOARDMODE_NONE(): number;
  112722. /** Billboard on X axis */
  112723. static get BILLBOARDMODE_X(): number;
  112724. /** Billboard on Y axis */
  112725. static get BILLBOARDMODE_Y(): number;
  112726. /** Billboard on Z axis */
  112727. static get BILLBOARDMODE_Z(): number;
  112728. /** Billboard on all axes */
  112729. static get BILLBOARDMODE_ALL(): number;
  112730. /** Billboard on using position instead of orientation */
  112731. static get BILLBOARDMODE_USE_POSITION(): number;
  112732. /** @hidden */
  112733. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  112734. /**
  112735. * The culling strategy to use to check whether the mesh must be rendered or not.
  112736. * This value can be changed at any time and will be used on the next render mesh selection.
  112737. * The possible values are :
  112738. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112739. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112740. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112741. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112742. * Please read each static variable documentation to get details about the culling process.
  112743. * */
  112744. cullingStrategy: number;
  112745. /**
  112746. * Gets the number of facets in the mesh
  112747. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112748. */
  112749. get facetNb(): number;
  112750. /**
  112751. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  112752. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112753. */
  112754. get partitioningSubdivisions(): number;
  112755. set partitioningSubdivisions(nb: number);
  112756. /**
  112757. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  112758. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  112759. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112760. */
  112761. get partitioningBBoxRatio(): number;
  112762. set partitioningBBoxRatio(ratio: number);
  112763. /**
  112764. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  112765. * Works only for updatable meshes.
  112766. * Doesn't work with multi-materials
  112767. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112768. */
  112769. get mustDepthSortFacets(): boolean;
  112770. set mustDepthSortFacets(sort: boolean);
  112771. /**
  112772. * The location (Vector3) where the facet depth sort must be computed from.
  112773. * By default, the active camera position.
  112774. * Used only when facet depth sort is enabled
  112775. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112776. */
  112777. get facetDepthSortFrom(): Vector3;
  112778. set facetDepthSortFrom(location: Vector3);
  112779. /**
  112780. * gets a boolean indicating if facetData is enabled
  112781. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112782. */
  112783. get isFacetDataEnabled(): boolean;
  112784. /** @hidden */
  112785. _updateNonUniformScalingState(value: boolean): boolean;
  112786. /**
  112787. * An event triggered when this mesh collides with another one
  112788. */
  112789. onCollideObservable: Observable<AbstractMesh>;
  112790. /** Set a function to call when this mesh collides with another one */
  112791. set onCollide(callback: () => void);
  112792. /**
  112793. * An event triggered when the collision's position changes
  112794. */
  112795. onCollisionPositionChangeObservable: Observable<Vector3>;
  112796. /** Set a function to call when the collision's position changes */
  112797. set onCollisionPositionChange(callback: () => void);
  112798. /**
  112799. * An event triggered when material is changed
  112800. */
  112801. onMaterialChangedObservable: Observable<AbstractMesh>;
  112802. /**
  112803. * Gets or sets the orientation for POV movement & rotation
  112804. */
  112805. definedFacingForward: boolean;
  112806. /** @hidden */
  112807. _occlusionQuery: Nullable<WebGLQuery>;
  112808. /** @hidden */
  112809. _renderingGroup: Nullable<RenderingGroup>;
  112810. /**
  112811. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112812. */
  112813. get visibility(): number;
  112814. /**
  112815. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112816. */
  112817. set visibility(value: number);
  112818. /** Gets or sets the alpha index used to sort transparent meshes
  112819. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  112820. */
  112821. alphaIndex: number;
  112822. /**
  112823. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  112824. */
  112825. isVisible: boolean;
  112826. /**
  112827. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  112828. */
  112829. isPickable: boolean;
  112830. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  112831. showSubMeshesBoundingBox: boolean;
  112832. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  112833. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112834. */
  112835. isBlocker: boolean;
  112836. /**
  112837. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  112838. */
  112839. enablePointerMoveEvents: boolean;
  112840. private _renderingGroupId;
  112841. /**
  112842. * Specifies the rendering group id for this mesh (0 by default)
  112843. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  112844. */
  112845. get renderingGroupId(): number;
  112846. set renderingGroupId(value: number);
  112847. private _material;
  112848. /** Gets or sets current material */
  112849. get material(): Nullable<Material>;
  112850. set material(value: Nullable<Material>);
  112851. /**
  112852. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  112853. * @see https://doc.babylonjs.com/babylon101/shadows
  112854. */
  112855. get receiveShadows(): boolean;
  112856. set receiveShadows(value: boolean);
  112857. /** Defines color to use when rendering outline */
  112858. outlineColor: Color3;
  112859. /** Define width to use when rendering outline */
  112860. outlineWidth: number;
  112861. /** Defines color to use when rendering overlay */
  112862. overlayColor: Color3;
  112863. /** Defines alpha to use when rendering overlay */
  112864. overlayAlpha: number;
  112865. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  112866. get hasVertexAlpha(): boolean;
  112867. set hasVertexAlpha(value: boolean);
  112868. /** 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) */
  112869. get useVertexColors(): boolean;
  112870. set useVertexColors(value: boolean);
  112871. /**
  112872. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  112873. */
  112874. get computeBonesUsingShaders(): boolean;
  112875. set computeBonesUsingShaders(value: boolean);
  112876. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  112877. get numBoneInfluencers(): number;
  112878. set numBoneInfluencers(value: number);
  112879. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  112880. get applyFog(): boolean;
  112881. set applyFog(value: boolean);
  112882. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  112883. useOctreeForRenderingSelection: boolean;
  112884. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  112885. useOctreeForPicking: boolean;
  112886. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  112887. useOctreeForCollisions: boolean;
  112888. /**
  112889. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  112890. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  112891. */
  112892. get layerMask(): number;
  112893. set layerMask(value: number);
  112894. /**
  112895. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  112896. */
  112897. alwaysSelectAsActiveMesh: boolean;
  112898. /**
  112899. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  112900. */
  112901. doNotSyncBoundingInfo: boolean;
  112902. /**
  112903. * Gets or sets the current action manager
  112904. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112905. */
  112906. actionManager: Nullable<AbstractActionManager>;
  112907. private _meshCollisionData;
  112908. /**
  112909. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  112910. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112911. */
  112912. ellipsoid: Vector3;
  112913. /**
  112914. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  112915. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112916. */
  112917. ellipsoidOffset: Vector3;
  112918. /**
  112919. * Gets or sets a collision mask used to mask collisions (default is -1).
  112920. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112921. */
  112922. get collisionMask(): number;
  112923. set collisionMask(mask: number);
  112924. /**
  112925. * Gets or sets a collision response flag (default is true).
  112926. * when collisionResponse is false, events are still triggered but colliding entity has no response
  112927. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  112928. * to respond to the collision.
  112929. */
  112930. get collisionResponse(): boolean;
  112931. set collisionResponse(response: boolean);
  112932. /**
  112933. * Gets or sets the current collision group mask (-1 by default).
  112934. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112935. */
  112936. get collisionGroup(): number;
  112937. set collisionGroup(mask: number);
  112938. /**
  112939. * Gets or sets current surrounding meshes (null by default).
  112940. *
  112941. * By default collision detection is tested against every mesh in the scene.
  112942. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112943. * meshes will be tested for the collision.
  112944. *
  112945. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112946. */
  112947. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112948. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112949. /**
  112950. * Defines edge width used when edgesRenderer is enabled
  112951. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112952. */
  112953. edgesWidth: number;
  112954. /**
  112955. * Defines edge color used when edgesRenderer is enabled
  112956. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112957. */
  112958. edgesColor: Color4;
  112959. /** @hidden */
  112960. _edgesRenderer: Nullable<IEdgesRenderer>;
  112961. /** @hidden */
  112962. _masterMesh: Nullable<AbstractMesh>;
  112963. /** @hidden */
  112964. _boundingInfo: Nullable<BoundingInfo>;
  112965. /** @hidden */
  112966. _renderId: number;
  112967. /**
  112968. * Gets or sets the list of subMeshes
  112969. * @see https://doc.babylonjs.com/how_to/multi_materials
  112970. */
  112971. subMeshes: SubMesh[];
  112972. /** @hidden */
  112973. _intersectionsInProgress: AbstractMesh[];
  112974. /** @hidden */
  112975. _unIndexed: boolean;
  112976. /** @hidden */
  112977. _lightSources: Light[];
  112978. /** Gets the list of lights affecting that mesh */
  112979. get lightSources(): Light[];
  112980. /** @hidden */
  112981. get _positions(): Nullable<Vector3[]>;
  112982. /** @hidden */
  112983. _waitingData: {
  112984. lods: Nullable<any>;
  112985. actions: Nullable<any>;
  112986. freezeWorldMatrix: Nullable<boolean>;
  112987. };
  112988. /** @hidden */
  112989. _bonesTransformMatrices: Nullable<Float32Array>;
  112990. /** @hidden */
  112991. _transformMatrixTexture: Nullable<RawTexture>;
  112992. /**
  112993. * Gets or sets a skeleton to apply skining transformations
  112994. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112995. */
  112996. set skeleton(value: Nullable<Skeleton>);
  112997. get skeleton(): Nullable<Skeleton>;
  112998. /**
  112999. * An event triggered when the mesh is rebuilt.
  113000. */
  113001. onRebuildObservable: Observable<AbstractMesh>;
  113002. /**
  113003. * Creates a new AbstractMesh
  113004. * @param name defines the name of the mesh
  113005. * @param scene defines the hosting scene
  113006. */
  113007. constructor(name: string, scene?: Nullable<Scene>);
  113008. /**
  113009. * Returns the string "AbstractMesh"
  113010. * @returns "AbstractMesh"
  113011. */
  113012. getClassName(): string;
  113013. /**
  113014. * Gets a string representation of the current mesh
  113015. * @param fullDetails defines a boolean indicating if full details must be included
  113016. * @returns a string representation of the current mesh
  113017. */
  113018. toString(fullDetails?: boolean): string;
  113019. /**
  113020. * @hidden
  113021. */
  113022. protected _getEffectiveParent(): Nullable<Node>;
  113023. /** @hidden */
  113024. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  113025. /** @hidden */
  113026. _rebuild(): void;
  113027. /** @hidden */
  113028. _resyncLightSources(): void;
  113029. /** @hidden */
  113030. _resyncLightSource(light: Light): void;
  113031. /** @hidden */
  113032. _unBindEffect(): void;
  113033. /** @hidden */
  113034. _removeLightSource(light: Light, dispose: boolean): void;
  113035. private _markSubMeshesAsDirty;
  113036. /** @hidden */
  113037. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  113038. /** @hidden */
  113039. _markSubMeshesAsAttributesDirty(): void;
  113040. /** @hidden */
  113041. _markSubMeshesAsMiscDirty(): void;
  113042. /**
  113043. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  113044. */
  113045. get scaling(): Vector3;
  113046. set scaling(newScaling: Vector3);
  113047. /**
  113048. * Returns true if the mesh is blocked. Implemented by child classes
  113049. */
  113050. get isBlocked(): boolean;
  113051. /**
  113052. * Returns the mesh itself by default. Implemented by child classes
  113053. * @param camera defines the camera to use to pick the right LOD level
  113054. * @returns the currentAbstractMesh
  113055. */
  113056. getLOD(camera: Camera): Nullable<AbstractMesh>;
  113057. /**
  113058. * Returns 0 by default. Implemented by child classes
  113059. * @returns an integer
  113060. */
  113061. getTotalVertices(): number;
  113062. /**
  113063. * Returns a positive integer : the total number of indices in this mesh geometry.
  113064. * @returns the numner of indices or zero if the mesh has no geometry.
  113065. */
  113066. getTotalIndices(): number;
  113067. /**
  113068. * Returns null by default. Implemented by child classes
  113069. * @returns null
  113070. */
  113071. getIndices(): Nullable<IndicesArray>;
  113072. /**
  113073. * Returns the array of the requested vertex data kind. Implemented by child classes
  113074. * @param kind defines the vertex data kind to use
  113075. * @returns null
  113076. */
  113077. getVerticesData(kind: string): Nullable<FloatArray>;
  113078. /**
  113079. * Sets the vertex data of the mesh geometry for the requested `kind`.
  113080. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  113081. * Note that a new underlying VertexBuffer object is created each call.
  113082. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  113083. * @param kind defines vertex data kind:
  113084. * * VertexBuffer.PositionKind
  113085. * * VertexBuffer.UVKind
  113086. * * VertexBuffer.UV2Kind
  113087. * * VertexBuffer.UV3Kind
  113088. * * VertexBuffer.UV4Kind
  113089. * * VertexBuffer.UV5Kind
  113090. * * VertexBuffer.UV6Kind
  113091. * * VertexBuffer.ColorKind
  113092. * * VertexBuffer.MatricesIndicesKind
  113093. * * VertexBuffer.MatricesIndicesExtraKind
  113094. * * VertexBuffer.MatricesWeightsKind
  113095. * * VertexBuffer.MatricesWeightsExtraKind
  113096. * @param data defines the data source
  113097. * @param updatable defines if the data must be flagged as updatable (or static)
  113098. * @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
  113099. * @returns the current mesh
  113100. */
  113101. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  113102. /**
  113103. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  113104. * If the mesh has no geometry, it is simply returned as it is.
  113105. * @param kind defines vertex data kind:
  113106. * * VertexBuffer.PositionKind
  113107. * * VertexBuffer.UVKind
  113108. * * VertexBuffer.UV2Kind
  113109. * * VertexBuffer.UV3Kind
  113110. * * VertexBuffer.UV4Kind
  113111. * * VertexBuffer.UV5Kind
  113112. * * VertexBuffer.UV6Kind
  113113. * * VertexBuffer.ColorKind
  113114. * * VertexBuffer.MatricesIndicesKind
  113115. * * VertexBuffer.MatricesIndicesExtraKind
  113116. * * VertexBuffer.MatricesWeightsKind
  113117. * * VertexBuffer.MatricesWeightsExtraKind
  113118. * @param data defines the data source
  113119. * @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
  113120. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  113121. * @returns the current mesh
  113122. */
  113123. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  113124. /**
  113125. * Sets the mesh indices,
  113126. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  113127. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  113128. * @param totalVertices Defines the total number of vertices
  113129. * @returns the current mesh
  113130. */
  113131. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  113132. /**
  113133. * Gets a boolean indicating if specific vertex data is present
  113134. * @param kind defines the vertex data kind to use
  113135. * @returns true is data kind is present
  113136. */
  113137. isVerticesDataPresent(kind: string): boolean;
  113138. /**
  113139. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  113140. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  113141. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  113142. * @returns a BoundingInfo
  113143. */
  113144. getBoundingInfo(): BoundingInfo;
  113145. /**
  113146. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  113147. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  113148. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  113149. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  113150. * @returns the current mesh
  113151. */
  113152. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  113153. /**
  113154. * Overwrite the current bounding info
  113155. * @param boundingInfo defines the new bounding info
  113156. * @returns the current mesh
  113157. */
  113158. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  113159. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  113160. get useBones(): boolean;
  113161. /** @hidden */
  113162. _preActivate(): void;
  113163. /** @hidden */
  113164. _preActivateForIntermediateRendering(renderId: number): void;
  113165. /** @hidden */
  113166. _activate(renderId: number, intermediateRendering: boolean): boolean;
  113167. /** @hidden */
  113168. _postActivate(): void;
  113169. /** @hidden */
  113170. _freeze(): void;
  113171. /** @hidden */
  113172. _unFreeze(): void;
  113173. /**
  113174. * Gets the current world matrix
  113175. * @returns a Matrix
  113176. */
  113177. getWorldMatrix(): Matrix;
  113178. /** @hidden */
  113179. _getWorldMatrixDeterminant(): number;
  113180. /**
  113181. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  113182. */
  113183. get isAnInstance(): boolean;
  113184. /**
  113185. * Gets a boolean indicating if this mesh has instances
  113186. */
  113187. get hasInstances(): boolean;
  113188. /**
  113189. * Gets a boolean indicating if this mesh has thin instances
  113190. */
  113191. get hasThinInstances(): boolean;
  113192. /**
  113193. * Perform relative position change from the point of view of behind the front of the mesh.
  113194. * This is performed taking into account the meshes current rotation, so you do not have to care.
  113195. * Supports definition of mesh facing forward or backward
  113196. * @param amountRight defines the distance on the right axis
  113197. * @param amountUp defines the distance on the up axis
  113198. * @param amountForward defines the distance on the forward axis
  113199. * @returns the current mesh
  113200. */
  113201. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  113202. /**
  113203. * Calculate relative position change from the point of view of behind the front of the mesh.
  113204. * This is performed taking into account the meshes current rotation, so you do not have to care.
  113205. * Supports definition of mesh facing forward or backward
  113206. * @param amountRight defines the distance on the right axis
  113207. * @param amountUp defines the distance on the up axis
  113208. * @param amountForward defines the distance on the forward axis
  113209. * @returns the new displacement vector
  113210. */
  113211. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  113212. /**
  113213. * Perform relative rotation change from the point of view of behind the front of the mesh.
  113214. * Supports definition of mesh facing forward or backward
  113215. * @param flipBack defines the flip
  113216. * @param twirlClockwise defines the twirl
  113217. * @param tiltRight defines the tilt
  113218. * @returns the current mesh
  113219. */
  113220. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  113221. /**
  113222. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  113223. * Supports definition of mesh facing forward or backward.
  113224. * @param flipBack defines the flip
  113225. * @param twirlClockwise defines the twirl
  113226. * @param tiltRight defines the tilt
  113227. * @returns the new rotation vector
  113228. */
  113229. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  113230. /**
  113231. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  113232. * This means the mesh underlying bounding box and sphere are recomputed.
  113233. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  113234. * @returns the current mesh
  113235. */
  113236. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  113237. /** @hidden */
  113238. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  113239. /** @hidden */
  113240. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  113241. /** @hidden */
  113242. _updateBoundingInfo(): AbstractMesh;
  113243. /** @hidden */
  113244. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  113245. /** @hidden */
  113246. protected _afterComputeWorldMatrix(): void;
  113247. /** @hidden */
  113248. get _effectiveMesh(): AbstractMesh;
  113249. /**
  113250. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  113251. * A mesh is in the frustum if its bounding box intersects the frustum
  113252. * @param frustumPlanes defines the frustum to test
  113253. * @returns true if the mesh is in the frustum planes
  113254. */
  113255. isInFrustum(frustumPlanes: Plane[]): boolean;
  113256. /**
  113257. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  113258. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  113259. * @param frustumPlanes defines the frustum to test
  113260. * @returns true if the mesh is completely in the frustum planes
  113261. */
  113262. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  113263. /**
  113264. * True if the mesh intersects another mesh or a SolidParticle object
  113265. * @param mesh defines a target mesh or SolidParticle to test
  113266. * @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)
  113267. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  113268. * @returns true if there is an intersection
  113269. */
  113270. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  113271. /**
  113272. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  113273. * @param point defines the point to test
  113274. * @returns true if there is an intersection
  113275. */
  113276. intersectsPoint(point: Vector3): boolean;
  113277. /**
  113278. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  113279. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  113280. */
  113281. get checkCollisions(): boolean;
  113282. set checkCollisions(collisionEnabled: boolean);
  113283. /**
  113284. * Gets Collider object used to compute collisions (not physics)
  113285. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  113286. */
  113287. get collider(): Nullable<Collider>;
  113288. /**
  113289. * Move the mesh using collision engine
  113290. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  113291. * @param displacement defines the requested displacement vector
  113292. * @returns the current mesh
  113293. */
  113294. moveWithCollisions(displacement: Vector3): AbstractMesh;
  113295. private _onCollisionPositionChange;
  113296. /** @hidden */
  113297. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  113298. /** @hidden */
  113299. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  113300. /** @hidden */
  113301. _checkCollision(collider: Collider): AbstractMesh;
  113302. /** @hidden */
  113303. _generatePointsArray(): boolean;
  113304. /**
  113305. * Checks if the passed Ray intersects with the mesh
  113306. * @param ray defines the ray to use
  113307. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  113308. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113309. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  113310. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  113311. * @returns the picking info
  113312. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  113313. */
  113314. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  113315. /**
  113316. * Clones the current mesh
  113317. * @param name defines the mesh name
  113318. * @param newParent defines the new mesh parent
  113319. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  113320. * @returns the new mesh
  113321. */
  113322. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  113323. /**
  113324. * Disposes all the submeshes of the current meshnp
  113325. * @returns the current mesh
  113326. */
  113327. releaseSubMeshes(): AbstractMesh;
  113328. /**
  113329. * Releases resources associated with this abstract mesh.
  113330. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113331. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113332. */
  113333. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113334. /**
  113335. * Adds the passed mesh as a child to the current mesh
  113336. * @param mesh defines the child mesh
  113337. * @returns the current mesh
  113338. */
  113339. addChild(mesh: AbstractMesh): AbstractMesh;
  113340. /**
  113341. * Removes the passed mesh from the current mesh children list
  113342. * @param mesh defines the child mesh
  113343. * @returns the current mesh
  113344. */
  113345. removeChild(mesh: AbstractMesh): AbstractMesh;
  113346. /** @hidden */
  113347. private _initFacetData;
  113348. /**
  113349. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  113350. * This method can be called within the render loop.
  113351. * 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
  113352. * @returns the current mesh
  113353. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113354. */
  113355. updateFacetData(): AbstractMesh;
  113356. /**
  113357. * Returns the facetLocalNormals array.
  113358. * The normals are expressed in the mesh local spac
  113359. * @returns an array of Vector3
  113360. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113361. */
  113362. getFacetLocalNormals(): Vector3[];
  113363. /**
  113364. * Returns the facetLocalPositions array.
  113365. * The facet positions are expressed in the mesh local space
  113366. * @returns an array of Vector3
  113367. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113368. */
  113369. getFacetLocalPositions(): Vector3[];
  113370. /**
  113371. * Returns the facetLocalPartioning array
  113372. * @returns an array of array of numbers
  113373. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113374. */
  113375. getFacetLocalPartitioning(): number[][];
  113376. /**
  113377. * Returns the i-th facet position in the world system.
  113378. * This method allocates a new Vector3 per call
  113379. * @param i defines the facet index
  113380. * @returns a new Vector3
  113381. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113382. */
  113383. getFacetPosition(i: number): Vector3;
  113384. /**
  113385. * Sets the reference Vector3 with the i-th facet position in the world system
  113386. * @param i defines the facet index
  113387. * @param ref defines the target vector
  113388. * @returns the current mesh
  113389. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113390. */
  113391. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  113392. /**
  113393. * Returns the i-th facet normal in the world system.
  113394. * This method allocates a new Vector3 per call
  113395. * @param i defines the facet index
  113396. * @returns a new Vector3
  113397. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113398. */
  113399. getFacetNormal(i: number): Vector3;
  113400. /**
  113401. * Sets the reference Vector3 with the i-th facet normal in the world system
  113402. * @param i defines the facet index
  113403. * @param ref defines the target vector
  113404. * @returns the current mesh
  113405. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113406. */
  113407. getFacetNormalToRef(i: number, ref: Vector3): this;
  113408. /**
  113409. * 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)
  113410. * @param x defines x coordinate
  113411. * @param y defines y coordinate
  113412. * @param z defines z coordinate
  113413. * @returns the array of facet indexes
  113414. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113415. */
  113416. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  113417. /**
  113418. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  113419. * @param projected sets as the (x,y,z) world projection on the facet
  113420. * @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
  113421. * @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
  113422. * @param x defines x coordinate
  113423. * @param y defines y coordinate
  113424. * @param z defines z coordinate
  113425. * @returns the face index if found (or null instead)
  113426. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113427. */
  113428. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113429. /**
  113430. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  113431. * @param projected sets as the (x,y,z) local projection on the facet
  113432. * @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
  113433. * @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
  113434. * @param x defines x coordinate
  113435. * @param y defines y coordinate
  113436. * @param z defines z coordinate
  113437. * @returns the face index if found (or null instead)
  113438. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113439. */
  113440. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113441. /**
  113442. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  113443. * @returns the parameters
  113444. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113445. */
  113446. getFacetDataParameters(): any;
  113447. /**
  113448. * Disables the feature FacetData and frees the related memory
  113449. * @returns the current mesh
  113450. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113451. */
  113452. disableFacetData(): AbstractMesh;
  113453. /**
  113454. * Updates the AbstractMesh indices array
  113455. * @param indices defines the data source
  113456. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113457. * @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)
  113458. * @returns the current mesh
  113459. */
  113460. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113461. /**
  113462. * Creates new normals data for the mesh
  113463. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  113464. * @returns the current mesh
  113465. */
  113466. createNormals(updatable: boolean): AbstractMesh;
  113467. /**
  113468. * Align the mesh with a normal
  113469. * @param normal defines the normal to use
  113470. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  113471. * @returns the current mesh
  113472. */
  113473. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  113474. /** @hidden */
  113475. _checkOcclusionQuery(): boolean;
  113476. /**
  113477. * Disables the mesh edge rendering mode
  113478. * @returns the currentAbstractMesh
  113479. */
  113480. disableEdgesRendering(): AbstractMesh;
  113481. /**
  113482. * Enables the edge rendering mode on the mesh.
  113483. * This mode makes the mesh edges visible
  113484. * @param epsilon defines the maximal distance between two angles to detect a face
  113485. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113486. * @returns the currentAbstractMesh
  113487. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113488. */
  113489. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  113490. /**
  113491. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  113492. * @returns an array of particle systems in the scene that use the mesh as an emitter
  113493. */
  113494. getConnectedParticleSystems(): IParticleSystem[];
  113495. }
  113496. }
  113497. declare module BABYLON {
  113498. /**
  113499. * Interface used to define ActionEvent
  113500. */
  113501. export interface IActionEvent {
  113502. /** The mesh or sprite that triggered the action */
  113503. source: any;
  113504. /** The X mouse cursor position at the time of the event */
  113505. pointerX: number;
  113506. /** The Y mouse cursor position at the time of the event */
  113507. pointerY: number;
  113508. /** The mesh that is currently pointed at (can be null) */
  113509. meshUnderPointer: Nullable<AbstractMesh>;
  113510. /** the original (browser) event that triggered the ActionEvent */
  113511. sourceEvent?: any;
  113512. /** additional data for the event */
  113513. additionalData?: any;
  113514. }
  113515. /**
  113516. * ActionEvent is the event being sent when an action is triggered.
  113517. */
  113518. export class ActionEvent implements IActionEvent {
  113519. /** The mesh or sprite that triggered the action */
  113520. source: any;
  113521. /** The X mouse cursor position at the time of the event */
  113522. pointerX: number;
  113523. /** The Y mouse cursor position at the time of the event */
  113524. pointerY: number;
  113525. /** The mesh that is currently pointed at (can be null) */
  113526. meshUnderPointer: Nullable<AbstractMesh>;
  113527. /** the original (browser) event that triggered the ActionEvent */
  113528. sourceEvent?: any;
  113529. /** additional data for the event */
  113530. additionalData?: any;
  113531. /**
  113532. * Creates a new ActionEvent
  113533. * @param source The mesh or sprite that triggered the action
  113534. * @param pointerX The X mouse cursor position at the time of the event
  113535. * @param pointerY The Y mouse cursor position at the time of the event
  113536. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  113537. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  113538. * @param additionalData additional data for the event
  113539. */
  113540. constructor(
  113541. /** The mesh or sprite that triggered the action */
  113542. source: any,
  113543. /** The X mouse cursor position at the time of the event */
  113544. pointerX: number,
  113545. /** The Y mouse cursor position at the time of the event */
  113546. pointerY: number,
  113547. /** The mesh that is currently pointed at (can be null) */
  113548. meshUnderPointer: Nullable<AbstractMesh>,
  113549. /** the original (browser) event that triggered the ActionEvent */
  113550. sourceEvent?: any,
  113551. /** additional data for the event */
  113552. additionalData?: any);
  113553. /**
  113554. * Helper function to auto-create an ActionEvent from a source mesh.
  113555. * @param source The source mesh that triggered the event
  113556. * @param evt The original (browser) event
  113557. * @param additionalData additional data for the event
  113558. * @returns the new ActionEvent
  113559. */
  113560. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  113561. /**
  113562. * Helper function to auto-create an ActionEvent from a source sprite
  113563. * @param source The source sprite that triggered the event
  113564. * @param scene Scene associated with the sprite
  113565. * @param evt The original (browser) event
  113566. * @param additionalData additional data for the event
  113567. * @returns the new ActionEvent
  113568. */
  113569. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  113570. /**
  113571. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  113572. * @param scene the scene where the event occurred
  113573. * @param evt The original (browser) event
  113574. * @returns the new ActionEvent
  113575. */
  113576. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  113577. /**
  113578. * Helper function to auto-create an ActionEvent from a primitive
  113579. * @param prim defines the target primitive
  113580. * @param pointerPos defines the pointer position
  113581. * @param evt The original (browser) event
  113582. * @param additionalData additional data for the event
  113583. * @returns the new ActionEvent
  113584. */
  113585. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  113586. }
  113587. }
  113588. declare module BABYLON {
  113589. /**
  113590. * Abstract class used to decouple action Manager from scene and meshes.
  113591. * Do not instantiate.
  113592. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  113593. */
  113594. export abstract class AbstractActionManager implements IDisposable {
  113595. /** Gets the list of active triggers */
  113596. static Triggers: {
  113597. [key: string]: number;
  113598. };
  113599. /** Gets the cursor to use when hovering items */
  113600. hoverCursor: string;
  113601. /** Gets the list of actions */
  113602. actions: IAction[];
  113603. /**
  113604. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  113605. */
  113606. isRecursive: boolean;
  113607. /**
  113608. * Releases all associated resources
  113609. */
  113610. abstract dispose(): void;
  113611. /**
  113612. * Does this action manager has pointer triggers
  113613. */
  113614. abstract get hasPointerTriggers(): boolean;
  113615. /**
  113616. * Does this action manager has pick triggers
  113617. */
  113618. abstract get hasPickTriggers(): boolean;
  113619. /**
  113620. * Process a specific trigger
  113621. * @param trigger defines the trigger to process
  113622. * @param evt defines the event details to be processed
  113623. */
  113624. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  113625. /**
  113626. * Does this action manager handles actions of any of the given triggers
  113627. * @param triggers defines the triggers to be tested
  113628. * @return a boolean indicating whether one (or more) of the triggers is handled
  113629. */
  113630. abstract hasSpecificTriggers(triggers: number[]): boolean;
  113631. /**
  113632. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  113633. * speed.
  113634. * @param triggerA defines the trigger to be tested
  113635. * @param triggerB defines the trigger to be tested
  113636. * @return a boolean indicating whether one (or more) of the triggers is handled
  113637. */
  113638. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  113639. /**
  113640. * Does this action manager handles actions of a given trigger
  113641. * @param trigger defines the trigger to be tested
  113642. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  113643. * @return whether the trigger is handled
  113644. */
  113645. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  113646. /**
  113647. * Serialize this manager to a JSON object
  113648. * @param name defines the property name to store this manager
  113649. * @returns a JSON representation of this manager
  113650. */
  113651. abstract serialize(name: string): any;
  113652. /**
  113653. * Registers an action to this action manager
  113654. * @param action defines the action to be registered
  113655. * @return the action amended (prepared) after registration
  113656. */
  113657. abstract registerAction(action: IAction): Nullable<IAction>;
  113658. /**
  113659. * Unregisters an action to this action manager
  113660. * @param action defines the action to be unregistered
  113661. * @return a boolean indicating whether the action has been unregistered
  113662. */
  113663. abstract unregisterAction(action: IAction): Boolean;
  113664. /**
  113665. * Does exist one action manager with at least one trigger
  113666. **/
  113667. static get HasTriggers(): boolean;
  113668. /**
  113669. * Does exist one action manager with at least one pick trigger
  113670. **/
  113671. static get HasPickTriggers(): boolean;
  113672. /**
  113673. * Does exist one action manager that handles actions of a given trigger
  113674. * @param trigger defines the trigger to be tested
  113675. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  113676. **/
  113677. static HasSpecificTrigger(trigger: number): boolean;
  113678. }
  113679. }
  113680. declare module BABYLON {
  113681. /**
  113682. * Defines how a node can be built from a string name.
  113683. */
  113684. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  113685. /**
  113686. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  113687. */
  113688. export class Node implements IBehaviorAware<Node> {
  113689. /** @hidden */
  113690. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  113691. private static _NodeConstructors;
  113692. /**
  113693. * Add a new node constructor
  113694. * @param type defines the type name of the node to construct
  113695. * @param constructorFunc defines the constructor function
  113696. */
  113697. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  113698. /**
  113699. * Returns a node constructor based on type name
  113700. * @param type defines the type name
  113701. * @param name defines the new node name
  113702. * @param scene defines the hosting scene
  113703. * @param options defines optional options to transmit to constructors
  113704. * @returns the new constructor or null
  113705. */
  113706. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  113707. /**
  113708. * Gets or sets the name of the node
  113709. */
  113710. name: string;
  113711. /**
  113712. * Gets or sets the id of the node
  113713. */
  113714. id: string;
  113715. /**
  113716. * Gets or sets the unique id of the node
  113717. */
  113718. uniqueId: number;
  113719. /**
  113720. * Gets or sets a string used to store user defined state for the node
  113721. */
  113722. state: string;
  113723. /**
  113724. * Gets or sets an object used to store user defined information for the node
  113725. */
  113726. metadata: any;
  113727. /**
  113728. * For internal use only. Please do not use.
  113729. */
  113730. reservedDataStore: any;
  113731. /**
  113732. * List of inspectable custom properties (used by the Inspector)
  113733. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113734. */
  113735. inspectableCustomProperties: IInspectable[];
  113736. private _doNotSerialize;
  113737. /**
  113738. * Gets or sets a boolean used to define if the node must be serialized
  113739. */
  113740. get doNotSerialize(): boolean;
  113741. set doNotSerialize(value: boolean);
  113742. /** @hidden */
  113743. _isDisposed: boolean;
  113744. /**
  113745. * Gets a list of Animations associated with the node
  113746. */
  113747. animations: Animation[];
  113748. protected _ranges: {
  113749. [name: string]: Nullable<AnimationRange>;
  113750. };
  113751. /**
  113752. * Callback raised when the node is ready to be used
  113753. */
  113754. onReady: Nullable<(node: Node) => void>;
  113755. private _isEnabled;
  113756. private _isParentEnabled;
  113757. private _isReady;
  113758. /** @hidden */
  113759. _currentRenderId: number;
  113760. private _parentUpdateId;
  113761. /** @hidden */
  113762. _childUpdateId: number;
  113763. /** @hidden */
  113764. _waitingParentId: Nullable<string>;
  113765. /** @hidden */
  113766. _scene: Scene;
  113767. /** @hidden */
  113768. _cache: any;
  113769. private _parentNode;
  113770. private _children;
  113771. /** @hidden */
  113772. _worldMatrix: Matrix;
  113773. /** @hidden */
  113774. _worldMatrixDeterminant: number;
  113775. /** @hidden */
  113776. _worldMatrixDeterminantIsDirty: boolean;
  113777. /** @hidden */
  113778. private _sceneRootNodesIndex;
  113779. /**
  113780. * Gets a boolean indicating if the node has been disposed
  113781. * @returns true if the node was disposed
  113782. */
  113783. isDisposed(): boolean;
  113784. /**
  113785. * Gets or sets the parent of the node (without keeping the current position in the scene)
  113786. * @see https://doc.babylonjs.com/how_to/parenting
  113787. */
  113788. set parent(parent: Nullable<Node>);
  113789. get parent(): Nullable<Node>;
  113790. /** @hidden */
  113791. _addToSceneRootNodes(): void;
  113792. /** @hidden */
  113793. _removeFromSceneRootNodes(): void;
  113794. private _animationPropertiesOverride;
  113795. /**
  113796. * Gets or sets the animation properties override
  113797. */
  113798. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  113799. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  113800. /**
  113801. * Gets a string identifying the name of the class
  113802. * @returns "Node" string
  113803. */
  113804. getClassName(): string;
  113805. /** @hidden */
  113806. readonly _isNode: boolean;
  113807. /**
  113808. * An event triggered when the mesh is disposed
  113809. */
  113810. onDisposeObservable: Observable<Node>;
  113811. private _onDisposeObserver;
  113812. /**
  113813. * Sets a callback that will be raised when the node will be disposed
  113814. */
  113815. set onDispose(callback: () => void);
  113816. /**
  113817. * Creates a new Node
  113818. * @param name the name and id to be given to this node
  113819. * @param scene the scene this node will be added to
  113820. */
  113821. constructor(name: string, scene?: Nullable<Scene>);
  113822. /**
  113823. * Gets the scene of the node
  113824. * @returns a scene
  113825. */
  113826. getScene(): Scene;
  113827. /**
  113828. * Gets the engine of the node
  113829. * @returns a Engine
  113830. */
  113831. getEngine(): Engine;
  113832. private _behaviors;
  113833. /**
  113834. * Attach a behavior to the node
  113835. * @see https://doc.babylonjs.com/features/behaviour
  113836. * @param behavior defines the behavior to attach
  113837. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  113838. * @returns the current Node
  113839. */
  113840. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  113841. /**
  113842. * Remove an attached behavior
  113843. * @see https://doc.babylonjs.com/features/behaviour
  113844. * @param behavior defines the behavior to attach
  113845. * @returns the current Node
  113846. */
  113847. removeBehavior(behavior: Behavior<Node>): Node;
  113848. /**
  113849. * Gets the list of attached behaviors
  113850. * @see https://doc.babylonjs.com/features/behaviour
  113851. */
  113852. get behaviors(): Behavior<Node>[];
  113853. /**
  113854. * Gets an attached behavior by name
  113855. * @param name defines the name of the behavior to look for
  113856. * @see https://doc.babylonjs.com/features/behaviour
  113857. * @returns null if behavior was not found else the requested behavior
  113858. */
  113859. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  113860. /**
  113861. * Returns the latest update of the World matrix
  113862. * @returns a Matrix
  113863. */
  113864. getWorldMatrix(): Matrix;
  113865. /** @hidden */
  113866. _getWorldMatrixDeterminant(): number;
  113867. /**
  113868. * Returns directly the latest state of the mesh World matrix.
  113869. * A Matrix is returned.
  113870. */
  113871. get worldMatrixFromCache(): Matrix;
  113872. /** @hidden */
  113873. _initCache(): void;
  113874. /** @hidden */
  113875. updateCache(force?: boolean): void;
  113876. /** @hidden */
  113877. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  113878. /** @hidden */
  113879. _updateCache(ignoreParentClass?: boolean): void;
  113880. /** @hidden */
  113881. _isSynchronized(): boolean;
  113882. /** @hidden */
  113883. _markSyncedWithParent(): void;
  113884. /** @hidden */
  113885. isSynchronizedWithParent(): boolean;
  113886. /** @hidden */
  113887. isSynchronized(): boolean;
  113888. /**
  113889. * Is this node ready to be used/rendered
  113890. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113891. * @return true if the node is ready
  113892. */
  113893. isReady(completeCheck?: boolean): boolean;
  113894. /**
  113895. * Is this node enabled?
  113896. * 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
  113897. * @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
  113898. * @return whether this node (and its parent) is enabled
  113899. */
  113900. isEnabled(checkAncestors?: boolean): boolean;
  113901. /** @hidden */
  113902. protected _syncParentEnabledState(): void;
  113903. /**
  113904. * Set the enabled state of this node
  113905. * @param value defines the new enabled state
  113906. */
  113907. setEnabled(value: boolean): void;
  113908. /**
  113909. * Is this node a descendant of the given node?
  113910. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  113911. * @param ancestor defines the parent node to inspect
  113912. * @returns a boolean indicating if this node is a descendant of the given node
  113913. */
  113914. isDescendantOf(ancestor: Node): boolean;
  113915. /** @hidden */
  113916. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  113917. /**
  113918. * Will return all nodes that have this node as ascendant
  113919. * @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
  113920. * @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
  113921. * @return all children nodes of all types
  113922. */
  113923. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  113924. /**
  113925. * Get all child-meshes of this node
  113926. * @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)
  113927. * @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
  113928. * @returns an array of AbstractMesh
  113929. */
  113930. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  113931. /**
  113932. * Get all direct children of this node
  113933. * @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
  113934. * @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)
  113935. * @returns an array of Node
  113936. */
  113937. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113938. /** @hidden */
  113939. _setReady(state: boolean): void;
  113940. /**
  113941. * Get an animation by name
  113942. * @param name defines the name of the animation to look for
  113943. * @returns null if not found else the requested animation
  113944. */
  113945. getAnimationByName(name: string): Nullable<Animation>;
  113946. /**
  113947. * Creates an animation range for this node
  113948. * @param name defines the name of the range
  113949. * @param from defines the starting key
  113950. * @param to defines the end key
  113951. */
  113952. createAnimationRange(name: string, from: number, to: number): void;
  113953. /**
  113954. * Delete a specific animation range
  113955. * @param name defines the name of the range to delete
  113956. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113957. */
  113958. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113959. /**
  113960. * Get an animation range by name
  113961. * @param name defines the name of the animation range to look for
  113962. * @returns null if not found else the requested animation range
  113963. */
  113964. getAnimationRange(name: string): Nullable<AnimationRange>;
  113965. /**
  113966. * Gets the list of all animation ranges defined on this node
  113967. * @returns an array
  113968. */
  113969. getAnimationRanges(): Nullable<AnimationRange>[];
  113970. /**
  113971. * Will start the animation sequence
  113972. * @param name defines the range frames for animation sequence
  113973. * @param loop defines if the animation should loop (false by default)
  113974. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113975. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113976. * @returns the object created for this animation. If range does not exist, it will return null
  113977. */
  113978. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113979. /**
  113980. * Serialize animation ranges into a JSON compatible object
  113981. * @returns serialization object
  113982. */
  113983. serializeAnimationRanges(): any;
  113984. /**
  113985. * Computes the world matrix of the node
  113986. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113987. * @returns the world matrix
  113988. */
  113989. computeWorldMatrix(force?: boolean): Matrix;
  113990. /**
  113991. * Releases resources associated with this node.
  113992. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113993. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113994. */
  113995. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113996. /**
  113997. * Parse animation range data from a serialization object and store them into a given node
  113998. * @param node defines where to store the animation ranges
  113999. * @param parsedNode defines the serialization object to read data from
  114000. * @param scene defines the hosting scene
  114001. */
  114002. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  114003. /**
  114004. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  114005. * @param includeDescendants Include bounding info from descendants as well (true by default)
  114006. * @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
  114007. * @returns the new bounding vectors
  114008. */
  114009. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  114010. min: Vector3;
  114011. max: Vector3;
  114012. };
  114013. }
  114014. }
  114015. declare module BABYLON {
  114016. /**
  114017. * @hidden
  114018. */
  114019. export class _IAnimationState {
  114020. key: number;
  114021. repeatCount: number;
  114022. workValue?: any;
  114023. loopMode?: number;
  114024. offsetValue?: any;
  114025. highLimitValue?: any;
  114026. }
  114027. /**
  114028. * Class used to store any kind of animation
  114029. */
  114030. export class Animation {
  114031. /**Name of the animation */
  114032. name: string;
  114033. /**Property to animate */
  114034. targetProperty: string;
  114035. /**The frames per second of the animation */
  114036. framePerSecond: number;
  114037. /**The data type of the animation */
  114038. dataType: number;
  114039. /**The loop mode of the animation */
  114040. loopMode?: number | undefined;
  114041. /**Specifies if blending should be enabled */
  114042. enableBlending?: boolean | undefined;
  114043. /**
  114044. * Use matrix interpolation instead of using direct key value when animating matrices
  114045. */
  114046. static AllowMatricesInterpolation: boolean;
  114047. /**
  114048. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  114049. */
  114050. static AllowMatrixDecomposeForInterpolation: boolean;
  114051. /** Define the Url to load snippets */
  114052. static SnippetUrl: string;
  114053. /** Snippet ID if the animation was created from the snippet server */
  114054. snippetId: string;
  114055. /**
  114056. * Stores the key frames of the animation
  114057. */
  114058. private _keys;
  114059. /**
  114060. * Stores the easing function of the animation
  114061. */
  114062. private _easingFunction;
  114063. /**
  114064. * @hidden Internal use only
  114065. */
  114066. _runtimeAnimations: RuntimeAnimation[];
  114067. /**
  114068. * The set of event that will be linked to this animation
  114069. */
  114070. private _events;
  114071. /**
  114072. * Stores an array of target property paths
  114073. */
  114074. targetPropertyPath: string[];
  114075. /**
  114076. * Stores the blending speed of the animation
  114077. */
  114078. blendingSpeed: number;
  114079. /**
  114080. * Stores the animation ranges for the animation
  114081. */
  114082. private _ranges;
  114083. /**
  114084. * @hidden Internal use
  114085. */
  114086. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  114087. /**
  114088. * Sets up an animation
  114089. * @param property The property to animate
  114090. * @param animationType The animation type to apply
  114091. * @param framePerSecond The frames per second of the animation
  114092. * @param easingFunction The easing function used in the animation
  114093. * @returns The created animation
  114094. */
  114095. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  114096. /**
  114097. * Create and start an animation on a node
  114098. * @param name defines the name of the global animation that will be run on all nodes
  114099. * @param node defines the root node where the animation will take place
  114100. * @param targetProperty defines property to animate
  114101. * @param framePerSecond defines the number of frame per second yo use
  114102. * @param totalFrame defines the number of frames in total
  114103. * @param from defines the initial value
  114104. * @param to defines the final value
  114105. * @param loopMode defines which loop mode you want to use (off by default)
  114106. * @param easingFunction defines the easing function to use (linear by default)
  114107. * @param onAnimationEnd defines the callback to call when animation end
  114108. * @returns the animatable created for this animation
  114109. */
  114110. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  114111. /**
  114112. * Create and start an animation on a node and its descendants
  114113. * @param name defines the name of the global animation that will be run on all nodes
  114114. * @param node defines the root node where the animation will take place
  114115. * @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
  114116. * @param targetProperty defines property to animate
  114117. * @param framePerSecond defines the number of frame per second to use
  114118. * @param totalFrame defines the number of frames in total
  114119. * @param from defines the initial value
  114120. * @param to defines the final value
  114121. * @param loopMode defines which loop mode you want to use (off by default)
  114122. * @param easingFunction defines the easing function to use (linear by default)
  114123. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  114124. * @returns the list of animatables created for all nodes
  114125. * @example https://www.babylonjs-playground.com/#MH0VLI
  114126. */
  114127. 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[]>;
  114128. /**
  114129. * Creates a new animation, merges it with the existing animations and starts it
  114130. * @param name Name of the animation
  114131. * @param node Node which contains the scene that begins the animations
  114132. * @param targetProperty Specifies which property to animate
  114133. * @param framePerSecond The frames per second of the animation
  114134. * @param totalFrame The total number of frames
  114135. * @param from The frame at the beginning of the animation
  114136. * @param to The frame at the end of the animation
  114137. * @param loopMode Specifies the loop mode of the animation
  114138. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  114139. * @param onAnimationEnd Callback to run once the animation is complete
  114140. * @returns Nullable animation
  114141. */
  114142. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  114143. /**
  114144. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  114145. * @param sourceAnimation defines the Animation containing keyframes to convert
  114146. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  114147. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  114148. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  114149. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  114150. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  114151. */
  114152. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  114153. /**
  114154. * Transition property of an host to the target Value
  114155. * @param property The property to transition
  114156. * @param targetValue The target Value of the property
  114157. * @param host The object where the property to animate belongs
  114158. * @param scene Scene used to run the animation
  114159. * @param frameRate Framerate (in frame/s) to use
  114160. * @param transition The transition type we want to use
  114161. * @param duration The duration of the animation, in milliseconds
  114162. * @param onAnimationEnd Callback trigger at the end of the animation
  114163. * @returns Nullable animation
  114164. */
  114165. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  114166. /**
  114167. * Return the array of runtime animations currently using this animation
  114168. */
  114169. get runtimeAnimations(): RuntimeAnimation[];
  114170. /**
  114171. * Specifies if any of the runtime animations are currently running
  114172. */
  114173. get hasRunningRuntimeAnimations(): boolean;
  114174. /**
  114175. * Initializes the animation
  114176. * @param name Name of the animation
  114177. * @param targetProperty Property to animate
  114178. * @param framePerSecond The frames per second of the animation
  114179. * @param dataType The data type of the animation
  114180. * @param loopMode The loop mode of the animation
  114181. * @param enableBlending Specifies if blending should be enabled
  114182. */
  114183. constructor(
  114184. /**Name of the animation */
  114185. name: string,
  114186. /**Property to animate */
  114187. targetProperty: string,
  114188. /**The frames per second of the animation */
  114189. framePerSecond: number,
  114190. /**The data type of the animation */
  114191. dataType: number,
  114192. /**The loop mode of the animation */
  114193. loopMode?: number | undefined,
  114194. /**Specifies if blending should be enabled */
  114195. enableBlending?: boolean | undefined);
  114196. /**
  114197. * Converts the animation to a string
  114198. * @param fullDetails support for multiple levels of logging within scene loading
  114199. * @returns String form of the animation
  114200. */
  114201. toString(fullDetails?: boolean): string;
  114202. /**
  114203. * Add an event to this animation
  114204. * @param event Event to add
  114205. */
  114206. addEvent(event: AnimationEvent): void;
  114207. /**
  114208. * Remove all events found at the given frame
  114209. * @param frame The frame to remove events from
  114210. */
  114211. removeEvents(frame: number): void;
  114212. /**
  114213. * Retrieves all the events from the animation
  114214. * @returns Events from the animation
  114215. */
  114216. getEvents(): AnimationEvent[];
  114217. /**
  114218. * Creates an animation range
  114219. * @param name Name of the animation range
  114220. * @param from Starting frame of the animation range
  114221. * @param to Ending frame of the animation
  114222. */
  114223. createRange(name: string, from: number, to: number): void;
  114224. /**
  114225. * Deletes an animation range by name
  114226. * @param name Name of the animation range to delete
  114227. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  114228. */
  114229. deleteRange(name: string, deleteFrames?: boolean): void;
  114230. /**
  114231. * Gets the animation range by name, or null if not defined
  114232. * @param name Name of the animation range
  114233. * @returns Nullable animation range
  114234. */
  114235. getRange(name: string): Nullable<AnimationRange>;
  114236. /**
  114237. * Gets the key frames from the animation
  114238. * @returns The key frames of the animation
  114239. */
  114240. getKeys(): Array<IAnimationKey>;
  114241. /**
  114242. * Gets the highest frame rate of the animation
  114243. * @returns Highest frame rate of the animation
  114244. */
  114245. getHighestFrame(): number;
  114246. /**
  114247. * Gets the easing function of the animation
  114248. * @returns Easing function of the animation
  114249. */
  114250. getEasingFunction(): IEasingFunction;
  114251. /**
  114252. * Sets the easing function of the animation
  114253. * @param easingFunction A custom mathematical formula for animation
  114254. */
  114255. setEasingFunction(easingFunction: EasingFunction): void;
  114256. /**
  114257. * Interpolates a scalar linearly
  114258. * @param startValue Start value of the animation curve
  114259. * @param endValue End value of the animation curve
  114260. * @param gradient Scalar amount to interpolate
  114261. * @returns Interpolated scalar value
  114262. */
  114263. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  114264. /**
  114265. * Interpolates a scalar cubically
  114266. * @param startValue Start value of the animation curve
  114267. * @param outTangent End tangent of the animation
  114268. * @param endValue End value of the animation curve
  114269. * @param inTangent Start tangent of the animation curve
  114270. * @param gradient Scalar amount to interpolate
  114271. * @returns Interpolated scalar value
  114272. */
  114273. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  114274. /**
  114275. * Interpolates a quaternion using a spherical linear interpolation
  114276. * @param startValue Start value of the animation curve
  114277. * @param endValue End value of the animation curve
  114278. * @param gradient Scalar amount to interpolate
  114279. * @returns Interpolated quaternion value
  114280. */
  114281. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  114282. /**
  114283. * Interpolates a quaternion cubically
  114284. * @param startValue Start value of the animation curve
  114285. * @param outTangent End tangent of the animation curve
  114286. * @param endValue End value of the animation curve
  114287. * @param inTangent Start tangent of the animation curve
  114288. * @param gradient Scalar amount to interpolate
  114289. * @returns Interpolated quaternion value
  114290. */
  114291. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  114292. /**
  114293. * Interpolates a Vector3 linearl
  114294. * @param startValue Start value of the animation curve
  114295. * @param endValue End value of the animation curve
  114296. * @param gradient Scalar amount to interpolate
  114297. * @returns Interpolated scalar value
  114298. */
  114299. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  114300. /**
  114301. * Interpolates a Vector3 cubically
  114302. * @param startValue Start value of the animation curve
  114303. * @param outTangent End tangent of the animation
  114304. * @param endValue End value of the animation curve
  114305. * @param inTangent Start tangent of the animation curve
  114306. * @param gradient Scalar amount to interpolate
  114307. * @returns InterpolatedVector3 value
  114308. */
  114309. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  114310. /**
  114311. * Interpolates a Vector2 linearly
  114312. * @param startValue Start value of the animation curve
  114313. * @param endValue End value of the animation curve
  114314. * @param gradient Scalar amount to interpolate
  114315. * @returns Interpolated Vector2 value
  114316. */
  114317. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  114318. /**
  114319. * Interpolates a Vector2 cubically
  114320. * @param startValue Start value of the animation curve
  114321. * @param outTangent End tangent of the animation
  114322. * @param endValue End value of the animation curve
  114323. * @param inTangent Start tangent of the animation curve
  114324. * @param gradient Scalar amount to interpolate
  114325. * @returns Interpolated Vector2 value
  114326. */
  114327. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  114328. /**
  114329. * Interpolates a size linearly
  114330. * @param startValue Start value of the animation curve
  114331. * @param endValue End value of the animation curve
  114332. * @param gradient Scalar amount to interpolate
  114333. * @returns Interpolated Size value
  114334. */
  114335. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  114336. /**
  114337. * Interpolates a Color3 linearly
  114338. * @param startValue Start value of the animation curve
  114339. * @param endValue End value of the animation curve
  114340. * @param gradient Scalar amount to interpolate
  114341. * @returns Interpolated Color3 value
  114342. */
  114343. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  114344. /**
  114345. * Interpolates a Color4 linearly
  114346. * @param startValue Start value of the animation curve
  114347. * @param endValue End value of the animation curve
  114348. * @param gradient Scalar amount to interpolate
  114349. * @returns Interpolated Color3 value
  114350. */
  114351. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  114352. /**
  114353. * @hidden Internal use only
  114354. */
  114355. _getKeyValue(value: any): any;
  114356. /**
  114357. * @hidden Internal use only
  114358. */
  114359. _interpolate(currentFrame: number, state: _IAnimationState): any;
  114360. /**
  114361. * Defines the function to use to interpolate matrices
  114362. * @param startValue defines the start matrix
  114363. * @param endValue defines the end matrix
  114364. * @param gradient defines the gradient between both matrices
  114365. * @param result defines an optional target matrix where to store the interpolation
  114366. * @returns the interpolated matrix
  114367. */
  114368. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  114369. /**
  114370. * Makes a copy of the animation
  114371. * @returns Cloned animation
  114372. */
  114373. clone(): Animation;
  114374. /**
  114375. * Sets the key frames of the animation
  114376. * @param values The animation key frames to set
  114377. */
  114378. setKeys(values: Array<IAnimationKey>): void;
  114379. /**
  114380. * Serializes the animation to an object
  114381. * @returns Serialized object
  114382. */
  114383. serialize(): any;
  114384. /**
  114385. * Float animation type
  114386. */
  114387. static readonly ANIMATIONTYPE_FLOAT: number;
  114388. /**
  114389. * Vector3 animation type
  114390. */
  114391. static readonly ANIMATIONTYPE_VECTOR3: number;
  114392. /**
  114393. * Quaternion animation type
  114394. */
  114395. static readonly ANIMATIONTYPE_QUATERNION: number;
  114396. /**
  114397. * Matrix animation type
  114398. */
  114399. static readonly ANIMATIONTYPE_MATRIX: number;
  114400. /**
  114401. * Color3 animation type
  114402. */
  114403. static readonly ANIMATIONTYPE_COLOR3: number;
  114404. /**
  114405. * Color3 animation type
  114406. */
  114407. static readonly ANIMATIONTYPE_COLOR4: number;
  114408. /**
  114409. * Vector2 animation type
  114410. */
  114411. static readonly ANIMATIONTYPE_VECTOR2: number;
  114412. /**
  114413. * Size animation type
  114414. */
  114415. static readonly ANIMATIONTYPE_SIZE: number;
  114416. /**
  114417. * Relative Loop Mode
  114418. */
  114419. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  114420. /**
  114421. * Cycle Loop Mode
  114422. */
  114423. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  114424. /**
  114425. * Constant Loop Mode
  114426. */
  114427. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  114428. /** @hidden */
  114429. static _UniversalLerp(left: any, right: any, amount: number): any;
  114430. /**
  114431. * Parses an animation object and creates an animation
  114432. * @param parsedAnimation Parsed animation object
  114433. * @returns Animation object
  114434. */
  114435. static Parse(parsedAnimation: any): Animation;
  114436. /**
  114437. * Appends the serialized animations from the source animations
  114438. * @param source Source containing the animations
  114439. * @param destination Target to store the animations
  114440. */
  114441. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114442. /**
  114443. * Creates a new animation or an array of animations from a snippet saved in a remote file
  114444. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  114445. * @param url defines the url to load from
  114446. * @returns a promise that will resolve to the new animation or an array of animations
  114447. */
  114448. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  114449. /**
  114450. * Creates an animation or an array of animations from a snippet saved by the Inspector
  114451. * @param snippetId defines the snippet to load
  114452. * @returns a promise that will resolve to the new animation or a new array of animations
  114453. */
  114454. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  114455. }
  114456. }
  114457. declare module BABYLON {
  114458. /**
  114459. * Interface containing an array of animations
  114460. */
  114461. export interface IAnimatable {
  114462. /**
  114463. * Array of animations
  114464. */
  114465. animations: Nullable<Array<Animation>>;
  114466. }
  114467. }
  114468. declare module BABYLON {
  114469. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  114470. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114471. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114472. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114473. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114474. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114475. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114476. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114477. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114478. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114479. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114480. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114481. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114482. /**
  114483. * Decorator used to define property that can be serialized as reference to a camera
  114484. * @param sourceName defines the name of the property to decorate
  114485. */
  114486. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114487. /**
  114488. * Class used to help serialization objects
  114489. */
  114490. export class SerializationHelper {
  114491. /** @hidden */
  114492. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  114493. /** @hidden */
  114494. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  114495. /** @hidden */
  114496. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  114497. /** @hidden */
  114498. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  114499. /**
  114500. * Appends the serialized animations from the source animations
  114501. * @param source Source containing the animations
  114502. * @param destination Target to store the animations
  114503. */
  114504. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114505. /**
  114506. * Static function used to serialized a specific entity
  114507. * @param entity defines the entity to serialize
  114508. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  114509. * @returns a JSON compatible object representing the serialization of the entity
  114510. */
  114511. static Serialize<T>(entity: T, serializationObject?: any): any;
  114512. /**
  114513. * Creates a new entity from a serialization data object
  114514. * @param creationFunction defines a function used to instanciated the new entity
  114515. * @param source defines the source serialization data
  114516. * @param scene defines the hosting scene
  114517. * @param rootUrl defines the root url for resources
  114518. * @returns a new entity
  114519. */
  114520. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  114521. /**
  114522. * Clones an object
  114523. * @param creationFunction defines the function used to instanciate the new object
  114524. * @param source defines the source object
  114525. * @returns the cloned object
  114526. */
  114527. static Clone<T>(creationFunction: () => T, source: T): T;
  114528. /**
  114529. * Instanciates a new object based on a source one (some data will be shared between both object)
  114530. * @param creationFunction defines the function used to instanciate the new object
  114531. * @param source defines the source object
  114532. * @returns the new object
  114533. */
  114534. static Instanciate<T>(creationFunction: () => T, source: T): T;
  114535. }
  114536. }
  114537. declare module BABYLON {
  114538. /**
  114539. * Base class of all the textures in babylon.
  114540. * It groups all the common properties the materials, post process, lights... might need
  114541. * in order to make a correct use of the texture.
  114542. */
  114543. export class BaseTexture implements IAnimatable {
  114544. /**
  114545. * Default anisotropic filtering level for the application.
  114546. * It is set to 4 as a good tradeoff between perf and quality.
  114547. */
  114548. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  114549. /**
  114550. * Gets or sets the unique id of the texture
  114551. */
  114552. uniqueId: number;
  114553. /**
  114554. * Define the name of the texture.
  114555. */
  114556. name: string;
  114557. /**
  114558. * Gets or sets an object used to store user defined information.
  114559. */
  114560. metadata: any;
  114561. /**
  114562. * For internal use only. Please do not use.
  114563. */
  114564. reservedDataStore: any;
  114565. private _hasAlpha;
  114566. /**
  114567. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  114568. */
  114569. set hasAlpha(value: boolean);
  114570. get hasAlpha(): boolean;
  114571. /**
  114572. * Defines if the alpha value should be determined via the rgb values.
  114573. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  114574. */
  114575. getAlphaFromRGB: boolean;
  114576. /**
  114577. * Intensity or strength of the texture.
  114578. * It is commonly used by materials to fine tune the intensity of the texture
  114579. */
  114580. level: number;
  114581. /**
  114582. * Define the UV chanel to use starting from 0 and defaulting to 0.
  114583. * This is part of the texture as textures usually maps to one uv set.
  114584. */
  114585. coordinatesIndex: number;
  114586. protected _coordinatesMode: number;
  114587. /**
  114588. * How a texture is mapped.
  114589. *
  114590. * | Value | Type | Description |
  114591. * | ----- | ----------------------------------- | ----------- |
  114592. * | 0 | EXPLICIT_MODE | |
  114593. * | 1 | SPHERICAL_MODE | |
  114594. * | 2 | PLANAR_MODE | |
  114595. * | 3 | CUBIC_MODE | |
  114596. * | 4 | PROJECTION_MODE | |
  114597. * | 5 | SKYBOX_MODE | |
  114598. * | 6 | INVCUBIC_MODE | |
  114599. * | 7 | EQUIRECTANGULAR_MODE | |
  114600. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  114601. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  114602. */
  114603. set coordinatesMode(value: number);
  114604. get coordinatesMode(): number;
  114605. private _wrapU;
  114606. /**
  114607. * | Value | Type | Description |
  114608. * | ----- | ------------------ | ----------- |
  114609. * | 0 | CLAMP_ADDRESSMODE | |
  114610. * | 1 | WRAP_ADDRESSMODE | |
  114611. * | 2 | MIRROR_ADDRESSMODE | |
  114612. */
  114613. get wrapU(): number;
  114614. set wrapU(value: number);
  114615. private _wrapV;
  114616. /**
  114617. * | Value | Type | Description |
  114618. * | ----- | ------------------ | ----------- |
  114619. * | 0 | CLAMP_ADDRESSMODE | |
  114620. * | 1 | WRAP_ADDRESSMODE | |
  114621. * | 2 | MIRROR_ADDRESSMODE | |
  114622. */
  114623. get wrapV(): number;
  114624. set wrapV(value: number);
  114625. /**
  114626. * | Value | Type | Description |
  114627. * | ----- | ------------------ | ----------- |
  114628. * | 0 | CLAMP_ADDRESSMODE | |
  114629. * | 1 | WRAP_ADDRESSMODE | |
  114630. * | 2 | MIRROR_ADDRESSMODE | |
  114631. */
  114632. wrapR: number;
  114633. /**
  114634. * With compliant hardware and browser (supporting anisotropic filtering)
  114635. * this defines the level of anisotropic filtering in the texture.
  114636. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  114637. */
  114638. anisotropicFilteringLevel: number;
  114639. /**
  114640. * Define if the texture is a cube texture or if false a 2d texture.
  114641. */
  114642. get isCube(): boolean;
  114643. set isCube(value: boolean);
  114644. /**
  114645. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  114646. */
  114647. get is3D(): boolean;
  114648. set is3D(value: boolean);
  114649. /**
  114650. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  114651. */
  114652. get is2DArray(): boolean;
  114653. set is2DArray(value: boolean);
  114654. private _gammaSpace;
  114655. /**
  114656. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  114657. * HDR texture are usually stored in linear space.
  114658. * This only impacts the PBR and Background materials
  114659. */
  114660. get gammaSpace(): boolean;
  114661. set gammaSpace(gamma: boolean);
  114662. /**
  114663. * Gets or sets whether or not the texture contains RGBD data.
  114664. */
  114665. get isRGBD(): boolean;
  114666. set isRGBD(value: boolean);
  114667. /**
  114668. * Is Z inverted in the texture (useful in a cube texture).
  114669. */
  114670. invertZ: boolean;
  114671. /**
  114672. * Are mip maps generated for this texture or not.
  114673. */
  114674. get noMipmap(): boolean;
  114675. /**
  114676. * @hidden
  114677. */
  114678. lodLevelInAlpha: boolean;
  114679. /**
  114680. * With prefiltered texture, defined the offset used during the prefiltering steps.
  114681. */
  114682. get lodGenerationOffset(): number;
  114683. set lodGenerationOffset(value: number);
  114684. /**
  114685. * With prefiltered texture, defined the scale used during the prefiltering steps.
  114686. */
  114687. get lodGenerationScale(): number;
  114688. set lodGenerationScale(value: number);
  114689. /**
  114690. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  114691. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  114692. * average roughness values.
  114693. */
  114694. get linearSpecularLOD(): boolean;
  114695. set linearSpecularLOD(value: boolean);
  114696. /**
  114697. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  114698. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  114699. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  114700. */
  114701. get irradianceTexture(): Nullable<BaseTexture>;
  114702. set irradianceTexture(value: Nullable<BaseTexture>);
  114703. /**
  114704. * Define if the texture is a render target.
  114705. */
  114706. isRenderTarget: boolean;
  114707. /**
  114708. * Define the unique id of the texture in the scene.
  114709. */
  114710. get uid(): string;
  114711. /** @hidden */
  114712. _prefiltered: boolean;
  114713. /**
  114714. * Return a string representation of the texture.
  114715. * @returns the texture as a string
  114716. */
  114717. toString(): string;
  114718. /**
  114719. * Get the class name of the texture.
  114720. * @returns "BaseTexture"
  114721. */
  114722. getClassName(): string;
  114723. /**
  114724. * Define the list of animation attached to the texture.
  114725. */
  114726. animations: Animation[];
  114727. /**
  114728. * An event triggered when the texture is disposed.
  114729. */
  114730. onDisposeObservable: Observable<BaseTexture>;
  114731. private _onDisposeObserver;
  114732. /**
  114733. * Callback triggered when the texture has been disposed.
  114734. * Kept for back compatibility, you can use the onDisposeObservable instead.
  114735. */
  114736. set onDispose(callback: () => void);
  114737. /**
  114738. * Define the current state of the loading sequence when in delayed load mode.
  114739. */
  114740. delayLoadState: number;
  114741. protected _scene: Nullable<Scene>;
  114742. protected _engine: Nullable<ThinEngine>;
  114743. /** @hidden */
  114744. _texture: Nullable<InternalTexture>;
  114745. private _uid;
  114746. /**
  114747. * Define if the texture is preventinga material to render or not.
  114748. * If not and the texture is not ready, the engine will use a default black texture instead.
  114749. */
  114750. get isBlocking(): boolean;
  114751. /**
  114752. * Instantiates a new BaseTexture.
  114753. * Base class of all the textures in babylon.
  114754. * It groups all the common properties the materials, post process, lights... might need
  114755. * in order to make a correct use of the texture.
  114756. * @param sceneOrEngine Define the scene or engine the texture blongs to
  114757. */
  114758. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  114759. /**
  114760. * Get the scene the texture belongs to.
  114761. * @returns the scene or null if undefined
  114762. */
  114763. getScene(): Nullable<Scene>;
  114764. /** @hidden */
  114765. protected _getEngine(): Nullable<ThinEngine>;
  114766. /**
  114767. * Get the texture transform matrix used to offset tile the texture for istance.
  114768. * @returns the transformation matrix
  114769. */
  114770. getTextureMatrix(): Matrix;
  114771. /**
  114772. * Get the texture reflection matrix used to rotate/transform the reflection.
  114773. * @returns the reflection matrix
  114774. */
  114775. getReflectionTextureMatrix(): Matrix;
  114776. /**
  114777. * Get the underlying lower level texture from Babylon.
  114778. * @returns the insternal texture
  114779. */
  114780. getInternalTexture(): Nullable<InternalTexture>;
  114781. /**
  114782. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  114783. * @returns true if ready or not blocking
  114784. */
  114785. isReadyOrNotBlocking(): boolean;
  114786. /**
  114787. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  114788. * @returns true if fully ready
  114789. */
  114790. isReady(): boolean;
  114791. private _cachedSize;
  114792. /**
  114793. * Get the size of the texture.
  114794. * @returns the texture size.
  114795. */
  114796. getSize(): ISize;
  114797. /**
  114798. * Get the base size of the texture.
  114799. * It can be different from the size if the texture has been resized for POT for instance
  114800. * @returns the base size
  114801. */
  114802. getBaseSize(): ISize;
  114803. /**
  114804. * Update the sampling mode of the texture.
  114805. * Default is Trilinear mode.
  114806. *
  114807. * | Value | Type | Description |
  114808. * | ----- | ------------------ | ----------- |
  114809. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  114810. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  114811. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  114812. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  114813. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  114814. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  114815. * | 7 | NEAREST_LINEAR | |
  114816. * | 8 | NEAREST_NEAREST | |
  114817. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  114818. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  114819. * | 11 | LINEAR_LINEAR | |
  114820. * | 12 | LINEAR_NEAREST | |
  114821. *
  114822. * > _mag_: magnification filter (close to the viewer)
  114823. * > _min_: minification filter (far from the viewer)
  114824. * > _mip_: filter used between mip map levels
  114825. *@param samplingMode Define the new sampling mode of the texture
  114826. */
  114827. updateSamplingMode(samplingMode: number): void;
  114828. /**
  114829. * Scales the texture if is `canRescale()`
  114830. * @param ratio the resize factor we want to use to rescale
  114831. */
  114832. scale(ratio: number): void;
  114833. /**
  114834. * Get if the texture can rescale.
  114835. */
  114836. get canRescale(): boolean;
  114837. /** @hidden */
  114838. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  114839. /** @hidden */
  114840. _rebuild(): void;
  114841. /**
  114842. * Triggers the load sequence in delayed load mode.
  114843. */
  114844. delayLoad(): void;
  114845. /**
  114846. * Clones the texture.
  114847. * @returns the cloned texture
  114848. */
  114849. clone(): Nullable<BaseTexture>;
  114850. /**
  114851. * Get the texture underlying type (INT, FLOAT...)
  114852. */
  114853. get textureType(): number;
  114854. /**
  114855. * Get the texture underlying format (RGB, RGBA...)
  114856. */
  114857. get textureFormat(): number;
  114858. /**
  114859. * Indicates that textures need to be re-calculated for all materials
  114860. */
  114861. protected _markAllSubMeshesAsTexturesDirty(): void;
  114862. /**
  114863. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  114864. * This will returns an RGBA array buffer containing either in values (0-255) or
  114865. * float values (0-1) depending of the underlying buffer type.
  114866. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  114867. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  114868. * @param buffer defines a user defined buffer to fill with data (can be null)
  114869. * @returns The Array buffer containing the pixels data.
  114870. */
  114871. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  114872. /**
  114873. * Release and destroy the underlying lower level texture aka internalTexture.
  114874. */
  114875. releaseInternalTexture(): void;
  114876. /** @hidden */
  114877. get _lodTextureHigh(): Nullable<BaseTexture>;
  114878. /** @hidden */
  114879. get _lodTextureMid(): Nullable<BaseTexture>;
  114880. /** @hidden */
  114881. get _lodTextureLow(): Nullable<BaseTexture>;
  114882. /**
  114883. * Dispose the texture and release its associated resources.
  114884. */
  114885. dispose(): void;
  114886. /**
  114887. * Serialize the texture into a JSON representation that can be parsed later on.
  114888. * @returns the JSON representation of the texture
  114889. */
  114890. serialize(): any;
  114891. /**
  114892. * Helper function to be called back once a list of texture contains only ready textures.
  114893. * @param textures Define the list of textures to wait for
  114894. * @param callback Define the callback triggered once the entire list will be ready
  114895. */
  114896. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  114897. private static _isScene;
  114898. }
  114899. }
  114900. declare module BABYLON {
  114901. /**
  114902. * Options to be used when creating an effect.
  114903. */
  114904. export interface IEffectCreationOptions {
  114905. /**
  114906. * Atrributes that will be used in the shader.
  114907. */
  114908. attributes: string[];
  114909. /**
  114910. * Uniform varible names that will be set in the shader.
  114911. */
  114912. uniformsNames: string[];
  114913. /**
  114914. * Uniform buffer variable names that will be set in the shader.
  114915. */
  114916. uniformBuffersNames: string[];
  114917. /**
  114918. * Sampler texture variable names that will be set in the shader.
  114919. */
  114920. samplers: string[];
  114921. /**
  114922. * Define statements that will be set in the shader.
  114923. */
  114924. defines: any;
  114925. /**
  114926. * Possible fallbacks for this effect to improve performance when needed.
  114927. */
  114928. fallbacks: Nullable<IEffectFallbacks>;
  114929. /**
  114930. * Callback that will be called when the shader is compiled.
  114931. */
  114932. onCompiled: Nullable<(effect: Effect) => void>;
  114933. /**
  114934. * Callback that will be called if an error occurs during shader compilation.
  114935. */
  114936. onError: Nullable<(effect: Effect, errors: string) => void>;
  114937. /**
  114938. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114939. */
  114940. indexParameters?: any;
  114941. /**
  114942. * Max number of lights that can be used in the shader.
  114943. */
  114944. maxSimultaneousLights?: number;
  114945. /**
  114946. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114947. */
  114948. transformFeedbackVaryings?: Nullable<string[]>;
  114949. /**
  114950. * 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
  114951. */
  114952. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114953. /**
  114954. * Is this effect rendering to several color attachments ?
  114955. */
  114956. multiTarget?: boolean;
  114957. }
  114958. /**
  114959. * Effect containing vertex and fragment shader that can be executed on an object.
  114960. */
  114961. export class Effect implements IDisposable {
  114962. /**
  114963. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114964. */
  114965. static ShadersRepository: string;
  114966. /**
  114967. * Enable logging of the shader code when a compilation error occurs
  114968. */
  114969. static LogShaderCodeOnCompilationError: boolean;
  114970. /**
  114971. * Name of the effect.
  114972. */
  114973. name: any;
  114974. /**
  114975. * String container all the define statements that should be set on the shader.
  114976. */
  114977. defines: string;
  114978. /**
  114979. * Callback that will be called when the shader is compiled.
  114980. */
  114981. onCompiled: Nullable<(effect: Effect) => void>;
  114982. /**
  114983. * Callback that will be called if an error occurs during shader compilation.
  114984. */
  114985. onError: Nullable<(effect: Effect, errors: string) => void>;
  114986. /**
  114987. * Callback that will be called when effect is bound.
  114988. */
  114989. onBind: Nullable<(effect: Effect) => void>;
  114990. /**
  114991. * Unique ID of the effect.
  114992. */
  114993. uniqueId: number;
  114994. /**
  114995. * Observable that will be called when the shader is compiled.
  114996. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114997. */
  114998. onCompileObservable: Observable<Effect>;
  114999. /**
  115000. * Observable that will be called if an error occurs during shader compilation.
  115001. */
  115002. onErrorObservable: Observable<Effect>;
  115003. /** @hidden */
  115004. _onBindObservable: Nullable<Observable<Effect>>;
  115005. /**
  115006. * @hidden
  115007. * Specifies if the effect was previously ready
  115008. */
  115009. _wasPreviouslyReady: boolean;
  115010. /**
  115011. * Observable that will be called when effect is bound.
  115012. */
  115013. get onBindObservable(): Observable<Effect>;
  115014. /** @hidden */
  115015. _bonesComputationForcedToCPU: boolean;
  115016. /** @hidden */
  115017. _multiTarget: boolean;
  115018. private static _uniqueIdSeed;
  115019. private _engine;
  115020. private _uniformBuffersNames;
  115021. private _uniformBuffersNamesList;
  115022. private _uniformsNames;
  115023. private _samplerList;
  115024. private _samplers;
  115025. private _isReady;
  115026. private _compilationError;
  115027. private _allFallbacksProcessed;
  115028. private _attributesNames;
  115029. private _attributes;
  115030. private _attributeLocationByName;
  115031. private _uniforms;
  115032. /**
  115033. * Key for the effect.
  115034. * @hidden
  115035. */
  115036. _key: string;
  115037. private _indexParameters;
  115038. private _fallbacks;
  115039. private _vertexSourceCode;
  115040. private _fragmentSourceCode;
  115041. private _vertexSourceCodeOverride;
  115042. private _fragmentSourceCodeOverride;
  115043. private _transformFeedbackVaryings;
  115044. /**
  115045. * Compiled shader to webGL program.
  115046. * @hidden
  115047. */
  115048. _pipelineContext: Nullable<IPipelineContext>;
  115049. private _valueCache;
  115050. private static _baseCache;
  115051. /**
  115052. * Instantiates an effect.
  115053. * An effect can be used to create/manage/execute vertex and fragment shaders.
  115054. * @param baseName Name of the effect.
  115055. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  115056. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  115057. * @param samplers List of sampler variables that will be passed to the shader.
  115058. * @param engine Engine to be used to render the effect
  115059. * @param defines Define statements to be added to the shader.
  115060. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  115061. * @param onCompiled Callback that will be called when the shader is compiled.
  115062. * @param onError Callback that will be called if an error occurs during shader compilation.
  115063. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  115064. */
  115065. 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);
  115066. private _useFinalCode;
  115067. /**
  115068. * Unique key for this effect
  115069. */
  115070. get key(): string;
  115071. /**
  115072. * If the effect has been compiled and prepared.
  115073. * @returns if the effect is compiled and prepared.
  115074. */
  115075. isReady(): boolean;
  115076. private _isReadyInternal;
  115077. /**
  115078. * The engine the effect was initialized with.
  115079. * @returns the engine.
  115080. */
  115081. getEngine(): Engine;
  115082. /**
  115083. * The pipeline context for this effect
  115084. * @returns the associated pipeline context
  115085. */
  115086. getPipelineContext(): Nullable<IPipelineContext>;
  115087. /**
  115088. * The set of names of attribute variables for the shader.
  115089. * @returns An array of attribute names.
  115090. */
  115091. getAttributesNames(): string[];
  115092. /**
  115093. * Returns the attribute at the given index.
  115094. * @param index The index of the attribute.
  115095. * @returns The location of the attribute.
  115096. */
  115097. getAttributeLocation(index: number): number;
  115098. /**
  115099. * Returns the attribute based on the name of the variable.
  115100. * @param name of the attribute to look up.
  115101. * @returns the attribute location.
  115102. */
  115103. getAttributeLocationByName(name: string): number;
  115104. /**
  115105. * The number of attributes.
  115106. * @returns the numnber of attributes.
  115107. */
  115108. getAttributesCount(): number;
  115109. /**
  115110. * Gets the index of a uniform variable.
  115111. * @param uniformName of the uniform to look up.
  115112. * @returns the index.
  115113. */
  115114. getUniformIndex(uniformName: string): number;
  115115. /**
  115116. * Returns the attribute based on the name of the variable.
  115117. * @param uniformName of the uniform to look up.
  115118. * @returns the location of the uniform.
  115119. */
  115120. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  115121. /**
  115122. * Returns an array of sampler variable names
  115123. * @returns The array of sampler variable names.
  115124. */
  115125. getSamplers(): string[];
  115126. /**
  115127. * Returns an array of uniform variable names
  115128. * @returns The array of uniform variable names.
  115129. */
  115130. getUniformNames(): string[];
  115131. /**
  115132. * Returns an array of uniform buffer variable names
  115133. * @returns The array of uniform buffer variable names.
  115134. */
  115135. getUniformBuffersNames(): string[];
  115136. /**
  115137. * Returns the index parameters used to create the effect
  115138. * @returns The index parameters object
  115139. */
  115140. getIndexParameters(): any;
  115141. /**
  115142. * The error from the last compilation.
  115143. * @returns the error string.
  115144. */
  115145. getCompilationError(): string;
  115146. /**
  115147. * Gets a boolean indicating that all fallbacks were used during compilation
  115148. * @returns true if all fallbacks were used
  115149. */
  115150. allFallbacksProcessed(): boolean;
  115151. /**
  115152. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  115153. * @param func The callback to be used.
  115154. */
  115155. executeWhenCompiled(func: (effect: Effect) => void): void;
  115156. private _checkIsReady;
  115157. private _loadShader;
  115158. /**
  115159. * Gets the vertex shader source code of this effect
  115160. */
  115161. get vertexSourceCode(): string;
  115162. /**
  115163. * Gets the fragment shader source code of this effect
  115164. */
  115165. get fragmentSourceCode(): string;
  115166. /**
  115167. * Recompiles the webGL program
  115168. * @param vertexSourceCode The source code for the vertex shader.
  115169. * @param fragmentSourceCode The source code for the fragment shader.
  115170. * @param onCompiled Callback called when completed.
  115171. * @param onError Callback called on error.
  115172. * @hidden
  115173. */
  115174. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  115175. /**
  115176. * Prepares the effect
  115177. * @hidden
  115178. */
  115179. _prepareEffect(): void;
  115180. private _getShaderCodeAndErrorLine;
  115181. private _processCompilationErrors;
  115182. /**
  115183. * Checks if the effect is supported. (Must be called after compilation)
  115184. */
  115185. get isSupported(): boolean;
  115186. /**
  115187. * Binds a texture to the engine to be used as output of the shader.
  115188. * @param channel Name of the output variable.
  115189. * @param texture Texture to bind.
  115190. * @hidden
  115191. */
  115192. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  115193. /**
  115194. * Sets a texture on the engine to be used in the shader.
  115195. * @param channel Name of the sampler variable.
  115196. * @param texture Texture to set.
  115197. */
  115198. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  115199. /**
  115200. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  115201. * @param channel Name of the sampler variable.
  115202. * @param texture Texture to set.
  115203. */
  115204. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  115205. /**
  115206. * Sets an array of textures on the engine to be used in the shader.
  115207. * @param channel Name of the variable.
  115208. * @param textures Textures to set.
  115209. */
  115210. setTextureArray(channel: string, textures: BaseTexture[]): void;
  115211. /**
  115212. * 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)
  115213. * @param channel Name of the sampler variable.
  115214. * @param postProcess Post process to get the input texture from.
  115215. */
  115216. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  115217. /**
  115218. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  115219. * 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)
  115220. * @param channel Name of the sampler variable.
  115221. * @param postProcess Post process to get the output texture from.
  115222. */
  115223. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  115224. /** @hidden */
  115225. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  115226. /** @hidden */
  115227. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  115228. /** @hidden */
  115229. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  115230. /** @hidden */
  115231. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  115232. /**
  115233. * Binds a buffer to a uniform.
  115234. * @param buffer Buffer to bind.
  115235. * @param name Name of the uniform variable to bind to.
  115236. */
  115237. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  115238. /**
  115239. * Binds block to a uniform.
  115240. * @param blockName Name of the block to bind.
  115241. * @param index Index to bind.
  115242. */
  115243. bindUniformBlock(blockName: string, index: number): void;
  115244. /**
  115245. * Sets an interger value on a uniform variable.
  115246. * @param uniformName Name of the variable.
  115247. * @param value Value to be set.
  115248. * @returns this effect.
  115249. */
  115250. setInt(uniformName: string, value: number): Effect;
  115251. /**
  115252. * Sets an int array on a uniform variable.
  115253. * @param uniformName Name of the variable.
  115254. * @param array array to be set.
  115255. * @returns this effect.
  115256. */
  115257. setIntArray(uniformName: string, array: Int32Array): Effect;
  115258. /**
  115259. * 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)
  115260. * @param uniformName Name of the variable.
  115261. * @param array array to be set.
  115262. * @returns this effect.
  115263. */
  115264. setIntArray2(uniformName: string, array: Int32Array): Effect;
  115265. /**
  115266. * 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)
  115267. * @param uniformName Name of the variable.
  115268. * @param array array to be set.
  115269. * @returns this effect.
  115270. */
  115271. setIntArray3(uniformName: string, array: Int32Array): Effect;
  115272. /**
  115273. * 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)
  115274. * @param uniformName Name of the variable.
  115275. * @param array array to be set.
  115276. * @returns this effect.
  115277. */
  115278. setIntArray4(uniformName: string, array: Int32Array): Effect;
  115279. /**
  115280. * Sets an float array on a uniform variable.
  115281. * @param uniformName Name of the variable.
  115282. * @param array array to be set.
  115283. * @returns this effect.
  115284. */
  115285. setFloatArray(uniformName: string, array: Float32Array): Effect;
  115286. /**
  115287. * 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)
  115288. * @param uniformName Name of the variable.
  115289. * @param array array to be set.
  115290. * @returns this effect.
  115291. */
  115292. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  115293. /**
  115294. * 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)
  115295. * @param uniformName Name of the variable.
  115296. * @param array array to be set.
  115297. * @returns this effect.
  115298. */
  115299. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  115300. /**
  115301. * 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)
  115302. * @param uniformName Name of the variable.
  115303. * @param array array to be set.
  115304. * @returns this effect.
  115305. */
  115306. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  115307. /**
  115308. * Sets an array on a uniform variable.
  115309. * @param uniformName Name of the variable.
  115310. * @param array array to be set.
  115311. * @returns this effect.
  115312. */
  115313. setArray(uniformName: string, array: number[]): Effect;
  115314. /**
  115315. * 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)
  115316. * @param uniformName Name of the variable.
  115317. * @param array array to be set.
  115318. * @returns this effect.
  115319. */
  115320. setArray2(uniformName: string, array: number[]): Effect;
  115321. /**
  115322. * 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)
  115323. * @param uniformName Name of the variable.
  115324. * @param array array to be set.
  115325. * @returns this effect.
  115326. */
  115327. setArray3(uniformName: string, array: number[]): Effect;
  115328. /**
  115329. * 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)
  115330. * @param uniformName Name of the variable.
  115331. * @param array array to be set.
  115332. * @returns this effect.
  115333. */
  115334. setArray4(uniformName: string, array: number[]): Effect;
  115335. /**
  115336. * Sets matrices on a uniform variable.
  115337. * @param uniformName Name of the variable.
  115338. * @param matrices matrices to be set.
  115339. * @returns this effect.
  115340. */
  115341. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  115342. /**
  115343. * Sets matrix on a uniform variable.
  115344. * @param uniformName Name of the variable.
  115345. * @param matrix matrix to be set.
  115346. * @returns this effect.
  115347. */
  115348. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  115349. /**
  115350. * 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)
  115351. * @param uniformName Name of the variable.
  115352. * @param matrix matrix to be set.
  115353. * @returns this effect.
  115354. */
  115355. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115356. /**
  115357. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  115358. * @param uniformName Name of the variable.
  115359. * @param matrix matrix to be set.
  115360. * @returns this effect.
  115361. */
  115362. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115363. /**
  115364. * Sets a float on a uniform variable.
  115365. * @param uniformName Name of the variable.
  115366. * @param value value to be set.
  115367. * @returns this effect.
  115368. */
  115369. setFloat(uniformName: string, value: number): Effect;
  115370. /**
  115371. * Sets a boolean on a uniform variable.
  115372. * @param uniformName Name of the variable.
  115373. * @param bool value to be set.
  115374. * @returns this effect.
  115375. */
  115376. setBool(uniformName: string, bool: boolean): Effect;
  115377. /**
  115378. * Sets a Vector2 on a uniform variable.
  115379. * @param uniformName Name of the variable.
  115380. * @param vector2 vector2 to be set.
  115381. * @returns this effect.
  115382. */
  115383. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  115384. /**
  115385. * Sets a float2 on a uniform variable.
  115386. * @param uniformName Name of the variable.
  115387. * @param x First float in float2.
  115388. * @param y Second float in float2.
  115389. * @returns this effect.
  115390. */
  115391. setFloat2(uniformName: string, x: number, y: number): Effect;
  115392. /**
  115393. * Sets a Vector3 on a uniform variable.
  115394. * @param uniformName Name of the variable.
  115395. * @param vector3 Value to be set.
  115396. * @returns this effect.
  115397. */
  115398. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  115399. /**
  115400. * Sets a float3 on a uniform variable.
  115401. * @param uniformName Name of the variable.
  115402. * @param x First float in float3.
  115403. * @param y Second float in float3.
  115404. * @param z Third float in float3.
  115405. * @returns this effect.
  115406. */
  115407. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  115408. /**
  115409. * Sets a Vector4 on a uniform variable.
  115410. * @param uniformName Name of the variable.
  115411. * @param vector4 Value to be set.
  115412. * @returns this effect.
  115413. */
  115414. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  115415. /**
  115416. * Sets a float4 on a uniform variable.
  115417. * @param uniformName Name of the variable.
  115418. * @param x First float in float4.
  115419. * @param y Second float in float4.
  115420. * @param z Third float in float4.
  115421. * @param w Fourth float in float4.
  115422. * @returns this effect.
  115423. */
  115424. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  115425. /**
  115426. * Sets a Color3 on a uniform variable.
  115427. * @param uniformName Name of the variable.
  115428. * @param color3 Value to be set.
  115429. * @returns this effect.
  115430. */
  115431. setColor3(uniformName: string, color3: IColor3Like): Effect;
  115432. /**
  115433. * Sets a Color4 on a uniform variable.
  115434. * @param uniformName Name of the variable.
  115435. * @param color3 Value to be set.
  115436. * @param alpha Alpha value to be set.
  115437. * @returns this effect.
  115438. */
  115439. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  115440. /**
  115441. * Sets a Color4 on a uniform variable
  115442. * @param uniformName defines the name of the variable
  115443. * @param color4 defines the value to be set
  115444. * @returns this effect.
  115445. */
  115446. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  115447. /** Release all associated resources */
  115448. dispose(): void;
  115449. /**
  115450. * This function will add a new shader to the shader store
  115451. * @param name the name of the shader
  115452. * @param pixelShader optional pixel shader content
  115453. * @param vertexShader optional vertex shader content
  115454. */
  115455. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  115456. /**
  115457. * Store of each shader (The can be looked up using effect.key)
  115458. */
  115459. static ShadersStore: {
  115460. [key: string]: string;
  115461. };
  115462. /**
  115463. * Store of each included file for a shader (The can be looked up using effect.key)
  115464. */
  115465. static IncludesShadersStore: {
  115466. [key: string]: string;
  115467. };
  115468. /**
  115469. * Resets the cache of effects.
  115470. */
  115471. static ResetCache(): void;
  115472. }
  115473. }
  115474. declare module BABYLON {
  115475. /**
  115476. * Interface used to describe the capabilities of the engine relatively to the current browser
  115477. */
  115478. export interface EngineCapabilities {
  115479. /** Maximum textures units per fragment shader */
  115480. maxTexturesImageUnits: number;
  115481. /** Maximum texture units per vertex shader */
  115482. maxVertexTextureImageUnits: number;
  115483. /** Maximum textures units in the entire pipeline */
  115484. maxCombinedTexturesImageUnits: number;
  115485. /** Maximum texture size */
  115486. maxTextureSize: number;
  115487. /** Maximum texture samples */
  115488. maxSamples?: number;
  115489. /** Maximum cube texture size */
  115490. maxCubemapTextureSize: number;
  115491. /** Maximum render texture size */
  115492. maxRenderTextureSize: number;
  115493. /** Maximum number of vertex attributes */
  115494. maxVertexAttribs: number;
  115495. /** Maximum number of varyings */
  115496. maxVaryingVectors: number;
  115497. /** Maximum number of uniforms per vertex shader */
  115498. maxVertexUniformVectors: number;
  115499. /** Maximum number of uniforms per fragment shader */
  115500. maxFragmentUniformVectors: number;
  115501. /** Defines if standard derivates (dx/dy) are supported */
  115502. standardDerivatives: boolean;
  115503. /** Defines if s3tc texture compression is supported */
  115504. s3tc?: WEBGL_compressed_texture_s3tc;
  115505. /** Defines if pvrtc texture compression is supported */
  115506. pvrtc: any;
  115507. /** Defines if etc1 texture compression is supported */
  115508. etc1: any;
  115509. /** Defines if etc2 texture compression is supported */
  115510. etc2: any;
  115511. /** Defines if astc texture compression is supported */
  115512. astc: any;
  115513. /** Defines if bptc texture compression is supported */
  115514. bptc: any;
  115515. /** Defines if float textures are supported */
  115516. textureFloat: boolean;
  115517. /** Defines if vertex array objects are supported */
  115518. vertexArrayObject: boolean;
  115519. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  115520. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  115521. /** Gets the maximum level of anisotropy supported */
  115522. maxAnisotropy: number;
  115523. /** Defines if instancing is supported */
  115524. instancedArrays: boolean;
  115525. /** Defines if 32 bits indices are supported */
  115526. uintIndices: boolean;
  115527. /** Defines if high precision shaders are supported */
  115528. highPrecisionShaderSupported: boolean;
  115529. /** Defines if depth reading in the fragment shader is supported */
  115530. fragmentDepthSupported: boolean;
  115531. /** Defines if float texture linear filtering is supported*/
  115532. textureFloatLinearFiltering: boolean;
  115533. /** Defines if rendering to float textures is supported */
  115534. textureFloatRender: boolean;
  115535. /** Defines if half float textures are supported*/
  115536. textureHalfFloat: boolean;
  115537. /** Defines if half float texture linear filtering is supported*/
  115538. textureHalfFloatLinearFiltering: boolean;
  115539. /** Defines if rendering to half float textures is supported */
  115540. textureHalfFloatRender: boolean;
  115541. /** Defines if textureLOD shader command is supported */
  115542. textureLOD: boolean;
  115543. /** Defines if draw buffers extension is supported */
  115544. drawBuffersExtension: boolean;
  115545. /** Defines if depth textures are supported */
  115546. depthTextureExtension: boolean;
  115547. /** Defines if float color buffer are supported */
  115548. colorBufferFloat: boolean;
  115549. /** Gets disjoint timer query extension (null if not supported) */
  115550. timerQuery?: EXT_disjoint_timer_query;
  115551. /** Defines if timestamp can be used with timer query */
  115552. canUseTimestampForTimerQuery: boolean;
  115553. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  115554. multiview?: any;
  115555. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  115556. oculusMultiview?: any;
  115557. /** Function used to let the system compiles shaders in background */
  115558. parallelShaderCompile?: {
  115559. COMPLETION_STATUS_KHR: number;
  115560. };
  115561. /** Max number of texture samples for MSAA */
  115562. maxMSAASamples: number;
  115563. /** Defines if the blend min max extension is supported */
  115564. blendMinMax: boolean;
  115565. }
  115566. }
  115567. declare module BABYLON {
  115568. /**
  115569. * @hidden
  115570. **/
  115571. export class DepthCullingState {
  115572. private _isDepthTestDirty;
  115573. private _isDepthMaskDirty;
  115574. private _isDepthFuncDirty;
  115575. private _isCullFaceDirty;
  115576. private _isCullDirty;
  115577. private _isZOffsetDirty;
  115578. private _isFrontFaceDirty;
  115579. private _depthTest;
  115580. private _depthMask;
  115581. private _depthFunc;
  115582. private _cull;
  115583. private _cullFace;
  115584. private _zOffset;
  115585. private _frontFace;
  115586. /**
  115587. * Initializes the state.
  115588. */
  115589. constructor();
  115590. get isDirty(): boolean;
  115591. get zOffset(): number;
  115592. set zOffset(value: number);
  115593. get cullFace(): Nullable<number>;
  115594. set cullFace(value: Nullable<number>);
  115595. get cull(): Nullable<boolean>;
  115596. set cull(value: Nullable<boolean>);
  115597. get depthFunc(): Nullable<number>;
  115598. set depthFunc(value: Nullable<number>);
  115599. get depthMask(): boolean;
  115600. set depthMask(value: boolean);
  115601. get depthTest(): boolean;
  115602. set depthTest(value: boolean);
  115603. get frontFace(): Nullable<number>;
  115604. set frontFace(value: Nullable<number>);
  115605. reset(): void;
  115606. apply(gl: WebGLRenderingContext): void;
  115607. }
  115608. }
  115609. declare module BABYLON {
  115610. /**
  115611. * @hidden
  115612. **/
  115613. export class StencilState {
  115614. /** 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 */
  115615. static readonly ALWAYS: number;
  115616. /** Passed to stencilOperation to specify that stencil value must be kept */
  115617. static readonly KEEP: number;
  115618. /** Passed to stencilOperation to specify that stencil value must be replaced */
  115619. static readonly REPLACE: number;
  115620. private _isStencilTestDirty;
  115621. private _isStencilMaskDirty;
  115622. private _isStencilFuncDirty;
  115623. private _isStencilOpDirty;
  115624. private _stencilTest;
  115625. private _stencilMask;
  115626. private _stencilFunc;
  115627. private _stencilFuncRef;
  115628. private _stencilFuncMask;
  115629. private _stencilOpStencilFail;
  115630. private _stencilOpDepthFail;
  115631. private _stencilOpStencilDepthPass;
  115632. get isDirty(): boolean;
  115633. get stencilFunc(): number;
  115634. set stencilFunc(value: number);
  115635. get stencilFuncRef(): number;
  115636. set stencilFuncRef(value: number);
  115637. get stencilFuncMask(): number;
  115638. set stencilFuncMask(value: number);
  115639. get stencilOpStencilFail(): number;
  115640. set stencilOpStencilFail(value: number);
  115641. get stencilOpDepthFail(): number;
  115642. set stencilOpDepthFail(value: number);
  115643. get stencilOpStencilDepthPass(): number;
  115644. set stencilOpStencilDepthPass(value: number);
  115645. get stencilMask(): number;
  115646. set stencilMask(value: number);
  115647. get stencilTest(): boolean;
  115648. set stencilTest(value: boolean);
  115649. constructor();
  115650. reset(): void;
  115651. apply(gl: WebGLRenderingContext): void;
  115652. }
  115653. }
  115654. declare module BABYLON {
  115655. /**
  115656. * @hidden
  115657. **/
  115658. export class AlphaState {
  115659. private _isAlphaBlendDirty;
  115660. private _isBlendFunctionParametersDirty;
  115661. private _isBlendEquationParametersDirty;
  115662. private _isBlendConstantsDirty;
  115663. private _alphaBlend;
  115664. private _blendFunctionParameters;
  115665. private _blendEquationParameters;
  115666. private _blendConstants;
  115667. /**
  115668. * Initializes the state.
  115669. */
  115670. constructor();
  115671. get isDirty(): boolean;
  115672. get alphaBlend(): boolean;
  115673. set alphaBlend(value: boolean);
  115674. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  115675. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  115676. setAlphaEquationParameters(rgb: number, alpha: number): void;
  115677. reset(): void;
  115678. apply(gl: WebGLRenderingContext): void;
  115679. }
  115680. }
  115681. declare module BABYLON {
  115682. /** @hidden */
  115683. export class WebGL2ShaderProcessor implements IShaderProcessor {
  115684. attributeProcessor(attribute: string): string;
  115685. varyingProcessor(varying: string, isFragment: boolean): string;
  115686. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  115687. }
  115688. }
  115689. declare module BABYLON {
  115690. /**
  115691. * Interface for attribute information associated with buffer instanciation
  115692. */
  115693. export interface InstancingAttributeInfo {
  115694. /**
  115695. * Name of the GLSL attribute
  115696. * if attribute index is not specified, this is used to retrieve the index from the effect
  115697. */
  115698. attributeName: string;
  115699. /**
  115700. * Index/offset of the attribute in the vertex shader
  115701. * if not specified, this will be computes from the name.
  115702. */
  115703. index?: number;
  115704. /**
  115705. * size of the attribute, 1, 2, 3 or 4
  115706. */
  115707. attributeSize: number;
  115708. /**
  115709. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  115710. */
  115711. offset: number;
  115712. /**
  115713. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  115714. * default to 1
  115715. */
  115716. divisor?: number;
  115717. /**
  115718. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  115719. * default is FLOAT
  115720. */
  115721. attributeType?: number;
  115722. /**
  115723. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  115724. */
  115725. normalized?: boolean;
  115726. }
  115727. }
  115728. declare module BABYLON {
  115729. interface ThinEngine {
  115730. /**
  115731. * Update a video texture
  115732. * @param texture defines the texture to update
  115733. * @param video defines the video element to use
  115734. * @param invertY defines if data must be stored with Y axis inverted
  115735. */
  115736. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  115737. }
  115738. }
  115739. declare module BABYLON {
  115740. interface ThinEngine {
  115741. /**
  115742. * Creates a dynamic texture
  115743. * @param width defines the width of the texture
  115744. * @param height defines the height of the texture
  115745. * @param generateMipMaps defines if the engine should generate the mip levels
  115746. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  115747. * @returns the dynamic texture inside an InternalTexture
  115748. */
  115749. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  115750. /**
  115751. * Update the content of a dynamic texture
  115752. * @param texture defines the texture to update
  115753. * @param canvas defines the canvas containing the source
  115754. * @param invertY defines if data must be stored with Y axis inverted
  115755. * @param premulAlpha defines if alpha is stored as premultiplied
  115756. * @param format defines the format of the data
  115757. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  115758. */
  115759. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  115760. }
  115761. }
  115762. declare module BABYLON {
  115763. /**
  115764. * Settings for finer control over video usage
  115765. */
  115766. export interface VideoTextureSettings {
  115767. /**
  115768. * Applies `autoplay` to video, if specified
  115769. */
  115770. autoPlay?: boolean;
  115771. /**
  115772. * Applies `muted` to video, if specified
  115773. */
  115774. muted?: boolean;
  115775. /**
  115776. * Applies `loop` to video, if specified
  115777. */
  115778. loop?: boolean;
  115779. /**
  115780. * Automatically updates internal texture from video at every frame in the render loop
  115781. */
  115782. autoUpdateTexture: boolean;
  115783. /**
  115784. * Image src displayed during the video loading or until the user interacts with the video.
  115785. */
  115786. poster?: string;
  115787. }
  115788. /**
  115789. * If you want to display a video in your scene, this is the special texture for that.
  115790. * This special texture works similar to other textures, with the exception of a few parameters.
  115791. * @see https://doc.babylonjs.com/how_to/video_texture
  115792. */
  115793. export class VideoTexture extends Texture {
  115794. /**
  115795. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  115796. */
  115797. readonly autoUpdateTexture: boolean;
  115798. /**
  115799. * The video instance used by the texture internally
  115800. */
  115801. readonly video: HTMLVideoElement;
  115802. private _onUserActionRequestedObservable;
  115803. /**
  115804. * Event triggerd when a dom action is required by the user to play the video.
  115805. * This happens due to recent changes in browser policies preventing video to auto start.
  115806. */
  115807. get onUserActionRequestedObservable(): Observable<Texture>;
  115808. private _generateMipMaps;
  115809. private _stillImageCaptured;
  115810. private _displayingPosterTexture;
  115811. private _settings;
  115812. private _createInternalTextureOnEvent;
  115813. private _frameId;
  115814. private _currentSrc;
  115815. /**
  115816. * Creates a video texture.
  115817. * If you want to display a video in your scene, this is the special texture for that.
  115818. * This special texture works similar to other textures, with the exception of a few parameters.
  115819. * @see https://doc.babylonjs.com/how_to/video_texture
  115820. * @param name optional name, will detect from video source, if not defined
  115821. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  115822. * @param scene is obviously the current scene.
  115823. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  115824. * @param invertY is false by default but can be used to invert video on Y axis
  115825. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  115826. * @param settings allows finer control over video usage
  115827. */
  115828. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  115829. private _getName;
  115830. private _getVideo;
  115831. private _createInternalTexture;
  115832. private reset;
  115833. /**
  115834. * @hidden Internal method to initiate `update`.
  115835. */
  115836. _rebuild(): void;
  115837. /**
  115838. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  115839. */
  115840. update(): void;
  115841. /**
  115842. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  115843. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  115844. */
  115845. updateTexture(isVisible: boolean): void;
  115846. protected _updateInternalTexture: () => void;
  115847. /**
  115848. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  115849. * @param url New url.
  115850. */
  115851. updateURL(url: string): void;
  115852. /**
  115853. * Clones the texture.
  115854. * @returns the cloned texture
  115855. */
  115856. clone(): VideoTexture;
  115857. /**
  115858. * Dispose the texture and release its associated resources.
  115859. */
  115860. dispose(): void;
  115861. /**
  115862. * Creates a video texture straight from a stream.
  115863. * @param scene Define the scene the texture should be created in
  115864. * @param stream Define the stream the texture should be created from
  115865. * @returns The created video texture as a promise
  115866. */
  115867. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  115868. /**
  115869. * Creates a video texture straight from your WebCam video feed.
  115870. * @param scene Define the scene the texture should be created in
  115871. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115872. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115873. * @returns The created video texture as a promise
  115874. */
  115875. static CreateFromWebCamAsync(scene: Scene, constraints: {
  115876. minWidth: number;
  115877. maxWidth: number;
  115878. minHeight: number;
  115879. maxHeight: number;
  115880. deviceId: string;
  115881. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  115882. /**
  115883. * Creates a video texture straight from your WebCam video feed.
  115884. * @param scene Define the scene the texture should be created in
  115885. * @param onReady Define a callback to triggered once the texture will be ready
  115886. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115887. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115888. */
  115889. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  115890. minWidth: number;
  115891. maxWidth: number;
  115892. minHeight: number;
  115893. maxHeight: number;
  115894. deviceId: string;
  115895. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  115896. }
  115897. }
  115898. declare module BABYLON {
  115899. /**
  115900. * Defines the interface used by objects working like Scene
  115901. * @hidden
  115902. */
  115903. export interface ISceneLike {
  115904. _addPendingData(data: any): void;
  115905. _removePendingData(data: any): void;
  115906. offlineProvider: IOfflineProvider;
  115907. }
  115908. /**
  115909. * Information about the current host
  115910. */
  115911. export interface HostInformation {
  115912. /**
  115913. * Defines if the current host is a mobile
  115914. */
  115915. isMobile: boolean;
  115916. }
  115917. /** Interface defining initialization parameters for Engine class */
  115918. export interface EngineOptions extends WebGLContextAttributes {
  115919. /**
  115920. * Defines if the engine should no exceed a specified device ratio
  115921. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  115922. */
  115923. limitDeviceRatio?: number;
  115924. /**
  115925. * Defines if webvr should be enabled automatically
  115926. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115927. */
  115928. autoEnableWebVR?: boolean;
  115929. /**
  115930. * Defines if webgl2 should be turned off even if supported
  115931. * @see https://doc.babylonjs.com/features/webgl2
  115932. */
  115933. disableWebGL2Support?: boolean;
  115934. /**
  115935. * Defines if webaudio should be initialized as well
  115936. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115937. */
  115938. audioEngine?: boolean;
  115939. /**
  115940. * Defines if animations should run using a deterministic lock step
  115941. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115942. */
  115943. deterministicLockstep?: boolean;
  115944. /** Defines the maximum steps to use with deterministic lock step mode */
  115945. lockstepMaxSteps?: number;
  115946. /** Defines the seconds between each deterministic lock step */
  115947. timeStep?: number;
  115948. /**
  115949. * Defines that engine should ignore context lost events
  115950. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115951. */
  115952. doNotHandleContextLost?: boolean;
  115953. /**
  115954. * Defines that engine should ignore modifying touch action attribute and style
  115955. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115956. */
  115957. doNotHandleTouchAction?: boolean;
  115958. /**
  115959. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115960. */
  115961. useHighPrecisionFloats?: boolean;
  115962. /**
  115963. * Make the canvas XR Compatible for XR sessions
  115964. */
  115965. xrCompatible?: boolean;
  115966. /**
  115967. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115968. */
  115969. useHighPrecisionMatrix?: boolean;
  115970. /**
  115971. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  115972. */
  115973. failIfMajorPerformanceCaveat?: boolean;
  115974. }
  115975. /**
  115976. * The base engine class (root of all engines)
  115977. */
  115978. export class ThinEngine {
  115979. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115980. static ExceptionList: ({
  115981. key: string;
  115982. capture: string;
  115983. captureConstraint: number;
  115984. targets: string[];
  115985. } | {
  115986. key: string;
  115987. capture: null;
  115988. captureConstraint: null;
  115989. targets: string[];
  115990. })[];
  115991. /** @hidden */
  115992. static _TextureLoaders: IInternalTextureLoader[];
  115993. /**
  115994. * Returns the current npm package of the sdk
  115995. */
  115996. static get NpmPackage(): string;
  115997. /**
  115998. * Returns the current version of the framework
  115999. */
  116000. static get Version(): string;
  116001. /**
  116002. * Returns a string describing the current engine
  116003. */
  116004. get description(): string;
  116005. /**
  116006. * Gets or sets the epsilon value used by collision engine
  116007. */
  116008. static CollisionsEpsilon: number;
  116009. /**
  116010. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  116011. */
  116012. static get ShadersRepository(): string;
  116013. static set ShadersRepository(value: string);
  116014. /** @hidden */
  116015. _shaderProcessor: IShaderProcessor;
  116016. /**
  116017. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  116018. */
  116019. forcePOTTextures: boolean;
  116020. /**
  116021. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  116022. */
  116023. isFullscreen: boolean;
  116024. /**
  116025. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  116026. */
  116027. cullBackFaces: boolean;
  116028. /**
  116029. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  116030. */
  116031. renderEvenInBackground: boolean;
  116032. /**
  116033. * Gets or sets a boolean indicating that cache can be kept between frames
  116034. */
  116035. preventCacheWipeBetweenFrames: boolean;
  116036. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  116037. validateShaderPrograms: boolean;
  116038. /**
  116039. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  116040. * This can provide greater z depth for distant objects.
  116041. */
  116042. useReverseDepthBuffer: boolean;
  116043. /**
  116044. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  116045. */
  116046. disableUniformBuffers: boolean;
  116047. /** @hidden */
  116048. _uniformBuffers: UniformBuffer[];
  116049. /**
  116050. * Gets a boolean indicating that the engine supports uniform buffers
  116051. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  116052. */
  116053. get supportsUniformBuffers(): boolean;
  116054. /** @hidden */
  116055. _gl: WebGLRenderingContext;
  116056. /** @hidden */
  116057. _webGLVersion: number;
  116058. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  116059. protected _windowIsBackground: boolean;
  116060. protected _creationOptions: EngineOptions;
  116061. protected _highPrecisionShadersAllowed: boolean;
  116062. /** @hidden */
  116063. get _shouldUseHighPrecisionShader(): boolean;
  116064. /**
  116065. * Gets a boolean indicating that only power of 2 textures are supported
  116066. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  116067. */
  116068. get needPOTTextures(): boolean;
  116069. /** @hidden */
  116070. _badOS: boolean;
  116071. /** @hidden */
  116072. _badDesktopOS: boolean;
  116073. private _hardwareScalingLevel;
  116074. /** @hidden */
  116075. _caps: EngineCapabilities;
  116076. private _isStencilEnable;
  116077. private _glVersion;
  116078. private _glRenderer;
  116079. private _glVendor;
  116080. /** @hidden */
  116081. _videoTextureSupported: boolean;
  116082. protected _renderingQueueLaunched: boolean;
  116083. protected _activeRenderLoops: (() => void)[];
  116084. /**
  116085. * Observable signaled when a context lost event is raised
  116086. */
  116087. onContextLostObservable: Observable<ThinEngine>;
  116088. /**
  116089. * Observable signaled when a context restored event is raised
  116090. */
  116091. onContextRestoredObservable: Observable<ThinEngine>;
  116092. private _onContextLost;
  116093. private _onContextRestored;
  116094. protected _contextWasLost: boolean;
  116095. /** @hidden */
  116096. _doNotHandleContextLost: boolean;
  116097. /**
  116098. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  116099. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  116100. */
  116101. get doNotHandleContextLost(): boolean;
  116102. set doNotHandleContextLost(value: boolean);
  116103. /**
  116104. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  116105. */
  116106. disableVertexArrayObjects: boolean;
  116107. /** @hidden */
  116108. protected _colorWrite: boolean;
  116109. /** @hidden */
  116110. protected _colorWriteChanged: boolean;
  116111. /** @hidden */
  116112. protected _depthCullingState: DepthCullingState;
  116113. /** @hidden */
  116114. protected _stencilState: StencilState;
  116115. /** @hidden */
  116116. _alphaState: AlphaState;
  116117. /** @hidden */
  116118. _alphaMode: number;
  116119. /** @hidden */
  116120. _alphaEquation: number;
  116121. /** @hidden */
  116122. _internalTexturesCache: InternalTexture[];
  116123. /** @hidden */
  116124. protected _activeChannel: number;
  116125. private _currentTextureChannel;
  116126. /** @hidden */
  116127. protected _boundTexturesCache: {
  116128. [key: string]: Nullable<InternalTexture>;
  116129. };
  116130. /** @hidden */
  116131. protected _currentEffect: Nullable<Effect>;
  116132. /** @hidden */
  116133. protected _currentProgram: Nullable<WebGLProgram>;
  116134. private _compiledEffects;
  116135. private _vertexAttribArraysEnabled;
  116136. /** @hidden */
  116137. protected _cachedViewport: Nullable<IViewportLike>;
  116138. private _cachedVertexArrayObject;
  116139. /** @hidden */
  116140. protected _cachedVertexBuffers: any;
  116141. /** @hidden */
  116142. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  116143. /** @hidden */
  116144. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  116145. /** @hidden */
  116146. _currentRenderTarget: Nullable<InternalTexture>;
  116147. private _uintIndicesCurrentlySet;
  116148. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  116149. /** @hidden */
  116150. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  116151. /** @hidden */
  116152. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  116153. private _currentBufferPointers;
  116154. private _currentInstanceLocations;
  116155. private _currentInstanceBuffers;
  116156. private _textureUnits;
  116157. /** @hidden */
  116158. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  116159. /** @hidden */
  116160. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  116161. /** @hidden */
  116162. _boundRenderFunction: any;
  116163. private _vaoRecordInProgress;
  116164. private _mustWipeVertexAttributes;
  116165. private _emptyTexture;
  116166. private _emptyCubeTexture;
  116167. private _emptyTexture3D;
  116168. private _emptyTexture2DArray;
  116169. /** @hidden */
  116170. _frameHandler: number;
  116171. private _nextFreeTextureSlots;
  116172. private _maxSimultaneousTextures;
  116173. private _activeRequests;
  116174. /** @hidden */
  116175. _transformTextureUrl: Nullable<(url: string) => string>;
  116176. /**
  116177. * Gets information about the current host
  116178. */
  116179. hostInformation: HostInformation;
  116180. protected get _supportsHardwareTextureRescaling(): boolean;
  116181. private _framebufferDimensionsObject;
  116182. /**
  116183. * sets the object from which width and height will be taken from when getting render width and height
  116184. * Will fallback to the gl object
  116185. * @param dimensions the framebuffer width and height that will be used.
  116186. */
  116187. set framebufferDimensionsObject(dimensions: Nullable<{
  116188. framebufferWidth: number;
  116189. framebufferHeight: number;
  116190. }>);
  116191. /**
  116192. * Gets the current viewport
  116193. */
  116194. get currentViewport(): Nullable<IViewportLike>;
  116195. /**
  116196. * Gets the default empty texture
  116197. */
  116198. get emptyTexture(): InternalTexture;
  116199. /**
  116200. * Gets the default empty 3D texture
  116201. */
  116202. get emptyTexture3D(): InternalTexture;
  116203. /**
  116204. * Gets the default empty 2D array texture
  116205. */
  116206. get emptyTexture2DArray(): InternalTexture;
  116207. /**
  116208. * Gets the default empty cube texture
  116209. */
  116210. get emptyCubeTexture(): InternalTexture;
  116211. /**
  116212. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  116213. */
  116214. readonly premultipliedAlpha: boolean;
  116215. /**
  116216. * Observable event triggered before each texture is initialized
  116217. */
  116218. onBeforeTextureInitObservable: Observable<Texture>;
  116219. /**
  116220. * Creates a new engine
  116221. * @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
  116222. * @param antialias defines enable antialiasing (default: false)
  116223. * @param options defines further options to be sent to the getContext() function
  116224. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  116225. */
  116226. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  116227. private _rebuildInternalTextures;
  116228. private _rebuildEffects;
  116229. /**
  116230. * Gets a boolean indicating if all created effects are ready
  116231. * @returns true if all effects are ready
  116232. */
  116233. areAllEffectsReady(): boolean;
  116234. protected _rebuildBuffers(): void;
  116235. protected _initGLContext(): void;
  116236. /**
  116237. * Gets version of the current webGL context
  116238. */
  116239. get webGLVersion(): number;
  116240. /**
  116241. * Gets a string identifying the name of the class
  116242. * @returns "Engine" string
  116243. */
  116244. getClassName(): string;
  116245. /**
  116246. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  116247. */
  116248. get isStencilEnable(): boolean;
  116249. /** @hidden */
  116250. _prepareWorkingCanvas(): void;
  116251. /**
  116252. * Reset the texture cache to empty state
  116253. */
  116254. resetTextureCache(): void;
  116255. /**
  116256. * Gets an object containing information about the current webGL context
  116257. * @returns an object containing the vender, the renderer and the version of the current webGL context
  116258. */
  116259. getGlInfo(): {
  116260. vendor: string;
  116261. renderer: string;
  116262. version: string;
  116263. };
  116264. /**
  116265. * Defines the hardware scaling level.
  116266. * By default the hardware scaling level is computed from the window device ratio.
  116267. * 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.
  116268. * @param level defines the level to use
  116269. */
  116270. setHardwareScalingLevel(level: number): void;
  116271. /**
  116272. * Gets the current hardware scaling level.
  116273. * By default the hardware scaling level is computed from the window device ratio.
  116274. * 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.
  116275. * @returns a number indicating the current hardware scaling level
  116276. */
  116277. getHardwareScalingLevel(): number;
  116278. /**
  116279. * Gets the list of loaded textures
  116280. * @returns an array containing all loaded textures
  116281. */
  116282. getLoadedTexturesCache(): InternalTexture[];
  116283. /**
  116284. * Gets the object containing all engine capabilities
  116285. * @returns the EngineCapabilities object
  116286. */
  116287. getCaps(): EngineCapabilities;
  116288. /**
  116289. * stop executing a render loop function and remove it from the execution array
  116290. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  116291. */
  116292. stopRenderLoop(renderFunction?: () => void): void;
  116293. /** @hidden */
  116294. _renderLoop(): void;
  116295. /**
  116296. * Gets the HTML canvas attached with the current webGL context
  116297. * @returns a HTML canvas
  116298. */
  116299. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  116300. /**
  116301. * Gets host window
  116302. * @returns the host window object
  116303. */
  116304. getHostWindow(): Nullable<Window>;
  116305. /**
  116306. * Gets the current render width
  116307. * @param useScreen defines if screen size must be used (or the current render target if any)
  116308. * @returns a number defining the current render width
  116309. */
  116310. getRenderWidth(useScreen?: boolean): number;
  116311. /**
  116312. * Gets the current render height
  116313. * @param useScreen defines if screen size must be used (or the current render target if any)
  116314. * @returns a number defining the current render height
  116315. */
  116316. getRenderHeight(useScreen?: boolean): number;
  116317. /**
  116318. * Can be used to override the current requestAnimationFrame requester.
  116319. * @hidden
  116320. */
  116321. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  116322. /**
  116323. * Register and execute a render loop. The engine can have more than one render function
  116324. * @param renderFunction defines the function to continuously execute
  116325. */
  116326. runRenderLoop(renderFunction: () => void): void;
  116327. /**
  116328. * Clear the current render buffer or the current render target (if any is set up)
  116329. * @param color defines the color to use
  116330. * @param backBuffer defines if the back buffer must be cleared
  116331. * @param depth defines if the depth buffer must be cleared
  116332. * @param stencil defines if the stencil buffer must be cleared
  116333. */
  116334. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  116335. private _viewportCached;
  116336. /** @hidden */
  116337. _viewport(x: number, y: number, width: number, height: number): void;
  116338. /**
  116339. * Set the WebGL's viewport
  116340. * @param viewport defines the viewport element to be used
  116341. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116342. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116343. */
  116344. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116345. /**
  116346. * Begin a new frame
  116347. */
  116348. beginFrame(): void;
  116349. /**
  116350. * Enf the current frame
  116351. */
  116352. endFrame(): void;
  116353. /**
  116354. * Resize the view according to the canvas' size
  116355. */
  116356. resize(): void;
  116357. /**
  116358. * Force a specific size of the canvas
  116359. * @param width defines the new canvas' width
  116360. * @param height defines the new canvas' height
  116361. * @returns true if the size was changed
  116362. */
  116363. setSize(width: number, height: number): boolean;
  116364. /**
  116365. * Binds the frame buffer to the specified texture.
  116366. * @param texture The texture to render to or null for the default canvas
  116367. * @param faceIndex The face of the texture to render to in case of cube texture
  116368. * @param requiredWidth The width of the target to render to
  116369. * @param requiredHeight The height of the target to render to
  116370. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116371. * @param lodLevel defines the lod level to bind to the frame buffer
  116372. * @param layer defines the 2d array index to bind to frame buffer to
  116373. */
  116374. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  116375. /** @hidden */
  116376. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  116377. /**
  116378. * Unbind the current render target texture from the webGL context
  116379. * @param texture defines the render target texture to unbind
  116380. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116381. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116382. */
  116383. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116384. /**
  116385. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  116386. */
  116387. flushFramebuffer(): void;
  116388. /**
  116389. * Unbind the current render target and bind the default framebuffer
  116390. */
  116391. restoreDefaultFramebuffer(): void;
  116392. /** @hidden */
  116393. protected _resetVertexBufferBinding(): void;
  116394. /**
  116395. * Creates a vertex buffer
  116396. * @param data the data for the vertex buffer
  116397. * @returns the new WebGL static buffer
  116398. */
  116399. createVertexBuffer(data: DataArray): DataBuffer;
  116400. private _createVertexBuffer;
  116401. /**
  116402. * Creates a dynamic vertex buffer
  116403. * @param data the data for the dynamic vertex buffer
  116404. * @returns the new WebGL dynamic buffer
  116405. */
  116406. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  116407. protected _resetIndexBufferBinding(): void;
  116408. /**
  116409. * Creates a new index buffer
  116410. * @param indices defines the content of the index buffer
  116411. * @param updatable defines if the index buffer must be updatable
  116412. * @returns a new webGL buffer
  116413. */
  116414. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  116415. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  116416. /**
  116417. * Bind a webGL buffer to the webGL context
  116418. * @param buffer defines the buffer to bind
  116419. */
  116420. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  116421. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  116422. private bindBuffer;
  116423. /**
  116424. * update the bound buffer with the given data
  116425. * @param data defines the data to update
  116426. */
  116427. updateArrayBuffer(data: Float32Array): void;
  116428. private _vertexAttribPointer;
  116429. /** @hidden */
  116430. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  116431. private _bindVertexBuffersAttributes;
  116432. /**
  116433. * Records a vertex array object
  116434. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116435. * @param vertexBuffers defines the list of vertex buffers to store
  116436. * @param indexBuffer defines the index buffer to store
  116437. * @param effect defines the effect to store
  116438. * @returns the new vertex array object
  116439. */
  116440. recordVertexArrayObject(vertexBuffers: {
  116441. [key: string]: VertexBuffer;
  116442. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  116443. /**
  116444. * Bind a specific vertex array object
  116445. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116446. * @param vertexArrayObject defines the vertex array object to bind
  116447. * @param indexBuffer defines the index buffer to bind
  116448. */
  116449. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  116450. /**
  116451. * Bind webGl buffers directly to the webGL context
  116452. * @param vertexBuffer defines the vertex buffer to bind
  116453. * @param indexBuffer defines the index buffer to bind
  116454. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116455. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116456. * @param effect defines the effect associated with the vertex buffer
  116457. */
  116458. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  116459. private _unbindVertexArrayObject;
  116460. /**
  116461. * Bind a list of vertex buffers to the webGL context
  116462. * @param vertexBuffers defines the list of vertex buffers to bind
  116463. * @param indexBuffer defines the index buffer to bind
  116464. * @param effect defines the effect associated with the vertex buffers
  116465. */
  116466. bindBuffers(vertexBuffers: {
  116467. [key: string]: Nullable<VertexBuffer>;
  116468. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  116469. /**
  116470. * Unbind all instance attributes
  116471. */
  116472. unbindInstanceAttributes(): void;
  116473. /**
  116474. * Release and free the memory of a vertex array object
  116475. * @param vao defines the vertex array object to delete
  116476. */
  116477. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  116478. /** @hidden */
  116479. _releaseBuffer(buffer: DataBuffer): boolean;
  116480. protected _deleteBuffer(buffer: DataBuffer): void;
  116481. /**
  116482. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  116483. * @param instancesBuffer defines the webGL buffer to update and bind
  116484. * @param data defines the data to store in the buffer
  116485. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  116486. */
  116487. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  116488. /**
  116489. * Bind the content of a webGL buffer used with instantiation
  116490. * @param instancesBuffer defines the webGL buffer to bind
  116491. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  116492. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  116493. */
  116494. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  116495. /**
  116496. * Disable the instance attribute corresponding to the name in parameter
  116497. * @param name defines the name of the attribute to disable
  116498. */
  116499. disableInstanceAttributeByName(name: string): void;
  116500. /**
  116501. * Disable the instance attribute corresponding to the location in parameter
  116502. * @param attributeLocation defines the attribute location of the attribute to disable
  116503. */
  116504. disableInstanceAttribute(attributeLocation: number): void;
  116505. /**
  116506. * Disable the attribute corresponding to the location in parameter
  116507. * @param attributeLocation defines the attribute location of the attribute to disable
  116508. */
  116509. disableAttributeByIndex(attributeLocation: number): void;
  116510. /**
  116511. * Send a draw order
  116512. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116513. * @param indexStart defines the starting index
  116514. * @param indexCount defines the number of index to draw
  116515. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116516. */
  116517. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116518. /**
  116519. * Draw a list of points
  116520. * @param verticesStart defines the index of first vertex to draw
  116521. * @param verticesCount defines the count of vertices to draw
  116522. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116523. */
  116524. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116525. /**
  116526. * Draw a list of unindexed primitives
  116527. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116528. * @param verticesStart defines the index of first vertex to draw
  116529. * @param verticesCount defines the count of vertices to draw
  116530. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116531. */
  116532. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116533. /**
  116534. * Draw a list of indexed primitives
  116535. * @param fillMode defines the primitive to use
  116536. * @param indexStart defines the starting index
  116537. * @param indexCount defines the number of index to draw
  116538. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116539. */
  116540. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116541. /**
  116542. * Draw a list of unindexed primitives
  116543. * @param fillMode defines the primitive to use
  116544. * @param verticesStart defines the index of first vertex to draw
  116545. * @param verticesCount defines the count of vertices to draw
  116546. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116547. */
  116548. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116549. private _drawMode;
  116550. /** @hidden */
  116551. protected _reportDrawCall(): void;
  116552. /** @hidden */
  116553. _releaseEffect(effect: Effect): void;
  116554. /** @hidden */
  116555. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116556. /**
  116557. * Create a new effect (used to store vertex/fragment shaders)
  116558. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  116559. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  116560. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  116561. * @param samplers defines an array of string used to represent textures
  116562. * @param defines defines the string containing the defines to use to compile the shaders
  116563. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116564. * @param onCompiled defines a function to call when the effect creation is successful
  116565. * @param onError defines a function to call when the effect creation has failed
  116566. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  116567. * @returns the new Effect
  116568. */
  116569. 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;
  116570. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  116571. private _compileShader;
  116572. private _compileRawShader;
  116573. /** @hidden */
  116574. _getShaderSource(shader: WebGLShader): Nullable<string>;
  116575. /**
  116576. * Directly creates a webGL program
  116577. * @param pipelineContext defines the pipeline context to attach to
  116578. * @param vertexCode defines the vertex shader code to use
  116579. * @param fragmentCode defines the fragment shader code to use
  116580. * @param context defines the webGL context to use (if not set, the current one will be used)
  116581. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116582. * @returns the new webGL program
  116583. */
  116584. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116585. /**
  116586. * Creates a webGL program
  116587. * @param pipelineContext defines the pipeline context to attach to
  116588. * @param vertexCode defines the vertex shader code to use
  116589. * @param fragmentCode defines the fragment shader code to use
  116590. * @param defines defines the string containing the defines to use to compile the shaders
  116591. * @param context defines the webGL context to use (if not set, the current one will be used)
  116592. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116593. * @returns the new webGL program
  116594. */
  116595. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116596. /**
  116597. * Creates a new pipeline context
  116598. * @returns the new pipeline
  116599. */
  116600. createPipelineContext(): IPipelineContext;
  116601. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116602. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  116603. /** @hidden */
  116604. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  116605. /** @hidden */
  116606. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  116607. /** @hidden */
  116608. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  116609. /**
  116610. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116611. * @param pipelineContext defines the pipeline context to use
  116612. * @param uniformsNames defines the list of uniform names
  116613. * @returns an array of webGL uniform locations
  116614. */
  116615. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116616. /**
  116617. * Gets the lsit of active attributes for a given webGL program
  116618. * @param pipelineContext defines the pipeline context to use
  116619. * @param attributesNames defines the list of attribute names to get
  116620. * @returns an array of indices indicating the offset of each attribute
  116621. */
  116622. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116623. /**
  116624. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116625. * @param effect defines the effect to activate
  116626. */
  116627. enableEffect(effect: Nullable<Effect>): void;
  116628. /**
  116629. * Set the value of an uniform to a number (int)
  116630. * @param uniform defines the webGL uniform location where to store the value
  116631. * @param value defines the int number to store
  116632. * @returns true if the value was set
  116633. */
  116634. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116635. /**
  116636. * Set the value of an uniform to an array of int32
  116637. * @param uniform defines the webGL uniform location where to store the value
  116638. * @param array defines the array of int32 to store
  116639. * @returns true if the value was set
  116640. */
  116641. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116642. /**
  116643. * Set the value of an uniform to an array of int32 (stored as vec2)
  116644. * @param uniform defines the webGL uniform location where to store the value
  116645. * @param array defines the array of int32 to store
  116646. * @returns true if the value was set
  116647. */
  116648. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116649. /**
  116650. * Set the value of an uniform to an array of int32 (stored as vec3)
  116651. * @param uniform defines the webGL uniform location where to store the value
  116652. * @param array defines the array of int32 to store
  116653. * @returns true if the value was set
  116654. */
  116655. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116656. /**
  116657. * Set the value of an uniform to an array of int32 (stored as vec4)
  116658. * @param uniform defines the webGL uniform location where to store the value
  116659. * @param array defines the array of int32 to store
  116660. * @returns true if the value was set
  116661. */
  116662. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116663. /**
  116664. * Set the value of an uniform to an array of number
  116665. * @param uniform defines the webGL uniform location where to store the value
  116666. * @param array defines the array of number to store
  116667. * @returns true if the value was set
  116668. */
  116669. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116670. /**
  116671. * Set the value of an uniform to an array of number (stored as vec2)
  116672. * @param uniform defines the webGL uniform location where to store the value
  116673. * @param array defines the array of number to store
  116674. * @returns true if the value was set
  116675. */
  116676. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116677. /**
  116678. * Set the value of an uniform to an array of number (stored as vec3)
  116679. * @param uniform defines the webGL uniform location where to store the value
  116680. * @param array defines the array of number to store
  116681. * @returns true if the value was set
  116682. */
  116683. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116684. /**
  116685. * Set the value of an uniform to an array of number (stored as vec4)
  116686. * @param uniform defines the webGL uniform location where to store the value
  116687. * @param array defines the array of number to store
  116688. * @returns true if the value was set
  116689. */
  116690. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116691. /**
  116692. * Set the value of an uniform to an array of float32 (stored as matrices)
  116693. * @param uniform defines the webGL uniform location where to store the value
  116694. * @param matrices defines the array of float32 to store
  116695. * @returns true if the value was set
  116696. */
  116697. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  116698. /**
  116699. * Set the value of an uniform to a matrix (3x3)
  116700. * @param uniform defines the webGL uniform location where to store the value
  116701. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116702. * @returns true if the value was set
  116703. */
  116704. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116705. /**
  116706. * Set the value of an uniform to a matrix (2x2)
  116707. * @param uniform defines the webGL uniform location where to store the value
  116708. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116709. * @returns true if the value was set
  116710. */
  116711. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116712. /**
  116713. * Set the value of an uniform to a number (float)
  116714. * @param uniform defines the webGL uniform location where to store the value
  116715. * @param value defines the float number to store
  116716. * @returns true if the value was transfered
  116717. */
  116718. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116719. /**
  116720. * Set the value of an uniform to a vec2
  116721. * @param uniform defines the webGL uniform location where to store the value
  116722. * @param x defines the 1st component of the value
  116723. * @param y defines the 2nd component of the value
  116724. * @returns true if the value was set
  116725. */
  116726. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  116727. /**
  116728. * Set the value of an uniform to a vec3
  116729. * @param uniform defines the webGL uniform location where to store the value
  116730. * @param x defines the 1st component of the value
  116731. * @param y defines the 2nd component of the value
  116732. * @param z defines the 3rd component of the value
  116733. * @returns true if the value was set
  116734. */
  116735. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  116736. /**
  116737. * Set the value of an uniform to a vec4
  116738. * @param uniform defines the webGL uniform location where to store the value
  116739. * @param x defines the 1st component of the value
  116740. * @param y defines the 2nd component of the value
  116741. * @param z defines the 3rd component of the value
  116742. * @param w defines the 4th component of the value
  116743. * @returns true if the value was set
  116744. */
  116745. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  116746. /**
  116747. * Apply all cached states (depth, culling, stencil and alpha)
  116748. */
  116749. applyStates(): void;
  116750. /**
  116751. * Enable or disable color writing
  116752. * @param enable defines the state to set
  116753. */
  116754. setColorWrite(enable: boolean): void;
  116755. /**
  116756. * Gets a boolean indicating if color writing is enabled
  116757. * @returns the current color writing state
  116758. */
  116759. getColorWrite(): boolean;
  116760. /**
  116761. * Gets the depth culling state manager
  116762. */
  116763. get depthCullingState(): DepthCullingState;
  116764. /**
  116765. * Gets the alpha state manager
  116766. */
  116767. get alphaState(): AlphaState;
  116768. /**
  116769. * Gets the stencil state manager
  116770. */
  116771. get stencilState(): StencilState;
  116772. /**
  116773. * Clears the list of texture accessible through engine.
  116774. * This can help preventing texture load conflict due to name collision.
  116775. */
  116776. clearInternalTexturesCache(): void;
  116777. /**
  116778. * Force the entire cache to be cleared
  116779. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116780. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116781. */
  116782. wipeCaches(bruteForce?: boolean): void;
  116783. /** @hidden */
  116784. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  116785. min: number;
  116786. mag: number;
  116787. };
  116788. /** @hidden */
  116789. _createTexture(): WebGLTexture;
  116790. /**
  116791. * Usually called from Texture.ts.
  116792. * Passed information to create a WebGLTexture
  116793. * @param url defines a value which contains one of the following:
  116794. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116795. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116796. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116797. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116798. * @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)
  116799. * @param scene needed for loading to the correct scene
  116800. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116801. * @param onLoad optional callback to be called upon successful completion
  116802. * @param onError optional callback to be called upon failure
  116803. * @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
  116804. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116805. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116806. * @param forcedExtension defines the extension to use to pick the right loader
  116807. * @param mimeType defines an optional mime type
  116808. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116809. */
  116810. 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;
  116811. /**
  116812. * Loads an image as an HTMLImageElement.
  116813. * @param input url string, ArrayBuffer, or Blob to load
  116814. * @param onLoad callback called when the image successfully loads
  116815. * @param onError callback called when the image fails to load
  116816. * @param offlineProvider offline provider for caching
  116817. * @param mimeType optional mime type
  116818. * @returns the HTMLImageElement of the loaded image
  116819. * @hidden
  116820. */
  116821. 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>;
  116822. /**
  116823. * @hidden
  116824. */
  116825. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116826. private _unpackFlipYCached;
  116827. /**
  116828. * In case you are sharing the context with other applications, it might
  116829. * be interested to not cache the unpack flip y state to ensure a consistent
  116830. * value would be set.
  116831. */
  116832. enableUnpackFlipYCached: boolean;
  116833. /** @hidden */
  116834. _unpackFlipY(value: boolean): void;
  116835. /** @hidden */
  116836. _getUnpackAlignement(): number;
  116837. private _getTextureTarget;
  116838. /**
  116839. * Update the sampling mode of a given texture
  116840. * @param samplingMode defines the required sampling mode
  116841. * @param texture defines the texture to update
  116842. * @param generateMipMaps defines whether to generate mipmaps for the texture
  116843. */
  116844. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  116845. /**
  116846. * Update the sampling mode of a given texture
  116847. * @param texture defines the texture to update
  116848. * @param wrapU defines the texture wrap mode of the u coordinates
  116849. * @param wrapV defines the texture wrap mode of the v coordinates
  116850. * @param wrapR defines the texture wrap mode of the r coordinates
  116851. */
  116852. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  116853. /** @hidden */
  116854. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  116855. width: number;
  116856. height: number;
  116857. layers?: number;
  116858. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  116859. /** @hidden */
  116860. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116861. /** @hidden */
  116862. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  116863. /**
  116864. * Update a portion of an internal texture
  116865. * @param texture defines the texture to update
  116866. * @param imageData defines the data to store into the texture
  116867. * @param xOffset defines the x coordinates of the update rectangle
  116868. * @param yOffset defines the y coordinates of the update rectangle
  116869. * @param width defines the width of the update rectangle
  116870. * @param height defines the height of the update rectangle
  116871. * @param faceIndex defines the face index if texture is a cube (0 by default)
  116872. * @param lod defines the lod level to update (0 by default)
  116873. */
  116874. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  116875. /** @hidden */
  116876. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116877. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  116878. private _prepareWebGLTexture;
  116879. /** @hidden */
  116880. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  116881. private _getDepthStencilBuffer;
  116882. /** @hidden */
  116883. _releaseFramebufferObjects(texture: InternalTexture): void;
  116884. /** @hidden */
  116885. _releaseTexture(texture: InternalTexture): void;
  116886. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  116887. protected _setProgram(program: WebGLProgram): void;
  116888. protected _boundUniforms: {
  116889. [key: number]: WebGLUniformLocation;
  116890. };
  116891. /**
  116892. * Binds an effect to the webGL context
  116893. * @param effect defines the effect to bind
  116894. */
  116895. bindSamplers(effect: Effect): void;
  116896. private _activateCurrentTexture;
  116897. /** @hidden */
  116898. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  116899. /** @hidden */
  116900. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  116901. /**
  116902. * Unbind all textures from the webGL context
  116903. */
  116904. unbindAllTextures(): void;
  116905. /**
  116906. * Sets a texture to the according uniform.
  116907. * @param channel The texture channel
  116908. * @param uniform The uniform to set
  116909. * @param texture The texture to apply
  116910. */
  116911. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  116912. private _bindSamplerUniformToChannel;
  116913. private _getTextureWrapMode;
  116914. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  116915. /**
  116916. * Sets an array of texture to the webGL context
  116917. * @param channel defines the channel where the texture array must be set
  116918. * @param uniform defines the associated uniform location
  116919. * @param textures defines the array of textures to bind
  116920. */
  116921. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  116922. /** @hidden */
  116923. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  116924. private _setTextureParameterFloat;
  116925. private _setTextureParameterInteger;
  116926. /**
  116927. * Unbind all vertex attributes from the webGL context
  116928. */
  116929. unbindAllAttributes(): void;
  116930. /**
  116931. * 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
  116932. */
  116933. releaseEffects(): void;
  116934. /**
  116935. * Dispose and release all associated resources
  116936. */
  116937. dispose(): void;
  116938. /**
  116939. * Attach a new callback raised when context lost event is fired
  116940. * @param callback defines the callback to call
  116941. */
  116942. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116943. /**
  116944. * Attach a new callback raised when context restored event is fired
  116945. * @param callback defines the callback to call
  116946. */
  116947. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116948. /**
  116949. * Get the current error code of the webGL context
  116950. * @returns the error code
  116951. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116952. */
  116953. getError(): number;
  116954. private _canRenderToFloatFramebuffer;
  116955. private _canRenderToHalfFloatFramebuffer;
  116956. private _canRenderToFramebuffer;
  116957. /** @hidden */
  116958. _getWebGLTextureType(type: number): number;
  116959. /** @hidden */
  116960. _getInternalFormat(format: number): number;
  116961. /** @hidden */
  116962. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116963. /** @hidden */
  116964. _getRGBAMultiSampleBufferFormat(type: number): number;
  116965. /** @hidden */
  116966. _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;
  116967. /**
  116968. * Loads a file from a url
  116969. * @param url url to load
  116970. * @param onSuccess callback called when the file successfully loads
  116971. * @param onProgress callback called while file is loading (if the server supports this mode)
  116972. * @param offlineProvider defines the offline provider for caching
  116973. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116974. * @param onError callback called when the file fails to load
  116975. * @returns a file request object
  116976. * @hidden
  116977. */
  116978. 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;
  116979. /**
  116980. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116981. * @param x defines the x coordinate of the rectangle where pixels must be read
  116982. * @param y defines the y coordinate of the rectangle where pixels must be read
  116983. * @param width defines the width of the rectangle where pixels must be read
  116984. * @param height defines the height of the rectangle where pixels must be read
  116985. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116986. * @returns a Uint8Array containing RGBA colors
  116987. */
  116988. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116989. private static _IsSupported;
  116990. private static _HasMajorPerformanceCaveat;
  116991. /**
  116992. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116993. */
  116994. static get IsSupported(): boolean;
  116995. /**
  116996. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116997. * @returns true if the engine can be created
  116998. * @ignorenaming
  116999. */
  117000. static isSupported(): boolean;
  117001. /**
  117002. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  117003. */
  117004. static get HasMajorPerformanceCaveat(): boolean;
  117005. /**
  117006. * Find the next highest power of two.
  117007. * @param x Number to start search from.
  117008. * @return Next highest power of two.
  117009. */
  117010. static CeilingPOT(x: number): number;
  117011. /**
  117012. * Find the next lowest power of two.
  117013. * @param x Number to start search from.
  117014. * @return Next lowest power of two.
  117015. */
  117016. static FloorPOT(x: number): number;
  117017. /**
  117018. * Find the nearest power of two.
  117019. * @param x Number to start search from.
  117020. * @return Next nearest power of two.
  117021. */
  117022. static NearestPOT(x: number): number;
  117023. /**
  117024. * Get the closest exponent of two
  117025. * @param value defines the value to approximate
  117026. * @param max defines the maximum value to return
  117027. * @param mode defines how to define the closest value
  117028. * @returns closest exponent of two of the given value
  117029. */
  117030. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  117031. /**
  117032. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  117033. * @param func - the function to be called
  117034. * @param requester - the object that will request the next frame. Falls back to window.
  117035. * @returns frame number
  117036. */
  117037. static QueueNewFrame(func: () => void, requester?: any): number;
  117038. /**
  117039. * Gets host document
  117040. * @returns the host document object
  117041. */
  117042. getHostDocument(): Nullable<Document>;
  117043. }
  117044. }
  117045. declare module BABYLON {
  117046. /**
  117047. * Class representing spherical harmonics coefficients to the 3rd degree
  117048. */
  117049. export class SphericalHarmonics {
  117050. /**
  117051. * Defines whether or not the harmonics have been prescaled for rendering.
  117052. */
  117053. preScaled: boolean;
  117054. /**
  117055. * The l0,0 coefficients of the spherical harmonics
  117056. */
  117057. l00: Vector3;
  117058. /**
  117059. * The l1,-1 coefficients of the spherical harmonics
  117060. */
  117061. l1_1: Vector3;
  117062. /**
  117063. * The l1,0 coefficients of the spherical harmonics
  117064. */
  117065. l10: Vector3;
  117066. /**
  117067. * The l1,1 coefficients of the spherical harmonics
  117068. */
  117069. l11: Vector3;
  117070. /**
  117071. * The l2,-2 coefficients of the spherical harmonics
  117072. */
  117073. l2_2: Vector3;
  117074. /**
  117075. * The l2,-1 coefficients of the spherical harmonics
  117076. */
  117077. l2_1: Vector3;
  117078. /**
  117079. * The l2,0 coefficients of the spherical harmonics
  117080. */
  117081. l20: Vector3;
  117082. /**
  117083. * The l2,1 coefficients of the spherical harmonics
  117084. */
  117085. l21: Vector3;
  117086. /**
  117087. * The l2,2 coefficients of the spherical harmonics
  117088. */
  117089. l22: Vector3;
  117090. /**
  117091. * Adds a light to the spherical harmonics
  117092. * @param direction the direction of the light
  117093. * @param color the color of the light
  117094. * @param deltaSolidAngle the delta solid angle of the light
  117095. */
  117096. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  117097. /**
  117098. * Scales the spherical harmonics by the given amount
  117099. * @param scale the amount to scale
  117100. */
  117101. scaleInPlace(scale: number): void;
  117102. /**
  117103. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  117104. *
  117105. * ```
  117106. * E_lm = A_l * L_lm
  117107. * ```
  117108. *
  117109. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  117110. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  117111. * the scaling factors are given in equation 9.
  117112. */
  117113. convertIncidentRadianceToIrradiance(): void;
  117114. /**
  117115. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  117116. *
  117117. * ```
  117118. * L = (1/pi) * E * rho
  117119. * ```
  117120. *
  117121. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  117122. */
  117123. convertIrradianceToLambertianRadiance(): void;
  117124. /**
  117125. * Integrates the reconstruction coefficients directly in to the SH preventing further
  117126. * required operations at run time.
  117127. *
  117128. * This is simply done by scaling back the SH with Ylm constants parameter.
  117129. * The trigonometric part being applied by the shader at run time.
  117130. */
  117131. preScaleForRendering(): void;
  117132. /**
  117133. * Constructs a spherical harmonics from an array.
  117134. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  117135. * @returns the spherical harmonics
  117136. */
  117137. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  117138. /**
  117139. * Gets the spherical harmonics from polynomial
  117140. * @param polynomial the spherical polynomial
  117141. * @returns the spherical harmonics
  117142. */
  117143. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  117144. }
  117145. /**
  117146. * Class representing spherical polynomial coefficients to the 3rd degree
  117147. */
  117148. export class SphericalPolynomial {
  117149. private _harmonics;
  117150. /**
  117151. * The spherical harmonics used to create the polynomials.
  117152. */
  117153. get preScaledHarmonics(): SphericalHarmonics;
  117154. /**
  117155. * The x coefficients of the spherical polynomial
  117156. */
  117157. x: Vector3;
  117158. /**
  117159. * The y coefficients of the spherical polynomial
  117160. */
  117161. y: Vector3;
  117162. /**
  117163. * The z coefficients of the spherical polynomial
  117164. */
  117165. z: Vector3;
  117166. /**
  117167. * The xx coefficients of the spherical polynomial
  117168. */
  117169. xx: Vector3;
  117170. /**
  117171. * The yy coefficients of the spherical polynomial
  117172. */
  117173. yy: Vector3;
  117174. /**
  117175. * The zz coefficients of the spherical polynomial
  117176. */
  117177. zz: Vector3;
  117178. /**
  117179. * The xy coefficients of the spherical polynomial
  117180. */
  117181. xy: Vector3;
  117182. /**
  117183. * The yz coefficients of the spherical polynomial
  117184. */
  117185. yz: Vector3;
  117186. /**
  117187. * The zx coefficients of the spherical polynomial
  117188. */
  117189. zx: Vector3;
  117190. /**
  117191. * Adds an ambient color to the spherical polynomial
  117192. * @param color the color to add
  117193. */
  117194. addAmbient(color: Color3): void;
  117195. /**
  117196. * Scales the spherical polynomial by the given amount
  117197. * @param scale the amount to scale
  117198. */
  117199. scaleInPlace(scale: number): void;
  117200. /**
  117201. * Gets the spherical polynomial from harmonics
  117202. * @param harmonics the spherical harmonics
  117203. * @returns the spherical polynomial
  117204. */
  117205. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  117206. /**
  117207. * Constructs a spherical polynomial from an array.
  117208. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  117209. * @returns the spherical polynomial
  117210. */
  117211. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  117212. }
  117213. }
  117214. declare module BABYLON {
  117215. /**
  117216. * Defines the source of the internal texture
  117217. */
  117218. export enum InternalTextureSource {
  117219. /**
  117220. * The source of the texture data is unknown
  117221. */
  117222. Unknown = 0,
  117223. /**
  117224. * Texture data comes from an URL
  117225. */
  117226. Url = 1,
  117227. /**
  117228. * Texture data is only used for temporary storage
  117229. */
  117230. Temp = 2,
  117231. /**
  117232. * Texture data comes from raw data (ArrayBuffer)
  117233. */
  117234. Raw = 3,
  117235. /**
  117236. * Texture content is dynamic (video or dynamic texture)
  117237. */
  117238. Dynamic = 4,
  117239. /**
  117240. * Texture content is generated by rendering to it
  117241. */
  117242. RenderTarget = 5,
  117243. /**
  117244. * Texture content is part of a multi render target process
  117245. */
  117246. MultiRenderTarget = 6,
  117247. /**
  117248. * Texture data comes from a cube data file
  117249. */
  117250. Cube = 7,
  117251. /**
  117252. * Texture data comes from a raw cube data
  117253. */
  117254. CubeRaw = 8,
  117255. /**
  117256. * Texture data come from a prefiltered cube data file
  117257. */
  117258. CubePrefiltered = 9,
  117259. /**
  117260. * Texture content is raw 3D data
  117261. */
  117262. Raw3D = 10,
  117263. /**
  117264. * Texture content is raw 2D array data
  117265. */
  117266. Raw2DArray = 11,
  117267. /**
  117268. * Texture content is a depth texture
  117269. */
  117270. Depth = 12,
  117271. /**
  117272. * Texture data comes from a raw cube data encoded with RGBD
  117273. */
  117274. CubeRawRGBD = 13
  117275. }
  117276. /**
  117277. * Class used to store data associated with WebGL texture data for the engine
  117278. * This class should not be used directly
  117279. */
  117280. export class InternalTexture {
  117281. /** @hidden */
  117282. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  117283. /**
  117284. * Defines if the texture is ready
  117285. */
  117286. isReady: boolean;
  117287. /**
  117288. * Defines if the texture is a cube texture
  117289. */
  117290. isCube: boolean;
  117291. /**
  117292. * Defines if the texture contains 3D data
  117293. */
  117294. is3D: boolean;
  117295. /**
  117296. * Defines if the texture contains 2D array data
  117297. */
  117298. is2DArray: boolean;
  117299. /**
  117300. * Defines if the texture contains multiview data
  117301. */
  117302. isMultiview: boolean;
  117303. /**
  117304. * Gets the URL used to load this texture
  117305. */
  117306. url: string;
  117307. /**
  117308. * Gets the sampling mode of the texture
  117309. */
  117310. samplingMode: number;
  117311. /**
  117312. * Gets a boolean indicating if the texture needs mipmaps generation
  117313. */
  117314. generateMipMaps: boolean;
  117315. /**
  117316. * Gets the number of samples used by the texture (WebGL2+ only)
  117317. */
  117318. samples: number;
  117319. /**
  117320. * Gets the type of the texture (int, float...)
  117321. */
  117322. type: number;
  117323. /**
  117324. * Gets the format of the texture (RGB, RGBA...)
  117325. */
  117326. format: number;
  117327. /**
  117328. * Observable called when the texture is loaded
  117329. */
  117330. onLoadedObservable: Observable<InternalTexture>;
  117331. /**
  117332. * Gets the width of the texture
  117333. */
  117334. width: number;
  117335. /**
  117336. * Gets the height of the texture
  117337. */
  117338. height: number;
  117339. /**
  117340. * Gets the depth of the texture
  117341. */
  117342. depth: number;
  117343. /**
  117344. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  117345. */
  117346. baseWidth: number;
  117347. /**
  117348. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  117349. */
  117350. baseHeight: number;
  117351. /**
  117352. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  117353. */
  117354. baseDepth: number;
  117355. /**
  117356. * Gets a boolean indicating if the texture is inverted on Y axis
  117357. */
  117358. invertY: boolean;
  117359. /** @hidden */
  117360. _invertVScale: boolean;
  117361. /** @hidden */
  117362. _associatedChannel: number;
  117363. /** @hidden */
  117364. _source: InternalTextureSource;
  117365. /** @hidden */
  117366. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  117367. /** @hidden */
  117368. _bufferView: Nullable<ArrayBufferView>;
  117369. /** @hidden */
  117370. _bufferViewArray: Nullable<ArrayBufferView[]>;
  117371. /** @hidden */
  117372. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  117373. /** @hidden */
  117374. _size: number;
  117375. /** @hidden */
  117376. _extension: string;
  117377. /** @hidden */
  117378. _files: Nullable<string[]>;
  117379. /** @hidden */
  117380. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  117381. /** @hidden */
  117382. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  117383. /** @hidden */
  117384. _framebuffer: Nullable<WebGLFramebuffer>;
  117385. /** @hidden */
  117386. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  117387. /** @hidden */
  117388. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  117389. /** @hidden */
  117390. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  117391. /** @hidden */
  117392. _attachments: Nullable<number[]>;
  117393. /** @hidden */
  117394. _textureArray: Nullable<InternalTexture[]>;
  117395. /** @hidden */
  117396. _cachedCoordinatesMode: Nullable<number>;
  117397. /** @hidden */
  117398. _cachedWrapU: Nullable<number>;
  117399. /** @hidden */
  117400. _cachedWrapV: Nullable<number>;
  117401. /** @hidden */
  117402. _cachedWrapR: Nullable<number>;
  117403. /** @hidden */
  117404. _cachedAnisotropicFilteringLevel: Nullable<number>;
  117405. /** @hidden */
  117406. _isDisabled: boolean;
  117407. /** @hidden */
  117408. _compression: Nullable<string>;
  117409. /** @hidden */
  117410. _generateStencilBuffer: boolean;
  117411. /** @hidden */
  117412. _generateDepthBuffer: boolean;
  117413. /** @hidden */
  117414. _comparisonFunction: number;
  117415. /** @hidden */
  117416. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  117417. /** @hidden */
  117418. _lodGenerationScale: number;
  117419. /** @hidden */
  117420. _lodGenerationOffset: number;
  117421. /** @hidden */
  117422. _depthStencilTexture: Nullable<InternalTexture>;
  117423. /** @hidden */
  117424. _colorTextureArray: Nullable<WebGLTexture>;
  117425. /** @hidden */
  117426. _depthStencilTextureArray: Nullable<WebGLTexture>;
  117427. /** @hidden */
  117428. _lodTextureHigh: Nullable<BaseTexture>;
  117429. /** @hidden */
  117430. _lodTextureMid: Nullable<BaseTexture>;
  117431. /** @hidden */
  117432. _lodTextureLow: Nullable<BaseTexture>;
  117433. /** @hidden */
  117434. _isRGBD: boolean;
  117435. /** @hidden */
  117436. _linearSpecularLOD: boolean;
  117437. /** @hidden */
  117438. _irradianceTexture: Nullable<BaseTexture>;
  117439. /** @hidden */
  117440. _webGLTexture: Nullable<WebGLTexture>;
  117441. /** @hidden */
  117442. _references: number;
  117443. /** @hidden */
  117444. _gammaSpace: Nullable<boolean>;
  117445. private _engine;
  117446. /**
  117447. * Gets the Engine the texture belongs to.
  117448. * @returns The babylon engine
  117449. */
  117450. getEngine(): ThinEngine;
  117451. /**
  117452. * Gets the data source type of the texture
  117453. */
  117454. get source(): InternalTextureSource;
  117455. /**
  117456. * Creates a new InternalTexture
  117457. * @param engine defines the engine to use
  117458. * @param source defines the type of data that will be used
  117459. * @param delayAllocation if the texture allocation should be delayed (default: false)
  117460. */
  117461. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  117462. /**
  117463. * Increments the number of references (ie. the number of Texture that point to it)
  117464. */
  117465. incrementReferences(): void;
  117466. /**
  117467. * Change the size of the texture (not the size of the content)
  117468. * @param width defines the new width
  117469. * @param height defines the new height
  117470. * @param depth defines the new depth (1 by default)
  117471. */
  117472. updateSize(width: int, height: int, depth?: int): void;
  117473. /** @hidden */
  117474. _rebuild(): void;
  117475. /** @hidden */
  117476. _swapAndDie(target: InternalTexture): void;
  117477. /**
  117478. * Dispose the current allocated resources
  117479. */
  117480. dispose(): void;
  117481. }
  117482. }
  117483. declare module BABYLON {
  117484. /**
  117485. * Class used to work with sound analyzer using fast fourier transform (FFT)
  117486. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117487. */
  117488. export class Analyser {
  117489. /**
  117490. * Gets or sets the smoothing
  117491. * @ignorenaming
  117492. */
  117493. SMOOTHING: number;
  117494. /**
  117495. * Gets or sets the FFT table size
  117496. * @ignorenaming
  117497. */
  117498. FFT_SIZE: number;
  117499. /**
  117500. * Gets or sets the bar graph amplitude
  117501. * @ignorenaming
  117502. */
  117503. BARGRAPHAMPLITUDE: number;
  117504. /**
  117505. * Gets or sets the position of the debug canvas
  117506. * @ignorenaming
  117507. */
  117508. DEBUGCANVASPOS: {
  117509. x: number;
  117510. y: number;
  117511. };
  117512. /**
  117513. * Gets or sets the debug canvas size
  117514. * @ignorenaming
  117515. */
  117516. DEBUGCANVASSIZE: {
  117517. width: number;
  117518. height: number;
  117519. };
  117520. private _byteFreqs;
  117521. private _byteTime;
  117522. private _floatFreqs;
  117523. private _webAudioAnalyser;
  117524. private _debugCanvas;
  117525. private _debugCanvasContext;
  117526. private _scene;
  117527. private _registerFunc;
  117528. private _audioEngine;
  117529. /**
  117530. * Creates a new analyser
  117531. * @param scene defines hosting scene
  117532. */
  117533. constructor(scene: Scene);
  117534. /**
  117535. * Get the number of data values you will have to play with for the visualization
  117536. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  117537. * @returns a number
  117538. */
  117539. getFrequencyBinCount(): number;
  117540. /**
  117541. * Gets the current frequency data as a byte array
  117542. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117543. * @returns a Uint8Array
  117544. */
  117545. getByteFrequencyData(): Uint8Array;
  117546. /**
  117547. * Gets the current waveform as a byte array
  117548. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  117549. * @returns a Uint8Array
  117550. */
  117551. getByteTimeDomainData(): Uint8Array;
  117552. /**
  117553. * Gets the current frequency data as a float array
  117554. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117555. * @returns a Float32Array
  117556. */
  117557. getFloatFrequencyData(): Float32Array;
  117558. /**
  117559. * Renders the debug canvas
  117560. */
  117561. drawDebugCanvas(): void;
  117562. /**
  117563. * Stops rendering the debug canvas and removes it
  117564. */
  117565. stopDebugCanvas(): void;
  117566. /**
  117567. * Connects two audio nodes
  117568. * @param inputAudioNode defines first node to connect
  117569. * @param outputAudioNode defines second node to connect
  117570. */
  117571. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  117572. /**
  117573. * Releases all associated resources
  117574. */
  117575. dispose(): void;
  117576. }
  117577. }
  117578. declare module BABYLON {
  117579. /**
  117580. * This represents an audio engine and it is responsible
  117581. * to play, synchronize and analyse sounds throughout the application.
  117582. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117583. */
  117584. export interface IAudioEngine extends IDisposable {
  117585. /**
  117586. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117587. */
  117588. readonly canUseWebAudio: boolean;
  117589. /**
  117590. * Gets the current AudioContext if available.
  117591. */
  117592. readonly audioContext: Nullable<AudioContext>;
  117593. /**
  117594. * The master gain node defines the global audio volume of your audio engine.
  117595. */
  117596. readonly masterGain: GainNode;
  117597. /**
  117598. * Gets whether or not mp3 are supported by your browser.
  117599. */
  117600. readonly isMP3supported: boolean;
  117601. /**
  117602. * Gets whether or not ogg are supported by your browser.
  117603. */
  117604. readonly isOGGsupported: boolean;
  117605. /**
  117606. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117607. * @ignoreNaming
  117608. */
  117609. WarnedWebAudioUnsupported: boolean;
  117610. /**
  117611. * Defines if the audio engine relies on a custom unlocked button.
  117612. * In this case, the embedded button will not be displayed.
  117613. */
  117614. useCustomUnlockedButton: boolean;
  117615. /**
  117616. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  117617. */
  117618. readonly unlocked: boolean;
  117619. /**
  117620. * Event raised when audio has been unlocked on the browser.
  117621. */
  117622. onAudioUnlockedObservable: Observable<AudioEngine>;
  117623. /**
  117624. * Event raised when audio has been locked on the browser.
  117625. */
  117626. onAudioLockedObservable: Observable<AudioEngine>;
  117627. /**
  117628. * Flags the audio engine in Locked state.
  117629. * This happens due to new browser policies preventing audio to autoplay.
  117630. */
  117631. lock(): void;
  117632. /**
  117633. * Unlocks the audio engine once a user action has been done on the dom.
  117634. * This is helpful to resume play once browser policies have been satisfied.
  117635. */
  117636. unlock(): void;
  117637. /**
  117638. * Gets the global volume sets on the master gain.
  117639. * @returns the global volume if set or -1 otherwise
  117640. */
  117641. getGlobalVolume(): number;
  117642. /**
  117643. * Sets the global volume of your experience (sets on the master gain).
  117644. * @param newVolume Defines the new global volume of the application
  117645. */
  117646. setGlobalVolume(newVolume: number): void;
  117647. /**
  117648. * Connect the audio engine to an audio analyser allowing some amazing
  117649. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117650. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117651. * @param analyser The analyser to connect to the engine
  117652. */
  117653. connectToAnalyser(analyser: Analyser): void;
  117654. }
  117655. /**
  117656. * This represents the default audio engine used in babylon.
  117657. * It is responsible to play, synchronize and analyse sounds throughout the application.
  117658. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117659. */
  117660. export class AudioEngine implements IAudioEngine {
  117661. private _audioContext;
  117662. private _audioContextInitialized;
  117663. private _muteButton;
  117664. private _hostElement;
  117665. /**
  117666. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117667. */
  117668. canUseWebAudio: boolean;
  117669. /**
  117670. * The master gain node defines the global audio volume of your audio engine.
  117671. */
  117672. masterGain: GainNode;
  117673. /**
  117674. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117675. * @ignoreNaming
  117676. */
  117677. WarnedWebAudioUnsupported: boolean;
  117678. /**
  117679. * Gets whether or not mp3 are supported by your browser.
  117680. */
  117681. isMP3supported: boolean;
  117682. /**
  117683. * Gets whether or not ogg are supported by your browser.
  117684. */
  117685. isOGGsupported: boolean;
  117686. /**
  117687. * Gets whether audio has been unlocked on the device.
  117688. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  117689. * a user interaction has happened.
  117690. */
  117691. unlocked: boolean;
  117692. /**
  117693. * Defines if the audio engine relies on a custom unlocked button.
  117694. * In this case, the embedded button will not be displayed.
  117695. */
  117696. useCustomUnlockedButton: boolean;
  117697. /**
  117698. * Event raised when audio has been unlocked on the browser.
  117699. */
  117700. onAudioUnlockedObservable: Observable<AudioEngine>;
  117701. /**
  117702. * Event raised when audio has been locked on the browser.
  117703. */
  117704. onAudioLockedObservable: Observable<AudioEngine>;
  117705. /**
  117706. * Gets the current AudioContext if available.
  117707. */
  117708. get audioContext(): Nullable<AudioContext>;
  117709. private _connectedAnalyser;
  117710. /**
  117711. * Instantiates a new audio engine.
  117712. *
  117713. * There should be only one per page as some browsers restrict the number
  117714. * of audio contexts you can create.
  117715. * @param hostElement defines the host element where to display the mute icon if necessary
  117716. */
  117717. constructor(hostElement?: Nullable<HTMLElement>);
  117718. /**
  117719. * Flags the audio engine in Locked state.
  117720. * This happens due to new browser policies preventing audio to autoplay.
  117721. */
  117722. lock(): void;
  117723. /**
  117724. * Unlocks the audio engine once a user action has been done on the dom.
  117725. * This is helpful to resume play once browser policies have been satisfied.
  117726. */
  117727. unlock(): void;
  117728. private _resumeAudioContext;
  117729. private _initializeAudioContext;
  117730. private _tryToRun;
  117731. private _triggerRunningState;
  117732. private _triggerSuspendedState;
  117733. private _displayMuteButton;
  117734. private _moveButtonToTopLeft;
  117735. private _onResize;
  117736. private _hideMuteButton;
  117737. /**
  117738. * Destroy and release the resources associated with the audio ccontext.
  117739. */
  117740. dispose(): void;
  117741. /**
  117742. * Gets the global volume sets on the master gain.
  117743. * @returns the global volume if set or -1 otherwise
  117744. */
  117745. getGlobalVolume(): number;
  117746. /**
  117747. * Sets the global volume of your experience (sets on the master gain).
  117748. * @param newVolume Defines the new global volume of the application
  117749. */
  117750. setGlobalVolume(newVolume: number): void;
  117751. /**
  117752. * Connect the audio engine to an audio analyser allowing some amazing
  117753. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117754. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117755. * @param analyser The analyser to connect to the engine
  117756. */
  117757. connectToAnalyser(analyser: Analyser): void;
  117758. }
  117759. }
  117760. declare module BABYLON {
  117761. /**
  117762. * Interface used to present a loading screen while loading a scene
  117763. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117764. */
  117765. export interface ILoadingScreen {
  117766. /**
  117767. * Function called to display the loading screen
  117768. */
  117769. displayLoadingUI: () => void;
  117770. /**
  117771. * Function called to hide the loading screen
  117772. */
  117773. hideLoadingUI: () => void;
  117774. /**
  117775. * Gets or sets the color to use for the background
  117776. */
  117777. loadingUIBackgroundColor: string;
  117778. /**
  117779. * Gets or sets the text to display while loading
  117780. */
  117781. loadingUIText: string;
  117782. }
  117783. /**
  117784. * Class used for the default loading screen
  117785. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117786. */
  117787. export class DefaultLoadingScreen implements ILoadingScreen {
  117788. private _renderingCanvas;
  117789. private _loadingText;
  117790. private _loadingDivBackgroundColor;
  117791. private _loadingDiv;
  117792. private _loadingTextDiv;
  117793. /** Gets or sets the logo url to use for the default loading screen */
  117794. static DefaultLogoUrl: string;
  117795. /** Gets or sets the spinner url to use for the default loading screen */
  117796. static DefaultSpinnerUrl: string;
  117797. /**
  117798. * Creates a new default loading screen
  117799. * @param _renderingCanvas defines the canvas used to render the scene
  117800. * @param _loadingText defines the default text to display
  117801. * @param _loadingDivBackgroundColor defines the default background color
  117802. */
  117803. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  117804. /**
  117805. * Function called to display the loading screen
  117806. */
  117807. displayLoadingUI(): void;
  117808. /**
  117809. * Function called to hide the loading screen
  117810. */
  117811. hideLoadingUI(): void;
  117812. /**
  117813. * Gets or sets the text to display while loading
  117814. */
  117815. set loadingUIText(text: string);
  117816. get loadingUIText(): string;
  117817. /**
  117818. * Gets or sets the color to use for the background
  117819. */
  117820. get loadingUIBackgroundColor(): string;
  117821. set loadingUIBackgroundColor(color: string);
  117822. private _resizeLoadingUI;
  117823. }
  117824. }
  117825. declare module BABYLON {
  117826. /**
  117827. * Interface for any object that can request an animation frame
  117828. */
  117829. export interface ICustomAnimationFrameRequester {
  117830. /**
  117831. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  117832. */
  117833. renderFunction?: Function;
  117834. /**
  117835. * Called to request the next frame to render to
  117836. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  117837. */
  117838. requestAnimationFrame: Function;
  117839. /**
  117840. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  117841. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  117842. */
  117843. requestID?: number;
  117844. }
  117845. }
  117846. declare module BABYLON {
  117847. /**
  117848. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  117849. */
  117850. export class PerformanceMonitor {
  117851. private _enabled;
  117852. private _rollingFrameTime;
  117853. private _lastFrameTimeMs;
  117854. /**
  117855. * constructor
  117856. * @param frameSampleSize The number of samples required to saturate the sliding window
  117857. */
  117858. constructor(frameSampleSize?: number);
  117859. /**
  117860. * Samples current frame
  117861. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  117862. */
  117863. sampleFrame(timeMs?: number): void;
  117864. /**
  117865. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117866. */
  117867. get averageFrameTime(): number;
  117868. /**
  117869. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117870. */
  117871. get averageFrameTimeVariance(): number;
  117872. /**
  117873. * Returns the frame time of the most recent frame
  117874. */
  117875. get instantaneousFrameTime(): number;
  117876. /**
  117877. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  117878. */
  117879. get averageFPS(): number;
  117880. /**
  117881. * Returns the average framerate in frames per second using the most recent frame time
  117882. */
  117883. get instantaneousFPS(): number;
  117884. /**
  117885. * Returns true if enough samples have been taken to completely fill the sliding window
  117886. */
  117887. get isSaturated(): boolean;
  117888. /**
  117889. * Enables contributions to the sliding window sample set
  117890. */
  117891. enable(): void;
  117892. /**
  117893. * Disables contributions to the sliding window sample set
  117894. * Samples will not be interpolated over the disabled period
  117895. */
  117896. disable(): void;
  117897. /**
  117898. * Returns true if sampling is enabled
  117899. */
  117900. get isEnabled(): boolean;
  117901. /**
  117902. * Resets performance monitor
  117903. */
  117904. reset(): void;
  117905. }
  117906. /**
  117907. * RollingAverage
  117908. *
  117909. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  117910. */
  117911. export class RollingAverage {
  117912. /**
  117913. * Current average
  117914. */
  117915. average: number;
  117916. /**
  117917. * Current variance
  117918. */
  117919. variance: number;
  117920. protected _samples: Array<number>;
  117921. protected _sampleCount: number;
  117922. protected _pos: number;
  117923. protected _m2: number;
  117924. /**
  117925. * constructor
  117926. * @param length The number of samples required to saturate the sliding window
  117927. */
  117928. constructor(length: number);
  117929. /**
  117930. * Adds a sample to the sample set
  117931. * @param v The sample value
  117932. */
  117933. add(v: number): void;
  117934. /**
  117935. * Returns previously added values or null if outside of history or outside the sliding window domain
  117936. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  117937. * @return Value previously recorded with add() or null if outside of range
  117938. */
  117939. history(i: number): number;
  117940. /**
  117941. * Returns true if enough samples have been taken to completely fill the sliding window
  117942. * @return true if sample-set saturated
  117943. */
  117944. isSaturated(): boolean;
  117945. /**
  117946. * Resets the rolling average (equivalent to 0 samples taken so far)
  117947. */
  117948. reset(): void;
  117949. /**
  117950. * Wraps a value around the sample range boundaries
  117951. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  117952. * @return Wrapped position in sample range
  117953. */
  117954. protected _wrapPosition(i: number): number;
  117955. }
  117956. }
  117957. declare module BABYLON {
  117958. /**
  117959. * This class is used to track a performance counter which is number based.
  117960. * The user has access to many properties which give statistics of different nature.
  117961. *
  117962. * The implementer can track two kinds of Performance Counter: time and count.
  117963. * 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.
  117964. * 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.
  117965. */
  117966. export class PerfCounter {
  117967. /**
  117968. * Gets or sets a global boolean to turn on and off all the counters
  117969. */
  117970. static Enabled: boolean;
  117971. /**
  117972. * Returns the smallest value ever
  117973. */
  117974. get min(): number;
  117975. /**
  117976. * Returns the biggest value ever
  117977. */
  117978. get max(): number;
  117979. /**
  117980. * Returns the average value since the performance counter is running
  117981. */
  117982. get average(): number;
  117983. /**
  117984. * Returns the average value of the last second the counter was monitored
  117985. */
  117986. get lastSecAverage(): number;
  117987. /**
  117988. * Returns the current value
  117989. */
  117990. get current(): number;
  117991. /**
  117992. * Gets the accumulated total
  117993. */
  117994. get total(): number;
  117995. /**
  117996. * Gets the total value count
  117997. */
  117998. get count(): number;
  117999. /**
  118000. * Creates a new counter
  118001. */
  118002. constructor();
  118003. /**
  118004. * Call this method to start monitoring a new frame.
  118005. * 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.
  118006. */
  118007. fetchNewFrame(): void;
  118008. /**
  118009. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  118010. * @param newCount the count value to add to the monitored count
  118011. * @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.
  118012. */
  118013. addCount(newCount: number, fetchResult: boolean): void;
  118014. /**
  118015. * Start monitoring this performance counter
  118016. */
  118017. beginMonitoring(): void;
  118018. /**
  118019. * Compute the time lapsed since the previous beginMonitoring() call.
  118020. * @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
  118021. */
  118022. endMonitoring(newFrame?: boolean): void;
  118023. private _fetchResult;
  118024. private _startMonitoringTime;
  118025. private _min;
  118026. private _max;
  118027. private _average;
  118028. private _current;
  118029. private _totalValueCount;
  118030. private _totalAccumulated;
  118031. private _lastSecAverage;
  118032. private _lastSecAccumulated;
  118033. private _lastSecTime;
  118034. private _lastSecValueCount;
  118035. }
  118036. }
  118037. declare module BABYLON {
  118038. interface ThinEngine {
  118039. /** @hidden */
  118040. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  118041. }
  118042. }
  118043. declare module BABYLON {
  118044. /**
  118045. * Defines the interface used by display changed events
  118046. */
  118047. export interface IDisplayChangedEventArgs {
  118048. /** Gets the vrDisplay object (if any) */
  118049. vrDisplay: Nullable<any>;
  118050. /** Gets a boolean indicating if webVR is supported */
  118051. vrSupported: boolean;
  118052. }
  118053. /**
  118054. * Defines the interface used by objects containing a viewport (like a camera)
  118055. */
  118056. interface IViewportOwnerLike {
  118057. /**
  118058. * Gets or sets the viewport
  118059. */
  118060. viewport: IViewportLike;
  118061. }
  118062. /**
  118063. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  118064. */
  118065. export class Engine extends ThinEngine {
  118066. /** Defines that alpha blending is disabled */
  118067. static readonly ALPHA_DISABLE: number;
  118068. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  118069. static readonly ALPHA_ADD: number;
  118070. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  118071. static readonly ALPHA_COMBINE: number;
  118072. /** Defines that alpha blending to DEST - SRC * DEST */
  118073. static readonly ALPHA_SUBTRACT: number;
  118074. /** Defines that alpha blending to SRC * DEST */
  118075. static readonly ALPHA_MULTIPLY: number;
  118076. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  118077. static readonly ALPHA_MAXIMIZED: number;
  118078. /** Defines that alpha blending to SRC + DEST */
  118079. static readonly ALPHA_ONEONE: number;
  118080. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  118081. static readonly ALPHA_PREMULTIPLIED: number;
  118082. /**
  118083. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  118084. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  118085. */
  118086. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  118087. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  118088. static readonly ALPHA_INTERPOLATE: number;
  118089. /**
  118090. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  118091. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  118092. */
  118093. static readonly ALPHA_SCREENMODE: number;
  118094. /** Defines that the ressource is not delayed*/
  118095. static readonly DELAYLOADSTATE_NONE: number;
  118096. /** Defines that the ressource was successfully delay loaded */
  118097. static readonly DELAYLOADSTATE_LOADED: number;
  118098. /** Defines that the ressource is currently delay loading */
  118099. static readonly DELAYLOADSTATE_LOADING: number;
  118100. /** Defines that the ressource is delayed and has not started loading */
  118101. static readonly DELAYLOADSTATE_NOTLOADED: number;
  118102. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  118103. static readonly NEVER: number;
  118104. /** 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 */
  118105. static readonly ALWAYS: number;
  118106. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  118107. static readonly LESS: number;
  118108. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  118109. static readonly EQUAL: number;
  118110. /** 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 */
  118111. static readonly LEQUAL: number;
  118112. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  118113. static readonly GREATER: number;
  118114. /** 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 */
  118115. static readonly GEQUAL: number;
  118116. /** 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 */
  118117. static readonly NOTEQUAL: number;
  118118. /** Passed to stencilOperation to specify that stencil value must be kept */
  118119. static readonly KEEP: number;
  118120. /** Passed to stencilOperation to specify that stencil value must be replaced */
  118121. static readonly REPLACE: number;
  118122. /** Passed to stencilOperation to specify that stencil value must be incremented */
  118123. static readonly INCR: number;
  118124. /** Passed to stencilOperation to specify that stencil value must be decremented */
  118125. static readonly DECR: number;
  118126. /** Passed to stencilOperation to specify that stencil value must be inverted */
  118127. static readonly INVERT: number;
  118128. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  118129. static readonly INCR_WRAP: number;
  118130. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  118131. static readonly DECR_WRAP: number;
  118132. /** Texture is not repeating outside of 0..1 UVs */
  118133. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  118134. /** Texture is repeating outside of 0..1 UVs */
  118135. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  118136. /** Texture is repeating and mirrored */
  118137. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  118138. /** ALPHA */
  118139. static readonly TEXTUREFORMAT_ALPHA: number;
  118140. /** LUMINANCE */
  118141. static readonly TEXTUREFORMAT_LUMINANCE: number;
  118142. /** LUMINANCE_ALPHA */
  118143. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  118144. /** RGB */
  118145. static readonly TEXTUREFORMAT_RGB: number;
  118146. /** RGBA */
  118147. static readonly TEXTUREFORMAT_RGBA: number;
  118148. /** RED */
  118149. static readonly TEXTUREFORMAT_RED: number;
  118150. /** RED (2nd reference) */
  118151. static readonly TEXTUREFORMAT_R: number;
  118152. /** RG */
  118153. static readonly TEXTUREFORMAT_RG: number;
  118154. /** RED_INTEGER */
  118155. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  118156. /** RED_INTEGER (2nd reference) */
  118157. static readonly TEXTUREFORMAT_R_INTEGER: number;
  118158. /** RG_INTEGER */
  118159. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  118160. /** RGB_INTEGER */
  118161. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  118162. /** RGBA_INTEGER */
  118163. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  118164. /** UNSIGNED_BYTE */
  118165. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  118166. /** UNSIGNED_BYTE (2nd reference) */
  118167. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  118168. /** FLOAT */
  118169. static readonly TEXTURETYPE_FLOAT: number;
  118170. /** HALF_FLOAT */
  118171. static readonly TEXTURETYPE_HALF_FLOAT: number;
  118172. /** BYTE */
  118173. static readonly TEXTURETYPE_BYTE: number;
  118174. /** SHORT */
  118175. static readonly TEXTURETYPE_SHORT: number;
  118176. /** UNSIGNED_SHORT */
  118177. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  118178. /** INT */
  118179. static readonly TEXTURETYPE_INT: number;
  118180. /** UNSIGNED_INT */
  118181. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  118182. /** UNSIGNED_SHORT_4_4_4_4 */
  118183. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  118184. /** UNSIGNED_SHORT_5_5_5_1 */
  118185. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  118186. /** UNSIGNED_SHORT_5_6_5 */
  118187. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  118188. /** UNSIGNED_INT_2_10_10_10_REV */
  118189. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  118190. /** UNSIGNED_INT_24_8 */
  118191. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  118192. /** UNSIGNED_INT_10F_11F_11F_REV */
  118193. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  118194. /** UNSIGNED_INT_5_9_9_9_REV */
  118195. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  118196. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  118197. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  118198. /** nearest is mag = nearest and min = nearest and mip = linear */
  118199. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  118200. /** Bilinear is mag = linear and min = linear and mip = nearest */
  118201. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  118202. /** Trilinear is mag = linear and min = linear and mip = linear */
  118203. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  118204. /** nearest is mag = nearest and min = nearest and mip = linear */
  118205. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  118206. /** Bilinear is mag = linear and min = linear and mip = nearest */
  118207. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  118208. /** Trilinear is mag = linear and min = linear and mip = linear */
  118209. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  118210. /** mag = nearest and min = nearest and mip = nearest */
  118211. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  118212. /** mag = nearest and min = linear and mip = nearest */
  118213. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  118214. /** mag = nearest and min = linear and mip = linear */
  118215. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  118216. /** mag = nearest and min = linear and mip = none */
  118217. static readonly TEXTURE_NEAREST_LINEAR: number;
  118218. /** mag = nearest and min = nearest and mip = none */
  118219. static readonly TEXTURE_NEAREST_NEAREST: number;
  118220. /** mag = linear and min = nearest and mip = nearest */
  118221. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  118222. /** mag = linear and min = nearest and mip = linear */
  118223. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  118224. /** mag = linear and min = linear and mip = none */
  118225. static readonly TEXTURE_LINEAR_LINEAR: number;
  118226. /** mag = linear and min = nearest and mip = none */
  118227. static readonly TEXTURE_LINEAR_NEAREST: number;
  118228. /** Explicit coordinates mode */
  118229. static readonly TEXTURE_EXPLICIT_MODE: number;
  118230. /** Spherical coordinates mode */
  118231. static readonly TEXTURE_SPHERICAL_MODE: number;
  118232. /** Planar coordinates mode */
  118233. static readonly TEXTURE_PLANAR_MODE: number;
  118234. /** Cubic coordinates mode */
  118235. static readonly TEXTURE_CUBIC_MODE: number;
  118236. /** Projection coordinates mode */
  118237. static readonly TEXTURE_PROJECTION_MODE: number;
  118238. /** Skybox coordinates mode */
  118239. static readonly TEXTURE_SKYBOX_MODE: number;
  118240. /** Inverse Cubic coordinates mode */
  118241. static readonly TEXTURE_INVCUBIC_MODE: number;
  118242. /** Equirectangular coordinates mode */
  118243. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  118244. /** Equirectangular Fixed coordinates mode */
  118245. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  118246. /** Equirectangular Fixed Mirrored coordinates mode */
  118247. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  118248. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  118249. static readonly SCALEMODE_FLOOR: number;
  118250. /** Defines that texture rescaling will look for the nearest power of 2 size */
  118251. static readonly SCALEMODE_NEAREST: number;
  118252. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  118253. static readonly SCALEMODE_CEILING: number;
  118254. /**
  118255. * Returns the current npm package of the sdk
  118256. */
  118257. static get NpmPackage(): string;
  118258. /**
  118259. * Returns the current version of the framework
  118260. */
  118261. static get Version(): string;
  118262. /** Gets the list of created engines */
  118263. static get Instances(): Engine[];
  118264. /**
  118265. * Gets the latest created engine
  118266. */
  118267. static get LastCreatedEngine(): Nullable<Engine>;
  118268. /**
  118269. * Gets the latest created scene
  118270. */
  118271. static get LastCreatedScene(): Nullable<Scene>;
  118272. /**
  118273. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  118274. * @param flag defines which part of the materials must be marked as dirty
  118275. * @param predicate defines a predicate used to filter which materials should be affected
  118276. */
  118277. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  118278. /**
  118279. * Method called to create the default loading screen.
  118280. * This can be overriden in your own app.
  118281. * @param canvas The rendering canvas element
  118282. * @returns The loading screen
  118283. */
  118284. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  118285. /**
  118286. * Method called to create the default rescale post process on each engine.
  118287. */
  118288. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  118289. /**
  118290. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  118291. **/
  118292. enableOfflineSupport: boolean;
  118293. /**
  118294. * 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)
  118295. **/
  118296. disableManifestCheck: boolean;
  118297. /**
  118298. * Gets the list of created scenes
  118299. */
  118300. scenes: Scene[];
  118301. /**
  118302. * Event raised when a new scene is created
  118303. */
  118304. onNewSceneAddedObservable: Observable<Scene>;
  118305. /**
  118306. * Gets the list of created postprocesses
  118307. */
  118308. postProcesses: PostProcess[];
  118309. /**
  118310. * Gets a boolean indicating if the pointer is currently locked
  118311. */
  118312. isPointerLock: boolean;
  118313. /**
  118314. * Observable event triggered each time the rendering canvas is resized
  118315. */
  118316. onResizeObservable: Observable<Engine>;
  118317. /**
  118318. * Observable event triggered each time the canvas loses focus
  118319. */
  118320. onCanvasBlurObservable: Observable<Engine>;
  118321. /**
  118322. * Observable event triggered each time the canvas gains focus
  118323. */
  118324. onCanvasFocusObservable: Observable<Engine>;
  118325. /**
  118326. * Observable event triggered each time the canvas receives pointerout event
  118327. */
  118328. onCanvasPointerOutObservable: Observable<PointerEvent>;
  118329. /**
  118330. * Observable raised when the engine begins a new frame
  118331. */
  118332. onBeginFrameObservable: Observable<Engine>;
  118333. /**
  118334. * If set, will be used to request the next animation frame for the render loop
  118335. */
  118336. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  118337. /**
  118338. * Observable raised when the engine ends the current frame
  118339. */
  118340. onEndFrameObservable: Observable<Engine>;
  118341. /**
  118342. * Observable raised when the engine is about to compile a shader
  118343. */
  118344. onBeforeShaderCompilationObservable: Observable<Engine>;
  118345. /**
  118346. * Observable raised when the engine has jsut compiled a shader
  118347. */
  118348. onAfterShaderCompilationObservable: Observable<Engine>;
  118349. /**
  118350. * Gets the audio engine
  118351. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118352. * @ignorenaming
  118353. */
  118354. static audioEngine: IAudioEngine;
  118355. /**
  118356. * Default AudioEngine factory responsible of creating the Audio Engine.
  118357. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  118358. */
  118359. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  118360. /**
  118361. * Default offline support factory responsible of creating a tool used to store data locally.
  118362. * By default, this will create a Database object if the workload has been embedded.
  118363. */
  118364. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  118365. private _loadingScreen;
  118366. private _pointerLockRequested;
  118367. private _rescalePostProcess;
  118368. private _deterministicLockstep;
  118369. private _lockstepMaxSteps;
  118370. private _timeStep;
  118371. protected get _supportsHardwareTextureRescaling(): boolean;
  118372. private _fps;
  118373. private _deltaTime;
  118374. /** @hidden */
  118375. _drawCalls: PerfCounter;
  118376. /** 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 */
  118377. canvasTabIndex: number;
  118378. /**
  118379. * Turn this value on if you want to pause FPS computation when in background
  118380. */
  118381. disablePerformanceMonitorInBackground: boolean;
  118382. private _performanceMonitor;
  118383. /**
  118384. * Gets the performance monitor attached to this engine
  118385. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118386. */
  118387. get performanceMonitor(): PerformanceMonitor;
  118388. private _onFocus;
  118389. private _onBlur;
  118390. private _onCanvasPointerOut;
  118391. private _onCanvasBlur;
  118392. private _onCanvasFocus;
  118393. private _onFullscreenChange;
  118394. private _onPointerLockChange;
  118395. /**
  118396. * Gets the HTML element used to attach event listeners
  118397. * @returns a HTML element
  118398. */
  118399. getInputElement(): Nullable<HTMLElement>;
  118400. /**
  118401. * Creates a new engine
  118402. * @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
  118403. * @param antialias defines enable antialiasing (default: false)
  118404. * @param options defines further options to be sent to the getContext() function
  118405. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  118406. */
  118407. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  118408. /**
  118409. * Gets current aspect ratio
  118410. * @param viewportOwner defines the camera to use to get the aspect ratio
  118411. * @param useScreen defines if screen size must be used (or the current render target if any)
  118412. * @returns a number defining the aspect ratio
  118413. */
  118414. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  118415. /**
  118416. * Gets current screen aspect ratio
  118417. * @returns a number defining the aspect ratio
  118418. */
  118419. getScreenAspectRatio(): number;
  118420. /**
  118421. * Gets the client rect of the HTML canvas attached with the current webGL context
  118422. * @returns a client rectanglee
  118423. */
  118424. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  118425. /**
  118426. * Gets the client rect of the HTML element used for events
  118427. * @returns a client rectanglee
  118428. */
  118429. getInputElementClientRect(): Nullable<ClientRect>;
  118430. /**
  118431. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  118432. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118433. * @returns true if engine is in deterministic lock step mode
  118434. */
  118435. isDeterministicLockStep(): boolean;
  118436. /**
  118437. * Gets the max steps when engine is running in deterministic lock step
  118438. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118439. * @returns the max steps
  118440. */
  118441. getLockstepMaxSteps(): number;
  118442. /**
  118443. * Returns the time in ms between steps when using deterministic lock step.
  118444. * @returns time step in (ms)
  118445. */
  118446. getTimeStep(): number;
  118447. /**
  118448. * Force the mipmap generation for the given render target texture
  118449. * @param texture defines the render target texture to use
  118450. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  118451. */
  118452. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  118453. /** States */
  118454. /**
  118455. * Set various states to the webGL context
  118456. * @param culling defines backface culling state
  118457. * @param zOffset defines the value to apply to zOffset (0 by default)
  118458. * @param force defines if states must be applied even if cache is up to date
  118459. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  118460. */
  118461. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  118462. /**
  118463. * Set the z offset to apply to current rendering
  118464. * @param value defines the offset to apply
  118465. */
  118466. setZOffset(value: number): void;
  118467. /**
  118468. * Gets the current value of the zOffset
  118469. * @returns the current zOffset state
  118470. */
  118471. getZOffset(): number;
  118472. /**
  118473. * Enable or disable depth buffering
  118474. * @param enable defines the state to set
  118475. */
  118476. setDepthBuffer(enable: boolean): void;
  118477. /**
  118478. * Gets a boolean indicating if depth writing is enabled
  118479. * @returns the current depth writing state
  118480. */
  118481. getDepthWrite(): boolean;
  118482. /**
  118483. * Enable or disable depth writing
  118484. * @param enable defines the state to set
  118485. */
  118486. setDepthWrite(enable: boolean): void;
  118487. /**
  118488. * Gets a boolean indicating if stencil buffer is enabled
  118489. * @returns the current stencil buffer state
  118490. */
  118491. getStencilBuffer(): boolean;
  118492. /**
  118493. * Enable or disable the stencil buffer
  118494. * @param enable defines if the stencil buffer must be enabled or disabled
  118495. */
  118496. setStencilBuffer(enable: boolean): void;
  118497. /**
  118498. * Gets the current stencil mask
  118499. * @returns a number defining the new stencil mask to use
  118500. */
  118501. getStencilMask(): number;
  118502. /**
  118503. * Sets the current stencil mask
  118504. * @param mask defines the new stencil mask to use
  118505. */
  118506. setStencilMask(mask: number): void;
  118507. /**
  118508. * Gets the current stencil function
  118509. * @returns a number defining the stencil function to use
  118510. */
  118511. getStencilFunction(): number;
  118512. /**
  118513. * Gets the current stencil reference value
  118514. * @returns a number defining the stencil reference value to use
  118515. */
  118516. getStencilFunctionReference(): number;
  118517. /**
  118518. * Gets the current stencil mask
  118519. * @returns a number defining the stencil mask to use
  118520. */
  118521. getStencilFunctionMask(): number;
  118522. /**
  118523. * Sets the current stencil function
  118524. * @param stencilFunc defines the new stencil function to use
  118525. */
  118526. setStencilFunction(stencilFunc: number): void;
  118527. /**
  118528. * Sets the current stencil reference
  118529. * @param reference defines the new stencil reference to use
  118530. */
  118531. setStencilFunctionReference(reference: number): void;
  118532. /**
  118533. * Sets the current stencil mask
  118534. * @param mask defines the new stencil mask to use
  118535. */
  118536. setStencilFunctionMask(mask: number): void;
  118537. /**
  118538. * Gets the current stencil operation when stencil fails
  118539. * @returns a number defining stencil operation to use when stencil fails
  118540. */
  118541. getStencilOperationFail(): number;
  118542. /**
  118543. * Gets the current stencil operation when depth fails
  118544. * @returns a number defining stencil operation to use when depth fails
  118545. */
  118546. getStencilOperationDepthFail(): number;
  118547. /**
  118548. * Gets the current stencil operation when stencil passes
  118549. * @returns a number defining stencil operation to use when stencil passes
  118550. */
  118551. getStencilOperationPass(): number;
  118552. /**
  118553. * Sets the stencil operation to use when stencil fails
  118554. * @param operation defines the stencil operation to use when stencil fails
  118555. */
  118556. setStencilOperationFail(operation: number): void;
  118557. /**
  118558. * Sets the stencil operation to use when depth fails
  118559. * @param operation defines the stencil operation to use when depth fails
  118560. */
  118561. setStencilOperationDepthFail(operation: number): void;
  118562. /**
  118563. * Sets the stencil operation to use when stencil passes
  118564. * @param operation defines the stencil operation to use when stencil passes
  118565. */
  118566. setStencilOperationPass(operation: number): void;
  118567. /**
  118568. * Sets a boolean indicating if the dithering state is enabled or disabled
  118569. * @param value defines the dithering state
  118570. */
  118571. setDitheringState(value: boolean): void;
  118572. /**
  118573. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  118574. * @param value defines the rasterizer state
  118575. */
  118576. setRasterizerState(value: boolean): void;
  118577. /**
  118578. * Gets the current depth function
  118579. * @returns a number defining the depth function
  118580. */
  118581. getDepthFunction(): Nullable<number>;
  118582. /**
  118583. * Sets the current depth function
  118584. * @param depthFunc defines the function to use
  118585. */
  118586. setDepthFunction(depthFunc: number): void;
  118587. /**
  118588. * Sets the current depth function to GREATER
  118589. */
  118590. setDepthFunctionToGreater(): void;
  118591. /**
  118592. * Sets the current depth function to GEQUAL
  118593. */
  118594. setDepthFunctionToGreaterOrEqual(): void;
  118595. /**
  118596. * Sets the current depth function to LESS
  118597. */
  118598. setDepthFunctionToLess(): void;
  118599. /**
  118600. * Sets the current depth function to LEQUAL
  118601. */
  118602. setDepthFunctionToLessOrEqual(): void;
  118603. private _cachedStencilBuffer;
  118604. private _cachedStencilFunction;
  118605. private _cachedStencilMask;
  118606. private _cachedStencilOperationPass;
  118607. private _cachedStencilOperationFail;
  118608. private _cachedStencilOperationDepthFail;
  118609. private _cachedStencilReference;
  118610. /**
  118611. * Caches the the state of the stencil buffer
  118612. */
  118613. cacheStencilState(): void;
  118614. /**
  118615. * Restores the state of the stencil buffer
  118616. */
  118617. restoreStencilState(): void;
  118618. /**
  118619. * Directly set the WebGL Viewport
  118620. * @param x defines the x coordinate of the viewport (in screen space)
  118621. * @param y defines the y coordinate of the viewport (in screen space)
  118622. * @param width defines the width of the viewport (in screen space)
  118623. * @param height defines the height of the viewport (in screen space)
  118624. * @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
  118625. */
  118626. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  118627. /**
  118628. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  118629. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118630. * @param y defines the y-coordinate of the corner of the clear rectangle
  118631. * @param width defines the width of the clear rectangle
  118632. * @param height defines the height of the clear rectangle
  118633. * @param clearColor defines the clear color
  118634. */
  118635. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  118636. /**
  118637. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  118638. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118639. * @param y defines the y-coordinate of the corner of the clear rectangle
  118640. * @param width defines the width of the clear rectangle
  118641. * @param height defines the height of the clear rectangle
  118642. */
  118643. enableScissor(x: number, y: number, width: number, height: number): void;
  118644. /**
  118645. * Disable previously set scissor test rectangle
  118646. */
  118647. disableScissor(): void;
  118648. protected _reportDrawCall(): void;
  118649. /**
  118650. * Initializes a webVR display and starts listening to display change events
  118651. * The onVRDisplayChangedObservable will be notified upon these changes
  118652. * @returns The onVRDisplayChangedObservable
  118653. */
  118654. initWebVR(): Observable<IDisplayChangedEventArgs>;
  118655. /** @hidden */
  118656. _prepareVRComponent(): void;
  118657. /** @hidden */
  118658. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  118659. /** @hidden */
  118660. _submitVRFrame(): void;
  118661. /**
  118662. * Call this function to leave webVR mode
  118663. * Will do nothing if webVR is not supported or if there is no webVR device
  118664. * @see https://doc.babylonjs.com/how_to/webvr_camera
  118665. */
  118666. disableVR(): void;
  118667. /**
  118668. * Gets a boolean indicating that the system is in VR mode and is presenting
  118669. * @returns true if VR mode is engaged
  118670. */
  118671. isVRPresenting(): boolean;
  118672. /** @hidden */
  118673. _requestVRFrame(): void;
  118674. /** @hidden */
  118675. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118676. /**
  118677. * Gets the source code of the vertex shader associated with a specific webGL program
  118678. * @param program defines the program to use
  118679. * @returns a string containing the source code of the vertex shader associated with the program
  118680. */
  118681. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  118682. /**
  118683. * Gets the source code of the fragment shader associated with a specific webGL program
  118684. * @param program defines the program to use
  118685. * @returns a string containing the source code of the fragment shader associated with the program
  118686. */
  118687. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  118688. /**
  118689. * Sets a depth stencil texture from a render target to the according uniform.
  118690. * @param channel The texture channel
  118691. * @param uniform The uniform to set
  118692. * @param texture The render target texture containing the depth stencil texture to apply
  118693. */
  118694. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  118695. /**
  118696. * Sets a texture to the webGL context from a postprocess
  118697. * @param channel defines the channel to use
  118698. * @param postProcess defines the source postprocess
  118699. */
  118700. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  118701. /**
  118702. * Binds the output of the passed in post process to the texture channel specified
  118703. * @param channel The channel the texture should be bound to
  118704. * @param postProcess The post process which's output should be bound
  118705. */
  118706. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  118707. protected _rebuildBuffers(): void;
  118708. /** @hidden */
  118709. _renderFrame(): void;
  118710. _renderLoop(): void;
  118711. /** @hidden */
  118712. _renderViews(): boolean;
  118713. /**
  118714. * Toggle full screen mode
  118715. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118716. */
  118717. switchFullscreen(requestPointerLock: boolean): void;
  118718. /**
  118719. * Enters full screen mode
  118720. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118721. */
  118722. enterFullscreen(requestPointerLock: boolean): void;
  118723. /**
  118724. * Exits full screen mode
  118725. */
  118726. exitFullscreen(): void;
  118727. /**
  118728. * Enters Pointerlock mode
  118729. */
  118730. enterPointerlock(): void;
  118731. /**
  118732. * Exits Pointerlock mode
  118733. */
  118734. exitPointerlock(): void;
  118735. /**
  118736. * Begin a new frame
  118737. */
  118738. beginFrame(): void;
  118739. /**
  118740. * Enf the current frame
  118741. */
  118742. endFrame(): void;
  118743. resize(): void;
  118744. /**
  118745. * Force a specific size of the canvas
  118746. * @param width defines the new canvas' width
  118747. * @param height defines the new canvas' height
  118748. * @returns true if the size was changed
  118749. */
  118750. setSize(width: number, height: number): boolean;
  118751. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118752. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118753. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118754. _releaseTexture(texture: InternalTexture): void;
  118755. /**
  118756. * @hidden
  118757. * Rescales a texture
  118758. * @param source input texutre
  118759. * @param destination destination texture
  118760. * @param scene scene to use to render the resize
  118761. * @param internalFormat format to use when resizing
  118762. * @param onComplete callback to be called when resize has completed
  118763. */
  118764. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  118765. /**
  118766. * Gets the current framerate
  118767. * @returns a number representing the framerate
  118768. */
  118769. getFps(): number;
  118770. /**
  118771. * Gets the time spent between current and previous frame
  118772. * @returns a number representing the delta time in ms
  118773. */
  118774. getDeltaTime(): number;
  118775. private _measureFps;
  118776. /** @hidden */
  118777. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  118778. /**
  118779. * Updates the sample count of a render target texture
  118780. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118781. * @param texture defines the texture to update
  118782. * @param samples defines the sample count to set
  118783. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118784. */
  118785. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  118786. /**
  118787. * Updates a depth texture Comparison Mode and Function.
  118788. * If the comparison Function is equal to 0, the mode will be set to none.
  118789. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  118790. * @param texture The texture to set the comparison function for
  118791. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  118792. */
  118793. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  118794. /**
  118795. * Creates a webGL buffer to use with instanciation
  118796. * @param capacity defines the size of the buffer
  118797. * @returns the webGL buffer
  118798. */
  118799. createInstancesBuffer(capacity: number): DataBuffer;
  118800. /**
  118801. * Delete a webGL buffer used with instanciation
  118802. * @param buffer defines the webGL buffer to delete
  118803. */
  118804. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  118805. private _clientWaitAsync;
  118806. /** @hidden */
  118807. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  118808. dispose(): void;
  118809. private _disableTouchAction;
  118810. /**
  118811. * Display the loading screen
  118812. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118813. */
  118814. displayLoadingUI(): void;
  118815. /**
  118816. * Hide the loading screen
  118817. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118818. */
  118819. hideLoadingUI(): void;
  118820. /**
  118821. * Gets the current loading screen object
  118822. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118823. */
  118824. get loadingScreen(): ILoadingScreen;
  118825. /**
  118826. * Sets the current loading screen object
  118827. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118828. */
  118829. set loadingScreen(loadingScreen: ILoadingScreen);
  118830. /**
  118831. * Sets the current loading screen text
  118832. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118833. */
  118834. set loadingUIText(text: string);
  118835. /**
  118836. * Sets the current loading screen background color
  118837. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118838. */
  118839. set loadingUIBackgroundColor(color: string);
  118840. /** Pointerlock and fullscreen */
  118841. /**
  118842. * Ask the browser to promote the current element to pointerlock mode
  118843. * @param element defines the DOM element to promote
  118844. */
  118845. static _RequestPointerlock(element: HTMLElement): void;
  118846. /**
  118847. * Asks the browser to exit pointerlock mode
  118848. */
  118849. static _ExitPointerlock(): void;
  118850. /**
  118851. * Ask the browser to promote the current element to fullscreen rendering mode
  118852. * @param element defines the DOM element to promote
  118853. */
  118854. static _RequestFullscreen(element: HTMLElement): void;
  118855. /**
  118856. * Asks the browser to exit fullscreen mode
  118857. */
  118858. static _ExitFullscreen(): void;
  118859. }
  118860. }
  118861. declare module BABYLON {
  118862. /**
  118863. * The engine store class is responsible to hold all the instances of Engine and Scene created
  118864. * during the life time of the application.
  118865. */
  118866. export class EngineStore {
  118867. /** Gets the list of created engines */
  118868. static Instances: Engine[];
  118869. /** @hidden */
  118870. static _LastCreatedScene: Nullable<Scene>;
  118871. /**
  118872. * Gets the latest created engine
  118873. */
  118874. static get LastCreatedEngine(): Nullable<Engine>;
  118875. /**
  118876. * Gets the latest created scene
  118877. */
  118878. static get LastCreatedScene(): Nullable<Scene>;
  118879. /**
  118880. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118881. * @ignorenaming
  118882. */
  118883. static UseFallbackTexture: boolean;
  118884. /**
  118885. * Texture content used if a texture cannot loaded
  118886. * @ignorenaming
  118887. */
  118888. static FallbackTexture: string;
  118889. }
  118890. }
  118891. declare module BABYLON {
  118892. /**
  118893. * Helper class that provides a small promise polyfill
  118894. */
  118895. export class PromisePolyfill {
  118896. /**
  118897. * Static function used to check if the polyfill is required
  118898. * If this is the case then the function will inject the polyfill to window.Promise
  118899. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  118900. */
  118901. static Apply(force?: boolean): void;
  118902. }
  118903. }
  118904. declare module BABYLON {
  118905. /**
  118906. * Interface for screenshot methods with describe argument called `size` as object with options
  118907. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  118908. */
  118909. export interface IScreenshotSize {
  118910. /**
  118911. * number in pixels for canvas height
  118912. */
  118913. height?: number;
  118914. /**
  118915. * multiplier allowing render at a higher or lower resolution
  118916. * If value is defined then height and width will be ignored and taken from camera
  118917. */
  118918. precision?: number;
  118919. /**
  118920. * number in pixels for canvas width
  118921. */
  118922. width?: number;
  118923. }
  118924. }
  118925. declare module BABYLON {
  118926. interface IColor4Like {
  118927. r: float;
  118928. g: float;
  118929. b: float;
  118930. a: float;
  118931. }
  118932. /**
  118933. * Class containing a set of static utilities functions
  118934. */
  118935. export class Tools {
  118936. /**
  118937. * Gets or sets the base URL to use to load assets
  118938. */
  118939. static get BaseUrl(): string;
  118940. static set BaseUrl(value: string);
  118941. /**
  118942. * Enable/Disable Custom HTTP Request Headers globally.
  118943. * default = false
  118944. * @see CustomRequestHeaders
  118945. */
  118946. static UseCustomRequestHeaders: boolean;
  118947. /**
  118948. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  118949. * i.e. when loading files, where the server/service expects an Authorization header
  118950. */
  118951. static CustomRequestHeaders: {
  118952. [key: string]: string;
  118953. };
  118954. /**
  118955. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  118956. */
  118957. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  118958. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  118959. /**
  118960. * Default behaviour for cors in the application.
  118961. * It can be a string if the expected behavior is identical in the entire app.
  118962. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  118963. */
  118964. static get CorsBehavior(): string | ((url: string | string[]) => string);
  118965. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  118966. /**
  118967. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118968. * @ignorenaming
  118969. */
  118970. static get UseFallbackTexture(): boolean;
  118971. static set UseFallbackTexture(value: boolean);
  118972. /**
  118973. * Use this object to register external classes like custom textures or material
  118974. * to allow the laoders to instantiate them
  118975. */
  118976. static get RegisteredExternalClasses(): {
  118977. [key: string]: Object;
  118978. };
  118979. static set RegisteredExternalClasses(classes: {
  118980. [key: string]: Object;
  118981. });
  118982. /**
  118983. * Texture content used if a texture cannot loaded
  118984. * @ignorenaming
  118985. */
  118986. static get fallbackTexture(): string;
  118987. static set fallbackTexture(value: string);
  118988. /**
  118989. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118990. * @param u defines the coordinate on X axis
  118991. * @param v defines the coordinate on Y axis
  118992. * @param width defines the width of the source data
  118993. * @param height defines the height of the source data
  118994. * @param pixels defines the source byte array
  118995. * @param color defines the output color
  118996. */
  118997. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118998. /**
  118999. * Interpolates between a and b via alpha
  119000. * @param a The lower value (returned when alpha = 0)
  119001. * @param b The upper value (returned when alpha = 1)
  119002. * @param alpha The interpolation-factor
  119003. * @return The mixed value
  119004. */
  119005. static Mix(a: number, b: number, alpha: number): number;
  119006. /**
  119007. * Tries to instantiate a new object from a given class name
  119008. * @param className defines the class name to instantiate
  119009. * @returns the new object or null if the system was not able to do the instantiation
  119010. */
  119011. static Instantiate(className: string): any;
  119012. /**
  119013. * Provides a slice function that will work even on IE
  119014. * @param data defines the array to slice
  119015. * @param start defines the start of the data (optional)
  119016. * @param end defines the end of the data (optional)
  119017. * @returns the new sliced array
  119018. */
  119019. static Slice<T>(data: T, start?: number, end?: number): T;
  119020. /**
  119021. * Polyfill for setImmediate
  119022. * @param action defines the action to execute after the current execution block
  119023. */
  119024. static SetImmediate(action: () => void): void;
  119025. /**
  119026. * Function indicating if a number is an exponent of 2
  119027. * @param value defines the value to test
  119028. * @returns true if the value is an exponent of 2
  119029. */
  119030. static IsExponentOfTwo(value: number): boolean;
  119031. private static _tmpFloatArray;
  119032. /**
  119033. * Returns the nearest 32-bit single precision float representation of a Number
  119034. * @param value A Number. If the parameter is of a different type, it will get converted
  119035. * to a number or to NaN if it cannot be converted
  119036. * @returns number
  119037. */
  119038. static FloatRound(value: number): number;
  119039. /**
  119040. * Extracts the filename from a path
  119041. * @param path defines the path to use
  119042. * @returns the filename
  119043. */
  119044. static GetFilename(path: string): string;
  119045. /**
  119046. * Extracts the "folder" part of a path (everything before the filename).
  119047. * @param uri The URI to extract the info from
  119048. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  119049. * @returns The "folder" part of the path
  119050. */
  119051. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  119052. /**
  119053. * Extracts text content from a DOM element hierarchy
  119054. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  119055. */
  119056. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  119057. /**
  119058. * Convert an angle in radians to degrees
  119059. * @param angle defines the angle to convert
  119060. * @returns the angle in degrees
  119061. */
  119062. static ToDegrees(angle: number): number;
  119063. /**
  119064. * Convert an angle in degrees to radians
  119065. * @param angle defines the angle to convert
  119066. * @returns the angle in radians
  119067. */
  119068. static ToRadians(angle: number): number;
  119069. /**
  119070. * Returns an array if obj is not an array
  119071. * @param obj defines the object to evaluate as an array
  119072. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  119073. * @returns either obj directly if obj is an array or a new array containing obj
  119074. */
  119075. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  119076. /**
  119077. * Gets the pointer prefix to use
  119078. * @param engine defines the engine we are finding the prefix for
  119079. * @returns "pointer" if touch is enabled. Else returns "mouse"
  119080. */
  119081. static GetPointerPrefix(engine: Engine): string;
  119082. /**
  119083. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  119084. * @param url define the url we are trying
  119085. * @param element define the dom element where to configure the cors policy
  119086. */
  119087. static SetCorsBehavior(url: string | string[], element: {
  119088. crossOrigin: string | null;
  119089. }): void;
  119090. /**
  119091. * Removes unwanted characters from an url
  119092. * @param url defines the url to clean
  119093. * @returns the cleaned url
  119094. */
  119095. static CleanUrl(url: string): string;
  119096. /**
  119097. * Gets or sets a function used to pre-process url before using them to load assets
  119098. */
  119099. static get PreprocessUrl(): (url: string) => string;
  119100. static set PreprocessUrl(processor: (url: string) => string);
  119101. /**
  119102. * Loads an image as an HTMLImageElement.
  119103. * @param input url string, ArrayBuffer, or Blob to load
  119104. * @param onLoad callback called when the image successfully loads
  119105. * @param onError callback called when the image fails to load
  119106. * @param offlineProvider offline provider for caching
  119107. * @param mimeType optional mime type
  119108. * @returns the HTMLImageElement of the loaded image
  119109. */
  119110. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  119111. /**
  119112. * Loads a file from a url
  119113. * @param url url string, ArrayBuffer, or Blob to load
  119114. * @param onSuccess callback called when the file successfully loads
  119115. * @param onProgress callback called while file is loading (if the server supports this mode)
  119116. * @param offlineProvider defines the offline provider for caching
  119117. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  119118. * @param onError callback called when the file fails to load
  119119. * @returns a file request object
  119120. */
  119121. 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;
  119122. /**
  119123. * Loads a file from a url
  119124. * @param url the file url to load
  119125. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  119126. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  119127. */
  119128. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  119129. /**
  119130. * Load a script (identified by an url). When the url returns, the
  119131. * content of this file is added into a new script element, attached to the DOM (body element)
  119132. * @param scriptUrl defines the url of the script to laod
  119133. * @param onSuccess defines the callback called when the script is loaded
  119134. * @param onError defines the callback to call if an error occurs
  119135. * @param scriptId defines the id of the script element
  119136. */
  119137. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  119138. /**
  119139. * Load an asynchronous script (identified by an url). When the url returns, the
  119140. * content of this file is added into a new script element, attached to the DOM (body element)
  119141. * @param scriptUrl defines the url of the script to laod
  119142. * @param scriptId defines the id of the script element
  119143. * @returns a promise request object
  119144. */
  119145. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  119146. /**
  119147. * Loads a file from a blob
  119148. * @param fileToLoad defines the blob to use
  119149. * @param callback defines the callback to call when data is loaded
  119150. * @param progressCallback defines the callback to call during loading process
  119151. * @returns a file request object
  119152. */
  119153. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  119154. /**
  119155. * Reads a file from a File object
  119156. * @param file defines the file to load
  119157. * @param onSuccess defines the callback to call when data is loaded
  119158. * @param onProgress defines the callback to call during loading process
  119159. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  119160. * @param onError defines the callback to call when an error occurs
  119161. * @returns a file request object
  119162. */
  119163. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  119164. /**
  119165. * Creates a data url from a given string content
  119166. * @param content defines the content to convert
  119167. * @returns the new data url link
  119168. */
  119169. static FileAsURL(content: string): string;
  119170. /**
  119171. * Format the given number to a specific decimal format
  119172. * @param value defines the number to format
  119173. * @param decimals defines the number of decimals to use
  119174. * @returns the formatted string
  119175. */
  119176. static Format(value: number, decimals?: number): string;
  119177. /**
  119178. * Tries to copy an object by duplicating every property
  119179. * @param source defines the source object
  119180. * @param destination defines the target object
  119181. * @param doNotCopyList defines a list of properties to avoid
  119182. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  119183. */
  119184. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  119185. /**
  119186. * Gets a boolean indicating if the given object has no own property
  119187. * @param obj defines the object to test
  119188. * @returns true if object has no own property
  119189. */
  119190. static IsEmpty(obj: any): boolean;
  119191. /**
  119192. * Function used to register events at window level
  119193. * @param windowElement defines the Window object to use
  119194. * @param events defines the events to register
  119195. */
  119196. static RegisterTopRootEvents(windowElement: Window, events: {
  119197. name: string;
  119198. handler: Nullable<(e: FocusEvent) => any>;
  119199. }[]): void;
  119200. /**
  119201. * Function used to unregister events from window level
  119202. * @param windowElement defines the Window object to use
  119203. * @param events defines the events to unregister
  119204. */
  119205. static UnregisterTopRootEvents(windowElement: Window, events: {
  119206. name: string;
  119207. handler: Nullable<(e: FocusEvent) => any>;
  119208. }[]): void;
  119209. /**
  119210. * @ignore
  119211. */
  119212. static _ScreenshotCanvas: HTMLCanvasElement;
  119213. /**
  119214. * Dumps the current bound framebuffer
  119215. * @param width defines the rendering width
  119216. * @param height defines the rendering height
  119217. * @param engine defines the hosting engine
  119218. * @param successCallback defines the callback triggered once the data are available
  119219. * @param mimeType defines the mime type of the result
  119220. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  119221. */
  119222. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  119223. /**
  119224. * Converts the canvas data to blob.
  119225. * This acts as a polyfill for browsers not supporting the to blob function.
  119226. * @param canvas Defines the canvas to extract the data from
  119227. * @param successCallback Defines the callback triggered once the data are available
  119228. * @param mimeType Defines the mime type of the result
  119229. */
  119230. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  119231. /**
  119232. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  119233. * @param successCallback defines the callback triggered once the data are available
  119234. * @param mimeType defines the mime type of the result
  119235. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  119236. */
  119237. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  119238. /**
  119239. * Downloads a blob in the browser
  119240. * @param blob defines the blob to download
  119241. * @param fileName defines the name of the downloaded file
  119242. */
  119243. static Download(blob: Blob, fileName: string): void;
  119244. /**
  119245. * Captures a screenshot of the current rendering
  119246. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  119247. * @param engine defines the rendering engine
  119248. * @param camera defines the source camera
  119249. * @param size This parameter can be set to a single number or to an object with the
  119250. * following (optional) properties: precision, width, height. If a single number is passed,
  119251. * it will be used for both width and height. If an object is passed, the screenshot size
  119252. * will be derived from the parameters. The precision property is a multiplier allowing
  119253. * rendering at a higher or lower resolution
  119254. * @param successCallback defines the callback receives a single parameter which contains the
  119255. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  119256. * src parameter of an <img> to display it
  119257. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  119258. * Check your browser for supported MIME types
  119259. */
  119260. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  119261. /**
  119262. * Captures a screenshot of the current rendering
  119263. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  119264. * @param engine defines the rendering engine
  119265. * @param camera defines the source camera
  119266. * @param size This parameter can be set to a single number or to an object with the
  119267. * following (optional) properties: precision, width, height. If a single number is passed,
  119268. * it will be used for both width and height. If an object is passed, the screenshot size
  119269. * will be derived from the parameters. The precision property is a multiplier allowing
  119270. * rendering at a higher or lower resolution
  119271. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  119272. * Check your browser for supported MIME types
  119273. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  119274. * to the src parameter of an <img> to display it
  119275. */
  119276. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  119277. /**
  119278. * Generates an image screenshot from the specified camera.
  119279. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  119280. * @param engine The engine to use for rendering
  119281. * @param camera The camera to use for rendering
  119282. * @param size This parameter can be set to a single number or to an object with the
  119283. * following (optional) properties: precision, width, height. If a single number is passed,
  119284. * it will be used for both width and height. If an object is passed, the screenshot size
  119285. * will be derived from the parameters. The precision property is a multiplier allowing
  119286. * rendering at a higher or lower resolution
  119287. * @param successCallback The callback receives a single parameter which contains the
  119288. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  119289. * src parameter of an <img> to display it
  119290. * @param mimeType The MIME type of the screenshot image (default: image/png).
  119291. * Check your browser for supported MIME types
  119292. * @param samples Texture samples (default: 1)
  119293. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  119294. * @param fileName A name for for the downloaded file.
  119295. */
  119296. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  119297. /**
  119298. * Generates an image screenshot from the specified camera.
  119299. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  119300. * @param engine The engine to use for rendering
  119301. * @param camera The camera to use for rendering
  119302. * @param size This parameter can be set to a single number or to an object with the
  119303. * following (optional) properties: precision, width, height. If a single number is passed,
  119304. * it will be used for both width and height. If an object is passed, the screenshot size
  119305. * will be derived from the parameters. The precision property is a multiplier allowing
  119306. * rendering at a higher or lower resolution
  119307. * @param mimeType The MIME type of the screenshot image (default: image/png).
  119308. * Check your browser for supported MIME types
  119309. * @param samples Texture samples (default: 1)
  119310. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  119311. * @param fileName A name for for the downloaded file.
  119312. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  119313. * to the src parameter of an <img> to display it
  119314. */
  119315. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  119316. /**
  119317. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  119318. * Be aware Math.random() could cause collisions, but:
  119319. * "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"
  119320. * @returns a pseudo random id
  119321. */
  119322. static RandomId(): string;
  119323. /**
  119324. * Test if the given uri is a base64 string
  119325. * @param uri The uri to test
  119326. * @return True if the uri is a base64 string or false otherwise
  119327. */
  119328. static IsBase64(uri: string): boolean;
  119329. /**
  119330. * Decode the given base64 uri.
  119331. * @param uri The uri to decode
  119332. * @return The decoded base64 data.
  119333. */
  119334. static DecodeBase64(uri: string): ArrayBuffer;
  119335. /**
  119336. * Gets the absolute url.
  119337. * @param url the input url
  119338. * @return the absolute url
  119339. */
  119340. static GetAbsoluteUrl(url: string): string;
  119341. /**
  119342. * No log
  119343. */
  119344. static readonly NoneLogLevel: number;
  119345. /**
  119346. * Only message logs
  119347. */
  119348. static readonly MessageLogLevel: number;
  119349. /**
  119350. * Only warning logs
  119351. */
  119352. static readonly WarningLogLevel: number;
  119353. /**
  119354. * Only error logs
  119355. */
  119356. static readonly ErrorLogLevel: number;
  119357. /**
  119358. * All logs
  119359. */
  119360. static readonly AllLogLevel: number;
  119361. /**
  119362. * Gets a value indicating the number of loading errors
  119363. * @ignorenaming
  119364. */
  119365. static get errorsCount(): number;
  119366. /**
  119367. * Callback called when a new log is added
  119368. */
  119369. static OnNewCacheEntry: (entry: string) => void;
  119370. /**
  119371. * Log a message to the console
  119372. * @param message defines the message to log
  119373. */
  119374. static Log(message: string): void;
  119375. /**
  119376. * Write a warning message to the console
  119377. * @param message defines the message to log
  119378. */
  119379. static Warn(message: string): void;
  119380. /**
  119381. * Write an error message to the console
  119382. * @param message defines the message to log
  119383. */
  119384. static Error(message: string): void;
  119385. /**
  119386. * Gets current log cache (list of logs)
  119387. */
  119388. static get LogCache(): string;
  119389. /**
  119390. * Clears the log cache
  119391. */
  119392. static ClearLogCache(): void;
  119393. /**
  119394. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  119395. */
  119396. static set LogLevels(level: number);
  119397. /**
  119398. * Checks if the window object exists
  119399. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  119400. */
  119401. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  119402. /**
  119403. * No performance log
  119404. */
  119405. static readonly PerformanceNoneLogLevel: number;
  119406. /**
  119407. * Use user marks to log performance
  119408. */
  119409. static readonly PerformanceUserMarkLogLevel: number;
  119410. /**
  119411. * Log performance to the console
  119412. */
  119413. static readonly PerformanceConsoleLogLevel: number;
  119414. private static _performance;
  119415. /**
  119416. * Sets the current performance log level
  119417. */
  119418. static set PerformanceLogLevel(level: number);
  119419. private static _StartPerformanceCounterDisabled;
  119420. private static _EndPerformanceCounterDisabled;
  119421. private static _StartUserMark;
  119422. private static _EndUserMark;
  119423. private static _StartPerformanceConsole;
  119424. private static _EndPerformanceConsole;
  119425. /**
  119426. * Starts a performance counter
  119427. */
  119428. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119429. /**
  119430. * Ends a specific performance coutner
  119431. */
  119432. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119433. /**
  119434. * Gets either window.performance.now() if supported or Date.now() else
  119435. */
  119436. static get Now(): number;
  119437. /**
  119438. * This method will return the name of the class used to create the instance of the given object.
  119439. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  119440. * @param object the object to get the class name from
  119441. * @param isType defines if the object is actually a type
  119442. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  119443. */
  119444. static GetClassName(object: any, isType?: boolean): string;
  119445. /**
  119446. * Gets the first element of an array satisfying a given predicate
  119447. * @param array defines the array to browse
  119448. * @param predicate defines the predicate to use
  119449. * @returns null if not found or the element
  119450. */
  119451. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  119452. /**
  119453. * This method will return the name of the full name of the class, including its owning module (if any).
  119454. * 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).
  119455. * @param object the object to get the class name from
  119456. * @param isType defines if the object is actually a type
  119457. * @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.
  119458. * @ignorenaming
  119459. */
  119460. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  119461. /**
  119462. * Returns a promise that resolves after the given amount of time.
  119463. * @param delay Number of milliseconds to delay
  119464. * @returns Promise that resolves after the given amount of time
  119465. */
  119466. static DelayAsync(delay: number): Promise<void>;
  119467. /**
  119468. * Utility function to detect if the current user agent is Safari
  119469. * @returns whether or not the current user agent is safari
  119470. */
  119471. static IsSafari(): boolean;
  119472. }
  119473. /**
  119474. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  119475. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  119476. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  119477. * @param name The name of the class, case should be preserved
  119478. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  119479. */
  119480. export function className(name: string, module?: string): (target: Object) => void;
  119481. /**
  119482. * An implementation of a loop for asynchronous functions.
  119483. */
  119484. export class AsyncLoop {
  119485. /**
  119486. * Defines the number of iterations for the loop
  119487. */
  119488. iterations: number;
  119489. /**
  119490. * Defines the current index of the loop.
  119491. */
  119492. index: number;
  119493. private _done;
  119494. private _fn;
  119495. private _successCallback;
  119496. /**
  119497. * Constructor.
  119498. * @param iterations the number of iterations.
  119499. * @param func the function to run each iteration
  119500. * @param successCallback the callback that will be called upon succesful execution
  119501. * @param offset starting offset.
  119502. */
  119503. constructor(
  119504. /**
  119505. * Defines the number of iterations for the loop
  119506. */
  119507. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  119508. /**
  119509. * Execute the next iteration. Must be called after the last iteration was finished.
  119510. */
  119511. executeNext(): void;
  119512. /**
  119513. * Break the loop and run the success callback.
  119514. */
  119515. breakLoop(): void;
  119516. /**
  119517. * Create and run an async loop.
  119518. * @param iterations the number of iterations.
  119519. * @param fn the function to run each iteration
  119520. * @param successCallback the callback that will be called upon succesful execution
  119521. * @param offset starting offset.
  119522. * @returns the created async loop object
  119523. */
  119524. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  119525. /**
  119526. * A for-loop that will run a given number of iterations synchronous and the rest async.
  119527. * @param iterations total number of iterations
  119528. * @param syncedIterations number of synchronous iterations in each async iteration.
  119529. * @param fn the function to call each iteration.
  119530. * @param callback a success call back that will be called when iterating stops.
  119531. * @param breakFunction a break condition (optional)
  119532. * @param timeout timeout settings for the setTimeout function. default - 0.
  119533. * @returns the created async loop object
  119534. */
  119535. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  119536. }
  119537. }
  119538. declare module BABYLON {
  119539. /**
  119540. * This class implement a typical dictionary using a string as key and the generic type T as value.
  119541. * The underlying implementation relies on an associative array to ensure the best performances.
  119542. * The value can be anything including 'null' but except 'undefined'
  119543. */
  119544. export class StringDictionary<T> {
  119545. /**
  119546. * This will clear this dictionary and copy the content from the 'source' one.
  119547. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  119548. * @param source the dictionary to take the content from and copy to this dictionary
  119549. */
  119550. copyFrom(source: StringDictionary<T>): void;
  119551. /**
  119552. * Get a value based from its key
  119553. * @param key the given key to get the matching value from
  119554. * @return the value if found, otherwise undefined is returned
  119555. */
  119556. get(key: string): T | undefined;
  119557. /**
  119558. * Get a value from its key or add it if it doesn't exist.
  119559. * This method will ensure you that a given key/data will be present in the dictionary.
  119560. * @param key the given key to get the matching value from
  119561. * @param factory the factory that will create the value if the key is not present in the dictionary.
  119562. * The factory will only be invoked if there's no data for the given key.
  119563. * @return the value corresponding to the key.
  119564. */
  119565. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  119566. /**
  119567. * Get a value from its key if present in the dictionary otherwise add it
  119568. * @param key the key to get the value from
  119569. * @param val if there's no such key/value pair in the dictionary add it with this value
  119570. * @return the value corresponding to the key
  119571. */
  119572. getOrAdd(key: string, val: T): T;
  119573. /**
  119574. * Check if there's a given key in the dictionary
  119575. * @param key the key to check for
  119576. * @return true if the key is present, false otherwise
  119577. */
  119578. contains(key: string): boolean;
  119579. /**
  119580. * Add a new key and its corresponding value
  119581. * @param key the key to add
  119582. * @param value the value corresponding to the key
  119583. * @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
  119584. */
  119585. add(key: string, value: T): boolean;
  119586. /**
  119587. * Update a specific value associated to a key
  119588. * @param key defines the key to use
  119589. * @param value defines the value to store
  119590. * @returns true if the value was updated (or false if the key was not found)
  119591. */
  119592. set(key: string, value: T): boolean;
  119593. /**
  119594. * Get the element of the given key and remove it from the dictionary
  119595. * @param key defines the key to search
  119596. * @returns the value associated with the key or null if not found
  119597. */
  119598. getAndRemove(key: string): Nullable<T>;
  119599. /**
  119600. * Remove a key/value from the dictionary.
  119601. * @param key the key to remove
  119602. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  119603. */
  119604. remove(key: string): boolean;
  119605. /**
  119606. * Clear the whole content of the dictionary
  119607. */
  119608. clear(): void;
  119609. /**
  119610. * Gets the current count
  119611. */
  119612. get count(): number;
  119613. /**
  119614. * Execute a callback on each key/val of the dictionary.
  119615. * Note that you can remove any element in this dictionary in the callback implementation
  119616. * @param callback the callback to execute on a given key/value pair
  119617. */
  119618. forEach(callback: (key: string, val: T) => void): void;
  119619. /**
  119620. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  119621. * If the callback returns null or undefined the method will iterate to the next key/value pair
  119622. * Note that you can remove any element in this dictionary in the callback implementation
  119623. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  119624. * @returns the first item
  119625. */
  119626. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  119627. private _count;
  119628. private _data;
  119629. }
  119630. }
  119631. declare module BABYLON {
  119632. /** @hidden */
  119633. export interface ICollisionCoordinator {
  119634. createCollider(): Collider;
  119635. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119636. init(scene: Scene): void;
  119637. }
  119638. /** @hidden */
  119639. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  119640. private _scene;
  119641. private _scaledPosition;
  119642. private _scaledVelocity;
  119643. private _finalPosition;
  119644. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119645. createCollider(): Collider;
  119646. init(scene: Scene): void;
  119647. private _collideWithWorld;
  119648. }
  119649. }
  119650. declare module BABYLON {
  119651. /**
  119652. * Class used to manage all inputs for the scene.
  119653. */
  119654. export class InputManager {
  119655. /** The distance in pixel that you have to move to prevent some events */
  119656. static DragMovementThreshold: number;
  119657. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  119658. static LongPressDelay: number;
  119659. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  119660. static DoubleClickDelay: number;
  119661. /** If you need to check double click without raising a single click at first click, enable this flag */
  119662. static ExclusiveDoubleClickMode: boolean;
  119663. /** 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. */
  119664. private _alreadyAttached;
  119665. private _wheelEventName;
  119666. private _onPointerMove;
  119667. private _onPointerDown;
  119668. private _onPointerUp;
  119669. private _initClickEvent;
  119670. private _initActionManager;
  119671. private _delayedSimpleClick;
  119672. private _delayedSimpleClickTimeout;
  119673. private _previousDelayedSimpleClickTimeout;
  119674. private _meshPickProceed;
  119675. private _previousButtonPressed;
  119676. private _currentPickResult;
  119677. private _previousPickResult;
  119678. private _totalPointersPressed;
  119679. private _doubleClickOccured;
  119680. private _pointerOverMesh;
  119681. private _pickedDownMesh;
  119682. private _pickedUpMesh;
  119683. private _pointerX;
  119684. private _pointerY;
  119685. private _unTranslatedPointerX;
  119686. private _unTranslatedPointerY;
  119687. private _startingPointerPosition;
  119688. private _previousStartingPointerPosition;
  119689. private _startingPointerTime;
  119690. private _previousStartingPointerTime;
  119691. private _pointerCaptures;
  119692. private _meshUnderPointerId;
  119693. private _onKeyDown;
  119694. private _onKeyUp;
  119695. private _onCanvasFocusObserver;
  119696. private _onCanvasBlurObserver;
  119697. private _scene;
  119698. /**
  119699. * Creates a new InputManager
  119700. * @param scene defines the hosting scene
  119701. */
  119702. constructor(scene: Scene);
  119703. /**
  119704. * Gets the mesh that is currently under the pointer
  119705. */
  119706. get meshUnderPointer(): Nullable<AbstractMesh>;
  119707. /**
  119708. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  119709. * @param pointerId the pointer id to use
  119710. * @returns The mesh under this pointer id or null if not found
  119711. */
  119712. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  119713. /**
  119714. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  119715. */
  119716. get unTranslatedPointer(): Vector2;
  119717. /**
  119718. * Gets or sets the current on-screen X position of the pointer
  119719. */
  119720. get pointerX(): number;
  119721. set pointerX(value: number);
  119722. /**
  119723. * Gets or sets the current on-screen Y position of the pointer
  119724. */
  119725. get pointerY(): number;
  119726. set pointerY(value: number);
  119727. private _updatePointerPosition;
  119728. private _processPointerMove;
  119729. private _setRayOnPointerInfo;
  119730. private _checkPrePointerObservable;
  119731. /**
  119732. * Use this method to simulate a pointer move on a mesh
  119733. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119734. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119735. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119736. */
  119737. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119738. /**
  119739. * Use this method to simulate a pointer down on a mesh
  119740. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119741. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119742. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119743. */
  119744. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119745. private _processPointerDown;
  119746. /** @hidden */
  119747. _isPointerSwiping(): boolean;
  119748. /**
  119749. * Use this method to simulate a pointer up on a mesh
  119750. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119751. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119752. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119753. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119754. */
  119755. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  119756. private _processPointerUp;
  119757. /**
  119758. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119759. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119760. * @returns true if the pointer was captured
  119761. */
  119762. isPointerCaptured(pointerId?: number): boolean;
  119763. /**
  119764. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119765. * @param attachUp defines if you want to attach events to pointerup
  119766. * @param attachDown defines if you want to attach events to pointerdown
  119767. * @param attachMove defines if you want to attach events to pointermove
  119768. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  119769. */
  119770. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  119771. /**
  119772. * Detaches all event handlers
  119773. */
  119774. detachControl(): void;
  119775. /**
  119776. * Force the value of meshUnderPointer
  119777. * @param mesh defines the mesh to use
  119778. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  119779. */
  119780. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  119781. /**
  119782. * Gets the mesh under the pointer
  119783. * @returns a Mesh or null if no mesh is under the pointer
  119784. */
  119785. getPointerOverMesh(): Nullable<AbstractMesh>;
  119786. }
  119787. }
  119788. declare module BABYLON {
  119789. /**
  119790. * This class defines the direct association between an animation and a target
  119791. */
  119792. export class TargetedAnimation {
  119793. /**
  119794. * Animation to perform
  119795. */
  119796. animation: Animation;
  119797. /**
  119798. * Target to animate
  119799. */
  119800. target: any;
  119801. /**
  119802. * Returns the string "TargetedAnimation"
  119803. * @returns "TargetedAnimation"
  119804. */
  119805. getClassName(): string;
  119806. /**
  119807. * Serialize the object
  119808. * @returns the JSON object representing the current entity
  119809. */
  119810. serialize(): any;
  119811. }
  119812. /**
  119813. * Use this class to create coordinated animations on multiple targets
  119814. */
  119815. export class AnimationGroup implements IDisposable {
  119816. /** The name of the animation group */
  119817. name: string;
  119818. private _scene;
  119819. private _targetedAnimations;
  119820. private _animatables;
  119821. private _from;
  119822. private _to;
  119823. private _isStarted;
  119824. private _isPaused;
  119825. private _speedRatio;
  119826. private _loopAnimation;
  119827. private _isAdditive;
  119828. /**
  119829. * Gets or sets the unique id of the node
  119830. */
  119831. uniqueId: number;
  119832. /**
  119833. * This observable will notify when one animation have ended
  119834. */
  119835. onAnimationEndObservable: Observable<TargetedAnimation>;
  119836. /**
  119837. * Observer raised when one animation loops
  119838. */
  119839. onAnimationLoopObservable: Observable<TargetedAnimation>;
  119840. /**
  119841. * Observer raised when all animations have looped
  119842. */
  119843. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  119844. /**
  119845. * This observable will notify when all animations have ended.
  119846. */
  119847. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  119848. /**
  119849. * This observable will notify when all animations have paused.
  119850. */
  119851. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  119852. /**
  119853. * This observable will notify when all animations are playing.
  119854. */
  119855. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  119856. /**
  119857. * Gets the first frame
  119858. */
  119859. get from(): number;
  119860. /**
  119861. * Gets the last frame
  119862. */
  119863. get to(): number;
  119864. /**
  119865. * Define if the animations are started
  119866. */
  119867. get isStarted(): boolean;
  119868. /**
  119869. * Gets a value indicating that the current group is playing
  119870. */
  119871. get isPlaying(): boolean;
  119872. /**
  119873. * Gets or sets the speed ratio to use for all animations
  119874. */
  119875. get speedRatio(): number;
  119876. /**
  119877. * Gets or sets the speed ratio to use for all animations
  119878. */
  119879. set speedRatio(value: number);
  119880. /**
  119881. * Gets or sets if all animations should loop or not
  119882. */
  119883. get loopAnimation(): boolean;
  119884. set loopAnimation(value: boolean);
  119885. /**
  119886. * Gets or sets if all animations should be evaluated additively
  119887. */
  119888. get isAdditive(): boolean;
  119889. set isAdditive(value: boolean);
  119890. /**
  119891. * Gets the targeted animations for this animation group
  119892. */
  119893. get targetedAnimations(): Array<TargetedAnimation>;
  119894. /**
  119895. * returning the list of animatables controlled by this animation group.
  119896. */
  119897. get animatables(): Array<Animatable>;
  119898. /**
  119899. * Gets the list of target animations
  119900. */
  119901. get children(): TargetedAnimation[];
  119902. /**
  119903. * Instantiates a new Animation Group.
  119904. * This helps managing several animations at once.
  119905. * @see https://doc.babylonjs.com/how_to/group
  119906. * @param name Defines the name of the group
  119907. * @param scene Defines the scene the group belongs to
  119908. */
  119909. constructor(
  119910. /** The name of the animation group */
  119911. name: string, scene?: Nullable<Scene>);
  119912. /**
  119913. * Add an animation (with its target) in the group
  119914. * @param animation defines the animation we want to add
  119915. * @param target defines the target of the animation
  119916. * @returns the TargetedAnimation object
  119917. */
  119918. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  119919. /**
  119920. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  119921. * It can add constant keys at begin or end
  119922. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  119923. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  119924. * @returns the animation group
  119925. */
  119926. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  119927. private _animationLoopCount;
  119928. private _animationLoopFlags;
  119929. private _processLoop;
  119930. /**
  119931. * Start all animations on given targets
  119932. * @param loop defines if animations must loop
  119933. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  119934. * @param from defines the from key (optional)
  119935. * @param to defines the to key (optional)
  119936. * @param isAdditive defines the additive state for the resulting animatables (optional)
  119937. * @returns the current animation group
  119938. */
  119939. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  119940. /**
  119941. * Pause all animations
  119942. * @returns the animation group
  119943. */
  119944. pause(): AnimationGroup;
  119945. /**
  119946. * Play all animations to initial state
  119947. * This function will start() the animations if they were not started or will restart() them if they were paused
  119948. * @param loop defines if animations must loop
  119949. * @returns the animation group
  119950. */
  119951. play(loop?: boolean): AnimationGroup;
  119952. /**
  119953. * Reset all animations to initial state
  119954. * @returns the animation group
  119955. */
  119956. reset(): AnimationGroup;
  119957. /**
  119958. * Restart animations from key 0
  119959. * @returns the animation group
  119960. */
  119961. restart(): AnimationGroup;
  119962. /**
  119963. * Stop all animations
  119964. * @returns the animation group
  119965. */
  119966. stop(): AnimationGroup;
  119967. /**
  119968. * Set animation weight for all animatables
  119969. * @param weight defines the weight to use
  119970. * @return the animationGroup
  119971. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119972. */
  119973. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119974. /**
  119975. * Synchronize and normalize all animatables with a source animatable
  119976. * @param root defines the root animatable to synchronize with
  119977. * @return the animationGroup
  119978. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119979. */
  119980. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119981. /**
  119982. * Goes to a specific frame in this animation group
  119983. * @param frame the frame number to go to
  119984. * @return the animationGroup
  119985. */
  119986. goToFrame(frame: number): AnimationGroup;
  119987. /**
  119988. * Dispose all associated resources
  119989. */
  119990. dispose(): void;
  119991. private _checkAnimationGroupEnded;
  119992. /**
  119993. * Clone the current animation group and returns a copy
  119994. * @param newName defines the name of the new group
  119995. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119996. * @returns the new aniamtion group
  119997. */
  119998. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119999. /**
  120000. * Serializes the animationGroup to an object
  120001. * @returns Serialized object
  120002. */
  120003. serialize(): any;
  120004. /**
  120005. * Returns a new AnimationGroup object parsed from the source provided.
  120006. * @param parsedAnimationGroup defines the source
  120007. * @param scene defines the scene that will receive the animationGroup
  120008. * @returns a new AnimationGroup
  120009. */
  120010. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  120011. /**
  120012. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  120013. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  120014. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  120015. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  120016. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  120017. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  120018. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  120019. */
  120020. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  120021. /**
  120022. * Returns the string "AnimationGroup"
  120023. * @returns "AnimationGroup"
  120024. */
  120025. getClassName(): string;
  120026. /**
  120027. * Creates a detailled string about the object
  120028. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  120029. * @returns a string representing the object
  120030. */
  120031. toString(fullDetails?: boolean): string;
  120032. }
  120033. }
  120034. declare module BABYLON {
  120035. /**
  120036. * Define an interface for all classes that will hold resources
  120037. */
  120038. export interface IDisposable {
  120039. /**
  120040. * Releases all held resources
  120041. */
  120042. dispose(): void;
  120043. }
  120044. /** Interface defining initialization parameters for Scene class */
  120045. export interface SceneOptions {
  120046. /**
  120047. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  120048. * It will improve performance when the number of geometries becomes important.
  120049. */
  120050. useGeometryUniqueIdsMap?: boolean;
  120051. /**
  120052. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  120053. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  120054. */
  120055. useMaterialMeshMap?: boolean;
  120056. /**
  120057. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  120058. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  120059. */
  120060. useClonedMeshMap?: boolean;
  120061. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  120062. virtual?: boolean;
  120063. }
  120064. /**
  120065. * Represents a scene to be rendered by the engine.
  120066. * @see https://doc.babylonjs.com/features/scene
  120067. */
  120068. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  120069. /** The fog is deactivated */
  120070. static readonly FOGMODE_NONE: number;
  120071. /** The fog density is following an exponential function */
  120072. static readonly FOGMODE_EXP: number;
  120073. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  120074. static readonly FOGMODE_EXP2: number;
  120075. /** The fog density is following a linear function. */
  120076. static readonly FOGMODE_LINEAR: number;
  120077. /**
  120078. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  120079. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120080. */
  120081. static MinDeltaTime: number;
  120082. /**
  120083. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  120084. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120085. */
  120086. static MaxDeltaTime: number;
  120087. /**
  120088. * Factory used to create the default material.
  120089. * @param name The name of the material to create
  120090. * @param scene The scene to create the material for
  120091. * @returns The default material
  120092. */
  120093. static DefaultMaterialFactory(scene: Scene): Material;
  120094. /**
  120095. * Factory used to create the a collision coordinator.
  120096. * @returns The collision coordinator
  120097. */
  120098. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  120099. /** @hidden */
  120100. _inputManager: InputManager;
  120101. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  120102. cameraToUseForPointers: Nullable<Camera>;
  120103. /** @hidden */
  120104. readonly _isScene: boolean;
  120105. /** @hidden */
  120106. _blockEntityCollection: boolean;
  120107. /**
  120108. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  120109. */
  120110. autoClear: boolean;
  120111. /**
  120112. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  120113. */
  120114. autoClearDepthAndStencil: boolean;
  120115. /**
  120116. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  120117. */
  120118. clearColor: Color4;
  120119. /**
  120120. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  120121. */
  120122. ambientColor: Color3;
  120123. /**
  120124. * This is use to store the default BRDF lookup for PBR materials in your scene.
  120125. * It should only be one of the following (if not the default embedded one):
  120126. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  120127. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  120128. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  120129. * The material properties need to be setup according to the type of texture in use.
  120130. */
  120131. environmentBRDFTexture: BaseTexture;
  120132. /**
  120133. * Texture used in all pbr material as the reflection texture.
  120134. * As in the majority of the scene they are the same (exception for multi room and so on),
  120135. * this is easier to reference from here than from all the materials.
  120136. */
  120137. get environmentTexture(): Nullable<BaseTexture>;
  120138. /**
  120139. * Texture used in all pbr material as the reflection texture.
  120140. * As in the majority of the scene they are the same (exception for multi room and so on),
  120141. * this is easier to set here than in all the materials.
  120142. */
  120143. set environmentTexture(value: Nullable<BaseTexture>);
  120144. /** @hidden */
  120145. protected _environmentIntensity: number;
  120146. /**
  120147. * Intensity of the environment in all pbr material.
  120148. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  120149. * As in the majority of the scene they are the same (exception for multi room and so on),
  120150. * this is easier to reference from here than from all the materials.
  120151. */
  120152. get environmentIntensity(): number;
  120153. /**
  120154. * Intensity of the environment in all pbr material.
  120155. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  120156. * As in the majority of the scene they are the same (exception for multi room and so on),
  120157. * this is easier to set here than in all the materials.
  120158. */
  120159. set environmentIntensity(value: number);
  120160. /** @hidden */
  120161. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120162. /**
  120163. * Default image processing configuration used either in the rendering
  120164. * Forward main pass or through the imageProcessingPostProcess if present.
  120165. * As in the majority of the scene they are the same (exception for multi camera),
  120166. * this is easier to reference from here than from all the materials and post process.
  120167. *
  120168. * No setter as we it is a shared configuration, you can set the values instead.
  120169. */
  120170. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  120171. private _forceWireframe;
  120172. /**
  120173. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  120174. */
  120175. set forceWireframe(value: boolean);
  120176. get forceWireframe(): boolean;
  120177. private _skipFrustumClipping;
  120178. /**
  120179. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  120180. */
  120181. set skipFrustumClipping(value: boolean);
  120182. get skipFrustumClipping(): boolean;
  120183. private _forcePointsCloud;
  120184. /**
  120185. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  120186. */
  120187. set forcePointsCloud(value: boolean);
  120188. get forcePointsCloud(): boolean;
  120189. /**
  120190. * Gets or sets the active clipplane 1
  120191. */
  120192. clipPlane: Nullable<Plane>;
  120193. /**
  120194. * Gets or sets the active clipplane 2
  120195. */
  120196. clipPlane2: Nullable<Plane>;
  120197. /**
  120198. * Gets or sets the active clipplane 3
  120199. */
  120200. clipPlane3: Nullable<Plane>;
  120201. /**
  120202. * Gets or sets the active clipplane 4
  120203. */
  120204. clipPlane4: Nullable<Plane>;
  120205. /**
  120206. * Gets or sets the active clipplane 5
  120207. */
  120208. clipPlane5: Nullable<Plane>;
  120209. /**
  120210. * Gets or sets the active clipplane 6
  120211. */
  120212. clipPlane6: Nullable<Plane>;
  120213. /**
  120214. * Gets or sets a boolean indicating if animations are enabled
  120215. */
  120216. animationsEnabled: boolean;
  120217. private _animationPropertiesOverride;
  120218. /**
  120219. * Gets or sets the animation properties override
  120220. */
  120221. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  120222. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  120223. /**
  120224. * Gets or sets a boolean indicating if a constant deltatime has to be used
  120225. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  120226. */
  120227. useConstantAnimationDeltaTime: boolean;
  120228. /**
  120229. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  120230. * Please note that it requires to run a ray cast through the scene on every frame
  120231. */
  120232. constantlyUpdateMeshUnderPointer: boolean;
  120233. /**
  120234. * Defines the HTML cursor to use when hovering over interactive elements
  120235. */
  120236. hoverCursor: string;
  120237. /**
  120238. * Defines the HTML default cursor to use (empty by default)
  120239. */
  120240. defaultCursor: string;
  120241. /**
  120242. * Defines whether cursors are handled by the scene.
  120243. */
  120244. doNotHandleCursors: boolean;
  120245. /**
  120246. * This is used to call preventDefault() on pointer down
  120247. * in order to block unwanted artifacts like system double clicks
  120248. */
  120249. preventDefaultOnPointerDown: boolean;
  120250. /**
  120251. * This is used to call preventDefault() on pointer up
  120252. * in order to block unwanted artifacts like system double clicks
  120253. */
  120254. preventDefaultOnPointerUp: boolean;
  120255. /**
  120256. * Gets or sets user defined metadata
  120257. */
  120258. metadata: any;
  120259. /**
  120260. * For internal use only. Please do not use.
  120261. */
  120262. reservedDataStore: any;
  120263. /**
  120264. * Gets the name of the plugin used to load this scene (null by default)
  120265. */
  120266. loadingPluginName: string;
  120267. /**
  120268. * Use this array to add regular expressions used to disable offline support for specific urls
  120269. */
  120270. disableOfflineSupportExceptionRules: RegExp[];
  120271. /**
  120272. * An event triggered when the scene is disposed.
  120273. */
  120274. onDisposeObservable: Observable<Scene>;
  120275. private _onDisposeObserver;
  120276. /** Sets a function to be executed when this scene is disposed. */
  120277. set onDispose(callback: () => void);
  120278. /**
  120279. * An event triggered before rendering the scene (right after animations and physics)
  120280. */
  120281. onBeforeRenderObservable: Observable<Scene>;
  120282. private _onBeforeRenderObserver;
  120283. /** Sets a function to be executed before rendering this scene */
  120284. set beforeRender(callback: Nullable<() => void>);
  120285. /**
  120286. * An event triggered after rendering the scene
  120287. */
  120288. onAfterRenderObservable: Observable<Scene>;
  120289. /**
  120290. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  120291. */
  120292. onAfterRenderCameraObservable: Observable<Camera>;
  120293. private _onAfterRenderObserver;
  120294. /** Sets a function to be executed after rendering this scene */
  120295. set afterRender(callback: Nullable<() => void>);
  120296. /**
  120297. * An event triggered before animating the scene
  120298. */
  120299. onBeforeAnimationsObservable: Observable<Scene>;
  120300. /**
  120301. * An event triggered after animations processing
  120302. */
  120303. onAfterAnimationsObservable: Observable<Scene>;
  120304. /**
  120305. * An event triggered before draw calls are ready to be sent
  120306. */
  120307. onBeforeDrawPhaseObservable: Observable<Scene>;
  120308. /**
  120309. * An event triggered after draw calls have been sent
  120310. */
  120311. onAfterDrawPhaseObservable: Observable<Scene>;
  120312. /**
  120313. * An event triggered when the scene is ready
  120314. */
  120315. onReadyObservable: Observable<Scene>;
  120316. /**
  120317. * An event triggered before rendering a camera
  120318. */
  120319. onBeforeCameraRenderObservable: Observable<Camera>;
  120320. private _onBeforeCameraRenderObserver;
  120321. /** Sets a function to be executed before rendering a camera*/
  120322. set beforeCameraRender(callback: () => void);
  120323. /**
  120324. * An event triggered after rendering a camera
  120325. */
  120326. onAfterCameraRenderObservable: Observable<Camera>;
  120327. private _onAfterCameraRenderObserver;
  120328. /** Sets a function to be executed after rendering a camera*/
  120329. set afterCameraRender(callback: () => void);
  120330. /**
  120331. * An event triggered when active meshes evaluation is about to start
  120332. */
  120333. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  120334. /**
  120335. * An event triggered when active meshes evaluation is done
  120336. */
  120337. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  120338. /**
  120339. * An event triggered when particles rendering is about to start
  120340. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  120341. */
  120342. onBeforeParticlesRenderingObservable: Observable<Scene>;
  120343. /**
  120344. * An event triggered when particles rendering is done
  120345. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  120346. */
  120347. onAfterParticlesRenderingObservable: Observable<Scene>;
  120348. /**
  120349. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  120350. */
  120351. onDataLoadedObservable: Observable<Scene>;
  120352. /**
  120353. * An event triggered when a camera is created
  120354. */
  120355. onNewCameraAddedObservable: Observable<Camera>;
  120356. /**
  120357. * An event triggered when a camera is removed
  120358. */
  120359. onCameraRemovedObservable: Observable<Camera>;
  120360. /**
  120361. * An event triggered when a light is created
  120362. */
  120363. onNewLightAddedObservable: Observable<Light>;
  120364. /**
  120365. * An event triggered when a light is removed
  120366. */
  120367. onLightRemovedObservable: Observable<Light>;
  120368. /**
  120369. * An event triggered when a geometry is created
  120370. */
  120371. onNewGeometryAddedObservable: Observable<Geometry>;
  120372. /**
  120373. * An event triggered when a geometry is removed
  120374. */
  120375. onGeometryRemovedObservable: Observable<Geometry>;
  120376. /**
  120377. * An event triggered when a transform node is created
  120378. */
  120379. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  120380. /**
  120381. * An event triggered when a transform node is removed
  120382. */
  120383. onTransformNodeRemovedObservable: Observable<TransformNode>;
  120384. /**
  120385. * An event triggered when a mesh is created
  120386. */
  120387. onNewMeshAddedObservable: Observable<AbstractMesh>;
  120388. /**
  120389. * An event triggered when a mesh is removed
  120390. */
  120391. onMeshRemovedObservable: Observable<AbstractMesh>;
  120392. /**
  120393. * An event triggered when a skeleton is created
  120394. */
  120395. onNewSkeletonAddedObservable: Observable<Skeleton>;
  120396. /**
  120397. * An event triggered when a skeleton is removed
  120398. */
  120399. onSkeletonRemovedObservable: Observable<Skeleton>;
  120400. /**
  120401. * An event triggered when a material is created
  120402. */
  120403. onNewMaterialAddedObservable: Observable<Material>;
  120404. /**
  120405. * An event triggered when a material is removed
  120406. */
  120407. onMaterialRemovedObservable: Observable<Material>;
  120408. /**
  120409. * An event triggered when a texture is created
  120410. */
  120411. onNewTextureAddedObservable: Observable<BaseTexture>;
  120412. /**
  120413. * An event triggered when a texture is removed
  120414. */
  120415. onTextureRemovedObservable: Observable<BaseTexture>;
  120416. /**
  120417. * An event triggered when render targets are about to be rendered
  120418. * Can happen multiple times per frame.
  120419. */
  120420. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  120421. /**
  120422. * An event triggered when render targets were rendered.
  120423. * Can happen multiple times per frame.
  120424. */
  120425. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  120426. /**
  120427. * An event triggered before calculating deterministic simulation step
  120428. */
  120429. onBeforeStepObservable: Observable<Scene>;
  120430. /**
  120431. * An event triggered after calculating deterministic simulation step
  120432. */
  120433. onAfterStepObservable: Observable<Scene>;
  120434. /**
  120435. * An event triggered when the activeCamera property is updated
  120436. */
  120437. onActiveCameraChanged: Observable<Scene>;
  120438. /**
  120439. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  120440. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120441. * 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)
  120442. */
  120443. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120444. /**
  120445. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  120446. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120447. * 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)
  120448. */
  120449. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120450. /**
  120451. * This Observable will when a mesh has been imported into the scene.
  120452. */
  120453. onMeshImportedObservable: Observable<AbstractMesh>;
  120454. /**
  120455. * This Observable will when an animation file has been imported into the scene.
  120456. */
  120457. onAnimationFileImportedObservable: Observable<Scene>;
  120458. /**
  120459. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  120460. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  120461. */
  120462. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  120463. /** @hidden */
  120464. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  120465. /**
  120466. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  120467. */
  120468. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  120469. /**
  120470. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  120471. */
  120472. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  120473. /**
  120474. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  120475. */
  120476. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  120477. /** Callback called when a pointer move is detected */
  120478. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120479. /** Callback called when a pointer down is detected */
  120480. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120481. /** Callback called when a pointer up is detected */
  120482. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  120483. /** Callback called when a pointer pick is detected */
  120484. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  120485. /**
  120486. * 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).
  120487. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  120488. */
  120489. onPrePointerObservable: Observable<PointerInfoPre>;
  120490. /**
  120491. * Observable event triggered each time an input event is received from the rendering canvas
  120492. */
  120493. onPointerObservable: Observable<PointerInfo>;
  120494. /**
  120495. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  120496. */
  120497. get unTranslatedPointer(): Vector2;
  120498. /**
  120499. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  120500. */
  120501. static get DragMovementThreshold(): number;
  120502. static set DragMovementThreshold(value: number);
  120503. /**
  120504. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  120505. */
  120506. static get LongPressDelay(): number;
  120507. static set LongPressDelay(value: number);
  120508. /**
  120509. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  120510. */
  120511. static get DoubleClickDelay(): number;
  120512. static set DoubleClickDelay(value: number);
  120513. /** If you need to check double click without raising a single click at first click, enable this flag */
  120514. static get ExclusiveDoubleClickMode(): boolean;
  120515. static set ExclusiveDoubleClickMode(value: boolean);
  120516. /** @hidden */
  120517. _mirroredCameraPosition: Nullable<Vector3>;
  120518. /**
  120519. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  120520. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  120521. */
  120522. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  120523. /**
  120524. * Observable event triggered each time an keyboard event is received from the hosting window
  120525. */
  120526. onKeyboardObservable: Observable<KeyboardInfo>;
  120527. private _useRightHandedSystem;
  120528. /**
  120529. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  120530. */
  120531. set useRightHandedSystem(value: boolean);
  120532. get useRightHandedSystem(): boolean;
  120533. private _timeAccumulator;
  120534. private _currentStepId;
  120535. private _currentInternalStep;
  120536. /**
  120537. * Sets the step Id used by deterministic lock step
  120538. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120539. * @param newStepId defines the step Id
  120540. */
  120541. setStepId(newStepId: number): void;
  120542. /**
  120543. * Gets the step Id used by deterministic lock step
  120544. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120545. * @returns the step Id
  120546. */
  120547. getStepId(): number;
  120548. /**
  120549. * Gets the internal step used by deterministic lock step
  120550. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120551. * @returns the internal step
  120552. */
  120553. getInternalStep(): number;
  120554. private _fogEnabled;
  120555. /**
  120556. * Gets or sets a boolean indicating if fog is enabled on this scene
  120557. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120558. * (Default is true)
  120559. */
  120560. set fogEnabled(value: boolean);
  120561. get fogEnabled(): boolean;
  120562. private _fogMode;
  120563. /**
  120564. * Gets or sets the fog mode to use
  120565. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120566. * | mode | value |
  120567. * | --- | --- |
  120568. * | FOGMODE_NONE | 0 |
  120569. * | FOGMODE_EXP | 1 |
  120570. * | FOGMODE_EXP2 | 2 |
  120571. * | FOGMODE_LINEAR | 3 |
  120572. */
  120573. set fogMode(value: number);
  120574. get fogMode(): number;
  120575. /**
  120576. * Gets or sets the fog color to use
  120577. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120578. * (Default is Color3(0.2, 0.2, 0.3))
  120579. */
  120580. fogColor: Color3;
  120581. /**
  120582. * Gets or sets the fog density to use
  120583. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120584. * (Default is 0.1)
  120585. */
  120586. fogDensity: number;
  120587. /**
  120588. * Gets or sets the fog start distance to use
  120589. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120590. * (Default is 0)
  120591. */
  120592. fogStart: number;
  120593. /**
  120594. * Gets or sets the fog end distance to use
  120595. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120596. * (Default is 1000)
  120597. */
  120598. fogEnd: number;
  120599. /**
  120600. * Flag indicating that the frame buffer binding is handled by another component
  120601. */
  120602. prePass: boolean;
  120603. private _shadowsEnabled;
  120604. /**
  120605. * Gets or sets a boolean indicating if shadows are enabled on this scene
  120606. */
  120607. set shadowsEnabled(value: boolean);
  120608. get shadowsEnabled(): boolean;
  120609. private _lightsEnabled;
  120610. /**
  120611. * Gets or sets a boolean indicating if lights are enabled on this scene
  120612. */
  120613. set lightsEnabled(value: boolean);
  120614. get lightsEnabled(): boolean;
  120615. /** All of the active cameras added to this scene. */
  120616. activeCameras: Camera[];
  120617. /** @hidden */
  120618. _activeCamera: Nullable<Camera>;
  120619. /** Gets or sets the current active camera */
  120620. get activeCamera(): Nullable<Camera>;
  120621. set activeCamera(value: Nullable<Camera>);
  120622. private _defaultMaterial;
  120623. /** The default material used on meshes when no material is affected */
  120624. get defaultMaterial(): Material;
  120625. /** The default material used on meshes when no material is affected */
  120626. set defaultMaterial(value: Material);
  120627. private _texturesEnabled;
  120628. /**
  120629. * Gets or sets a boolean indicating if textures are enabled on this scene
  120630. */
  120631. set texturesEnabled(value: boolean);
  120632. get texturesEnabled(): boolean;
  120633. /**
  120634. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  120635. */
  120636. physicsEnabled: boolean;
  120637. /**
  120638. * Gets or sets a boolean indicating if particles are enabled on this scene
  120639. */
  120640. particlesEnabled: boolean;
  120641. /**
  120642. * Gets or sets a boolean indicating if sprites are enabled on this scene
  120643. */
  120644. spritesEnabled: boolean;
  120645. private _skeletonsEnabled;
  120646. /**
  120647. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  120648. */
  120649. set skeletonsEnabled(value: boolean);
  120650. get skeletonsEnabled(): boolean;
  120651. /**
  120652. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  120653. */
  120654. lensFlaresEnabled: boolean;
  120655. /**
  120656. * Gets or sets a boolean indicating if collisions are enabled on this scene
  120657. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120658. */
  120659. collisionsEnabled: boolean;
  120660. private _collisionCoordinator;
  120661. /** @hidden */
  120662. get collisionCoordinator(): ICollisionCoordinator;
  120663. /**
  120664. * Defines the gravity applied to this scene (used only for collisions)
  120665. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120666. */
  120667. gravity: Vector3;
  120668. /**
  120669. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  120670. */
  120671. postProcessesEnabled: boolean;
  120672. /**
  120673. * Gets the current postprocess manager
  120674. */
  120675. postProcessManager: PostProcessManager;
  120676. /**
  120677. * Gets or sets a boolean indicating if render targets are enabled on this scene
  120678. */
  120679. renderTargetsEnabled: boolean;
  120680. /**
  120681. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  120682. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  120683. */
  120684. dumpNextRenderTargets: boolean;
  120685. /**
  120686. * The list of user defined render targets added to the scene
  120687. */
  120688. customRenderTargets: RenderTargetTexture[];
  120689. /**
  120690. * Defines if texture loading must be delayed
  120691. * If true, textures will only be loaded when they need to be rendered
  120692. */
  120693. useDelayedTextureLoading: boolean;
  120694. /**
  120695. * Gets the list of meshes imported to the scene through SceneLoader
  120696. */
  120697. importedMeshesFiles: String[];
  120698. /**
  120699. * Gets or sets a boolean indicating if probes are enabled on this scene
  120700. */
  120701. probesEnabled: boolean;
  120702. /**
  120703. * Gets or sets the current offline provider to use to store scene data
  120704. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120705. */
  120706. offlineProvider: IOfflineProvider;
  120707. /**
  120708. * Gets or sets the action manager associated with the scene
  120709. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120710. */
  120711. actionManager: AbstractActionManager;
  120712. private _meshesForIntersections;
  120713. /**
  120714. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  120715. */
  120716. proceduralTexturesEnabled: boolean;
  120717. private _engine;
  120718. private _totalVertices;
  120719. /** @hidden */
  120720. _activeIndices: PerfCounter;
  120721. /** @hidden */
  120722. _activeParticles: PerfCounter;
  120723. /** @hidden */
  120724. _activeBones: PerfCounter;
  120725. private _animationRatio;
  120726. /** @hidden */
  120727. _animationTimeLast: number;
  120728. /** @hidden */
  120729. _animationTime: number;
  120730. /**
  120731. * Gets or sets a general scale for animation speed
  120732. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  120733. */
  120734. animationTimeScale: number;
  120735. /** @hidden */
  120736. _cachedMaterial: Nullable<Material>;
  120737. /** @hidden */
  120738. _cachedEffect: Nullable<Effect>;
  120739. /** @hidden */
  120740. _cachedVisibility: Nullable<number>;
  120741. private _renderId;
  120742. private _frameId;
  120743. private _executeWhenReadyTimeoutId;
  120744. private _intermediateRendering;
  120745. private _viewUpdateFlag;
  120746. private _projectionUpdateFlag;
  120747. /** @hidden */
  120748. _toBeDisposed: Nullable<IDisposable>[];
  120749. private _activeRequests;
  120750. /** @hidden */
  120751. _pendingData: any[];
  120752. private _isDisposed;
  120753. /**
  120754. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  120755. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  120756. */
  120757. dispatchAllSubMeshesOfActiveMeshes: boolean;
  120758. private _activeMeshes;
  120759. private _processedMaterials;
  120760. private _renderTargets;
  120761. /** @hidden */
  120762. _activeParticleSystems: SmartArray<IParticleSystem>;
  120763. private _activeSkeletons;
  120764. private _softwareSkinnedMeshes;
  120765. private _renderingManager;
  120766. /** @hidden */
  120767. _activeAnimatables: Animatable[];
  120768. private _transformMatrix;
  120769. private _sceneUbo;
  120770. /** @hidden */
  120771. _viewMatrix: Matrix;
  120772. private _projectionMatrix;
  120773. /** @hidden */
  120774. _forcedViewPosition: Nullable<Vector3>;
  120775. /** @hidden */
  120776. _frustumPlanes: Plane[];
  120777. /**
  120778. * Gets the list of frustum planes (built from the active camera)
  120779. */
  120780. get frustumPlanes(): Plane[];
  120781. /**
  120782. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  120783. * This is useful if there are more lights that the maximum simulteanous authorized
  120784. */
  120785. requireLightSorting: boolean;
  120786. /** @hidden */
  120787. readonly useMaterialMeshMap: boolean;
  120788. /** @hidden */
  120789. readonly useClonedMeshMap: boolean;
  120790. private _externalData;
  120791. private _uid;
  120792. /**
  120793. * @hidden
  120794. * Backing store of defined scene components.
  120795. */
  120796. _components: ISceneComponent[];
  120797. /**
  120798. * @hidden
  120799. * Backing store of defined scene components.
  120800. */
  120801. _serializableComponents: ISceneSerializableComponent[];
  120802. /**
  120803. * List of components to register on the next registration step.
  120804. */
  120805. private _transientComponents;
  120806. /**
  120807. * Registers the transient components if needed.
  120808. */
  120809. private _registerTransientComponents;
  120810. /**
  120811. * @hidden
  120812. * Add a component to the scene.
  120813. * Note that the ccomponent could be registered on th next frame if this is called after
  120814. * the register component stage.
  120815. * @param component Defines the component to add to the scene
  120816. */
  120817. _addComponent(component: ISceneComponent): void;
  120818. /**
  120819. * @hidden
  120820. * Gets a component from the scene.
  120821. * @param name defines the name of the component to retrieve
  120822. * @returns the component or null if not present
  120823. */
  120824. _getComponent(name: string): Nullable<ISceneComponent>;
  120825. /**
  120826. * @hidden
  120827. * Defines the actions happening before camera updates.
  120828. */
  120829. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  120830. /**
  120831. * @hidden
  120832. * Defines the actions happening before clear the canvas.
  120833. */
  120834. _beforeClearStage: Stage<SimpleStageAction>;
  120835. /**
  120836. * @hidden
  120837. * Defines the actions when collecting render targets for the frame.
  120838. */
  120839. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120840. /**
  120841. * @hidden
  120842. * Defines the actions happening for one camera in the frame.
  120843. */
  120844. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120845. /**
  120846. * @hidden
  120847. * Defines the actions happening during the per mesh ready checks.
  120848. */
  120849. _isReadyForMeshStage: Stage<MeshStageAction>;
  120850. /**
  120851. * @hidden
  120852. * Defines the actions happening before evaluate active mesh checks.
  120853. */
  120854. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  120855. /**
  120856. * @hidden
  120857. * Defines the actions happening during the evaluate sub mesh checks.
  120858. */
  120859. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  120860. /**
  120861. * @hidden
  120862. * Defines the actions happening during the active mesh stage.
  120863. */
  120864. _activeMeshStage: Stage<ActiveMeshStageAction>;
  120865. /**
  120866. * @hidden
  120867. * Defines the actions happening during the per camera render target step.
  120868. */
  120869. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  120870. /**
  120871. * @hidden
  120872. * Defines the actions happening just before the active camera is drawing.
  120873. */
  120874. _beforeCameraDrawStage: Stage<CameraStageAction>;
  120875. /**
  120876. * @hidden
  120877. * Defines the actions happening just before a render target is drawing.
  120878. */
  120879. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120880. /**
  120881. * @hidden
  120882. * Defines the actions happening just before a rendering group is drawing.
  120883. */
  120884. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120885. /**
  120886. * @hidden
  120887. * Defines the actions happening just before a mesh is drawing.
  120888. */
  120889. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120890. /**
  120891. * @hidden
  120892. * Defines the actions happening just after a mesh has been drawn.
  120893. */
  120894. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120895. /**
  120896. * @hidden
  120897. * Defines the actions happening just after a rendering group has been drawn.
  120898. */
  120899. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120900. /**
  120901. * @hidden
  120902. * Defines the actions happening just after the active camera has been drawn.
  120903. */
  120904. _afterCameraDrawStage: Stage<CameraStageAction>;
  120905. /**
  120906. * @hidden
  120907. * Defines the actions happening just after a render target has been drawn.
  120908. */
  120909. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120910. /**
  120911. * @hidden
  120912. * Defines the actions happening just after rendering all cameras and computing intersections.
  120913. */
  120914. _afterRenderStage: Stage<SimpleStageAction>;
  120915. /**
  120916. * @hidden
  120917. * Defines the actions happening when a pointer move event happens.
  120918. */
  120919. _pointerMoveStage: Stage<PointerMoveStageAction>;
  120920. /**
  120921. * @hidden
  120922. * Defines the actions happening when a pointer down event happens.
  120923. */
  120924. _pointerDownStage: Stage<PointerUpDownStageAction>;
  120925. /**
  120926. * @hidden
  120927. * Defines the actions happening when a pointer up event happens.
  120928. */
  120929. _pointerUpStage: Stage<PointerUpDownStageAction>;
  120930. /**
  120931. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  120932. */
  120933. private geometriesByUniqueId;
  120934. /**
  120935. * Creates a new Scene
  120936. * @param engine defines the engine to use to render this scene
  120937. * @param options defines the scene options
  120938. */
  120939. constructor(engine: Engine, options?: SceneOptions);
  120940. /**
  120941. * Gets a string identifying the name of the class
  120942. * @returns "Scene" string
  120943. */
  120944. getClassName(): string;
  120945. private _defaultMeshCandidates;
  120946. /**
  120947. * @hidden
  120948. */
  120949. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120950. private _defaultSubMeshCandidates;
  120951. /**
  120952. * @hidden
  120953. */
  120954. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120955. /**
  120956. * Sets the default candidate providers for the scene.
  120957. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  120958. * and getCollidingSubMeshCandidates to their default function
  120959. */
  120960. setDefaultCandidateProviders(): void;
  120961. /**
  120962. * Gets the mesh that is currently under the pointer
  120963. */
  120964. get meshUnderPointer(): Nullable<AbstractMesh>;
  120965. /**
  120966. * Gets or sets the current on-screen X position of the pointer
  120967. */
  120968. get pointerX(): number;
  120969. set pointerX(value: number);
  120970. /**
  120971. * Gets or sets the current on-screen Y position of the pointer
  120972. */
  120973. get pointerY(): number;
  120974. set pointerY(value: number);
  120975. /**
  120976. * Gets the cached material (ie. the latest rendered one)
  120977. * @returns the cached material
  120978. */
  120979. getCachedMaterial(): Nullable<Material>;
  120980. /**
  120981. * Gets the cached effect (ie. the latest rendered one)
  120982. * @returns the cached effect
  120983. */
  120984. getCachedEffect(): Nullable<Effect>;
  120985. /**
  120986. * Gets the cached visibility state (ie. the latest rendered one)
  120987. * @returns the cached visibility state
  120988. */
  120989. getCachedVisibility(): Nullable<number>;
  120990. /**
  120991. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120992. * @param material defines the current material
  120993. * @param effect defines the current effect
  120994. * @param visibility defines the current visibility state
  120995. * @returns true if one parameter is not cached
  120996. */
  120997. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120998. /**
  120999. * Gets the engine associated with the scene
  121000. * @returns an Engine
  121001. */
  121002. getEngine(): Engine;
  121003. /**
  121004. * Gets the total number of vertices rendered per frame
  121005. * @returns the total number of vertices rendered per frame
  121006. */
  121007. getTotalVertices(): number;
  121008. /**
  121009. * Gets the performance counter for total vertices
  121010. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  121011. */
  121012. get totalVerticesPerfCounter(): PerfCounter;
  121013. /**
  121014. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  121015. * @returns the total number of active indices rendered per frame
  121016. */
  121017. getActiveIndices(): number;
  121018. /**
  121019. * Gets the performance counter for active indices
  121020. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  121021. */
  121022. get totalActiveIndicesPerfCounter(): PerfCounter;
  121023. /**
  121024. * Gets the total number of active particles rendered per frame
  121025. * @returns the total number of active particles rendered per frame
  121026. */
  121027. getActiveParticles(): number;
  121028. /**
  121029. * Gets the performance counter for active particles
  121030. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  121031. */
  121032. get activeParticlesPerfCounter(): PerfCounter;
  121033. /**
  121034. * Gets the total number of active bones rendered per frame
  121035. * @returns the total number of active bones rendered per frame
  121036. */
  121037. getActiveBones(): number;
  121038. /**
  121039. * Gets the performance counter for active bones
  121040. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  121041. */
  121042. get activeBonesPerfCounter(): PerfCounter;
  121043. /**
  121044. * Gets the array of active meshes
  121045. * @returns an array of AbstractMesh
  121046. */
  121047. getActiveMeshes(): SmartArray<AbstractMesh>;
  121048. /**
  121049. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  121050. * @returns a number
  121051. */
  121052. getAnimationRatio(): number;
  121053. /**
  121054. * Gets an unique Id for the current render phase
  121055. * @returns a number
  121056. */
  121057. getRenderId(): number;
  121058. /**
  121059. * Gets an unique Id for the current frame
  121060. * @returns a number
  121061. */
  121062. getFrameId(): number;
  121063. /** Call this function if you want to manually increment the render Id*/
  121064. incrementRenderId(): void;
  121065. private _createUbo;
  121066. /**
  121067. * Use this method to simulate a pointer move on a mesh
  121068. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  121069. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  121070. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  121071. * @returns the current scene
  121072. */
  121073. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  121074. /**
  121075. * Use this method to simulate a pointer down on a mesh
  121076. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  121077. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  121078. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  121079. * @returns the current scene
  121080. */
  121081. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  121082. /**
  121083. * Use this method to simulate a pointer up on a mesh
  121084. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  121085. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  121086. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  121087. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  121088. * @returns the current scene
  121089. */
  121090. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  121091. /**
  121092. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  121093. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  121094. * @returns true if the pointer was captured
  121095. */
  121096. isPointerCaptured(pointerId?: number): boolean;
  121097. /**
  121098. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  121099. * @param attachUp defines if you want to attach events to pointerup
  121100. * @param attachDown defines if you want to attach events to pointerdown
  121101. * @param attachMove defines if you want to attach events to pointermove
  121102. */
  121103. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  121104. /** Detaches all event handlers*/
  121105. detachControl(): void;
  121106. /**
  121107. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  121108. * Delay loaded resources are not taking in account
  121109. * @return true if all required resources are ready
  121110. */
  121111. isReady(): boolean;
  121112. /** Resets all cached information relative to material (including effect and visibility) */
  121113. resetCachedMaterial(): void;
  121114. /**
  121115. * Registers a function to be called before every frame render
  121116. * @param func defines the function to register
  121117. */
  121118. registerBeforeRender(func: () => void): void;
  121119. /**
  121120. * Unregisters a function called before every frame render
  121121. * @param func defines the function to unregister
  121122. */
  121123. unregisterBeforeRender(func: () => void): void;
  121124. /**
  121125. * Registers a function to be called after every frame render
  121126. * @param func defines the function to register
  121127. */
  121128. registerAfterRender(func: () => void): void;
  121129. /**
  121130. * Unregisters a function called after every frame render
  121131. * @param func defines the function to unregister
  121132. */
  121133. unregisterAfterRender(func: () => void): void;
  121134. private _executeOnceBeforeRender;
  121135. /**
  121136. * The provided function will run before render once and will be disposed afterwards.
  121137. * A timeout delay can be provided so that the function will be executed in N ms.
  121138. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  121139. * @param func The function to be executed.
  121140. * @param timeout optional delay in ms
  121141. */
  121142. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  121143. /** @hidden */
  121144. _addPendingData(data: any): void;
  121145. /** @hidden */
  121146. _removePendingData(data: any): void;
  121147. /**
  121148. * Returns the number of items waiting to be loaded
  121149. * @returns the number of items waiting to be loaded
  121150. */
  121151. getWaitingItemsCount(): number;
  121152. /**
  121153. * Returns a boolean indicating if the scene is still loading data
  121154. */
  121155. get isLoading(): boolean;
  121156. /**
  121157. * Registers a function to be executed when the scene is ready
  121158. * @param {Function} func - the function to be executed
  121159. */
  121160. executeWhenReady(func: () => void): void;
  121161. /**
  121162. * Returns a promise that resolves when the scene is ready
  121163. * @returns A promise that resolves when the scene is ready
  121164. */
  121165. whenReadyAsync(): Promise<void>;
  121166. /** @hidden */
  121167. _checkIsReady(): void;
  121168. /**
  121169. * Gets all animatable attached to the scene
  121170. */
  121171. get animatables(): Animatable[];
  121172. /**
  121173. * Resets the last animation time frame.
  121174. * Useful to override when animations start running when loading a scene for the first time.
  121175. */
  121176. resetLastAnimationTimeFrame(): void;
  121177. /**
  121178. * Gets the current view matrix
  121179. * @returns a Matrix
  121180. */
  121181. getViewMatrix(): Matrix;
  121182. /**
  121183. * Gets the current projection matrix
  121184. * @returns a Matrix
  121185. */
  121186. getProjectionMatrix(): Matrix;
  121187. /**
  121188. * Gets the current transform matrix
  121189. * @returns a Matrix made of View * Projection
  121190. */
  121191. getTransformMatrix(): Matrix;
  121192. /**
  121193. * Sets the current transform matrix
  121194. * @param viewL defines the View matrix to use
  121195. * @param projectionL defines the Projection matrix to use
  121196. * @param viewR defines the right View matrix to use (if provided)
  121197. * @param projectionR defines the right Projection matrix to use (if provided)
  121198. */
  121199. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  121200. /**
  121201. * Gets the uniform buffer used to store scene data
  121202. * @returns a UniformBuffer
  121203. */
  121204. getSceneUniformBuffer(): UniformBuffer;
  121205. /**
  121206. * Gets an unique (relatively to the current scene) Id
  121207. * @returns an unique number for the scene
  121208. */
  121209. getUniqueId(): number;
  121210. /**
  121211. * Add a mesh to the list of scene's meshes
  121212. * @param newMesh defines the mesh to add
  121213. * @param recursive if all child meshes should also be added to the scene
  121214. */
  121215. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  121216. /**
  121217. * Remove a mesh for the list of scene's meshes
  121218. * @param toRemove defines the mesh to remove
  121219. * @param recursive if all child meshes should also be removed from the scene
  121220. * @returns the index where the mesh was in the mesh list
  121221. */
  121222. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  121223. /**
  121224. * Add a transform node to the list of scene's transform nodes
  121225. * @param newTransformNode defines the transform node to add
  121226. */
  121227. addTransformNode(newTransformNode: TransformNode): void;
  121228. /**
  121229. * Remove a transform node for the list of scene's transform nodes
  121230. * @param toRemove defines the transform node to remove
  121231. * @returns the index where the transform node was in the transform node list
  121232. */
  121233. removeTransformNode(toRemove: TransformNode): number;
  121234. /**
  121235. * Remove a skeleton for the list of scene's skeletons
  121236. * @param toRemove defines the skeleton to remove
  121237. * @returns the index where the skeleton was in the skeleton list
  121238. */
  121239. removeSkeleton(toRemove: Skeleton): number;
  121240. /**
  121241. * Remove a morph target for the list of scene's morph targets
  121242. * @param toRemove defines the morph target to remove
  121243. * @returns the index where the morph target was in the morph target list
  121244. */
  121245. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  121246. /**
  121247. * Remove a light for the list of scene's lights
  121248. * @param toRemove defines the light to remove
  121249. * @returns the index where the light was in the light list
  121250. */
  121251. removeLight(toRemove: Light): number;
  121252. /**
  121253. * Remove a camera for the list of scene's cameras
  121254. * @param toRemove defines the camera to remove
  121255. * @returns the index where the camera was in the camera list
  121256. */
  121257. removeCamera(toRemove: Camera): number;
  121258. /**
  121259. * Remove a particle system for the list of scene's particle systems
  121260. * @param toRemove defines the particle system to remove
  121261. * @returns the index where the particle system was in the particle system list
  121262. */
  121263. removeParticleSystem(toRemove: IParticleSystem): number;
  121264. /**
  121265. * Remove a animation for the list of scene's animations
  121266. * @param toRemove defines the animation to remove
  121267. * @returns the index where the animation was in the animation list
  121268. */
  121269. removeAnimation(toRemove: Animation): number;
  121270. /**
  121271. * Will stop the animation of the given target
  121272. * @param target - the target
  121273. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  121274. * @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)
  121275. */
  121276. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  121277. /**
  121278. * Removes the given animation group from this scene.
  121279. * @param toRemove The animation group to remove
  121280. * @returns The index of the removed animation group
  121281. */
  121282. removeAnimationGroup(toRemove: AnimationGroup): number;
  121283. /**
  121284. * Removes the given multi-material from this scene.
  121285. * @param toRemove The multi-material to remove
  121286. * @returns The index of the removed multi-material
  121287. */
  121288. removeMultiMaterial(toRemove: MultiMaterial): number;
  121289. /**
  121290. * Removes the given material from this scene.
  121291. * @param toRemove The material to remove
  121292. * @returns The index of the removed material
  121293. */
  121294. removeMaterial(toRemove: Material): number;
  121295. /**
  121296. * Removes the given action manager from this scene.
  121297. * @param toRemove The action manager to remove
  121298. * @returns The index of the removed action manager
  121299. */
  121300. removeActionManager(toRemove: AbstractActionManager): number;
  121301. /**
  121302. * Removes the given texture from this scene.
  121303. * @param toRemove The texture to remove
  121304. * @returns The index of the removed texture
  121305. */
  121306. removeTexture(toRemove: BaseTexture): number;
  121307. /**
  121308. * Adds the given light to this scene
  121309. * @param newLight The light to add
  121310. */
  121311. addLight(newLight: Light): void;
  121312. /**
  121313. * Sorts the list list based on light priorities
  121314. */
  121315. sortLightsByPriority(): void;
  121316. /**
  121317. * Adds the given camera to this scene
  121318. * @param newCamera The camera to add
  121319. */
  121320. addCamera(newCamera: Camera): void;
  121321. /**
  121322. * Adds the given skeleton to this scene
  121323. * @param newSkeleton The skeleton to add
  121324. */
  121325. addSkeleton(newSkeleton: Skeleton): void;
  121326. /**
  121327. * Adds the given particle system to this scene
  121328. * @param newParticleSystem The particle system to add
  121329. */
  121330. addParticleSystem(newParticleSystem: IParticleSystem): void;
  121331. /**
  121332. * Adds the given animation to this scene
  121333. * @param newAnimation The animation to add
  121334. */
  121335. addAnimation(newAnimation: Animation): void;
  121336. /**
  121337. * Adds the given animation group to this scene.
  121338. * @param newAnimationGroup The animation group to add
  121339. */
  121340. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  121341. /**
  121342. * Adds the given multi-material to this scene
  121343. * @param newMultiMaterial The multi-material to add
  121344. */
  121345. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  121346. /**
  121347. * Adds the given material to this scene
  121348. * @param newMaterial The material to add
  121349. */
  121350. addMaterial(newMaterial: Material): void;
  121351. /**
  121352. * Adds the given morph target to this scene
  121353. * @param newMorphTargetManager The morph target to add
  121354. */
  121355. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  121356. /**
  121357. * Adds the given geometry to this scene
  121358. * @param newGeometry The geometry to add
  121359. */
  121360. addGeometry(newGeometry: Geometry): void;
  121361. /**
  121362. * Adds the given action manager to this scene
  121363. * @param newActionManager The action manager to add
  121364. */
  121365. addActionManager(newActionManager: AbstractActionManager): void;
  121366. /**
  121367. * Adds the given texture to this scene.
  121368. * @param newTexture The texture to add
  121369. */
  121370. addTexture(newTexture: BaseTexture): void;
  121371. /**
  121372. * Switch active camera
  121373. * @param newCamera defines the new active camera
  121374. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  121375. */
  121376. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  121377. /**
  121378. * sets the active camera of the scene using its ID
  121379. * @param id defines the camera's ID
  121380. * @return the new active camera or null if none found.
  121381. */
  121382. setActiveCameraByID(id: string): Nullable<Camera>;
  121383. /**
  121384. * sets the active camera of the scene using its name
  121385. * @param name defines the camera's name
  121386. * @returns the new active camera or null if none found.
  121387. */
  121388. setActiveCameraByName(name: string): Nullable<Camera>;
  121389. /**
  121390. * get an animation group using its name
  121391. * @param name defines the material's name
  121392. * @return the animation group or null if none found.
  121393. */
  121394. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  121395. /**
  121396. * Get a material using its unique id
  121397. * @param uniqueId defines the material's unique id
  121398. * @return the material or null if none found.
  121399. */
  121400. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  121401. /**
  121402. * get a material using its id
  121403. * @param id defines the material's ID
  121404. * @return the material or null if none found.
  121405. */
  121406. getMaterialByID(id: string): Nullable<Material>;
  121407. /**
  121408. * Gets a the last added material using a given id
  121409. * @param id defines the material's ID
  121410. * @return the last material with the given id or null if none found.
  121411. */
  121412. getLastMaterialByID(id: string): Nullable<Material>;
  121413. /**
  121414. * Gets a material using its name
  121415. * @param name defines the material's name
  121416. * @return the material or null if none found.
  121417. */
  121418. getMaterialByName(name: string): Nullable<Material>;
  121419. /**
  121420. * Get a texture using its unique id
  121421. * @param uniqueId defines the texture's unique id
  121422. * @return the texture or null if none found.
  121423. */
  121424. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  121425. /**
  121426. * Gets a camera using its id
  121427. * @param id defines the id to look for
  121428. * @returns the camera or null if not found
  121429. */
  121430. getCameraByID(id: string): Nullable<Camera>;
  121431. /**
  121432. * Gets a camera using its unique id
  121433. * @param uniqueId defines the unique id to look for
  121434. * @returns the camera or null if not found
  121435. */
  121436. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  121437. /**
  121438. * Gets a camera using its name
  121439. * @param name defines the camera's name
  121440. * @return the camera or null if none found.
  121441. */
  121442. getCameraByName(name: string): Nullable<Camera>;
  121443. /**
  121444. * Gets a bone using its id
  121445. * @param id defines the bone's id
  121446. * @return the bone or null if not found
  121447. */
  121448. getBoneByID(id: string): Nullable<Bone>;
  121449. /**
  121450. * Gets a bone using its id
  121451. * @param name defines the bone's name
  121452. * @return the bone or null if not found
  121453. */
  121454. getBoneByName(name: string): Nullable<Bone>;
  121455. /**
  121456. * Gets a light node using its name
  121457. * @param name defines the the light's name
  121458. * @return the light or null if none found.
  121459. */
  121460. getLightByName(name: string): Nullable<Light>;
  121461. /**
  121462. * Gets a light node using its id
  121463. * @param id defines the light's id
  121464. * @return the light or null if none found.
  121465. */
  121466. getLightByID(id: string): Nullable<Light>;
  121467. /**
  121468. * Gets a light node using its scene-generated unique ID
  121469. * @param uniqueId defines the light's unique id
  121470. * @return the light or null if none found.
  121471. */
  121472. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  121473. /**
  121474. * Gets a particle system by id
  121475. * @param id defines the particle system id
  121476. * @return the corresponding system or null if none found
  121477. */
  121478. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  121479. /**
  121480. * Gets a geometry using its ID
  121481. * @param id defines the geometry's id
  121482. * @return the geometry or null if none found.
  121483. */
  121484. getGeometryByID(id: string): Nullable<Geometry>;
  121485. private _getGeometryByUniqueID;
  121486. /**
  121487. * Add a new geometry to this scene
  121488. * @param geometry defines the geometry to be added to the scene.
  121489. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  121490. * @return a boolean defining if the geometry was added or not
  121491. */
  121492. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  121493. /**
  121494. * Removes an existing geometry
  121495. * @param geometry defines the geometry to be removed from the scene
  121496. * @return a boolean defining if the geometry was removed or not
  121497. */
  121498. removeGeometry(geometry: Geometry): boolean;
  121499. /**
  121500. * Gets the list of geometries attached to the scene
  121501. * @returns an array of Geometry
  121502. */
  121503. getGeometries(): Geometry[];
  121504. /**
  121505. * Gets the first added mesh found of a given ID
  121506. * @param id defines the id to search for
  121507. * @return the mesh found or null if not found at all
  121508. */
  121509. getMeshByID(id: string): Nullable<AbstractMesh>;
  121510. /**
  121511. * Gets a list of meshes using their id
  121512. * @param id defines the id to search for
  121513. * @returns a list of meshes
  121514. */
  121515. getMeshesByID(id: string): Array<AbstractMesh>;
  121516. /**
  121517. * Gets the first added transform node found of a given ID
  121518. * @param id defines the id to search for
  121519. * @return the found transform node or null if not found at all.
  121520. */
  121521. getTransformNodeByID(id: string): Nullable<TransformNode>;
  121522. /**
  121523. * Gets a transform node with its auto-generated unique id
  121524. * @param uniqueId efines the unique id to search for
  121525. * @return the found transform node or null if not found at all.
  121526. */
  121527. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  121528. /**
  121529. * Gets a list of transform nodes using their id
  121530. * @param id defines the id to search for
  121531. * @returns a list of transform nodes
  121532. */
  121533. getTransformNodesByID(id: string): Array<TransformNode>;
  121534. /**
  121535. * Gets a mesh with its auto-generated unique id
  121536. * @param uniqueId defines the unique id to search for
  121537. * @return the found mesh or null if not found at all.
  121538. */
  121539. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  121540. /**
  121541. * Gets a the last added mesh using a given id
  121542. * @param id defines the id to search for
  121543. * @return the found mesh or null if not found at all.
  121544. */
  121545. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  121546. /**
  121547. * Gets a the last added node (Mesh, Camera, Light) using a given id
  121548. * @param id defines the id to search for
  121549. * @return the found node or null if not found at all
  121550. */
  121551. getLastEntryByID(id: string): Nullable<Node>;
  121552. /**
  121553. * Gets a node (Mesh, Camera, Light) using a given id
  121554. * @param id defines the id to search for
  121555. * @return the found node or null if not found at all
  121556. */
  121557. getNodeByID(id: string): Nullable<Node>;
  121558. /**
  121559. * Gets a node (Mesh, Camera, Light) using a given name
  121560. * @param name defines the name to search for
  121561. * @return the found node or null if not found at all.
  121562. */
  121563. getNodeByName(name: string): Nullable<Node>;
  121564. /**
  121565. * Gets a mesh using a given name
  121566. * @param name defines the name to search for
  121567. * @return the found mesh or null if not found at all.
  121568. */
  121569. getMeshByName(name: string): Nullable<AbstractMesh>;
  121570. /**
  121571. * Gets a transform node using a given name
  121572. * @param name defines the name to search for
  121573. * @return the found transform node or null if not found at all.
  121574. */
  121575. getTransformNodeByName(name: string): Nullable<TransformNode>;
  121576. /**
  121577. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  121578. * @param id defines the id to search for
  121579. * @return the found skeleton or null if not found at all.
  121580. */
  121581. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  121582. /**
  121583. * Gets a skeleton using a given auto generated unique id
  121584. * @param uniqueId defines the unique id to search for
  121585. * @return the found skeleton or null if not found at all.
  121586. */
  121587. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  121588. /**
  121589. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  121590. * @param id defines the id to search for
  121591. * @return the found skeleton or null if not found at all.
  121592. */
  121593. getSkeletonById(id: string): Nullable<Skeleton>;
  121594. /**
  121595. * Gets a skeleton using a given name
  121596. * @param name defines the name to search for
  121597. * @return the found skeleton or null if not found at all.
  121598. */
  121599. getSkeletonByName(name: string): Nullable<Skeleton>;
  121600. /**
  121601. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  121602. * @param id defines the id to search for
  121603. * @return the found morph target manager or null if not found at all.
  121604. */
  121605. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  121606. /**
  121607. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  121608. * @param id defines the id to search for
  121609. * @return the found morph target or null if not found at all.
  121610. */
  121611. getMorphTargetById(id: string): Nullable<MorphTarget>;
  121612. /**
  121613. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  121614. * @param name defines the name to search for
  121615. * @return the found morph target or null if not found at all.
  121616. */
  121617. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  121618. /**
  121619. * Gets a post process using a given name (if many are found, this function will pick the first one)
  121620. * @param name defines the name to search for
  121621. * @return the found post process or null if not found at all.
  121622. */
  121623. getPostProcessByName(name: string): Nullable<PostProcess>;
  121624. /**
  121625. * Gets a boolean indicating if the given mesh is active
  121626. * @param mesh defines the mesh to look for
  121627. * @returns true if the mesh is in the active list
  121628. */
  121629. isActiveMesh(mesh: AbstractMesh): boolean;
  121630. /**
  121631. * Return a unique id as a string which can serve as an identifier for the scene
  121632. */
  121633. get uid(): string;
  121634. /**
  121635. * Add an externaly attached data from its key.
  121636. * This method call will fail and return false, if such key already exists.
  121637. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  121638. * @param key the unique key that identifies the data
  121639. * @param data the data object to associate to the key for this Engine instance
  121640. * @return true if no such key were already present and the data was added successfully, false otherwise
  121641. */
  121642. addExternalData<T>(key: string, data: T): boolean;
  121643. /**
  121644. * Get an externaly attached data from its key
  121645. * @param key the unique key that identifies the data
  121646. * @return the associated data, if present (can be null), or undefined if not present
  121647. */
  121648. getExternalData<T>(key: string): Nullable<T>;
  121649. /**
  121650. * Get an externaly attached data from its key, create it using a factory if it's not already present
  121651. * @param key the unique key that identifies the data
  121652. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  121653. * @return the associated data, can be null if the factory returned null.
  121654. */
  121655. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  121656. /**
  121657. * Remove an externaly attached data from the Engine instance
  121658. * @param key the unique key that identifies the data
  121659. * @return true if the data was successfully removed, false if it doesn't exist
  121660. */
  121661. removeExternalData(key: string): boolean;
  121662. private _evaluateSubMesh;
  121663. /**
  121664. * Clear the processed materials smart array preventing retention point in material dispose.
  121665. */
  121666. freeProcessedMaterials(): void;
  121667. private _preventFreeActiveMeshesAndRenderingGroups;
  121668. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  121669. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  121670. * when disposing several meshes in a row or a hierarchy of meshes.
  121671. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  121672. */
  121673. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  121674. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  121675. /**
  121676. * Clear the active meshes smart array preventing retention point in mesh dispose.
  121677. */
  121678. freeActiveMeshes(): void;
  121679. /**
  121680. * Clear the info related to rendering groups preventing retention points during dispose.
  121681. */
  121682. freeRenderingGroups(): void;
  121683. /** @hidden */
  121684. _isInIntermediateRendering(): boolean;
  121685. /**
  121686. * Lambda returning the list of potentially active meshes.
  121687. */
  121688. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  121689. /**
  121690. * Lambda returning the list of potentially active sub meshes.
  121691. */
  121692. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  121693. /**
  121694. * Lambda returning the list of potentially intersecting sub meshes.
  121695. */
  121696. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  121697. /**
  121698. * Lambda returning the list of potentially colliding sub meshes.
  121699. */
  121700. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  121701. private _activeMeshesFrozen;
  121702. private _skipEvaluateActiveMeshesCompletely;
  121703. /**
  121704. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  121705. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  121706. * @param onSuccess optional success callback
  121707. * @param onError optional error callback
  121708. * @returns the current scene
  121709. */
  121710. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  121711. /**
  121712. * Use this function to restart evaluating active meshes on every frame
  121713. * @returns the current scene
  121714. */
  121715. unfreezeActiveMeshes(): Scene;
  121716. private _evaluateActiveMeshes;
  121717. private _activeMesh;
  121718. /**
  121719. * Update the transform matrix to update from the current active camera
  121720. * @param force defines a boolean used to force the update even if cache is up to date
  121721. */
  121722. updateTransformMatrix(force?: boolean): void;
  121723. private _bindFrameBuffer;
  121724. /** @hidden */
  121725. _allowPostProcessClearColor: boolean;
  121726. /** @hidden */
  121727. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  121728. private _processSubCameras;
  121729. private _checkIntersections;
  121730. /** @hidden */
  121731. _advancePhysicsEngineStep(step: number): void;
  121732. /**
  121733. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  121734. */
  121735. getDeterministicFrameTime: () => number;
  121736. /** @hidden */
  121737. _animate(): void;
  121738. /** Execute all animations (for a frame) */
  121739. animate(): void;
  121740. /**
  121741. * Render the scene
  121742. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  121743. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  121744. */
  121745. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  121746. /**
  121747. * Freeze all materials
  121748. * A frozen material will not be updatable but should be faster to render
  121749. */
  121750. freezeMaterials(): void;
  121751. /**
  121752. * Unfreeze all materials
  121753. * A frozen material will not be updatable but should be faster to render
  121754. */
  121755. unfreezeMaterials(): void;
  121756. /**
  121757. * Releases all held ressources
  121758. */
  121759. dispose(): void;
  121760. /**
  121761. * Gets if the scene is already disposed
  121762. */
  121763. get isDisposed(): boolean;
  121764. /**
  121765. * Call this function to reduce memory footprint of the scene.
  121766. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  121767. */
  121768. clearCachedVertexData(): void;
  121769. /**
  121770. * This function will remove the local cached buffer data from texture.
  121771. * It will save memory but will prevent the texture from being rebuilt
  121772. */
  121773. cleanCachedTextureBuffer(): void;
  121774. /**
  121775. * Get the world extend vectors with an optional filter
  121776. *
  121777. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  121778. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  121779. */
  121780. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  121781. min: Vector3;
  121782. max: Vector3;
  121783. };
  121784. /**
  121785. * Creates a ray that can be used to pick in the scene
  121786. * @param x defines the x coordinate of the origin (on-screen)
  121787. * @param y defines the y coordinate of the origin (on-screen)
  121788. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121789. * @param camera defines the camera to use for the picking
  121790. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121791. * @returns a Ray
  121792. */
  121793. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  121794. /**
  121795. * Creates a ray that can be used to pick in the scene
  121796. * @param x defines the x coordinate of the origin (on-screen)
  121797. * @param y defines the y coordinate of the origin (on-screen)
  121798. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121799. * @param result defines the ray where to store the picking ray
  121800. * @param camera defines the camera to use for the picking
  121801. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121802. * @returns the current scene
  121803. */
  121804. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  121805. /**
  121806. * Creates a ray that can be used to pick in the scene
  121807. * @param x defines the x coordinate of the origin (on-screen)
  121808. * @param y defines the y coordinate of the origin (on-screen)
  121809. * @param camera defines the camera to use for the picking
  121810. * @returns a Ray
  121811. */
  121812. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  121813. /**
  121814. * Creates a ray that can be used to pick in the scene
  121815. * @param x defines the x coordinate of the origin (on-screen)
  121816. * @param y defines the y coordinate of the origin (on-screen)
  121817. * @param result defines the ray where to store the picking ray
  121818. * @param camera defines the camera to use for the picking
  121819. * @returns the current scene
  121820. */
  121821. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  121822. /** Launch a ray to try to pick a mesh in the scene
  121823. * @param x position on screen
  121824. * @param y position on screen
  121825. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  121826. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121827. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121828. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121829. * @returns a PickingInfo
  121830. */
  121831. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121832. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  121833. * @param x position on screen
  121834. * @param y position on screen
  121835. * @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
  121836. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121837. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121838. * @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)
  121839. */
  121840. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  121841. /** Use the given ray to pick a mesh in the scene
  121842. * @param ray The ray to use to pick meshes
  121843. * @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
  121844. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121845. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121846. * @returns a PickingInfo
  121847. */
  121848. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121849. /**
  121850. * Launch a ray to try to pick a mesh in the scene
  121851. * @param x X position on screen
  121852. * @param y Y position on screen
  121853. * @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
  121854. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121855. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121856. * @returns an array of PickingInfo
  121857. */
  121858. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121859. /**
  121860. * Launch a ray to try to pick a mesh in the scene
  121861. * @param ray Ray to use
  121862. * @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
  121863. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121864. * @returns an array of PickingInfo
  121865. */
  121866. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121867. /**
  121868. * Force the value of meshUnderPointer
  121869. * @param mesh defines the mesh to use
  121870. * @param pointerId optional pointer id when using more than one pointer
  121871. */
  121872. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  121873. /**
  121874. * Gets the mesh under the pointer
  121875. * @returns a Mesh or null if no mesh is under the pointer
  121876. */
  121877. getPointerOverMesh(): Nullable<AbstractMesh>;
  121878. /** @hidden */
  121879. _rebuildGeometries(): void;
  121880. /** @hidden */
  121881. _rebuildTextures(): void;
  121882. private _getByTags;
  121883. /**
  121884. * Get a list of meshes by tags
  121885. * @param tagsQuery defines the tags query to use
  121886. * @param forEach defines a predicate used to filter results
  121887. * @returns an array of Mesh
  121888. */
  121889. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  121890. /**
  121891. * Get a list of cameras by tags
  121892. * @param tagsQuery defines the tags query to use
  121893. * @param forEach defines a predicate used to filter results
  121894. * @returns an array of Camera
  121895. */
  121896. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  121897. /**
  121898. * Get a list of lights by tags
  121899. * @param tagsQuery defines the tags query to use
  121900. * @param forEach defines a predicate used to filter results
  121901. * @returns an array of Light
  121902. */
  121903. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  121904. /**
  121905. * Get a list of materials by tags
  121906. * @param tagsQuery defines the tags query to use
  121907. * @param forEach defines a predicate used to filter results
  121908. * @returns an array of Material
  121909. */
  121910. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  121911. /**
  121912. * Get a list of transform nodes by tags
  121913. * @param tagsQuery defines the tags query to use
  121914. * @param forEach defines a predicate used to filter results
  121915. * @returns an array of TransformNode
  121916. */
  121917. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  121918. /**
  121919. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121920. * This allowed control for front to back rendering or reversly depending of the special needs.
  121921. *
  121922. * @param renderingGroupId The rendering group id corresponding to its index
  121923. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121924. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121925. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121926. */
  121927. 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;
  121928. /**
  121929. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121930. *
  121931. * @param renderingGroupId The rendering group id corresponding to its index
  121932. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121933. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121934. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121935. */
  121936. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  121937. /**
  121938. * Gets the current auto clear configuration for one rendering group of the rendering
  121939. * manager.
  121940. * @param index the rendering group index to get the information for
  121941. * @returns The auto clear setup for the requested rendering group
  121942. */
  121943. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  121944. private _blockMaterialDirtyMechanism;
  121945. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  121946. get blockMaterialDirtyMechanism(): boolean;
  121947. set blockMaterialDirtyMechanism(value: boolean);
  121948. /**
  121949. * Will flag all materials as dirty to trigger new shader compilation
  121950. * @param flag defines the flag used to specify which material part must be marked as dirty
  121951. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  121952. */
  121953. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121954. /** @hidden */
  121955. _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;
  121956. /** @hidden */
  121957. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121958. /** @hidden */
  121959. _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;
  121960. /** @hidden */
  121961. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  121962. /** @hidden */
  121963. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  121964. /** @hidden */
  121965. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121966. }
  121967. }
  121968. declare module BABYLON {
  121969. /**
  121970. * Set of assets to keep when moving a scene into an asset container.
  121971. */
  121972. export class KeepAssets extends AbstractScene {
  121973. }
  121974. /**
  121975. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121976. */
  121977. export class InstantiatedEntries {
  121978. /**
  121979. * List of new root nodes (eg. nodes with no parent)
  121980. */
  121981. rootNodes: TransformNode[];
  121982. /**
  121983. * List of new skeletons
  121984. */
  121985. skeletons: Skeleton[];
  121986. /**
  121987. * List of new animation groups
  121988. */
  121989. animationGroups: AnimationGroup[];
  121990. }
  121991. /**
  121992. * Container with a set of assets that can be added or removed from a scene.
  121993. */
  121994. export class AssetContainer extends AbstractScene {
  121995. private _wasAddedToScene;
  121996. /**
  121997. * The scene the AssetContainer belongs to.
  121998. */
  121999. scene: Scene;
  122000. /**
  122001. * Instantiates an AssetContainer.
  122002. * @param scene The scene the AssetContainer belongs to.
  122003. */
  122004. constructor(scene: Scene);
  122005. /**
  122006. * Instantiate or clone all meshes and add the new ones to the scene.
  122007. * Skeletons and animation groups will all be cloned
  122008. * @param nameFunction defines an optional function used to get new names for clones
  122009. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  122010. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  122011. */
  122012. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  122013. /**
  122014. * Adds all the assets from the container to the scene.
  122015. */
  122016. addAllToScene(): void;
  122017. /**
  122018. * Removes all the assets in the container from the scene
  122019. */
  122020. removeAllFromScene(): void;
  122021. /**
  122022. * Disposes all the assets in the container
  122023. */
  122024. dispose(): void;
  122025. private _moveAssets;
  122026. /**
  122027. * Removes all the assets contained in the scene and adds them to the container.
  122028. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  122029. */
  122030. moveAllFromScene(keepAssets?: KeepAssets): void;
  122031. /**
  122032. * 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.
  122033. * @returns the root mesh
  122034. */
  122035. createRootMesh(): Mesh;
  122036. /**
  122037. * Merge animations (direct and animation groups) from this asset container into a scene
  122038. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  122039. * @param animatables set of animatables to retarget to a node from the scene
  122040. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  122041. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  122042. */
  122043. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  122044. }
  122045. }
  122046. declare module BABYLON {
  122047. /**
  122048. * Defines how the parser contract is defined.
  122049. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  122050. */
  122051. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  122052. /**
  122053. * Defines how the individual parser contract is defined.
  122054. * These parser can parse an individual asset
  122055. */
  122056. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  122057. /**
  122058. * Base class of the scene acting as a container for the different elements composing a scene.
  122059. * This class is dynamically extended by the different components of the scene increasing
  122060. * flexibility and reducing coupling
  122061. */
  122062. export abstract class AbstractScene {
  122063. /**
  122064. * Stores the list of available parsers in the application.
  122065. */
  122066. private static _BabylonFileParsers;
  122067. /**
  122068. * Stores the list of available individual parsers in the application.
  122069. */
  122070. private static _IndividualBabylonFileParsers;
  122071. /**
  122072. * Adds a parser in the list of available ones
  122073. * @param name Defines the name of the parser
  122074. * @param parser Defines the parser to add
  122075. */
  122076. static AddParser(name: string, parser: BabylonFileParser): void;
  122077. /**
  122078. * Gets a general parser from the list of avaialble ones
  122079. * @param name Defines the name of the parser
  122080. * @returns the requested parser or null
  122081. */
  122082. static GetParser(name: string): Nullable<BabylonFileParser>;
  122083. /**
  122084. * Adds n individual parser in the list of available ones
  122085. * @param name Defines the name of the parser
  122086. * @param parser Defines the parser to add
  122087. */
  122088. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  122089. /**
  122090. * Gets an individual parser from the list of avaialble ones
  122091. * @param name Defines the name of the parser
  122092. * @returns the requested parser or null
  122093. */
  122094. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  122095. /**
  122096. * Parser json data and populate both a scene and its associated container object
  122097. * @param jsonData Defines the data to parse
  122098. * @param scene Defines the scene to parse the data for
  122099. * @param container Defines the container attached to the parsing sequence
  122100. * @param rootUrl Defines the root url of the data
  122101. */
  122102. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  122103. /**
  122104. * Gets the list of root nodes (ie. nodes with no parent)
  122105. */
  122106. rootNodes: Node[];
  122107. /** All of the cameras added to this scene
  122108. * @see https://doc.babylonjs.com/babylon101/cameras
  122109. */
  122110. cameras: Camera[];
  122111. /**
  122112. * All of the lights added to this scene
  122113. * @see https://doc.babylonjs.com/babylon101/lights
  122114. */
  122115. lights: Light[];
  122116. /**
  122117. * All of the (abstract) meshes added to this scene
  122118. */
  122119. meshes: AbstractMesh[];
  122120. /**
  122121. * The list of skeletons added to the scene
  122122. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  122123. */
  122124. skeletons: Skeleton[];
  122125. /**
  122126. * All of the particle systems added to this scene
  122127. * @see https://doc.babylonjs.com/babylon101/particles
  122128. */
  122129. particleSystems: IParticleSystem[];
  122130. /**
  122131. * Gets a list of Animations associated with the scene
  122132. */
  122133. animations: Animation[];
  122134. /**
  122135. * All of the animation groups added to this scene
  122136. * @see https://doc.babylonjs.com/how_to/group
  122137. */
  122138. animationGroups: AnimationGroup[];
  122139. /**
  122140. * All of the multi-materials added to this scene
  122141. * @see https://doc.babylonjs.com/how_to/multi_materials
  122142. */
  122143. multiMaterials: MultiMaterial[];
  122144. /**
  122145. * All of the materials added to this scene
  122146. * In the context of a Scene, it is not supposed to be modified manually.
  122147. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  122148. * Note also that the order of the Material within the array is not significant and might change.
  122149. * @see https://doc.babylonjs.com/babylon101/materials
  122150. */
  122151. materials: Material[];
  122152. /**
  122153. * The list of morph target managers added to the scene
  122154. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  122155. */
  122156. morphTargetManagers: MorphTargetManager[];
  122157. /**
  122158. * The list of geometries used in the scene.
  122159. */
  122160. geometries: Geometry[];
  122161. /**
  122162. * All of the tranform nodes added to this scene
  122163. * In the context of a Scene, it is not supposed to be modified manually.
  122164. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  122165. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  122166. * @see https://doc.babylonjs.com/how_to/transformnode
  122167. */
  122168. transformNodes: TransformNode[];
  122169. /**
  122170. * ActionManagers available on the scene.
  122171. */
  122172. actionManagers: AbstractActionManager[];
  122173. /**
  122174. * Textures to keep.
  122175. */
  122176. textures: BaseTexture[];
  122177. /** @hidden */
  122178. protected _environmentTexture: Nullable<BaseTexture>;
  122179. /**
  122180. * Texture used in all pbr material as the reflection texture.
  122181. * As in the majority of the scene they are the same (exception for multi room and so on),
  122182. * this is easier to reference from here than from all the materials.
  122183. */
  122184. get environmentTexture(): Nullable<BaseTexture>;
  122185. set environmentTexture(value: Nullable<BaseTexture>);
  122186. /**
  122187. * The list of postprocesses added to the scene
  122188. */
  122189. postProcesses: PostProcess[];
  122190. /**
  122191. * @returns all meshes, lights, cameras, transformNodes and bones
  122192. */
  122193. getNodes(): Array<Node>;
  122194. }
  122195. }
  122196. declare module BABYLON {
  122197. /**
  122198. * Interface used to define options for Sound class
  122199. */
  122200. export interface ISoundOptions {
  122201. /**
  122202. * Does the sound autoplay once loaded.
  122203. */
  122204. autoplay?: boolean;
  122205. /**
  122206. * Does the sound loop after it finishes playing once.
  122207. */
  122208. loop?: boolean;
  122209. /**
  122210. * Sound's volume
  122211. */
  122212. volume?: number;
  122213. /**
  122214. * Is it a spatial sound?
  122215. */
  122216. spatialSound?: boolean;
  122217. /**
  122218. * Maximum distance to hear that sound
  122219. */
  122220. maxDistance?: number;
  122221. /**
  122222. * Uses user defined attenuation function
  122223. */
  122224. useCustomAttenuation?: boolean;
  122225. /**
  122226. * Define the roll off factor of spatial sounds.
  122227. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122228. */
  122229. rolloffFactor?: number;
  122230. /**
  122231. * Define the reference distance the sound should be heard perfectly.
  122232. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122233. */
  122234. refDistance?: number;
  122235. /**
  122236. * Define the distance attenuation model the sound will follow.
  122237. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122238. */
  122239. distanceModel?: string;
  122240. /**
  122241. * Defines the playback speed (1 by default)
  122242. */
  122243. playbackRate?: number;
  122244. /**
  122245. * Defines if the sound is from a streaming source
  122246. */
  122247. streaming?: boolean;
  122248. /**
  122249. * Defines an optional length (in seconds) inside the sound file
  122250. */
  122251. length?: number;
  122252. /**
  122253. * Defines an optional offset (in seconds) inside the sound file
  122254. */
  122255. offset?: number;
  122256. /**
  122257. * If true, URLs will not be required to state the audio file codec to use.
  122258. */
  122259. skipCodecCheck?: boolean;
  122260. }
  122261. /**
  122262. * Defines a sound that can be played in the application.
  122263. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  122264. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122265. */
  122266. export class Sound {
  122267. /**
  122268. * The name of the sound in the scene.
  122269. */
  122270. name: string;
  122271. /**
  122272. * Does the sound autoplay once loaded.
  122273. */
  122274. autoplay: boolean;
  122275. /**
  122276. * Does the sound loop after it finishes playing once.
  122277. */
  122278. loop: boolean;
  122279. /**
  122280. * Does the sound use a custom attenuation curve to simulate the falloff
  122281. * happening when the source gets further away from the camera.
  122282. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  122283. */
  122284. useCustomAttenuation: boolean;
  122285. /**
  122286. * The sound track id this sound belongs to.
  122287. */
  122288. soundTrackId: number;
  122289. /**
  122290. * Is this sound currently played.
  122291. */
  122292. isPlaying: boolean;
  122293. /**
  122294. * Is this sound currently paused.
  122295. */
  122296. isPaused: boolean;
  122297. /**
  122298. * Does this sound enables spatial sound.
  122299. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122300. */
  122301. spatialSound: boolean;
  122302. /**
  122303. * Define the reference distance the sound should be heard perfectly.
  122304. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122305. */
  122306. refDistance: number;
  122307. /**
  122308. * Define the roll off factor of spatial sounds.
  122309. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122310. */
  122311. rolloffFactor: number;
  122312. /**
  122313. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  122314. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122315. */
  122316. maxDistance: number;
  122317. /**
  122318. * Define the distance attenuation model the sound will follow.
  122319. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122320. */
  122321. distanceModel: string;
  122322. /**
  122323. * @hidden
  122324. * Back Compat
  122325. **/
  122326. onended: () => any;
  122327. /**
  122328. * Gets or sets an object used to store user defined information for the sound.
  122329. */
  122330. metadata: any;
  122331. /**
  122332. * Observable event when the current playing sound finishes.
  122333. */
  122334. onEndedObservable: Observable<Sound>;
  122335. private _panningModel;
  122336. private _playbackRate;
  122337. private _streaming;
  122338. private _startTime;
  122339. private _startOffset;
  122340. private _position;
  122341. /** @hidden */
  122342. _positionInEmitterSpace: boolean;
  122343. private _localDirection;
  122344. private _volume;
  122345. private _isReadyToPlay;
  122346. private _isDirectional;
  122347. private _readyToPlayCallback;
  122348. private _audioBuffer;
  122349. private _soundSource;
  122350. private _streamingSource;
  122351. private _soundPanner;
  122352. private _soundGain;
  122353. private _inputAudioNode;
  122354. private _outputAudioNode;
  122355. private _coneInnerAngle;
  122356. private _coneOuterAngle;
  122357. private _coneOuterGain;
  122358. private _scene;
  122359. private _connectedTransformNode;
  122360. private _customAttenuationFunction;
  122361. private _registerFunc;
  122362. private _isOutputConnected;
  122363. private _htmlAudioElement;
  122364. private _urlType;
  122365. private _length?;
  122366. private _offset?;
  122367. /** @hidden */
  122368. static _SceneComponentInitialization: (scene: Scene) => void;
  122369. /**
  122370. * Create a sound and attach it to a scene
  122371. * @param name Name of your sound
  122372. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  122373. * @param scene defines the scene the sound belongs to
  122374. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  122375. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  122376. */
  122377. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  122378. /**
  122379. * Release the sound and its associated resources
  122380. */
  122381. dispose(): void;
  122382. /**
  122383. * Gets if the sounds is ready to be played or not.
  122384. * @returns true if ready, otherwise false
  122385. */
  122386. isReady(): boolean;
  122387. private _soundLoaded;
  122388. /**
  122389. * Sets the data of the sound from an audiobuffer
  122390. * @param audioBuffer The audioBuffer containing the data
  122391. */
  122392. setAudioBuffer(audioBuffer: AudioBuffer): void;
  122393. /**
  122394. * Updates the current sounds options such as maxdistance, loop...
  122395. * @param options A JSON object containing values named as the object properties
  122396. */
  122397. updateOptions(options: ISoundOptions): void;
  122398. private _createSpatialParameters;
  122399. private _updateSpatialParameters;
  122400. /**
  122401. * Switch the panning model to HRTF:
  122402. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122403. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122404. */
  122405. switchPanningModelToHRTF(): void;
  122406. /**
  122407. * Switch the panning model to Equal Power:
  122408. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122409. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122410. */
  122411. switchPanningModelToEqualPower(): void;
  122412. private _switchPanningModel;
  122413. /**
  122414. * Connect this sound to a sound track audio node like gain...
  122415. * @param soundTrackAudioNode the sound track audio node to connect to
  122416. */
  122417. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  122418. /**
  122419. * Transform this sound into a directional source
  122420. * @param coneInnerAngle Size of the inner cone in degree
  122421. * @param coneOuterAngle Size of the outer cone in degree
  122422. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  122423. */
  122424. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  122425. /**
  122426. * Gets or sets the inner angle for the directional cone.
  122427. */
  122428. get directionalConeInnerAngle(): number;
  122429. /**
  122430. * Gets or sets the inner angle for the directional cone.
  122431. */
  122432. set directionalConeInnerAngle(value: number);
  122433. /**
  122434. * Gets or sets the outer angle for the directional cone.
  122435. */
  122436. get directionalConeOuterAngle(): number;
  122437. /**
  122438. * Gets or sets the outer angle for the directional cone.
  122439. */
  122440. set directionalConeOuterAngle(value: number);
  122441. /**
  122442. * Sets the position of the emitter if spatial sound is enabled
  122443. * @param newPosition Defines the new posisiton
  122444. */
  122445. setPosition(newPosition: Vector3): void;
  122446. /**
  122447. * Sets the local direction of the emitter if spatial sound is enabled
  122448. * @param newLocalDirection Defines the new local direction
  122449. */
  122450. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  122451. private _updateDirection;
  122452. /** @hidden */
  122453. updateDistanceFromListener(): void;
  122454. /**
  122455. * Sets a new custom attenuation function for the sound.
  122456. * @param callback Defines the function used for the attenuation
  122457. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  122458. */
  122459. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  122460. /**
  122461. * Play the sound
  122462. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  122463. * @param offset (optional) Start the sound at a specific time in seconds
  122464. * @param length (optional) Sound duration (in seconds)
  122465. */
  122466. play(time?: number, offset?: number, length?: number): void;
  122467. private _onended;
  122468. /**
  122469. * Stop the sound
  122470. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  122471. */
  122472. stop(time?: number): void;
  122473. /**
  122474. * Put the sound in pause
  122475. */
  122476. pause(): void;
  122477. /**
  122478. * Sets a dedicated volume for this sounds
  122479. * @param newVolume Define the new volume of the sound
  122480. * @param time Define time for gradual change to new volume
  122481. */
  122482. setVolume(newVolume: number, time?: number): void;
  122483. /**
  122484. * Set the sound play back rate
  122485. * @param newPlaybackRate Define the playback rate the sound should be played at
  122486. */
  122487. setPlaybackRate(newPlaybackRate: number): void;
  122488. /**
  122489. * Gets the volume of the sound.
  122490. * @returns the volume of the sound
  122491. */
  122492. getVolume(): number;
  122493. /**
  122494. * Attach the sound to a dedicated mesh
  122495. * @param transformNode The transform node to connect the sound with
  122496. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122497. */
  122498. attachToMesh(transformNode: TransformNode): void;
  122499. /**
  122500. * Detach the sound from the previously attached mesh
  122501. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122502. */
  122503. detachFromMesh(): void;
  122504. private _onRegisterAfterWorldMatrixUpdate;
  122505. /**
  122506. * Clone the current sound in the scene.
  122507. * @returns the new sound clone
  122508. */
  122509. clone(): Nullable<Sound>;
  122510. /**
  122511. * Gets the current underlying audio buffer containing the data
  122512. * @returns the audio buffer
  122513. */
  122514. getAudioBuffer(): Nullable<AudioBuffer>;
  122515. /**
  122516. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  122517. * @returns the source node
  122518. */
  122519. getSoundSource(): Nullable<AudioBufferSourceNode>;
  122520. /**
  122521. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  122522. * @returns the gain node
  122523. */
  122524. getSoundGain(): Nullable<GainNode>;
  122525. /**
  122526. * Serializes the Sound in a JSON representation
  122527. * @returns the JSON representation of the sound
  122528. */
  122529. serialize(): any;
  122530. /**
  122531. * Parse a JSON representation of a sound to innstantiate in a given scene
  122532. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  122533. * @param scene Define the scene the new parsed sound should be created in
  122534. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  122535. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  122536. * @returns the newly parsed sound
  122537. */
  122538. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  122539. }
  122540. }
  122541. declare module BABYLON {
  122542. /**
  122543. * This defines an action helpful to play a defined sound on a triggered action.
  122544. */
  122545. export class PlaySoundAction extends Action {
  122546. private _sound;
  122547. /**
  122548. * Instantiate the action
  122549. * @param triggerOptions defines the trigger options
  122550. * @param sound defines the sound to play
  122551. * @param condition defines the trigger related conditions
  122552. */
  122553. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122554. /** @hidden */
  122555. _prepare(): void;
  122556. /**
  122557. * Execute the action and play the sound.
  122558. */
  122559. execute(): void;
  122560. /**
  122561. * Serializes the actions and its related information.
  122562. * @param parent defines the object to serialize in
  122563. * @returns the serialized object
  122564. */
  122565. serialize(parent: any): any;
  122566. }
  122567. /**
  122568. * This defines an action helpful to stop a defined sound on a triggered action.
  122569. */
  122570. export class StopSoundAction extends Action {
  122571. private _sound;
  122572. /**
  122573. * Instantiate the action
  122574. * @param triggerOptions defines the trigger options
  122575. * @param sound defines the sound to stop
  122576. * @param condition defines the trigger related conditions
  122577. */
  122578. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122579. /** @hidden */
  122580. _prepare(): void;
  122581. /**
  122582. * Execute the action and stop the sound.
  122583. */
  122584. execute(): void;
  122585. /**
  122586. * Serializes the actions and its related information.
  122587. * @param parent defines the object to serialize in
  122588. * @returns the serialized object
  122589. */
  122590. serialize(parent: any): any;
  122591. }
  122592. }
  122593. declare module BABYLON {
  122594. /**
  122595. * This defines an action responsible to change the value of a property
  122596. * by interpolating between its current value and the newly set one once triggered.
  122597. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  122598. */
  122599. export class InterpolateValueAction extends Action {
  122600. /**
  122601. * Defines the path of the property where the value should be interpolated
  122602. */
  122603. propertyPath: string;
  122604. /**
  122605. * Defines the target value at the end of the interpolation.
  122606. */
  122607. value: any;
  122608. /**
  122609. * Defines the time it will take for the property to interpolate to the value.
  122610. */
  122611. duration: number;
  122612. /**
  122613. * Defines if the other scene animations should be stopped when the action has been triggered
  122614. */
  122615. stopOtherAnimations?: boolean;
  122616. /**
  122617. * Defines a callback raised once the interpolation animation has been done.
  122618. */
  122619. onInterpolationDone?: () => void;
  122620. /**
  122621. * Observable triggered once the interpolation animation has been done.
  122622. */
  122623. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  122624. private _target;
  122625. private _effectiveTarget;
  122626. private _property;
  122627. /**
  122628. * Instantiate the action
  122629. * @param triggerOptions defines the trigger options
  122630. * @param target defines the object containing the value to interpolate
  122631. * @param propertyPath defines the path to the property in the target object
  122632. * @param value defines the target value at the end of the interpolation
  122633. * @param duration deines the time it will take for the property to interpolate to the value.
  122634. * @param condition defines the trigger related conditions
  122635. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  122636. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  122637. */
  122638. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  122639. /** @hidden */
  122640. _prepare(): void;
  122641. /**
  122642. * Execute the action starts the value interpolation.
  122643. */
  122644. execute(): void;
  122645. /**
  122646. * Serializes the actions and its related information.
  122647. * @param parent defines the object to serialize in
  122648. * @returns the serialized object
  122649. */
  122650. serialize(parent: any): any;
  122651. }
  122652. }
  122653. declare module BABYLON {
  122654. /**
  122655. * Options allowed during the creation of a sound track.
  122656. */
  122657. export interface ISoundTrackOptions {
  122658. /**
  122659. * The volume the sound track should take during creation
  122660. */
  122661. volume?: number;
  122662. /**
  122663. * Define if the sound track is the main sound track of the scene
  122664. */
  122665. mainTrack?: boolean;
  122666. }
  122667. /**
  122668. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  122669. * It will be also used in a future release to apply effects on a specific track.
  122670. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122671. */
  122672. export class SoundTrack {
  122673. /**
  122674. * The unique identifier of the sound track in the scene.
  122675. */
  122676. id: number;
  122677. /**
  122678. * The list of sounds included in the sound track.
  122679. */
  122680. soundCollection: Array<Sound>;
  122681. private _outputAudioNode;
  122682. private _scene;
  122683. private _connectedAnalyser;
  122684. private _options;
  122685. private _isInitialized;
  122686. /**
  122687. * Creates a new sound track.
  122688. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122689. * @param scene Define the scene the sound track belongs to
  122690. * @param options
  122691. */
  122692. constructor(scene: Scene, options?: ISoundTrackOptions);
  122693. private _initializeSoundTrackAudioGraph;
  122694. /**
  122695. * Release the sound track and its associated resources
  122696. */
  122697. dispose(): void;
  122698. /**
  122699. * Adds a sound to this sound track
  122700. * @param sound define the cound to add
  122701. * @ignoreNaming
  122702. */
  122703. AddSound(sound: Sound): void;
  122704. /**
  122705. * Removes a sound to this sound track
  122706. * @param sound define the cound to remove
  122707. * @ignoreNaming
  122708. */
  122709. RemoveSound(sound: Sound): void;
  122710. /**
  122711. * Set a global volume for the full sound track.
  122712. * @param newVolume Define the new volume of the sound track
  122713. */
  122714. setVolume(newVolume: number): void;
  122715. /**
  122716. * Switch the panning model to HRTF:
  122717. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122718. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122719. */
  122720. switchPanningModelToHRTF(): void;
  122721. /**
  122722. * Switch the panning model to Equal Power:
  122723. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122724. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122725. */
  122726. switchPanningModelToEqualPower(): void;
  122727. /**
  122728. * Connect the sound track to an audio analyser allowing some amazing
  122729. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122730. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122731. * @param analyser The analyser to connect to the engine
  122732. */
  122733. connectToAnalyser(analyser: Analyser): void;
  122734. }
  122735. }
  122736. declare module BABYLON {
  122737. interface AbstractScene {
  122738. /**
  122739. * The list of sounds used in the scene.
  122740. */
  122741. sounds: Nullable<Array<Sound>>;
  122742. }
  122743. interface Scene {
  122744. /**
  122745. * @hidden
  122746. * Backing field
  122747. */
  122748. _mainSoundTrack: SoundTrack;
  122749. /**
  122750. * The main sound track played by the scene.
  122751. * It cotains your primary collection of sounds.
  122752. */
  122753. mainSoundTrack: SoundTrack;
  122754. /**
  122755. * The list of sound tracks added to the scene
  122756. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122757. */
  122758. soundTracks: Nullable<Array<SoundTrack>>;
  122759. /**
  122760. * Gets a sound using a given name
  122761. * @param name defines the name to search for
  122762. * @return the found sound or null if not found at all.
  122763. */
  122764. getSoundByName(name: string): Nullable<Sound>;
  122765. /**
  122766. * Gets or sets if audio support is enabled
  122767. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122768. */
  122769. audioEnabled: boolean;
  122770. /**
  122771. * Gets or sets if audio will be output to headphones
  122772. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122773. */
  122774. headphone: boolean;
  122775. /**
  122776. * Gets or sets custom audio listener position provider
  122777. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122778. */
  122779. audioListenerPositionProvider: Nullable<() => Vector3>;
  122780. /**
  122781. * Gets or sets a refresh rate when using 3D audio positioning
  122782. */
  122783. audioPositioningRefreshRate: number;
  122784. }
  122785. /**
  122786. * Defines the sound scene component responsible to manage any sounds
  122787. * in a given scene.
  122788. */
  122789. export class AudioSceneComponent implements ISceneSerializableComponent {
  122790. private static _CameraDirectionLH;
  122791. private static _CameraDirectionRH;
  122792. /**
  122793. * The component name helpfull to identify the component in the list of scene components.
  122794. */
  122795. readonly name: string;
  122796. /**
  122797. * The scene the component belongs to.
  122798. */
  122799. scene: Scene;
  122800. private _audioEnabled;
  122801. /**
  122802. * Gets whether audio is enabled or not.
  122803. * Please use related enable/disable method to switch state.
  122804. */
  122805. get audioEnabled(): boolean;
  122806. private _headphone;
  122807. /**
  122808. * Gets whether audio is outputing to headphone or not.
  122809. * Please use the according Switch methods to change output.
  122810. */
  122811. get headphone(): boolean;
  122812. /**
  122813. * Gets or sets a refresh rate when using 3D audio positioning
  122814. */
  122815. audioPositioningRefreshRate: number;
  122816. private _audioListenerPositionProvider;
  122817. /**
  122818. * Gets the current audio listener position provider
  122819. */
  122820. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  122821. /**
  122822. * Sets a custom listener position for all sounds in the scene
  122823. * By default, this is the position of the first active camera
  122824. */
  122825. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  122826. /**
  122827. * Creates a new instance of the component for the given scene
  122828. * @param scene Defines the scene to register the component in
  122829. */
  122830. constructor(scene: Scene);
  122831. /**
  122832. * Registers the component in a given scene
  122833. */
  122834. register(): void;
  122835. /**
  122836. * Rebuilds the elements related to this component in case of
  122837. * context lost for instance.
  122838. */
  122839. rebuild(): void;
  122840. /**
  122841. * Serializes the component data to the specified json object
  122842. * @param serializationObject The object to serialize to
  122843. */
  122844. serialize(serializationObject: any): void;
  122845. /**
  122846. * Adds all the elements from the container to the scene
  122847. * @param container the container holding the elements
  122848. */
  122849. addFromContainer(container: AbstractScene): void;
  122850. /**
  122851. * Removes all the elements in the container from the scene
  122852. * @param container contains the elements to remove
  122853. * @param dispose if the removed element should be disposed (default: false)
  122854. */
  122855. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122856. /**
  122857. * Disposes the component and the associated ressources.
  122858. */
  122859. dispose(): void;
  122860. /**
  122861. * Disables audio in the associated scene.
  122862. */
  122863. disableAudio(): void;
  122864. /**
  122865. * Enables audio in the associated scene.
  122866. */
  122867. enableAudio(): void;
  122868. /**
  122869. * Switch audio to headphone output.
  122870. */
  122871. switchAudioModeForHeadphones(): void;
  122872. /**
  122873. * Switch audio to normal speakers.
  122874. */
  122875. switchAudioModeForNormalSpeakers(): void;
  122876. private _cachedCameraDirection;
  122877. private _cachedCameraPosition;
  122878. private _lastCheck;
  122879. private _afterRender;
  122880. }
  122881. }
  122882. declare module BABYLON {
  122883. /**
  122884. * Wraps one or more Sound objects and selects one with random weight for playback.
  122885. */
  122886. export class WeightedSound {
  122887. /** When true a Sound will be selected and played when the current playing Sound completes. */
  122888. loop: boolean;
  122889. private _coneInnerAngle;
  122890. private _coneOuterAngle;
  122891. private _volume;
  122892. /** A Sound is currently playing. */
  122893. isPlaying: boolean;
  122894. /** A Sound is currently paused. */
  122895. isPaused: boolean;
  122896. private _sounds;
  122897. private _weights;
  122898. private _currentIndex?;
  122899. /**
  122900. * Creates a new WeightedSound from the list of sounds given.
  122901. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  122902. * @param sounds Array of Sounds that will be selected from.
  122903. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  122904. */
  122905. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  122906. /**
  122907. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  122908. */
  122909. get directionalConeInnerAngle(): number;
  122910. /**
  122911. * The size of cone in degress for a directional sound in which there will be no attenuation.
  122912. */
  122913. set directionalConeInnerAngle(value: number);
  122914. /**
  122915. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122916. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122917. */
  122918. get directionalConeOuterAngle(): number;
  122919. /**
  122920. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122921. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122922. */
  122923. set directionalConeOuterAngle(value: number);
  122924. /**
  122925. * Playback volume.
  122926. */
  122927. get volume(): number;
  122928. /**
  122929. * Playback volume.
  122930. */
  122931. set volume(value: number);
  122932. private _onended;
  122933. /**
  122934. * Suspend playback
  122935. */
  122936. pause(): void;
  122937. /**
  122938. * Stop playback
  122939. */
  122940. stop(): void;
  122941. /**
  122942. * Start playback.
  122943. * @param startOffset Position the clip head at a specific time in seconds.
  122944. */
  122945. play(startOffset?: number): void;
  122946. }
  122947. }
  122948. declare module BABYLON {
  122949. /**
  122950. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  122951. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122952. */
  122953. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  122954. /**
  122955. * Gets the name of the behavior.
  122956. */
  122957. get name(): string;
  122958. /**
  122959. * The easing function used by animations
  122960. */
  122961. static EasingFunction: BackEase;
  122962. /**
  122963. * The easing mode used by animations
  122964. */
  122965. static EasingMode: number;
  122966. /**
  122967. * The duration of the animation, in milliseconds
  122968. */
  122969. transitionDuration: number;
  122970. /**
  122971. * Length of the distance animated by the transition when lower radius is reached
  122972. */
  122973. lowerRadiusTransitionRange: number;
  122974. /**
  122975. * Length of the distance animated by the transition when upper radius is reached
  122976. */
  122977. upperRadiusTransitionRange: number;
  122978. private _autoTransitionRange;
  122979. /**
  122980. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122981. */
  122982. get autoTransitionRange(): boolean;
  122983. /**
  122984. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122985. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122986. */
  122987. set autoTransitionRange(value: boolean);
  122988. private _attachedCamera;
  122989. private _onAfterCheckInputsObserver;
  122990. private _onMeshTargetChangedObserver;
  122991. /**
  122992. * Initializes the behavior.
  122993. */
  122994. init(): void;
  122995. /**
  122996. * Attaches the behavior to its arc rotate camera.
  122997. * @param camera Defines the camera to attach the behavior to
  122998. */
  122999. attach(camera: ArcRotateCamera): void;
  123000. /**
  123001. * Detaches the behavior from its current arc rotate camera.
  123002. */
  123003. detach(): void;
  123004. private _radiusIsAnimating;
  123005. private _radiusBounceTransition;
  123006. private _animatables;
  123007. private _cachedWheelPrecision;
  123008. /**
  123009. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  123010. * @param radiusLimit The limit to check against.
  123011. * @return Bool to indicate if at limit.
  123012. */
  123013. private _isRadiusAtLimit;
  123014. /**
  123015. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  123016. * @param radiusDelta The delta by which to animate to. Can be negative.
  123017. */
  123018. private _applyBoundRadiusAnimation;
  123019. /**
  123020. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  123021. */
  123022. protected _clearAnimationLocks(): void;
  123023. /**
  123024. * Stops and removes all animations that have been applied to the camera
  123025. */
  123026. stopAllAnimations(): void;
  123027. }
  123028. }
  123029. declare module BABYLON {
  123030. /**
  123031. * 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.
  123032. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123033. */
  123034. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  123035. /**
  123036. * Gets the name of the behavior.
  123037. */
  123038. get name(): string;
  123039. private _mode;
  123040. private _radiusScale;
  123041. private _positionScale;
  123042. private _defaultElevation;
  123043. private _elevationReturnTime;
  123044. private _elevationReturnWaitTime;
  123045. private _zoomStopsAnimation;
  123046. private _framingTime;
  123047. /**
  123048. * The easing function used by animations
  123049. */
  123050. static EasingFunction: ExponentialEase;
  123051. /**
  123052. * The easing mode used by animations
  123053. */
  123054. static EasingMode: number;
  123055. /**
  123056. * Sets the current mode used by the behavior
  123057. */
  123058. set mode(mode: number);
  123059. /**
  123060. * Gets current mode used by the behavior.
  123061. */
  123062. get mode(): number;
  123063. /**
  123064. * Sets the scale applied to the radius (1 by default)
  123065. */
  123066. set radiusScale(radius: number);
  123067. /**
  123068. * Gets the scale applied to the radius
  123069. */
  123070. get radiusScale(): number;
  123071. /**
  123072. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  123073. */
  123074. set positionScale(scale: number);
  123075. /**
  123076. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  123077. */
  123078. get positionScale(): number;
  123079. /**
  123080. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  123081. * behaviour is triggered, in radians.
  123082. */
  123083. set defaultElevation(elevation: number);
  123084. /**
  123085. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  123086. * behaviour is triggered, in radians.
  123087. */
  123088. get defaultElevation(): number;
  123089. /**
  123090. * Sets the time (in milliseconds) taken to return to the default beta position.
  123091. * Negative value indicates camera should not return to default.
  123092. */
  123093. set elevationReturnTime(speed: number);
  123094. /**
  123095. * Gets the time (in milliseconds) taken to return to the default beta position.
  123096. * Negative value indicates camera should not return to default.
  123097. */
  123098. get elevationReturnTime(): number;
  123099. /**
  123100. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  123101. */
  123102. set elevationReturnWaitTime(time: number);
  123103. /**
  123104. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  123105. */
  123106. get elevationReturnWaitTime(): number;
  123107. /**
  123108. * Sets the flag that indicates if user zooming should stop animation.
  123109. */
  123110. set zoomStopsAnimation(flag: boolean);
  123111. /**
  123112. * Gets the flag that indicates if user zooming should stop animation.
  123113. */
  123114. get zoomStopsAnimation(): boolean;
  123115. /**
  123116. * Sets the transition time when framing the mesh, in milliseconds
  123117. */
  123118. set framingTime(time: number);
  123119. /**
  123120. * Gets the transition time when framing the mesh, in milliseconds
  123121. */
  123122. get framingTime(): number;
  123123. /**
  123124. * Define if the behavior should automatically change the configured
  123125. * camera limits and sensibilities.
  123126. */
  123127. autoCorrectCameraLimitsAndSensibility: boolean;
  123128. private _onPrePointerObservableObserver;
  123129. private _onAfterCheckInputsObserver;
  123130. private _onMeshTargetChangedObserver;
  123131. private _attachedCamera;
  123132. private _isPointerDown;
  123133. private _lastInteractionTime;
  123134. /**
  123135. * Initializes the behavior.
  123136. */
  123137. init(): void;
  123138. /**
  123139. * Attaches the behavior to its arc rotate camera.
  123140. * @param camera Defines the camera to attach the behavior to
  123141. */
  123142. attach(camera: ArcRotateCamera): void;
  123143. /**
  123144. * Detaches the behavior from its current arc rotate camera.
  123145. */
  123146. detach(): void;
  123147. private _animatables;
  123148. private _betaIsAnimating;
  123149. private _betaTransition;
  123150. private _radiusTransition;
  123151. private _vectorTransition;
  123152. /**
  123153. * Targets the given mesh and updates zoom level accordingly.
  123154. * @param mesh The mesh to target.
  123155. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  123156. * @param onAnimationEnd Callback triggered at the end of the framing animation
  123157. */
  123158. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  123159. /**
  123160. * Targets the given mesh with its children and updates zoom level accordingly.
  123161. * @param mesh The mesh to target.
  123162. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  123163. * @param onAnimationEnd Callback triggered at the end of the framing animation
  123164. */
  123165. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  123166. /**
  123167. * Targets the given meshes with their children and updates zoom level accordingly.
  123168. * @param meshes The mesh to target.
  123169. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  123170. * @param onAnimationEnd Callback triggered at the end of the framing animation
  123171. */
  123172. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  123173. /**
  123174. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  123175. * @param minimumWorld Determines the smaller position of the bounding box extend
  123176. * @param maximumWorld Determines the bigger position of the bounding box extend
  123177. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  123178. * @param onAnimationEnd Callback triggered at the end of the framing animation
  123179. */
  123180. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  123181. /**
  123182. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  123183. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  123184. * frustum width.
  123185. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  123186. * to fully enclose the mesh in the viewing frustum.
  123187. */
  123188. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  123189. /**
  123190. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  123191. * is automatically returned to its default position (expected to be above ground plane).
  123192. */
  123193. private _maintainCameraAboveGround;
  123194. /**
  123195. * Returns the frustum slope based on the canvas ratio and camera FOV
  123196. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  123197. */
  123198. private _getFrustumSlope;
  123199. /**
  123200. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  123201. */
  123202. private _clearAnimationLocks;
  123203. /**
  123204. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123205. */
  123206. private _applyUserInteraction;
  123207. /**
  123208. * Stops and removes all animations that have been applied to the camera
  123209. */
  123210. stopAllAnimations(): void;
  123211. /**
  123212. * Gets a value indicating if the user is moving the camera
  123213. */
  123214. get isUserIsMoving(): boolean;
  123215. /**
  123216. * The camera can move all the way towards the mesh.
  123217. */
  123218. static IgnoreBoundsSizeMode: number;
  123219. /**
  123220. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  123221. */
  123222. static FitFrustumSidesMode: number;
  123223. }
  123224. }
  123225. declare module BABYLON {
  123226. /**
  123227. * Base class for Camera Pointer Inputs.
  123228. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  123229. * for example usage.
  123230. */
  123231. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  123232. /**
  123233. * Defines the camera the input is attached to.
  123234. */
  123235. abstract camera: Camera;
  123236. /**
  123237. * Whether keyboard modifier keys are pressed at time of last mouse event.
  123238. */
  123239. protected _altKey: boolean;
  123240. protected _ctrlKey: boolean;
  123241. protected _metaKey: boolean;
  123242. protected _shiftKey: boolean;
  123243. /**
  123244. * Which mouse buttons were pressed at time of last mouse event.
  123245. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  123246. */
  123247. protected _buttonsPressed: number;
  123248. /**
  123249. * Defines the buttons associated with the input to handle camera move.
  123250. */
  123251. buttons: number[];
  123252. /**
  123253. * Attach the input controls to a specific dom element to get the input from.
  123254. * @param element Defines the element the controls should be listened from
  123255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123256. */
  123257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123258. /**
  123259. * Detach the current controls from the specified dom element.
  123260. * @param element Defines the element to stop listening the inputs from
  123261. */
  123262. detachControl(element: Nullable<HTMLElement>): void;
  123263. /**
  123264. * Gets the class name of the current input.
  123265. * @returns the class name
  123266. */
  123267. getClassName(): string;
  123268. /**
  123269. * Get the friendly name associated with the input class.
  123270. * @returns the input friendly name
  123271. */
  123272. getSimpleName(): string;
  123273. /**
  123274. * Called on pointer POINTERDOUBLETAP event.
  123275. * Override this method to provide functionality on POINTERDOUBLETAP event.
  123276. */
  123277. protected onDoubleTap(type: string): void;
  123278. /**
  123279. * Called on pointer POINTERMOVE event if only a single touch is active.
  123280. * Override this method to provide functionality.
  123281. */
  123282. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123283. /**
  123284. * Called on pointer POINTERMOVE event if multiple touches are active.
  123285. * Override this method to provide functionality.
  123286. */
  123287. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123288. /**
  123289. * Called on JS contextmenu event.
  123290. * Override this method to provide functionality.
  123291. */
  123292. protected onContextMenu(evt: PointerEvent): void;
  123293. /**
  123294. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  123295. * press.
  123296. * Override this method to provide functionality.
  123297. */
  123298. protected onButtonDown(evt: PointerEvent): void;
  123299. /**
  123300. * Called each time a new POINTERUP event occurs. Ie, for each button
  123301. * release.
  123302. * Override this method to provide functionality.
  123303. */
  123304. protected onButtonUp(evt: PointerEvent): void;
  123305. /**
  123306. * Called when window becomes inactive.
  123307. * Override this method to provide functionality.
  123308. */
  123309. protected onLostFocus(): void;
  123310. private _pointerInput;
  123311. private _observer;
  123312. private _onLostFocus;
  123313. private pointA;
  123314. private pointB;
  123315. }
  123316. }
  123317. declare module BABYLON {
  123318. /**
  123319. * Manage the pointers inputs to control an arc rotate camera.
  123320. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123321. */
  123322. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  123323. /**
  123324. * Defines the camera the input is attached to.
  123325. */
  123326. camera: ArcRotateCamera;
  123327. /**
  123328. * Gets the class name of the current input.
  123329. * @returns the class name
  123330. */
  123331. getClassName(): string;
  123332. /**
  123333. * Defines the buttons associated with the input to handle camera move.
  123334. */
  123335. buttons: number[];
  123336. /**
  123337. * Defines the pointer angular sensibility along the X axis or how fast is
  123338. * the camera rotating.
  123339. */
  123340. angularSensibilityX: number;
  123341. /**
  123342. * Defines the pointer angular sensibility along the Y axis or how fast is
  123343. * the camera rotating.
  123344. */
  123345. angularSensibilityY: number;
  123346. /**
  123347. * Defines the pointer pinch precision or how fast is the camera zooming.
  123348. */
  123349. pinchPrecision: number;
  123350. /**
  123351. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123352. * from 0.
  123353. * It defines the percentage of current camera.radius to use as delta when
  123354. * pinch zoom is used.
  123355. */
  123356. pinchDeltaPercentage: number;
  123357. /**
  123358. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123359. * that any object in the plane at the camera's target point will scale
  123360. * perfectly with finger motion.
  123361. * Overrides pinchDeltaPercentage and pinchPrecision.
  123362. */
  123363. useNaturalPinchZoom: boolean;
  123364. /**
  123365. * Defines the pointer panning sensibility or how fast is the camera moving.
  123366. */
  123367. panningSensibility: number;
  123368. /**
  123369. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  123370. */
  123371. multiTouchPanning: boolean;
  123372. /**
  123373. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  123374. * zoom (pinch) through multitouch.
  123375. */
  123376. multiTouchPanAndZoom: boolean;
  123377. /**
  123378. * Revers pinch action direction.
  123379. */
  123380. pinchInwards: boolean;
  123381. private _isPanClick;
  123382. private _twoFingerActivityCount;
  123383. private _isPinching;
  123384. /**
  123385. * Called on pointer POINTERMOVE event if only a single touch is active.
  123386. */
  123387. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123388. /**
  123389. * Called on pointer POINTERDOUBLETAP event.
  123390. */
  123391. protected onDoubleTap(type: string): void;
  123392. /**
  123393. * Called on pointer POINTERMOVE event if multiple touches are active.
  123394. */
  123395. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123396. /**
  123397. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  123398. * press.
  123399. */
  123400. protected onButtonDown(evt: PointerEvent): void;
  123401. /**
  123402. * Called each time a new POINTERUP event occurs. Ie, for each button
  123403. * release.
  123404. */
  123405. protected onButtonUp(evt: PointerEvent): void;
  123406. /**
  123407. * Called when window becomes inactive.
  123408. */
  123409. protected onLostFocus(): void;
  123410. }
  123411. }
  123412. declare module BABYLON {
  123413. /**
  123414. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  123415. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123416. */
  123417. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  123418. /**
  123419. * Defines the camera the input is attached to.
  123420. */
  123421. camera: ArcRotateCamera;
  123422. /**
  123423. * Defines the list of key codes associated with the up action (increase alpha)
  123424. */
  123425. keysUp: number[];
  123426. /**
  123427. * Defines the list of key codes associated with the down action (decrease alpha)
  123428. */
  123429. keysDown: number[];
  123430. /**
  123431. * Defines the list of key codes associated with the left action (increase beta)
  123432. */
  123433. keysLeft: number[];
  123434. /**
  123435. * Defines the list of key codes associated with the right action (decrease beta)
  123436. */
  123437. keysRight: number[];
  123438. /**
  123439. * Defines the list of key codes associated with the reset action.
  123440. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  123441. */
  123442. keysReset: number[];
  123443. /**
  123444. * Defines the panning sensibility of the inputs.
  123445. * (How fast is the camera panning)
  123446. */
  123447. panningSensibility: number;
  123448. /**
  123449. * Defines the zooming sensibility of the inputs.
  123450. * (How fast is the camera zooming)
  123451. */
  123452. zoomingSensibility: number;
  123453. /**
  123454. * Defines whether maintaining the alt key down switch the movement mode from
  123455. * orientation to zoom.
  123456. */
  123457. useAltToZoom: boolean;
  123458. /**
  123459. * Rotation speed of the camera
  123460. */
  123461. angularSpeed: number;
  123462. private _keys;
  123463. private _ctrlPressed;
  123464. private _altPressed;
  123465. private _onCanvasBlurObserver;
  123466. private _onKeyboardObserver;
  123467. private _engine;
  123468. private _scene;
  123469. /**
  123470. * Attach the input controls to a specific dom element to get the input from.
  123471. * @param element Defines the element the controls should be listened from
  123472. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123473. */
  123474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123475. /**
  123476. * Detach the current controls from the specified dom element.
  123477. * @param element Defines the element to stop listening the inputs from
  123478. */
  123479. detachControl(element: Nullable<HTMLElement>): void;
  123480. /**
  123481. * Update the current camera state depending on the inputs that have been used this frame.
  123482. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123483. */
  123484. checkInputs(): void;
  123485. /**
  123486. * Gets the class name of the current intput.
  123487. * @returns the class name
  123488. */
  123489. getClassName(): string;
  123490. /**
  123491. * Get the friendly name associated with the input class.
  123492. * @returns the input friendly name
  123493. */
  123494. getSimpleName(): string;
  123495. }
  123496. }
  123497. declare module BABYLON {
  123498. /**
  123499. * Manage the mouse wheel inputs to control an arc rotate camera.
  123500. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123501. */
  123502. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  123503. /**
  123504. * Defines the camera the input is attached to.
  123505. */
  123506. camera: ArcRotateCamera;
  123507. /**
  123508. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123509. */
  123510. wheelPrecision: number;
  123511. /**
  123512. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123513. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123514. */
  123515. wheelDeltaPercentage: number;
  123516. private _wheel;
  123517. private _observer;
  123518. private computeDeltaFromMouseWheelLegacyEvent;
  123519. /**
  123520. * Attach the input controls to a specific dom element to get the input from.
  123521. * @param element Defines the element the controls should be listened from
  123522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123523. */
  123524. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123525. /**
  123526. * Detach the current controls from the specified dom element.
  123527. * @param element Defines the element to stop listening the inputs from
  123528. */
  123529. detachControl(element: Nullable<HTMLElement>): void;
  123530. /**
  123531. * Gets the class name of the current intput.
  123532. * @returns the class name
  123533. */
  123534. getClassName(): string;
  123535. /**
  123536. * Get the friendly name associated with the input class.
  123537. * @returns the input friendly name
  123538. */
  123539. getSimpleName(): string;
  123540. }
  123541. }
  123542. declare module BABYLON {
  123543. /**
  123544. * Default Inputs manager for the ArcRotateCamera.
  123545. * It groups all the default supported inputs for ease of use.
  123546. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123547. */
  123548. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  123549. /**
  123550. * Instantiates a new ArcRotateCameraInputsManager.
  123551. * @param camera Defines the camera the inputs belong to
  123552. */
  123553. constructor(camera: ArcRotateCamera);
  123554. /**
  123555. * Add mouse wheel input support to the input manager.
  123556. * @returns the current input manager
  123557. */
  123558. addMouseWheel(): ArcRotateCameraInputsManager;
  123559. /**
  123560. * Add pointers input support to the input manager.
  123561. * @returns the current input manager
  123562. */
  123563. addPointers(): ArcRotateCameraInputsManager;
  123564. /**
  123565. * Add keyboard input support to the input manager.
  123566. * @returns the current input manager
  123567. */
  123568. addKeyboard(): ArcRotateCameraInputsManager;
  123569. }
  123570. }
  123571. declare module BABYLON {
  123572. /**
  123573. * This represents an orbital type of camera.
  123574. *
  123575. * 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.
  123576. * 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.
  123577. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  123578. */
  123579. export class ArcRotateCamera extends TargetCamera {
  123580. /**
  123581. * Defines the rotation angle of the camera along the longitudinal axis.
  123582. */
  123583. alpha: number;
  123584. /**
  123585. * Defines the rotation angle of the camera along the latitudinal axis.
  123586. */
  123587. beta: number;
  123588. /**
  123589. * Defines the radius of the camera from it s target point.
  123590. */
  123591. radius: number;
  123592. protected _target: Vector3;
  123593. protected _targetHost: Nullable<AbstractMesh>;
  123594. /**
  123595. * Defines the target point of the camera.
  123596. * The camera looks towards it form the radius distance.
  123597. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  123598. */
  123599. get target(): Vector3;
  123600. set target(value: Vector3);
  123601. /**
  123602. * Define the current local position of the camera in the scene
  123603. */
  123604. get position(): Vector3;
  123605. set position(newPosition: Vector3);
  123606. protected _upToYMatrix: Matrix;
  123607. protected _YToUpMatrix: Matrix;
  123608. /**
  123609. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  123610. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  123611. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  123612. */
  123613. set upVector(vec: Vector3);
  123614. get upVector(): Vector3;
  123615. /**
  123616. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  123617. */
  123618. setMatUp(): void;
  123619. /**
  123620. * Current inertia value on the longitudinal axis.
  123621. * The bigger this number the longer it will take for the camera to stop.
  123622. */
  123623. inertialAlphaOffset: number;
  123624. /**
  123625. * Current inertia value on the latitudinal axis.
  123626. * The bigger this number the longer it will take for the camera to stop.
  123627. */
  123628. inertialBetaOffset: number;
  123629. /**
  123630. * Current inertia value on the radius axis.
  123631. * The bigger this number the longer it will take for the camera to stop.
  123632. */
  123633. inertialRadiusOffset: number;
  123634. /**
  123635. * Minimum allowed angle on the longitudinal axis.
  123636. * This can help limiting how the Camera is able to move in the scene.
  123637. */
  123638. lowerAlphaLimit: Nullable<number>;
  123639. /**
  123640. * Maximum allowed angle on the longitudinal axis.
  123641. * This can help limiting how the Camera is able to move in the scene.
  123642. */
  123643. upperAlphaLimit: Nullable<number>;
  123644. /**
  123645. * Minimum allowed angle on the latitudinal axis.
  123646. * This can help limiting how the Camera is able to move in the scene.
  123647. */
  123648. lowerBetaLimit: number;
  123649. /**
  123650. * Maximum allowed angle on the latitudinal axis.
  123651. * This can help limiting how the Camera is able to move in the scene.
  123652. */
  123653. upperBetaLimit: number;
  123654. /**
  123655. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  123656. * This can help limiting how the Camera is able to move in the scene.
  123657. */
  123658. lowerRadiusLimit: Nullable<number>;
  123659. /**
  123660. * Maximum allowed distance of the camera to the target (The camera can not get further).
  123661. * This can help limiting how the Camera is able to move in the scene.
  123662. */
  123663. upperRadiusLimit: Nullable<number>;
  123664. /**
  123665. * Defines the current inertia value used during panning of the camera along the X axis.
  123666. */
  123667. inertialPanningX: number;
  123668. /**
  123669. * Defines the current inertia value used during panning of the camera along the Y axis.
  123670. */
  123671. inertialPanningY: number;
  123672. /**
  123673. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  123674. * Basically if your fingers moves away from more than this distance you will be considered
  123675. * in pinch mode.
  123676. */
  123677. pinchToPanMaxDistance: number;
  123678. /**
  123679. * Defines the maximum distance the camera can pan.
  123680. * This could help keeping the cammera always in your scene.
  123681. */
  123682. panningDistanceLimit: Nullable<number>;
  123683. /**
  123684. * Defines the target of the camera before paning.
  123685. */
  123686. panningOriginTarget: Vector3;
  123687. /**
  123688. * Defines the value of the inertia used during panning.
  123689. * 0 would mean stop inertia and one would mean no decelleration at all.
  123690. */
  123691. panningInertia: number;
  123692. /**
  123693. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  123694. */
  123695. get angularSensibilityX(): number;
  123696. set angularSensibilityX(value: number);
  123697. /**
  123698. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  123699. */
  123700. get angularSensibilityY(): number;
  123701. set angularSensibilityY(value: number);
  123702. /**
  123703. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  123704. */
  123705. get pinchPrecision(): number;
  123706. set pinchPrecision(value: number);
  123707. /**
  123708. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  123709. * It will be used instead of pinchDeltaPrecision if different from 0.
  123710. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123711. */
  123712. get pinchDeltaPercentage(): number;
  123713. set pinchDeltaPercentage(value: number);
  123714. /**
  123715. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  123716. * and pinch delta percentage.
  123717. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123718. * that any object in the plane at the camera's target point will scale
  123719. * perfectly with finger motion.
  123720. */
  123721. get useNaturalPinchZoom(): boolean;
  123722. set useNaturalPinchZoom(value: boolean);
  123723. /**
  123724. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  123725. */
  123726. get panningSensibility(): number;
  123727. set panningSensibility(value: number);
  123728. /**
  123729. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  123730. */
  123731. get keysUp(): number[];
  123732. set keysUp(value: number[]);
  123733. /**
  123734. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  123735. */
  123736. get keysDown(): number[];
  123737. set keysDown(value: number[]);
  123738. /**
  123739. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  123740. */
  123741. get keysLeft(): number[];
  123742. set keysLeft(value: number[]);
  123743. /**
  123744. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  123745. */
  123746. get keysRight(): number[];
  123747. set keysRight(value: number[]);
  123748. /**
  123749. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123750. */
  123751. get wheelPrecision(): number;
  123752. set wheelPrecision(value: number);
  123753. /**
  123754. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  123755. * It will be used instead of pinchDeltaPrecision if different from 0.
  123756. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123757. */
  123758. get wheelDeltaPercentage(): number;
  123759. set wheelDeltaPercentage(value: number);
  123760. /**
  123761. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  123762. */
  123763. zoomOnFactor: number;
  123764. /**
  123765. * Defines a screen offset for the camera position.
  123766. */
  123767. targetScreenOffset: Vector2;
  123768. /**
  123769. * Allows the camera to be completely reversed.
  123770. * If false the camera can not arrive upside down.
  123771. */
  123772. allowUpsideDown: boolean;
  123773. /**
  123774. * Define if double tap/click is used to restore the previously saved state of the camera.
  123775. */
  123776. useInputToRestoreState: boolean;
  123777. /** @hidden */
  123778. _viewMatrix: Matrix;
  123779. /** @hidden */
  123780. _useCtrlForPanning: boolean;
  123781. /** @hidden */
  123782. _panningMouseButton: number;
  123783. /**
  123784. * Defines the input associated to the camera.
  123785. */
  123786. inputs: ArcRotateCameraInputsManager;
  123787. /** @hidden */
  123788. _reset: () => void;
  123789. /**
  123790. * Defines the allowed panning axis.
  123791. */
  123792. panningAxis: Vector3;
  123793. protected _localDirection: Vector3;
  123794. protected _transformedDirection: Vector3;
  123795. private _bouncingBehavior;
  123796. /**
  123797. * Gets the bouncing behavior of the camera if it has been enabled.
  123798. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123799. */
  123800. get bouncingBehavior(): Nullable<BouncingBehavior>;
  123801. /**
  123802. * Defines if the bouncing behavior of the camera is enabled on the camera.
  123803. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123804. */
  123805. get useBouncingBehavior(): boolean;
  123806. set useBouncingBehavior(value: boolean);
  123807. private _framingBehavior;
  123808. /**
  123809. * Gets the framing behavior of the camera if it has been enabled.
  123810. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123811. */
  123812. get framingBehavior(): Nullable<FramingBehavior>;
  123813. /**
  123814. * Defines if the framing behavior of the camera is enabled on the camera.
  123815. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123816. */
  123817. get useFramingBehavior(): boolean;
  123818. set useFramingBehavior(value: boolean);
  123819. private _autoRotationBehavior;
  123820. /**
  123821. * Gets the auto rotation behavior of the camera if it has been enabled.
  123822. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123823. */
  123824. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  123825. /**
  123826. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  123827. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123828. */
  123829. get useAutoRotationBehavior(): boolean;
  123830. set useAutoRotationBehavior(value: boolean);
  123831. /**
  123832. * Observable triggered when the mesh target has been changed on the camera.
  123833. */
  123834. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  123835. /**
  123836. * Event raised when the camera is colliding with a mesh.
  123837. */
  123838. onCollide: (collidedMesh: AbstractMesh) => void;
  123839. /**
  123840. * Defines whether the camera should check collision with the objects oh the scene.
  123841. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  123842. */
  123843. checkCollisions: boolean;
  123844. /**
  123845. * Defines the collision radius of the camera.
  123846. * This simulates a sphere around the camera.
  123847. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123848. */
  123849. collisionRadius: Vector3;
  123850. protected _collider: Collider;
  123851. protected _previousPosition: Vector3;
  123852. protected _collisionVelocity: Vector3;
  123853. protected _newPosition: Vector3;
  123854. protected _previousAlpha: number;
  123855. protected _previousBeta: number;
  123856. protected _previousRadius: number;
  123857. protected _collisionTriggered: boolean;
  123858. protected _targetBoundingCenter: Nullable<Vector3>;
  123859. private _computationVector;
  123860. /**
  123861. * Instantiates a new ArcRotateCamera in a given scene
  123862. * @param name Defines the name of the camera
  123863. * @param alpha Defines the camera rotation along the logitudinal axis
  123864. * @param beta Defines the camera rotation along the latitudinal axis
  123865. * @param radius Defines the camera distance from its target
  123866. * @param target Defines the camera target
  123867. * @param scene Defines the scene the camera belongs to
  123868. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  123869. */
  123870. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123871. /** @hidden */
  123872. _initCache(): void;
  123873. /** @hidden */
  123874. _updateCache(ignoreParentClass?: boolean): void;
  123875. protected _getTargetPosition(): Vector3;
  123876. private _storedAlpha;
  123877. private _storedBeta;
  123878. private _storedRadius;
  123879. private _storedTarget;
  123880. private _storedTargetScreenOffset;
  123881. /**
  123882. * Stores the current state of the camera (alpha, beta, radius and target)
  123883. * @returns the camera itself
  123884. */
  123885. storeState(): Camera;
  123886. /**
  123887. * @hidden
  123888. * Restored camera state. You must call storeState() first
  123889. */
  123890. _restoreStateValues(): boolean;
  123891. /** @hidden */
  123892. _isSynchronizedViewMatrix(): boolean;
  123893. /**
  123894. * Attached controls to the current camera.
  123895. * @param element Defines the element the controls should be listened from
  123896. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123897. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  123898. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  123899. */
  123900. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  123901. /**
  123902. * Detach the current controls from the camera.
  123903. * The camera will stop reacting to inputs.
  123904. * @param element Defines the element to stop listening the inputs from
  123905. */
  123906. detachControl(element: HTMLElement): void;
  123907. /** @hidden */
  123908. _checkInputs(): void;
  123909. protected _checkLimits(): void;
  123910. /**
  123911. * Rebuilds angles (alpha, beta) and radius from the give position and target
  123912. */
  123913. rebuildAnglesAndRadius(): void;
  123914. /**
  123915. * Use a position to define the current camera related information like alpha, beta and radius
  123916. * @param position Defines the position to set the camera at
  123917. */
  123918. setPosition(position: Vector3): void;
  123919. /**
  123920. * Defines the target the camera should look at.
  123921. * This will automatically adapt alpha beta and radius to fit within the new target.
  123922. * @param target Defines the new target as a Vector or a mesh
  123923. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  123924. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  123925. */
  123926. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  123927. /** @hidden */
  123928. _getViewMatrix(): Matrix;
  123929. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  123930. /**
  123931. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  123932. * @param meshes Defines the mesh to zoom on
  123933. * @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)
  123934. */
  123935. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  123936. /**
  123937. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  123938. * The target will be changed but the radius
  123939. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  123940. * @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)
  123941. */
  123942. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  123943. min: Vector3;
  123944. max: Vector3;
  123945. distance: number;
  123946. }, doNotUpdateMaxZ?: boolean): void;
  123947. /**
  123948. * @override
  123949. * Override Camera.createRigCamera
  123950. */
  123951. createRigCamera(name: string, cameraIndex: number): Camera;
  123952. /**
  123953. * @hidden
  123954. * @override
  123955. * Override Camera._updateRigCameras
  123956. */
  123957. _updateRigCameras(): void;
  123958. /**
  123959. * Destroy the camera and release the current resources hold by it.
  123960. */
  123961. dispose(): void;
  123962. /**
  123963. * Gets the current object class name.
  123964. * @return the class name
  123965. */
  123966. getClassName(): string;
  123967. }
  123968. }
  123969. declare module BABYLON {
  123970. /**
  123971. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123972. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123973. */
  123974. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123975. /**
  123976. * Gets the name of the behavior.
  123977. */
  123978. get name(): string;
  123979. private _zoomStopsAnimation;
  123980. private _idleRotationSpeed;
  123981. private _idleRotationWaitTime;
  123982. private _idleRotationSpinupTime;
  123983. /**
  123984. * Sets the flag that indicates if user zooming should stop animation.
  123985. */
  123986. set zoomStopsAnimation(flag: boolean);
  123987. /**
  123988. * Gets the flag that indicates if user zooming should stop animation.
  123989. */
  123990. get zoomStopsAnimation(): boolean;
  123991. /**
  123992. * Sets the default speed at which the camera rotates around the model.
  123993. */
  123994. set idleRotationSpeed(speed: number);
  123995. /**
  123996. * Gets the default speed at which the camera rotates around the model.
  123997. */
  123998. get idleRotationSpeed(): number;
  123999. /**
  124000. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  124001. */
  124002. set idleRotationWaitTime(time: number);
  124003. /**
  124004. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  124005. */
  124006. get idleRotationWaitTime(): number;
  124007. /**
  124008. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  124009. */
  124010. set idleRotationSpinupTime(time: number);
  124011. /**
  124012. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  124013. */
  124014. get idleRotationSpinupTime(): number;
  124015. /**
  124016. * Gets a value indicating if the camera is currently rotating because of this behavior
  124017. */
  124018. get rotationInProgress(): boolean;
  124019. private _onPrePointerObservableObserver;
  124020. private _onAfterCheckInputsObserver;
  124021. private _attachedCamera;
  124022. private _isPointerDown;
  124023. private _lastFrameTime;
  124024. private _lastInteractionTime;
  124025. private _cameraRotationSpeed;
  124026. /**
  124027. * Initializes the behavior.
  124028. */
  124029. init(): void;
  124030. /**
  124031. * Attaches the behavior to its arc rotate camera.
  124032. * @param camera Defines the camera to attach the behavior to
  124033. */
  124034. attach(camera: ArcRotateCamera): void;
  124035. /**
  124036. * Detaches the behavior from its current arc rotate camera.
  124037. */
  124038. detach(): void;
  124039. /**
  124040. * Returns true if user is scrolling.
  124041. * @return true if user is scrolling.
  124042. */
  124043. private _userIsZooming;
  124044. private _lastFrameRadius;
  124045. private _shouldAnimationStopForInteraction;
  124046. /**
  124047. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  124048. */
  124049. private _applyUserInteraction;
  124050. private _userIsMoving;
  124051. }
  124052. }
  124053. declare module BABYLON {
  124054. /**
  124055. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  124056. */
  124057. export class AttachToBoxBehavior implements Behavior<Mesh> {
  124058. private ui;
  124059. /**
  124060. * The name of the behavior
  124061. */
  124062. name: string;
  124063. /**
  124064. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  124065. */
  124066. distanceAwayFromFace: number;
  124067. /**
  124068. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  124069. */
  124070. distanceAwayFromBottomOfFace: number;
  124071. private _faceVectors;
  124072. private _target;
  124073. private _scene;
  124074. private _onRenderObserver;
  124075. private _tmpMatrix;
  124076. private _tmpVector;
  124077. /**
  124078. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  124079. * @param ui The transform node that should be attched to the mesh
  124080. */
  124081. constructor(ui: TransformNode);
  124082. /**
  124083. * Initializes the behavior
  124084. */
  124085. init(): void;
  124086. private _closestFace;
  124087. private _zeroVector;
  124088. private _lookAtTmpMatrix;
  124089. private _lookAtToRef;
  124090. /**
  124091. * Attaches the AttachToBoxBehavior to the passed in mesh
  124092. * @param target The mesh that the specified node will be attached to
  124093. */
  124094. attach(target: Mesh): void;
  124095. /**
  124096. * Detaches the behavior from the mesh
  124097. */
  124098. detach(): void;
  124099. }
  124100. }
  124101. declare module BABYLON {
  124102. /**
  124103. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  124104. */
  124105. export class FadeInOutBehavior implements Behavior<Mesh> {
  124106. /**
  124107. * Time in milliseconds to delay before fading in (Default: 0)
  124108. */
  124109. delay: number;
  124110. /**
  124111. * Time in milliseconds for the mesh to fade in (Default: 300)
  124112. */
  124113. fadeInTime: number;
  124114. private _millisecondsPerFrame;
  124115. private _hovered;
  124116. private _hoverValue;
  124117. private _ownerNode;
  124118. /**
  124119. * Instatiates the FadeInOutBehavior
  124120. */
  124121. constructor();
  124122. /**
  124123. * The name of the behavior
  124124. */
  124125. get name(): string;
  124126. /**
  124127. * Initializes the behavior
  124128. */
  124129. init(): void;
  124130. /**
  124131. * Attaches the fade behavior on the passed in mesh
  124132. * @param ownerNode The mesh that will be faded in/out once attached
  124133. */
  124134. attach(ownerNode: Mesh): void;
  124135. /**
  124136. * Detaches the behavior from the mesh
  124137. */
  124138. detach(): void;
  124139. /**
  124140. * Triggers the mesh to begin fading in or out
  124141. * @param value if the object should fade in or out (true to fade in)
  124142. */
  124143. fadeIn(value: boolean): void;
  124144. private _update;
  124145. private _setAllVisibility;
  124146. }
  124147. }
  124148. declare module BABYLON {
  124149. /**
  124150. * Class containing a set of static utilities functions for managing Pivots
  124151. * @hidden
  124152. */
  124153. export class PivotTools {
  124154. private static _PivotCached;
  124155. private static _OldPivotPoint;
  124156. private static _PivotTranslation;
  124157. private static _PivotTmpVector;
  124158. private static _PivotPostMultiplyPivotMatrix;
  124159. /** @hidden */
  124160. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  124161. /** @hidden */
  124162. static _RestorePivotPoint(mesh: AbstractMesh): void;
  124163. }
  124164. }
  124165. declare module BABYLON {
  124166. /**
  124167. * Class containing static functions to help procedurally build meshes
  124168. */
  124169. export class PlaneBuilder {
  124170. /**
  124171. * Creates a plane mesh
  124172. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  124173. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  124174. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  124175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124176. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124178. * @param name defines the name of the mesh
  124179. * @param options defines the options used to create the mesh
  124180. * @param scene defines the hosting scene
  124181. * @returns the plane mesh
  124182. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124183. */
  124184. static CreatePlane(name: string, options: {
  124185. size?: number;
  124186. width?: number;
  124187. height?: number;
  124188. sideOrientation?: number;
  124189. frontUVs?: Vector4;
  124190. backUVs?: Vector4;
  124191. updatable?: boolean;
  124192. sourcePlane?: Plane;
  124193. }, scene?: Nullable<Scene>): Mesh;
  124194. }
  124195. }
  124196. declare module BABYLON {
  124197. /**
  124198. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  124199. */
  124200. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  124201. private static _AnyMouseID;
  124202. /**
  124203. * Abstract mesh the behavior is set on
  124204. */
  124205. attachedNode: AbstractMesh;
  124206. private _dragPlane;
  124207. private _scene;
  124208. private _pointerObserver;
  124209. private _beforeRenderObserver;
  124210. private static _planeScene;
  124211. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  124212. /**
  124213. * 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)
  124214. */
  124215. maxDragAngle: number;
  124216. /**
  124217. * @hidden
  124218. */
  124219. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  124220. /**
  124221. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  124222. */
  124223. currentDraggingPointerID: number;
  124224. /**
  124225. * The last position where the pointer hit the drag plane in world space
  124226. */
  124227. lastDragPosition: Vector3;
  124228. /**
  124229. * If the behavior is currently in a dragging state
  124230. */
  124231. dragging: boolean;
  124232. /**
  124233. * 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)
  124234. */
  124235. dragDeltaRatio: number;
  124236. /**
  124237. * If the drag plane orientation should be updated during the dragging (Default: true)
  124238. */
  124239. updateDragPlane: boolean;
  124240. private _debugMode;
  124241. private _moving;
  124242. /**
  124243. * Fires each time the attached mesh is dragged with the pointer
  124244. * * delta between last drag position and current drag position in world space
  124245. * * dragDistance along the drag axis
  124246. * * dragPlaneNormal normal of the current drag plane used during the drag
  124247. * * dragPlanePoint in world space where the drag intersects the drag plane
  124248. */
  124249. onDragObservable: Observable<{
  124250. delta: Vector3;
  124251. dragPlanePoint: Vector3;
  124252. dragPlaneNormal: Vector3;
  124253. dragDistance: number;
  124254. pointerId: number;
  124255. }>;
  124256. /**
  124257. * Fires each time a drag begins (eg. mouse down on mesh)
  124258. */
  124259. onDragStartObservable: Observable<{
  124260. dragPlanePoint: Vector3;
  124261. pointerId: number;
  124262. }>;
  124263. /**
  124264. * Fires each time a drag ends (eg. mouse release after drag)
  124265. */
  124266. onDragEndObservable: Observable<{
  124267. dragPlanePoint: Vector3;
  124268. pointerId: number;
  124269. }>;
  124270. /**
  124271. * If the attached mesh should be moved when dragged
  124272. */
  124273. moveAttached: boolean;
  124274. /**
  124275. * If the drag behavior will react to drag events (Default: true)
  124276. */
  124277. enabled: boolean;
  124278. /**
  124279. * If pointer events should start and release the drag (Default: true)
  124280. */
  124281. startAndReleaseDragOnPointerEvents: boolean;
  124282. /**
  124283. * If camera controls should be detached during the drag
  124284. */
  124285. detachCameraControls: boolean;
  124286. /**
  124287. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  124288. */
  124289. useObjectOrientationForDragging: boolean;
  124290. private _options;
  124291. /**
  124292. * Gets the options used by the behavior
  124293. */
  124294. get options(): {
  124295. dragAxis?: Vector3;
  124296. dragPlaneNormal?: Vector3;
  124297. };
  124298. /**
  124299. * Sets the options used by the behavior
  124300. */
  124301. set options(options: {
  124302. dragAxis?: Vector3;
  124303. dragPlaneNormal?: Vector3;
  124304. });
  124305. /**
  124306. * Creates a pointer drag behavior that can be attached to a mesh
  124307. * @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)
  124308. */
  124309. constructor(options?: {
  124310. dragAxis?: Vector3;
  124311. dragPlaneNormal?: Vector3;
  124312. });
  124313. /**
  124314. * Predicate to determine if it is valid to move the object to a new position when it is moved
  124315. */
  124316. validateDrag: (targetPosition: Vector3) => boolean;
  124317. /**
  124318. * The name of the behavior
  124319. */
  124320. get name(): string;
  124321. /**
  124322. * Initializes the behavior
  124323. */
  124324. init(): void;
  124325. private _tmpVector;
  124326. private _alternatePickedPoint;
  124327. private _worldDragAxis;
  124328. private _targetPosition;
  124329. private _attachedElement;
  124330. /**
  124331. * Attaches the drag behavior the passed in mesh
  124332. * @param ownerNode The mesh that will be dragged around once attached
  124333. * @param predicate Predicate to use for pick filtering
  124334. */
  124335. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  124336. /**
  124337. * Force relase the drag action by code.
  124338. */
  124339. releaseDrag(): void;
  124340. private _startDragRay;
  124341. private _lastPointerRay;
  124342. /**
  124343. * Simulates the start of a pointer drag event on the behavior
  124344. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  124345. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  124346. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  124347. */
  124348. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  124349. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  124350. private _dragDelta;
  124351. protected _moveDrag(ray: Ray): void;
  124352. private _pickWithRayOnDragPlane;
  124353. private _pointA;
  124354. private _pointC;
  124355. private _localAxis;
  124356. private _lookAt;
  124357. private _updateDragPlanePosition;
  124358. /**
  124359. * Detaches the behavior from the mesh
  124360. */
  124361. detach(): void;
  124362. }
  124363. }
  124364. declare module BABYLON {
  124365. /**
  124366. * A behavior that when attached to a mesh will allow the mesh to be scaled
  124367. */
  124368. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  124369. private _dragBehaviorA;
  124370. private _dragBehaviorB;
  124371. private _startDistance;
  124372. private _initialScale;
  124373. private _targetScale;
  124374. private _ownerNode;
  124375. private _sceneRenderObserver;
  124376. /**
  124377. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  124378. */
  124379. constructor();
  124380. /**
  124381. * The name of the behavior
  124382. */
  124383. get name(): string;
  124384. /**
  124385. * Initializes the behavior
  124386. */
  124387. init(): void;
  124388. private _getCurrentDistance;
  124389. /**
  124390. * Attaches the scale behavior the passed in mesh
  124391. * @param ownerNode The mesh that will be scaled around once attached
  124392. */
  124393. attach(ownerNode: Mesh): void;
  124394. /**
  124395. * Detaches the behavior from the mesh
  124396. */
  124397. detach(): void;
  124398. }
  124399. }
  124400. declare module BABYLON {
  124401. /**
  124402. * 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
  124403. */
  124404. export class SixDofDragBehavior implements Behavior<Mesh> {
  124405. private static _virtualScene;
  124406. private _ownerNode;
  124407. private _sceneRenderObserver;
  124408. private _scene;
  124409. private _targetPosition;
  124410. private _virtualOriginMesh;
  124411. private _virtualDragMesh;
  124412. private _pointerObserver;
  124413. private _moving;
  124414. private _startingOrientation;
  124415. private _attachedElement;
  124416. /**
  124417. * 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)
  124418. */
  124419. private zDragFactor;
  124420. /**
  124421. * If the object should rotate to face the drag origin
  124422. */
  124423. rotateDraggedObject: boolean;
  124424. /**
  124425. * If the behavior is currently in a dragging state
  124426. */
  124427. dragging: boolean;
  124428. /**
  124429. * 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)
  124430. */
  124431. dragDeltaRatio: number;
  124432. /**
  124433. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  124434. */
  124435. currentDraggingPointerID: number;
  124436. /**
  124437. * If camera controls should be detached during the drag
  124438. */
  124439. detachCameraControls: boolean;
  124440. /**
  124441. * Fires each time a drag starts
  124442. */
  124443. onDragStartObservable: Observable<{}>;
  124444. /**
  124445. * Fires each time a drag ends (eg. mouse release after drag)
  124446. */
  124447. onDragEndObservable: Observable<{}>;
  124448. /**
  124449. * 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
  124450. */
  124451. constructor();
  124452. /**
  124453. * The name of the behavior
  124454. */
  124455. get name(): string;
  124456. /**
  124457. * Initializes the behavior
  124458. */
  124459. init(): void;
  124460. /**
  124461. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  124462. */
  124463. private get _pointerCamera();
  124464. /**
  124465. * Attaches the scale behavior the passed in mesh
  124466. * @param ownerNode The mesh that will be scaled around once attached
  124467. */
  124468. attach(ownerNode: Mesh): void;
  124469. /**
  124470. * Detaches the behavior from the mesh
  124471. */
  124472. detach(): void;
  124473. }
  124474. }
  124475. declare module BABYLON {
  124476. /**
  124477. * Class used to apply inverse kinematics to bones
  124478. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  124479. */
  124480. export class BoneIKController {
  124481. private static _tmpVecs;
  124482. private static _tmpQuat;
  124483. private static _tmpMats;
  124484. /**
  124485. * Gets or sets the target mesh
  124486. */
  124487. targetMesh: AbstractMesh;
  124488. /** Gets or sets the mesh used as pole */
  124489. poleTargetMesh: AbstractMesh;
  124490. /**
  124491. * Gets or sets the bone used as pole
  124492. */
  124493. poleTargetBone: Nullable<Bone>;
  124494. /**
  124495. * Gets or sets the target position
  124496. */
  124497. targetPosition: Vector3;
  124498. /**
  124499. * Gets or sets the pole target position
  124500. */
  124501. poleTargetPosition: Vector3;
  124502. /**
  124503. * Gets or sets the pole target local offset
  124504. */
  124505. poleTargetLocalOffset: Vector3;
  124506. /**
  124507. * Gets or sets the pole angle
  124508. */
  124509. poleAngle: number;
  124510. /**
  124511. * Gets or sets the mesh associated with the controller
  124512. */
  124513. mesh: AbstractMesh;
  124514. /**
  124515. * 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)
  124516. */
  124517. slerpAmount: number;
  124518. private _bone1Quat;
  124519. private _bone1Mat;
  124520. private _bone2Ang;
  124521. private _bone1;
  124522. private _bone2;
  124523. private _bone1Length;
  124524. private _bone2Length;
  124525. private _maxAngle;
  124526. private _maxReach;
  124527. private _rightHandedSystem;
  124528. private _bendAxis;
  124529. private _slerping;
  124530. private _adjustRoll;
  124531. /**
  124532. * Gets or sets maximum allowed angle
  124533. */
  124534. get maxAngle(): number;
  124535. set maxAngle(value: number);
  124536. /**
  124537. * Creates a new BoneIKController
  124538. * @param mesh defines the mesh to control
  124539. * @param bone defines the bone to control
  124540. * @param options defines options to set up the controller
  124541. */
  124542. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  124543. targetMesh?: AbstractMesh;
  124544. poleTargetMesh?: AbstractMesh;
  124545. poleTargetBone?: Bone;
  124546. poleTargetLocalOffset?: Vector3;
  124547. poleAngle?: number;
  124548. bendAxis?: Vector3;
  124549. maxAngle?: number;
  124550. slerpAmount?: number;
  124551. });
  124552. private _setMaxAngle;
  124553. /**
  124554. * Force the controller to update the bones
  124555. */
  124556. update(): void;
  124557. }
  124558. }
  124559. declare module BABYLON {
  124560. /**
  124561. * Class used to make a bone look toward a point in space
  124562. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  124563. */
  124564. export class BoneLookController {
  124565. private static _tmpVecs;
  124566. private static _tmpQuat;
  124567. private static _tmpMats;
  124568. /**
  124569. * The target Vector3 that the bone will look at
  124570. */
  124571. target: Vector3;
  124572. /**
  124573. * The mesh that the bone is attached to
  124574. */
  124575. mesh: AbstractMesh;
  124576. /**
  124577. * The bone that will be looking to the target
  124578. */
  124579. bone: Bone;
  124580. /**
  124581. * The up axis of the coordinate system that is used when the bone is rotated
  124582. */
  124583. upAxis: Vector3;
  124584. /**
  124585. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  124586. */
  124587. upAxisSpace: Space;
  124588. /**
  124589. * Used to make an adjustment to the yaw of the bone
  124590. */
  124591. adjustYaw: number;
  124592. /**
  124593. * Used to make an adjustment to the pitch of the bone
  124594. */
  124595. adjustPitch: number;
  124596. /**
  124597. * Used to make an adjustment to the roll of the bone
  124598. */
  124599. adjustRoll: number;
  124600. /**
  124601. * 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)
  124602. */
  124603. slerpAmount: number;
  124604. private _minYaw;
  124605. private _maxYaw;
  124606. private _minPitch;
  124607. private _maxPitch;
  124608. private _minYawSin;
  124609. private _minYawCos;
  124610. private _maxYawSin;
  124611. private _maxYawCos;
  124612. private _midYawConstraint;
  124613. private _minPitchTan;
  124614. private _maxPitchTan;
  124615. private _boneQuat;
  124616. private _slerping;
  124617. private _transformYawPitch;
  124618. private _transformYawPitchInv;
  124619. private _firstFrameSkipped;
  124620. private _yawRange;
  124621. private _fowardAxis;
  124622. /**
  124623. * Gets or sets the minimum yaw angle that the bone can look to
  124624. */
  124625. get minYaw(): number;
  124626. set minYaw(value: number);
  124627. /**
  124628. * Gets or sets the maximum yaw angle that the bone can look to
  124629. */
  124630. get maxYaw(): number;
  124631. set maxYaw(value: number);
  124632. /**
  124633. * Gets or sets the minimum pitch angle that the bone can look to
  124634. */
  124635. get minPitch(): number;
  124636. set minPitch(value: number);
  124637. /**
  124638. * Gets or sets the maximum pitch angle that the bone can look to
  124639. */
  124640. get maxPitch(): number;
  124641. set maxPitch(value: number);
  124642. /**
  124643. * Create a BoneLookController
  124644. * @param mesh the mesh that the bone belongs to
  124645. * @param bone the bone that will be looking to the target
  124646. * @param target the target Vector3 to look at
  124647. * @param options optional settings:
  124648. * * maxYaw: the maximum angle the bone will yaw to
  124649. * * minYaw: the minimum angle the bone will yaw to
  124650. * * maxPitch: the maximum angle the bone will pitch to
  124651. * * minPitch: the minimum angle the bone will yaw to
  124652. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  124653. * * upAxis: the up axis of the coordinate system
  124654. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  124655. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  124656. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  124657. * * adjustYaw: used to make an adjustment to the yaw of the bone
  124658. * * adjustPitch: used to make an adjustment to the pitch of the bone
  124659. * * adjustRoll: used to make an adjustment to the roll of the bone
  124660. **/
  124661. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  124662. maxYaw?: number;
  124663. minYaw?: number;
  124664. maxPitch?: number;
  124665. minPitch?: number;
  124666. slerpAmount?: number;
  124667. upAxis?: Vector3;
  124668. upAxisSpace?: Space;
  124669. yawAxis?: Vector3;
  124670. pitchAxis?: Vector3;
  124671. adjustYaw?: number;
  124672. adjustPitch?: number;
  124673. adjustRoll?: number;
  124674. });
  124675. /**
  124676. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  124677. */
  124678. update(): void;
  124679. private _getAngleDiff;
  124680. private _getAngleBetween;
  124681. private _isAngleBetween;
  124682. }
  124683. }
  124684. declare module BABYLON {
  124685. /**
  124686. * Manage the gamepad inputs to control an arc rotate camera.
  124687. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124688. */
  124689. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  124690. /**
  124691. * Defines the camera the input is attached to.
  124692. */
  124693. camera: ArcRotateCamera;
  124694. /**
  124695. * Defines the gamepad the input is gathering event from.
  124696. */
  124697. gamepad: Nullable<Gamepad>;
  124698. /**
  124699. * Defines the gamepad rotation sensiblity.
  124700. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124701. */
  124702. gamepadRotationSensibility: number;
  124703. /**
  124704. * Defines the gamepad move sensiblity.
  124705. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124706. */
  124707. gamepadMoveSensibility: number;
  124708. private _yAxisScale;
  124709. /**
  124710. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124711. */
  124712. get invertYAxis(): boolean;
  124713. set invertYAxis(value: boolean);
  124714. private _onGamepadConnectedObserver;
  124715. private _onGamepadDisconnectedObserver;
  124716. /**
  124717. * Attach the input controls to a specific dom element to get the input from.
  124718. * @param element Defines the element the controls should be listened from
  124719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124720. */
  124721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124722. /**
  124723. * Detach the current controls from the specified dom element.
  124724. * @param element Defines the element to stop listening the inputs from
  124725. */
  124726. detachControl(element: Nullable<HTMLElement>): void;
  124727. /**
  124728. * Update the current camera state depending on the inputs that have been used this frame.
  124729. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124730. */
  124731. checkInputs(): void;
  124732. /**
  124733. * Gets the class name of the current intput.
  124734. * @returns the class name
  124735. */
  124736. getClassName(): string;
  124737. /**
  124738. * Get the friendly name associated with the input class.
  124739. * @returns the input friendly name
  124740. */
  124741. getSimpleName(): string;
  124742. }
  124743. }
  124744. declare module BABYLON {
  124745. interface ArcRotateCameraInputsManager {
  124746. /**
  124747. * Add orientation input support to the input manager.
  124748. * @returns the current input manager
  124749. */
  124750. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  124751. }
  124752. /**
  124753. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  124754. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124755. */
  124756. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  124757. /**
  124758. * Defines the camera the input is attached to.
  124759. */
  124760. camera: ArcRotateCamera;
  124761. /**
  124762. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  124763. */
  124764. alphaCorrection: number;
  124765. /**
  124766. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  124767. */
  124768. gammaCorrection: number;
  124769. private _alpha;
  124770. private _gamma;
  124771. private _dirty;
  124772. private _deviceOrientationHandler;
  124773. /**
  124774. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  124775. */
  124776. constructor();
  124777. /**
  124778. * Attach the input controls to a specific dom element to get the input from.
  124779. * @param element Defines the element the controls should be listened from
  124780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124781. */
  124782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124783. /** @hidden */
  124784. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  124785. /**
  124786. * Update the current camera state depending on the inputs that have been used this frame.
  124787. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124788. */
  124789. checkInputs(): void;
  124790. /**
  124791. * Detach the current controls from the specified dom element.
  124792. * @param element Defines the element to stop listening the inputs from
  124793. */
  124794. detachControl(element: Nullable<HTMLElement>): void;
  124795. /**
  124796. * Gets the class name of the current intput.
  124797. * @returns the class name
  124798. */
  124799. getClassName(): string;
  124800. /**
  124801. * Get the friendly name associated with the input class.
  124802. * @returns the input friendly name
  124803. */
  124804. getSimpleName(): string;
  124805. }
  124806. }
  124807. declare module BABYLON {
  124808. /**
  124809. * Listen to mouse events to control the camera.
  124810. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124811. */
  124812. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  124813. /**
  124814. * Defines the camera the input is attached to.
  124815. */
  124816. camera: FlyCamera;
  124817. /**
  124818. * Defines if touch is enabled. (Default is true.)
  124819. */
  124820. touchEnabled: boolean;
  124821. /**
  124822. * Defines the buttons associated with the input to handle camera rotation.
  124823. */
  124824. buttons: number[];
  124825. /**
  124826. * Assign buttons for Yaw control.
  124827. */
  124828. buttonsYaw: number[];
  124829. /**
  124830. * Assign buttons for Pitch control.
  124831. */
  124832. buttonsPitch: number[];
  124833. /**
  124834. * Assign buttons for Roll control.
  124835. */
  124836. buttonsRoll: number[];
  124837. /**
  124838. * Detect if any button is being pressed while mouse is moved.
  124839. * -1 = Mouse locked.
  124840. * 0 = Left button.
  124841. * 1 = Middle Button.
  124842. * 2 = Right Button.
  124843. */
  124844. activeButton: number;
  124845. /**
  124846. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  124847. * Higher values reduce its sensitivity.
  124848. */
  124849. angularSensibility: number;
  124850. private _observer;
  124851. private _rollObserver;
  124852. private previousPosition;
  124853. private noPreventDefault;
  124854. private element;
  124855. /**
  124856. * Listen to mouse events to control the camera.
  124857. * @param touchEnabled Define if touch is enabled. (Default is true.)
  124858. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124859. */
  124860. constructor(touchEnabled?: boolean);
  124861. /**
  124862. * Attach the mouse control to the HTML DOM element.
  124863. * @param element Defines the element that listens to the input events.
  124864. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  124865. */
  124866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124867. /**
  124868. * Detach the current controls from the specified dom element.
  124869. * @param element Defines the element to stop listening the inputs from
  124870. */
  124871. detachControl(element: Nullable<HTMLElement>): void;
  124872. /**
  124873. * Gets the class name of the current input.
  124874. * @returns the class name.
  124875. */
  124876. getClassName(): string;
  124877. /**
  124878. * Get the friendly name associated with the input class.
  124879. * @returns the input's friendly name.
  124880. */
  124881. getSimpleName(): string;
  124882. private _pointerInput;
  124883. private _onMouseMove;
  124884. /**
  124885. * Rotate camera by mouse offset.
  124886. */
  124887. private rotateCamera;
  124888. }
  124889. }
  124890. declare module BABYLON {
  124891. /**
  124892. * Default Inputs manager for the FlyCamera.
  124893. * It groups all the default supported inputs for ease of use.
  124894. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124895. */
  124896. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  124897. /**
  124898. * Instantiates a new FlyCameraInputsManager.
  124899. * @param camera Defines the camera the inputs belong to.
  124900. */
  124901. constructor(camera: FlyCamera);
  124902. /**
  124903. * Add keyboard input support to the input manager.
  124904. * @returns the new FlyCameraKeyboardMoveInput().
  124905. */
  124906. addKeyboard(): FlyCameraInputsManager;
  124907. /**
  124908. * Add mouse input support to the input manager.
  124909. * @param touchEnabled Enable touch screen support.
  124910. * @returns the new FlyCameraMouseInput().
  124911. */
  124912. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  124913. }
  124914. }
  124915. declare module BABYLON {
  124916. /**
  124917. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124918. * such as in a 3D Space Shooter or a Flight Simulator.
  124919. */
  124920. export class FlyCamera extends TargetCamera {
  124921. /**
  124922. * Define the collision ellipsoid of the camera.
  124923. * This is helpful for simulating a camera body, like a player's body.
  124924. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  124925. */
  124926. ellipsoid: Vector3;
  124927. /**
  124928. * Define an offset for the position of the ellipsoid around the camera.
  124929. * This can be helpful if the camera is attached away from the player's body center,
  124930. * such as at its head.
  124931. */
  124932. ellipsoidOffset: Vector3;
  124933. /**
  124934. * Enable or disable collisions of the camera with the rest of the scene objects.
  124935. */
  124936. checkCollisions: boolean;
  124937. /**
  124938. * Enable or disable gravity on the camera.
  124939. */
  124940. applyGravity: boolean;
  124941. /**
  124942. * Define the current direction the camera is moving to.
  124943. */
  124944. cameraDirection: Vector3;
  124945. /**
  124946. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  124947. * This overrides and empties cameraRotation.
  124948. */
  124949. rotationQuaternion: Quaternion;
  124950. /**
  124951. * Track Roll to maintain the wanted Rolling when looking around.
  124952. */
  124953. _trackRoll: number;
  124954. /**
  124955. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  124956. */
  124957. rollCorrect: number;
  124958. /**
  124959. * Mimic a banked turn, Rolling the camera when Yawing.
  124960. * It's recommended to use rollCorrect = 10 for faster banking correction.
  124961. */
  124962. bankedTurn: boolean;
  124963. /**
  124964. * Limit in radians for how much Roll banking will add. (Default: 90°)
  124965. */
  124966. bankedTurnLimit: number;
  124967. /**
  124968. * Value of 0 disables the banked Roll.
  124969. * Value of 1 is equal to the Yaw angle in radians.
  124970. */
  124971. bankedTurnMultiplier: number;
  124972. /**
  124973. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124974. */
  124975. inputs: FlyCameraInputsManager;
  124976. /**
  124977. * Gets the input sensibility for mouse input.
  124978. * Higher values reduce sensitivity.
  124979. */
  124980. get angularSensibility(): number;
  124981. /**
  124982. * Sets the input sensibility for a mouse input.
  124983. * Higher values reduce sensitivity.
  124984. */
  124985. set angularSensibility(value: number);
  124986. /**
  124987. * Get the keys for camera movement forward.
  124988. */
  124989. get keysForward(): number[];
  124990. /**
  124991. * Set the keys for camera movement forward.
  124992. */
  124993. set keysForward(value: number[]);
  124994. /**
  124995. * Get the keys for camera movement backward.
  124996. */
  124997. get keysBackward(): number[];
  124998. set keysBackward(value: number[]);
  124999. /**
  125000. * Get the keys for camera movement up.
  125001. */
  125002. get keysUp(): number[];
  125003. /**
  125004. * Set the keys for camera movement up.
  125005. */
  125006. set keysUp(value: number[]);
  125007. /**
  125008. * Get the keys for camera movement down.
  125009. */
  125010. get keysDown(): number[];
  125011. /**
  125012. * Set the keys for camera movement down.
  125013. */
  125014. set keysDown(value: number[]);
  125015. /**
  125016. * Get the keys for camera movement left.
  125017. */
  125018. get keysLeft(): number[];
  125019. /**
  125020. * Set the keys for camera movement left.
  125021. */
  125022. set keysLeft(value: number[]);
  125023. /**
  125024. * Set the keys for camera movement right.
  125025. */
  125026. get keysRight(): number[];
  125027. /**
  125028. * Set the keys for camera movement right.
  125029. */
  125030. set keysRight(value: number[]);
  125031. /**
  125032. * Event raised when the camera collides with a mesh in the scene.
  125033. */
  125034. onCollide: (collidedMesh: AbstractMesh) => void;
  125035. private _collider;
  125036. private _needMoveForGravity;
  125037. private _oldPosition;
  125038. private _diffPosition;
  125039. private _newPosition;
  125040. /** @hidden */
  125041. _localDirection: Vector3;
  125042. /** @hidden */
  125043. _transformedDirection: Vector3;
  125044. /**
  125045. * Instantiates a FlyCamera.
  125046. * This is a flying camera, designed for 3D movement and rotation in all directions,
  125047. * such as in a 3D Space Shooter or a Flight Simulator.
  125048. * @param name Define the name of the camera in the scene.
  125049. * @param position Define the starting position of the camera in the scene.
  125050. * @param scene Define the scene the camera belongs to.
  125051. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  125052. */
  125053. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  125054. /**
  125055. * Attach a control to the HTML DOM element.
  125056. * @param element Defines the element that listens to the input events.
  125057. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  125058. */
  125059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125060. /**
  125061. * Detach a control from the HTML DOM element.
  125062. * The camera will stop reacting to that input.
  125063. * @param element Defines the element that listens to the input events.
  125064. */
  125065. detachControl(element: HTMLElement): void;
  125066. private _collisionMask;
  125067. /**
  125068. * Get the mask that the camera ignores in collision events.
  125069. */
  125070. get collisionMask(): number;
  125071. /**
  125072. * Set the mask that the camera ignores in collision events.
  125073. */
  125074. set collisionMask(mask: number);
  125075. /** @hidden */
  125076. _collideWithWorld(displacement: Vector3): void;
  125077. /** @hidden */
  125078. private _onCollisionPositionChange;
  125079. /** @hidden */
  125080. _checkInputs(): void;
  125081. /** @hidden */
  125082. _decideIfNeedsToMove(): boolean;
  125083. /** @hidden */
  125084. _updatePosition(): void;
  125085. /**
  125086. * Restore the Roll to its target value at the rate specified.
  125087. * @param rate - Higher means slower restoring.
  125088. * @hidden
  125089. */
  125090. restoreRoll(rate: number): void;
  125091. /**
  125092. * Destroy the camera and release the current resources held by it.
  125093. */
  125094. dispose(): void;
  125095. /**
  125096. * Get the current object class name.
  125097. * @returns the class name.
  125098. */
  125099. getClassName(): string;
  125100. }
  125101. }
  125102. declare module BABYLON {
  125103. /**
  125104. * Listen to keyboard events to control the camera.
  125105. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125106. */
  125107. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  125108. /**
  125109. * Defines the camera the input is attached to.
  125110. */
  125111. camera: FlyCamera;
  125112. /**
  125113. * The list of keyboard keys used to control the forward move of the camera.
  125114. */
  125115. keysForward: number[];
  125116. /**
  125117. * The list of keyboard keys used to control the backward move of the camera.
  125118. */
  125119. keysBackward: number[];
  125120. /**
  125121. * The list of keyboard keys used to control the forward move of the camera.
  125122. */
  125123. keysUp: number[];
  125124. /**
  125125. * The list of keyboard keys used to control the backward move of the camera.
  125126. */
  125127. keysDown: number[];
  125128. /**
  125129. * The list of keyboard keys used to control the right strafe move of the camera.
  125130. */
  125131. keysRight: number[];
  125132. /**
  125133. * The list of keyboard keys used to control the left strafe move of the camera.
  125134. */
  125135. keysLeft: number[];
  125136. private _keys;
  125137. private _onCanvasBlurObserver;
  125138. private _onKeyboardObserver;
  125139. private _engine;
  125140. private _scene;
  125141. /**
  125142. * Attach the input controls to a specific dom element to get the input from.
  125143. * @param element Defines the element the controls should be listened from
  125144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125145. */
  125146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125147. /**
  125148. * Detach the current controls from the specified dom element.
  125149. * @param element Defines the element to stop listening the inputs from
  125150. */
  125151. detachControl(element: Nullable<HTMLElement>): void;
  125152. /**
  125153. * Gets the class name of the current intput.
  125154. * @returns the class name
  125155. */
  125156. getClassName(): string;
  125157. /** @hidden */
  125158. _onLostFocus(e: FocusEvent): void;
  125159. /**
  125160. * Get the friendly name associated with the input class.
  125161. * @returns the input friendly name
  125162. */
  125163. getSimpleName(): string;
  125164. /**
  125165. * Update the current camera state depending on the inputs that have been used this frame.
  125166. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125167. */
  125168. checkInputs(): void;
  125169. }
  125170. }
  125171. declare module BABYLON {
  125172. /**
  125173. * Manage the mouse wheel inputs to control a follow camera.
  125174. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125175. */
  125176. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  125177. /**
  125178. * Defines the camera the input is attached to.
  125179. */
  125180. camera: FollowCamera;
  125181. /**
  125182. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  125183. */
  125184. axisControlRadius: boolean;
  125185. /**
  125186. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  125187. */
  125188. axisControlHeight: boolean;
  125189. /**
  125190. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  125191. */
  125192. axisControlRotation: boolean;
  125193. /**
  125194. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  125195. * relation to mouseWheel events.
  125196. */
  125197. wheelPrecision: number;
  125198. /**
  125199. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  125200. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  125201. */
  125202. wheelDeltaPercentage: number;
  125203. private _wheel;
  125204. private _observer;
  125205. /**
  125206. * Attach the input controls to a specific dom element to get the input from.
  125207. * @param element Defines the element the controls should be listened from
  125208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125209. */
  125210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125211. /**
  125212. * Detach the current controls from the specified dom element.
  125213. * @param element Defines the element to stop listening the inputs from
  125214. */
  125215. detachControl(element: Nullable<HTMLElement>): void;
  125216. /**
  125217. * Gets the class name of the current intput.
  125218. * @returns the class name
  125219. */
  125220. getClassName(): string;
  125221. /**
  125222. * Get the friendly name associated with the input class.
  125223. * @returns the input friendly name
  125224. */
  125225. getSimpleName(): string;
  125226. }
  125227. }
  125228. declare module BABYLON {
  125229. /**
  125230. * Manage the pointers inputs to control an follow camera.
  125231. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125232. */
  125233. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  125234. /**
  125235. * Defines the camera the input is attached to.
  125236. */
  125237. camera: FollowCamera;
  125238. /**
  125239. * Gets the class name of the current input.
  125240. * @returns the class name
  125241. */
  125242. getClassName(): string;
  125243. /**
  125244. * Defines the pointer angular sensibility along the X axis or how fast is
  125245. * the camera rotating.
  125246. * A negative number will reverse the axis direction.
  125247. */
  125248. angularSensibilityX: number;
  125249. /**
  125250. * Defines the pointer angular sensibility along the Y axis or how fast is
  125251. * the camera rotating.
  125252. * A negative number will reverse the axis direction.
  125253. */
  125254. angularSensibilityY: number;
  125255. /**
  125256. * Defines the pointer pinch precision or how fast is the camera zooming.
  125257. * A negative number will reverse the axis direction.
  125258. */
  125259. pinchPrecision: number;
  125260. /**
  125261. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  125262. * from 0.
  125263. * It defines the percentage of current camera.radius to use as delta when
  125264. * pinch zoom is used.
  125265. */
  125266. pinchDeltaPercentage: number;
  125267. /**
  125268. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  125269. */
  125270. axisXControlRadius: boolean;
  125271. /**
  125272. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  125273. */
  125274. axisXControlHeight: boolean;
  125275. /**
  125276. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  125277. */
  125278. axisXControlRotation: boolean;
  125279. /**
  125280. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  125281. */
  125282. axisYControlRadius: boolean;
  125283. /**
  125284. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  125285. */
  125286. axisYControlHeight: boolean;
  125287. /**
  125288. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  125289. */
  125290. axisYControlRotation: boolean;
  125291. /**
  125292. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  125293. */
  125294. axisPinchControlRadius: boolean;
  125295. /**
  125296. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  125297. */
  125298. axisPinchControlHeight: boolean;
  125299. /**
  125300. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  125301. */
  125302. axisPinchControlRotation: boolean;
  125303. /**
  125304. * Log error messages if basic misconfiguration has occurred.
  125305. */
  125306. warningEnable: boolean;
  125307. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  125308. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  125309. private _warningCounter;
  125310. private _warning;
  125311. }
  125312. }
  125313. declare module BABYLON {
  125314. /**
  125315. * Default Inputs manager for the FollowCamera.
  125316. * It groups all the default supported inputs for ease of use.
  125317. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125318. */
  125319. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  125320. /**
  125321. * Instantiates a new FollowCameraInputsManager.
  125322. * @param camera Defines the camera the inputs belong to
  125323. */
  125324. constructor(camera: FollowCamera);
  125325. /**
  125326. * Add keyboard input support to the input manager.
  125327. * @returns the current input manager
  125328. */
  125329. addKeyboard(): FollowCameraInputsManager;
  125330. /**
  125331. * Add mouse wheel input support to the input manager.
  125332. * @returns the current input manager
  125333. */
  125334. addMouseWheel(): FollowCameraInputsManager;
  125335. /**
  125336. * Add pointers input support to the input manager.
  125337. * @returns the current input manager
  125338. */
  125339. addPointers(): FollowCameraInputsManager;
  125340. /**
  125341. * Add orientation input support to the input manager.
  125342. * @returns the current input manager
  125343. */
  125344. addVRDeviceOrientation(): FollowCameraInputsManager;
  125345. }
  125346. }
  125347. declare module BABYLON {
  125348. /**
  125349. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  125350. * an arc rotate version arcFollowCamera are available.
  125351. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125352. */
  125353. export class FollowCamera extends TargetCamera {
  125354. /**
  125355. * Distance the follow camera should follow an object at
  125356. */
  125357. radius: number;
  125358. /**
  125359. * Minimum allowed distance of the camera to the axis of rotation
  125360. * (The camera can not get closer).
  125361. * This can help limiting how the Camera is able to move in the scene.
  125362. */
  125363. lowerRadiusLimit: Nullable<number>;
  125364. /**
  125365. * Maximum allowed distance of the camera to the axis of rotation
  125366. * (The camera can not get further).
  125367. * This can help limiting how the Camera is able to move in the scene.
  125368. */
  125369. upperRadiusLimit: Nullable<number>;
  125370. /**
  125371. * Define a rotation offset between the camera and the object it follows
  125372. */
  125373. rotationOffset: number;
  125374. /**
  125375. * Minimum allowed angle to camera position relative to target object.
  125376. * This can help limiting how the Camera is able to move in the scene.
  125377. */
  125378. lowerRotationOffsetLimit: Nullable<number>;
  125379. /**
  125380. * Maximum allowed angle to camera position relative to target object.
  125381. * This can help limiting how the Camera is able to move in the scene.
  125382. */
  125383. upperRotationOffsetLimit: Nullable<number>;
  125384. /**
  125385. * Define a height offset between the camera and the object it follows.
  125386. * It can help following an object from the top (like a car chaing a plane)
  125387. */
  125388. heightOffset: number;
  125389. /**
  125390. * Minimum allowed height of camera position relative to target object.
  125391. * This can help limiting how the Camera is able to move in the scene.
  125392. */
  125393. lowerHeightOffsetLimit: Nullable<number>;
  125394. /**
  125395. * Maximum allowed height of camera position relative to target object.
  125396. * This can help limiting how the Camera is able to move in the scene.
  125397. */
  125398. upperHeightOffsetLimit: Nullable<number>;
  125399. /**
  125400. * Define how fast the camera can accelerate to follow it s target.
  125401. */
  125402. cameraAcceleration: number;
  125403. /**
  125404. * Define the speed limit of the camera following an object.
  125405. */
  125406. maxCameraSpeed: number;
  125407. /**
  125408. * Define the target of the camera.
  125409. */
  125410. lockedTarget: Nullable<AbstractMesh>;
  125411. /**
  125412. * Defines the input associated with the camera.
  125413. */
  125414. inputs: FollowCameraInputsManager;
  125415. /**
  125416. * Instantiates the follow camera.
  125417. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125418. * @param name Define the name of the camera in the scene
  125419. * @param position Define the position of the camera
  125420. * @param scene Define the scene the camera belong to
  125421. * @param lockedTarget Define the target of the camera
  125422. */
  125423. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  125424. private _follow;
  125425. /**
  125426. * Attached controls to the current camera.
  125427. * @param element Defines the element the controls should be listened from
  125428. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125429. */
  125430. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125431. /**
  125432. * Detach the current controls from the camera.
  125433. * The camera will stop reacting to inputs.
  125434. * @param element Defines the element to stop listening the inputs from
  125435. */
  125436. detachControl(element: HTMLElement): void;
  125437. /** @hidden */
  125438. _checkInputs(): void;
  125439. private _checkLimits;
  125440. /**
  125441. * Gets the camera class name.
  125442. * @returns the class name
  125443. */
  125444. getClassName(): string;
  125445. }
  125446. /**
  125447. * Arc Rotate version of the follow camera.
  125448. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  125449. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125450. */
  125451. export class ArcFollowCamera extends TargetCamera {
  125452. /** The longitudinal angle of the camera */
  125453. alpha: number;
  125454. /** The latitudinal angle of the camera */
  125455. beta: number;
  125456. /** The radius of the camera from its target */
  125457. radius: number;
  125458. private _cartesianCoordinates;
  125459. /** Define the camera target (the mesh it should follow) */
  125460. private _meshTarget;
  125461. /**
  125462. * Instantiates a new ArcFollowCamera
  125463. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125464. * @param name Define the name of the camera
  125465. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  125466. * @param beta Define the rotation angle of the camera around the elevation axis
  125467. * @param radius Define the radius of the camera from its target point
  125468. * @param target Define the target of the camera
  125469. * @param scene Define the scene the camera belongs to
  125470. */
  125471. constructor(name: string,
  125472. /** The longitudinal angle of the camera */
  125473. alpha: number,
  125474. /** The latitudinal angle of the camera */
  125475. beta: number,
  125476. /** The radius of the camera from its target */
  125477. radius: number,
  125478. /** Define the camera target (the mesh it should follow) */
  125479. target: Nullable<AbstractMesh>, scene: Scene);
  125480. private _follow;
  125481. /** @hidden */
  125482. _checkInputs(): void;
  125483. /**
  125484. * Returns the class name of the object.
  125485. * It is mostly used internally for serialization purposes.
  125486. */
  125487. getClassName(): string;
  125488. }
  125489. }
  125490. declare module BABYLON {
  125491. /**
  125492. * Manage the keyboard inputs to control the movement of a follow camera.
  125493. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125494. */
  125495. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  125496. /**
  125497. * Defines the camera the input is attached to.
  125498. */
  125499. camera: FollowCamera;
  125500. /**
  125501. * Defines the list of key codes associated with the up action (increase heightOffset)
  125502. */
  125503. keysHeightOffsetIncr: number[];
  125504. /**
  125505. * Defines the list of key codes associated with the down action (decrease heightOffset)
  125506. */
  125507. keysHeightOffsetDecr: number[];
  125508. /**
  125509. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  125510. */
  125511. keysHeightOffsetModifierAlt: boolean;
  125512. /**
  125513. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  125514. */
  125515. keysHeightOffsetModifierCtrl: boolean;
  125516. /**
  125517. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  125518. */
  125519. keysHeightOffsetModifierShift: boolean;
  125520. /**
  125521. * Defines the list of key codes associated with the left action (increase rotationOffset)
  125522. */
  125523. keysRotationOffsetIncr: number[];
  125524. /**
  125525. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  125526. */
  125527. keysRotationOffsetDecr: number[];
  125528. /**
  125529. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  125530. */
  125531. keysRotationOffsetModifierAlt: boolean;
  125532. /**
  125533. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  125534. */
  125535. keysRotationOffsetModifierCtrl: boolean;
  125536. /**
  125537. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  125538. */
  125539. keysRotationOffsetModifierShift: boolean;
  125540. /**
  125541. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  125542. */
  125543. keysRadiusIncr: number[];
  125544. /**
  125545. * Defines the list of key codes associated with the zoom-out action (increase radius)
  125546. */
  125547. keysRadiusDecr: number[];
  125548. /**
  125549. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  125550. */
  125551. keysRadiusModifierAlt: boolean;
  125552. /**
  125553. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  125554. */
  125555. keysRadiusModifierCtrl: boolean;
  125556. /**
  125557. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  125558. */
  125559. keysRadiusModifierShift: boolean;
  125560. /**
  125561. * Defines the rate of change of heightOffset.
  125562. */
  125563. heightSensibility: number;
  125564. /**
  125565. * Defines the rate of change of rotationOffset.
  125566. */
  125567. rotationSensibility: number;
  125568. /**
  125569. * Defines the rate of change of radius.
  125570. */
  125571. radiusSensibility: number;
  125572. private _keys;
  125573. private _ctrlPressed;
  125574. private _altPressed;
  125575. private _shiftPressed;
  125576. private _onCanvasBlurObserver;
  125577. private _onKeyboardObserver;
  125578. private _engine;
  125579. private _scene;
  125580. /**
  125581. * Attach the input controls to a specific dom element to get the input from.
  125582. * @param element Defines the element the controls should be listened from
  125583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125584. */
  125585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125586. /**
  125587. * Detach the current controls from the specified dom element.
  125588. * @param element Defines the element to stop listening the inputs from
  125589. */
  125590. detachControl(element: Nullable<HTMLElement>): void;
  125591. /**
  125592. * Update the current camera state depending on the inputs that have been used this frame.
  125593. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125594. */
  125595. checkInputs(): void;
  125596. /**
  125597. * Gets the class name of the current input.
  125598. * @returns the class name
  125599. */
  125600. getClassName(): string;
  125601. /**
  125602. * Get the friendly name associated with the input class.
  125603. * @returns the input friendly name
  125604. */
  125605. getSimpleName(): string;
  125606. /**
  125607. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125608. * allow modification of the heightOffset value.
  125609. */
  125610. private _modifierHeightOffset;
  125611. /**
  125612. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125613. * allow modification of the rotationOffset value.
  125614. */
  125615. private _modifierRotationOffset;
  125616. /**
  125617. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125618. * allow modification of the radius value.
  125619. */
  125620. private _modifierRadius;
  125621. }
  125622. }
  125623. declare module BABYLON {
  125624. interface FreeCameraInputsManager {
  125625. /**
  125626. * @hidden
  125627. */
  125628. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  125629. /**
  125630. * Add orientation input support to the input manager.
  125631. * @returns the current input manager
  125632. */
  125633. addDeviceOrientation(): FreeCameraInputsManager;
  125634. }
  125635. /**
  125636. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  125637. * Screen rotation is taken into account.
  125638. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125639. */
  125640. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  125641. private _camera;
  125642. private _screenOrientationAngle;
  125643. private _constantTranform;
  125644. private _screenQuaternion;
  125645. private _alpha;
  125646. private _beta;
  125647. private _gamma;
  125648. /**
  125649. * Can be used to detect if a device orientation sensor is available on a device
  125650. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  125651. * @returns a promise that will resolve on orientation change
  125652. */
  125653. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  125654. /**
  125655. * @hidden
  125656. */
  125657. _onDeviceOrientationChangedObservable: Observable<void>;
  125658. /**
  125659. * Instantiates a new input
  125660. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125661. */
  125662. constructor();
  125663. /**
  125664. * Define the camera controlled by the input.
  125665. */
  125666. get camera(): FreeCamera;
  125667. set camera(camera: FreeCamera);
  125668. /**
  125669. * Attach the input controls to a specific dom element to get the input from.
  125670. * @param element Defines the element the controls should be listened from
  125671. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125672. */
  125673. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125674. private _orientationChanged;
  125675. private _deviceOrientation;
  125676. /**
  125677. * Detach the current controls from the specified dom element.
  125678. * @param element Defines the element to stop listening the inputs from
  125679. */
  125680. detachControl(element: Nullable<HTMLElement>): void;
  125681. /**
  125682. * Update the current camera state depending on the inputs that have been used this frame.
  125683. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125684. */
  125685. checkInputs(): void;
  125686. /**
  125687. * Gets the class name of the current intput.
  125688. * @returns the class name
  125689. */
  125690. getClassName(): string;
  125691. /**
  125692. * Get the friendly name associated with the input class.
  125693. * @returns the input friendly name
  125694. */
  125695. getSimpleName(): string;
  125696. }
  125697. }
  125698. declare module BABYLON {
  125699. /**
  125700. * Manage the gamepad inputs to control a free camera.
  125701. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125702. */
  125703. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  125704. /**
  125705. * Define the camera the input is attached to.
  125706. */
  125707. camera: FreeCamera;
  125708. /**
  125709. * Define the Gamepad controlling the input
  125710. */
  125711. gamepad: Nullable<Gamepad>;
  125712. /**
  125713. * Defines the gamepad rotation sensiblity.
  125714. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125715. */
  125716. gamepadAngularSensibility: number;
  125717. /**
  125718. * Defines the gamepad move sensiblity.
  125719. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125720. */
  125721. gamepadMoveSensibility: number;
  125722. private _yAxisScale;
  125723. /**
  125724. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  125725. */
  125726. get invertYAxis(): boolean;
  125727. set invertYAxis(value: boolean);
  125728. private _onGamepadConnectedObserver;
  125729. private _onGamepadDisconnectedObserver;
  125730. private _cameraTransform;
  125731. private _deltaTransform;
  125732. private _vector3;
  125733. private _vector2;
  125734. /**
  125735. * Attach the input controls to a specific dom element to get the input from.
  125736. * @param element Defines the element the controls should be listened from
  125737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125738. */
  125739. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125740. /**
  125741. * Detach the current controls from the specified dom element.
  125742. * @param element Defines the element to stop listening the inputs from
  125743. */
  125744. detachControl(element: Nullable<HTMLElement>): void;
  125745. /**
  125746. * Update the current camera state depending on the inputs that have been used this frame.
  125747. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125748. */
  125749. checkInputs(): void;
  125750. /**
  125751. * Gets the class name of the current intput.
  125752. * @returns the class name
  125753. */
  125754. getClassName(): string;
  125755. /**
  125756. * Get the friendly name associated with the input class.
  125757. * @returns the input friendly name
  125758. */
  125759. getSimpleName(): string;
  125760. }
  125761. }
  125762. declare module BABYLON {
  125763. /**
  125764. * Defines the potential axis of a Joystick
  125765. */
  125766. export enum JoystickAxis {
  125767. /** X axis */
  125768. X = 0,
  125769. /** Y axis */
  125770. Y = 1,
  125771. /** Z axis */
  125772. Z = 2
  125773. }
  125774. /**
  125775. * Represents the different customization options available
  125776. * for VirtualJoystick
  125777. */
  125778. interface VirtualJoystickCustomizations {
  125779. /**
  125780. * Size of the joystick's puck
  125781. */
  125782. puckSize: number;
  125783. /**
  125784. * Size of the joystick's container
  125785. */
  125786. containerSize: number;
  125787. /**
  125788. * Color of the joystick && puck
  125789. */
  125790. color: string;
  125791. /**
  125792. * Image URL for the joystick's puck
  125793. */
  125794. puckImage?: string;
  125795. /**
  125796. * Image URL for the joystick's container
  125797. */
  125798. containerImage?: string;
  125799. /**
  125800. * Defines the unmoving position of the joystick container
  125801. */
  125802. position?: {
  125803. x: number;
  125804. y: number;
  125805. };
  125806. /**
  125807. * Defines whether or not the joystick container is always visible
  125808. */
  125809. alwaysVisible: boolean;
  125810. /**
  125811. * Defines whether or not to limit the movement of the puck to the joystick's container
  125812. */
  125813. limitToContainer: boolean;
  125814. }
  125815. /**
  125816. * Class used to define virtual joystick (used in touch mode)
  125817. */
  125818. export class VirtualJoystick {
  125819. /**
  125820. * Gets or sets a boolean indicating that left and right values must be inverted
  125821. */
  125822. reverseLeftRight: boolean;
  125823. /**
  125824. * Gets or sets a boolean indicating that up and down values must be inverted
  125825. */
  125826. reverseUpDown: boolean;
  125827. /**
  125828. * Gets the offset value for the position (ie. the change of the position value)
  125829. */
  125830. deltaPosition: Vector3;
  125831. /**
  125832. * Gets a boolean indicating if the virtual joystick was pressed
  125833. */
  125834. pressed: boolean;
  125835. /**
  125836. * Canvas the virtual joystick will render onto, default z-index of this is 5
  125837. */
  125838. static Canvas: Nullable<HTMLCanvasElement>;
  125839. /**
  125840. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  125841. */
  125842. limitToContainer: boolean;
  125843. private static _globalJoystickIndex;
  125844. private static _alwaysVisibleSticks;
  125845. private static vjCanvasContext;
  125846. private static vjCanvasWidth;
  125847. private static vjCanvasHeight;
  125848. private static halfWidth;
  125849. private static _GetDefaultOptions;
  125850. private _action;
  125851. private _axisTargetedByLeftAndRight;
  125852. private _axisTargetedByUpAndDown;
  125853. private _joystickSensibility;
  125854. private _inversedSensibility;
  125855. private _joystickPointerID;
  125856. private _joystickColor;
  125857. private _joystickPointerPos;
  125858. private _joystickPreviousPointerPos;
  125859. private _joystickPointerStartPos;
  125860. private _deltaJoystickVector;
  125861. private _leftJoystick;
  125862. private _touches;
  125863. private _joystickPosition;
  125864. private _alwaysVisible;
  125865. private _puckImage;
  125866. private _containerImage;
  125867. private _joystickPuckSize;
  125868. private _joystickContainerSize;
  125869. private _clearPuckSize;
  125870. private _clearContainerSize;
  125871. private _clearPuckSizeOffset;
  125872. private _clearContainerSizeOffset;
  125873. private _onPointerDownHandlerRef;
  125874. private _onPointerMoveHandlerRef;
  125875. private _onPointerUpHandlerRef;
  125876. private _onResize;
  125877. /**
  125878. * Creates a new virtual joystick
  125879. * @param leftJoystick defines that the joystick is for left hand (false by default)
  125880. * @param customizations Defines the options we want to customize the VirtualJoystick
  125881. */
  125882. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  125883. /**
  125884. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  125885. * @param newJoystickSensibility defines the new sensibility
  125886. */
  125887. setJoystickSensibility(newJoystickSensibility: number): void;
  125888. private _onPointerDown;
  125889. private _onPointerMove;
  125890. private _onPointerUp;
  125891. /**
  125892. * Change the color of the virtual joystick
  125893. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  125894. */
  125895. setJoystickColor(newColor: string): void;
  125896. /**
  125897. * Size of the joystick's container
  125898. */
  125899. set containerSize(newSize: number);
  125900. get containerSize(): number;
  125901. /**
  125902. * Size of the joystick's puck
  125903. */
  125904. set puckSize(newSize: number);
  125905. get puckSize(): number;
  125906. /**
  125907. * Clears the set position of the joystick
  125908. */
  125909. clearPosition(): void;
  125910. /**
  125911. * Defines whether or not the joystick container is always visible
  125912. */
  125913. set alwaysVisible(value: boolean);
  125914. get alwaysVisible(): boolean;
  125915. /**
  125916. * Sets the constant position of the Joystick container
  125917. * @param x X axis coordinate
  125918. * @param y Y axis coordinate
  125919. */
  125920. setPosition(x: number, y: number): void;
  125921. /**
  125922. * Defines a callback to call when the joystick is touched
  125923. * @param action defines the callback
  125924. */
  125925. setActionOnTouch(action: () => any): void;
  125926. /**
  125927. * Defines which axis you'd like to control for left & right
  125928. * @param axis defines the axis to use
  125929. */
  125930. setAxisForLeftRight(axis: JoystickAxis): void;
  125931. /**
  125932. * Defines which axis you'd like to control for up & down
  125933. * @param axis defines the axis to use
  125934. */
  125935. setAxisForUpDown(axis: JoystickAxis): void;
  125936. /**
  125937. * Clears the canvas from the previous puck / container draw
  125938. */
  125939. private _clearPreviousDraw;
  125940. /**
  125941. * Loads `urlPath` to be used for the container's image
  125942. * @param urlPath defines the urlPath of an image to use
  125943. */
  125944. setContainerImage(urlPath: string): void;
  125945. /**
  125946. * Loads `urlPath` to be used for the puck's image
  125947. * @param urlPath defines the urlPath of an image to use
  125948. */
  125949. setPuckImage(urlPath: string): void;
  125950. /**
  125951. * Draws the Virtual Joystick's container
  125952. */
  125953. private _drawContainer;
  125954. /**
  125955. * Draws the Virtual Joystick's puck
  125956. */
  125957. private _drawPuck;
  125958. private _drawVirtualJoystick;
  125959. /**
  125960. * Release internal HTML canvas
  125961. */
  125962. releaseCanvas(): void;
  125963. }
  125964. }
  125965. declare module BABYLON {
  125966. interface FreeCameraInputsManager {
  125967. /**
  125968. * Add virtual joystick input support to the input manager.
  125969. * @returns the current input manager
  125970. */
  125971. addVirtualJoystick(): FreeCameraInputsManager;
  125972. }
  125973. /**
  125974. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125975. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125976. */
  125977. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125978. /**
  125979. * Defines the camera the input is attached to.
  125980. */
  125981. camera: FreeCamera;
  125982. private _leftjoystick;
  125983. private _rightjoystick;
  125984. /**
  125985. * Gets the left stick of the virtual joystick.
  125986. * @returns The virtual Joystick
  125987. */
  125988. getLeftJoystick(): VirtualJoystick;
  125989. /**
  125990. * Gets the right stick of the virtual joystick.
  125991. * @returns The virtual Joystick
  125992. */
  125993. getRightJoystick(): VirtualJoystick;
  125994. /**
  125995. * Update the current camera state depending on the inputs that have been used this frame.
  125996. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125997. */
  125998. checkInputs(): void;
  125999. /**
  126000. * Attach the input controls to a specific dom element to get the input from.
  126001. * @param element Defines the element the controls should be listened from
  126002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126003. */
  126004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126005. /**
  126006. * Detach the current controls from the specified dom element.
  126007. * @param element Defines the element to stop listening the inputs from
  126008. */
  126009. detachControl(element: Nullable<HTMLElement>): void;
  126010. /**
  126011. * Gets the class name of the current intput.
  126012. * @returns the class name
  126013. */
  126014. getClassName(): string;
  126015. /**
  126016. * Get the friendly name associated with the input class.
  126017. * @returns the input friendly name
  126018. */
  126019. getSimpleName(): string;
  126020. }
  126021. }
  126022. declare module BABYLON {
  126023. /**
  126024. * This represents a FPS type of camera controlled by touch.
  126025. * This is like a universal camera minus the Gamepad controls.
  126026. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126027. */
  126028. export class TouchCamera extends FreeCamera {
  126029. /**
  126030. * Defines the touch sensibility for rotation.
  126031. * The higher the faster.
  126032. */
  126033. get touchAngularSensibility(): number;
  126034. set touchAngularSensibility(value: number);
  126035. /**
  126036. * Defines the touch sensibility for move.
  126037. * The higher the faster.
  126038. */
  126039. get touchMoveSensibility(): number;
  126040. set touchMoveSensibility(value: number);
  126041. /**
  126042. * Instantiates a new touch camera.
  126043. * This represents a FPS type of camera controlled by touch.
  126044. * This is like a universal camera minus the Gamepad controls.
  126045. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126046. * @param name Define the name of the camera in the scene
  126047. * @param position Define the start position of the camera in the scene
  126048. * @param scene Define the scene the camera belongs to
  126049. */
  126050. constructor(name: string, position: Vector3, scene: Scene);
  126051. /**
  126052. * Gets the current object class name.
  126053. * @return the class name
  126054. */
  126055. getClassName(): string;
  126056. /** @hidden */
  126057. _setupInputs(): void;
  126058. }
  126059. }
  126060. declare module BABYLON {
  126061. /**
  126062. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  126063. * being tilted forward or back and left or right.
  126064. */
  126065. export class DeviceOrientationCamera extends FreeCamera {
  126066. private _initialQuaternion;
  126067. private _quaternionCache;
  126068. private _tmpDragQuaternion;
  126069. private _disablePointerInputWhenUsingDeviceOrientation;
  126070. /**
  126071. * Creates a new device orientation camera
  126072. * @param name The name of the camera
  126073. * @param position The start position camera
  126074. * @param scene The scene the camera belongs to
  126075. */
  126076. constructor(name: string, position: Vector3, scene: Scene);
  126077. /**
  126078. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  126079. */
  126080. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  126081. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  126082. private _dragFactor;
  126083. /**
  126084. * Enabled turning on the y axis when the orientation sensor is active
  126085. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  126086. */
  126087. enableHorizontalDragging(dragFactor?: number): void;
  126088. /**
  126089. * Gets the current instance class name ("DeviceOrientationCamera").
  126090. * This helps avoiding instanceof at run time.
  126091. * @returns the class name
  126092. */
  126093. getClassName(): string;
  126094. /**
  126095. * @hidden
  126096. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  126097. */
  126098. _checkInputs(): void;
  126099. /**
  126100. * Reset the camera to its default orientation on the specified axis only.
  126101. * @param axis The axis to reset
  126102. */
  126103. resetToCurrentRotation(axis?: Axis): void;
  126104. }
  126105. }
  126106. declare module BABYLON {
  126107. /**
  126108. * Defines supported buttons for XBox360 compatible gamepads
  126109. */
  126110. export enum Xbox360Button {
  126111. /** A */
  126112. A = 0,
  126113. /** B */
  126114. B = 1,
  126115. /** X */
  126116. X = 2,
  126117. /** Y */
  126118. Y = 3,
  126119. /** Left button */
  126120. LB = 4,
  126121. /** Right button */
  126122. RB = 5,
  126123. /** Back */
  126124. Back = 8,
  126125. /** Start */
  126126. Start = 9,
  126127. /** Left stick */
  126128. LeftStick = 10,
  126129. /** Right stick */
  126130. RightStick = 11
  126131. }
  126132. /** Defines values for XBox360 DPad */
  126133. export enum Xbox360Dpad {
  126134. /** Up */
  126135. Up = 12,
  126136. /** Down */
  126137. Down = 13,
  126138. /** Left */
  126139. Left = 14,
  126140. /** Right */
  126141. Right = 15
  126142. }
  126143. /**
  126144. * Defines a XBox360 gamepad
  126145. */
  126146. export class Xbox360Pad extends Gamepad {
  126147. private _leftTrigger;
  126148. private _rightTrigger;
  126149. private _onlefttriggerchanged;
  126150. private _onrighttriggerchanged;
  126151. private _onbuttondown;
  126152. private _onbuttonup;
  126153. private _ondpaddown;
  126154. private _ondpadup;
  126155. /** Observable raised when a button is pressed */
  126156. onButtonDownObservable: Observable<Xbox360Button>;
  126157. /** Observable raised when a button is released */
  126158. onButtonUpObservable: Observable<Xbox360Button>;
  126159. /** Observable raised when a pad is pressed */
  126160. onPadDownObservable: Observable<Xbox360Dpad>;
  126161. /** Observable raised when a pad is released */
  126162. onPadUpObservable: Observable<Xbox360Dpad>;
  126163. private _buttonA;
  126164. private _buttonB;
  126165. private _buttonX;
  126166. private _buttonY;
  126167. private _buttonBack;
  126168. private _buttonStart;
  126169. private _buttonLB;
  126170. private _buttonRB;
  126171. private _buttonLeftStick;
  126172. private _buttonRightStick;
  126173. private _dPadUp;
  126174. private _dPadDown;
  126175. private _dPadLeft;
  126176. private _dPadRight;
  126177. private _isXboxOnePad;
  126178. /**
  126179. * Creates a new XBox360 gamepad object
  126180. * @param id defines the id of this gamepad
  126181. * @param index defines its index
  126182. * @param gamepad defines the internal HTML gamepad object
  126183. * @param xboxOne defines if it is a XBox One gamepad
  126184. */
  126185. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  126186. /**
  126187. * Defines the callback to call when left trigger is pressed
  126188. * @param callback defines the callback to use
  126189. */
  126190. onlefttriggerchanged(callback: (value: number) => void): void;
  126191. /**
  126192. * Defines the callback to call when right trigger is pressed
  126193. * @param callback defines the callback to use
  126194. */
  126195. onrighttriggerchanged(callback: (value: number) => void): void;
  126196. /**
  126197. * Gets the left trigger value
  126198. */
  126199. get leftTrigger(): number;
  126200. /**
  126201. * Sets the left trigger value
  126202. */
  126203. set leftTrigger(newValue: number);
  126204. /**
  126205. * Gets the right trigger value
  126206. */
  126207. get rightTrigger(): number;
  126208. /**
  126209. * Sets the right trigger value
  126210. */
  126211. set rightTrigger(newValue: number);
  126212. /**
  126213. * Defines the callback to call when a button is pressed
  126214. * @param callback defines the callback to use
  126215. */
  126216. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  126217. /**
  126218. * Defines the callback to call when a button is released
  126219. * @param callback defines the callback to use
  126220. */
  126221. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  126222. /**
  126223. * Defines the callback to call when a pad is pressed
  126224. * @param callback defines the callback to use
  126225. */
  126226. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  126227. /**
  126228. * Defines the callback to call when a pad is released
  126229. * @param callback defines the callback to use
  126230. */
  126231. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  126232. private _setButtonValue;
  126233. private _setDPadValue;
  126234. /**
  126235. * Gets the value of the `A` button
  126236. */
  126237. get buttonA(): number;
  126238. /**
  126239. * Sets the value of the `A` button
  126240. */
  126241. set buttonA(value: number);
  126242. /**
  126243. * Gets the value of the `B` button
  126244. */
  126245. get buttonB(): number;
  126246. /**
  126247. * Sets the value of the `B` button
  126248. */
  126249. set buttonB(value: number);
  126250. /**
  126251. * Gets the value of the `X` button
  126252. */
  126253. get buttonX(): number;
  126254. /**
  126255. * Sets the value of the `X` button
  126256. */
  126257. set buttonX(value: number);
  126258. /**
  126259. * Gets the value of the `Y` button
  126260. */
  126261. get buttonY(): number;
  126262. /**
  126263. * Sets the value of the `Y` button
  126264. */
  126265. set buttonY(value: number);
  126266. /**
  126267. * Gets the value of the `Start` button
  126268. */
  126269. get buttonStart(): number;
  126270. /**
  126271. * Sets the value of the `Start` button
  126272. */
  126273. set buttonStart(value: number);
  126274. /**
  126275. * Gets the value of the `Back` button
  126276. */
  126277. get buttonBack(): number;
  126278. /**
  126279. * Sets the value of the `Back` button
  126280. */
  126281. set buttonBack(value: number);
  126282. /**
  126283. * Gets the value of the `Left` button
  126284. */
  126285. get buttonLB(): number;
  126286. /**
  126287. * Sets the value of the `Left` button
  126288. */
  126289. set buttonLB(value: number);
  126290. /**
  126291. * Gets the value of the `Right` button
  126292. */
  126293. get buttonRB(): number;
  126294. /**
  126295. * Sets the value of the `Right` button
  126296. */
  126297. set buttonRB(value: number);
  126298. /**
  126299. * Gets the value of the Left joystick
  126300. */
  126301. get buttonLeftStick(): number;
  126302. /**
  126303. * Sets the value of the Left joystick
  126304. */
  126305. set buttonLeftStick(value: number);
  126306. /**
  126307. * Gets the value of the Right joystick
  126308. */
  126309. get buttonRightStick(): number;
  126310. /**
  126311. * Sets the value of the Right joystick
  126312. */
  126313. set buttonRightStick(value: number);
  126314. /**
  126315. * Gets the value of D-pad up
  126316. */
  126317. get dPadUp(): number;
  126318. /**
  126319. * Sets the value of D-pad up
  126320. */
  126321. set dPadUp(value: number);
  126322. /**
  126323. * Gets the value of D-pad down
  126324. */
  126325. get dPadDown(): number;
  126326. /**
  126327. * Sets the value of D-pad down
  126328. */
  126329. set dPadDown(value: number);
  126330. /**
  126331. * Gets the value of D-pad left
  126332. */
  126333. get dPadLeft(): number;
  126334. /**
  126335. * Sets the value of D-pad left
  126336. */
  126337. set dPadLeft(value: number);
  126338. /**
  126339. * Gets the value of D-pad right
  126340. */
  126341. get dPadRight(): number;
  126342. /**
  126343. * Sets the value of D-pad right
  126344. */
  126345. set dPadRight(value: number);
  126346. /**
  126347. * Force the gamepad to synchronize with device values
  126348. */
  126349. update(): void;
  126350. /**
  126351. * Disposes the gamepad
  126352. */
  126353. dispose(): void;
  126354. }
  126355. }
  126356. declare module BABYLON {
  126357. /**
  126358. * Defines supported buttons for DualShock compatible gamepads
  126359. */
  126360. export enum DualShockButton {
  126361. /** Cross */
  126362. Cross = 0,
  126363. /** Circle */
  126364. Circle = 1,
  126365. /** Square */
  126366. Square = 2,
  126367. /** Triangle */
  126368. Triangle = 3,
  126369. /** L1 */
  126370. L1 = 4,
  126371. /** R1 */
  126372. R1 = 5,
  126373. /** Share */
  126374. Share = 8,
  126375. /** Options */
  126376. Options = 9,
  126377. /** Left stick */
  126378. LeftStick = 10,
  126379. /** Right stick */
  126380. RightStick = 11
  126381. }
  126382. /** Defines values for DualShock DPad */
  126383. export enum DualShockDpad {
  126384. /** Up */
  126385. Up = 12,
  126386. /** Down */
  126387. Down = 13,
  126388. /** Left */
  126389. Left = 14,
  126390. /** Right */
  126391. Right = 15
  126392. }
  126393. /**
  126394. * Defines a DualShock gamepad
  126395. */
  126396. export class DualShockPad extends Gamepad {
  126397. private _leftTrigger;
  126398. private _rightTrigger;
  126399. private _onlefttriggerchanged;
  126400. private _onrighttriggerchanged;
  126401. private _onbuttondown;
  126402. private _onbuttonup;
  126403. private _ondpaddown;
  126404. private _ondpadup;
  126405. /** Observable raised when a button is pressed */
  126406. onButtonDownObservable: Observable<DualShockButton>;
  126407. /** Observable raised when a button is released */
  126408. onButtonUpObservable: Observable<DualShockButton>;
  126409. /** Observable raised when a pad is pressed */
  126410. onPadDownObservable: Observable<DualShockDpad>;
  126411. /** Observable raised when a pad is released */
  126412. onPadUpObservable: Observable<DualShockDpad>;
  126413. private _buttonCross;
  126414. private _buttonCircle;
  126415. private _buttonSquare;
  126416. private _buttonTriangle;
  126417. private _buttonShare;
  126418. private _buttonOptions;
  126419. private _buttonL1;
  126420. private _buttonR1;
  126421. private _buttonLeftStick;
  126422. private _buttonRightStick;
  126423. private _dPadUp;
  126424. private _dPadDown;
  126425. private _dPadLeft;
  126426. private _dPadRight;
  126427. /**
  126428. * Creates a new DualShock gamepad object
  126429. * @param id defines the id of this gamepad
  126430. * @param index defines its index
  126431. * @param gamepad defines the internal HTML gamepad object
  126432. */
  126433. constructor(id: string, index: number, gamepad: any);
  126434. /**
  126435. * Defines the callback to call when left trigger is pressed
  126436. * @param callback defines the callback to use
  126437. */
  126438. onlefttriggerchanged(callback: (value: number) => void): void;
  126439. /**
  126440. * Defines the callback to call when right trigger is pressed
  126441. * @param callback defines the callback to use
  126442. */
  126443. onrighttriggerchanged(callback: (value: number) => void): void;
  126444. /**
  126445. * Gets the left trigger value
  126446. */
  126447. get leftTrigger(): number;
  126448. /**
  126449. * Sets the left trigger value
  126450. */
  126451. set leftTrigger(newValue: number);
  126452. /**
  126453. * Gets the right trigger value
  126454. */
  126455. get rightTrigger(): number;
  126456. /**
  126457. * Sets the right trigger value
  126458. */
  126459. set rightTrigger(newValue: number);
  126460. /**
  126461. * Defines the callback to call when a button is pressed
  126462. * @param callback defines the callback to use
  126463. */
  126464. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  126465. /**
  126466. * Defines the callback to call when a button is released
  126467. * @param callback defines the callback to use
  126468. */
  126469. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  126470. /**
  126471. * Defines the callback to call when a pad is pressed
  126472. * @param callback defines the callback to use
  126473. */
  126474. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  126475. /**
  126476. * Defines the callback to call when a pad is released
  126477. * @param callback defines the callback to use
  126478. */
  126479. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  126480. private _setButtonValue;
  126481. private _setDPadValue;
  126482. /**
  126483. * Gets the value of the `Cross` button
  126484. */
  126485. get buttonCross(): number;
  126486. /**
  126487. * Sets the value of the `Cross` button
  126488. */
  126489. set buttonCross(value: number);
  126490. /**
  126491. * Gets the value of the `Circle` button
  126492. */
  126493. get buttonCircle(): number;
  126494. /**
  126495. * Sets the value of the `Circle` button
  126496. */
  126497. set buttonCircle(value: number);
  126498. /**
  126499. * Gets the value of the `Square` button
  126500. */
  126501. get buttonSquare(): number;
  126502. /**
  126503. * Sets the value of the `Square` button
  126504. */
  126505. set buttonSquare(value: number);
  126506. /**
  126507. * Gets the value of the `Triangle` button
  126508. */
  126509. get buttonTriangle(): number;
  126510. /**
  126511. * Sets the value of the `Triangle` button
  126512. */
  126513. set buttonTriangle(value: number);
  126514. /**
  126515. * Gets the value of the `Options` button
  126516. */
  126517. get buttonOptions(): number;
  126518. /**
  126519. * Sets the value of the `Options` button
  126520. */
  126521. set buttonOptions(value: number);
  126522. /**
  126523. * Gets the value of the `Share` button
  126524. */
  126525. get buttonShare(): number;
  126526. /**
  126527. * Sets the value of the `Share` button
  126528. */
  126529. set buttonShare(value: number);
  126530. /**
  126531. * Gets the value of the `L1` button
  126532. */
  126533. get buttonL1(): number;
  126534. /**
  126535. * Sets the value of the `L1` button
  126536. */
  126537. set buttonL1(value: number);
  126538. /**
  126539. * Gets the value of the `R1` button
  126540. */
  126541. get buttonR1(): number;
  126542. /**
  126543. * Sets the value of the `R1` button
  126544. */
  126545. set buttonR1(value: number);
  126546. /**
  126547. * Gets the value of the Left joystick
  126548. */
  126549. get buttonLeftStick(): number;
  126550. /**
  126551. * Sets the value of the Left joystick
  126552. */
  126553. set buttonLeftStick(value: number);
  126554. /**
  126555. * Gets the value of the Right joystick
  126556. */
  126557. get buttonRightStick(): number;
  126558. /**
  126559. * Sets the value of the Right joystick
  126560. */
  126561. set buttonRightStick(value: number);
  126562. /**
  126563. * Gets the value of D-pad up
  126564. */
  126565. get dPadUp(): number;
  126566. /**
  126567. * Sets the value of D-pad up
  126568. */
  126569. set dPadUp(value: number);
  126570. /**
  126571. * Gets the value of D-pad down
  126572. */
  126573. get dPadDown(): number;
  126574. /**
  126575. * Sets the value of D-pad down
  126576. */
  126577. set dPadDown(value: number);
  126578. /**
  126579. * Gets the value of D-pad left
  126580. */
  126581. get dPadLeft(): number;
  126582. /**
  126583. * Sets the value of D-pad left
  126584. */
  126585. set dPadLeft(value: number);
  126586. /**
  126587. * Gets the value of D-pad right
  126588. */
  126589. get dPadRight(): number;
  126590. /**
  126591. * Sets the value of D-pad right
  126592. */
  126593. set dPadRight(value: number);
  126594. /**
  126595. * Force the gamepad to synchronize with device values
  126596. */
  126597. update(): void;
  126598. /**
  126599. * Disposes the gamepad
  126600. */
  126601. dispose(): void;
  126602. }
  126603. }
  126604. declare module BABYLON {
  126605. /**
  126606. * Manager for handling gamepads
  126607. */
  126608. export class GamepadManager {
  126609. private _scene?;
  126610. private _babylonGamepads;
  126611. private _oneGamepadConnected;
  126612. /** @hidden */
  126613. _isMonitoring: boolean;
  126614. private _gamepadEventSupported;
  126615. private _gamepadSupport?;
  126616. /**
  126617. * observable to be triggered when the gamepad controller has been connected
  126618. */
  126619. onGamepadConnectedObservable: Observable<Gamepad>;
  126620. /**
  126621. * observable to be triggered when the gamepad controller has been disconnected
  126622. */
  126623. onGamepadDisconnectedObservable: Observable<Gamepad>;
  126624. private _onGamepadConnectedEvent;
  126625. private _onGamepadDisconnectedEvent;
  126626. /**
  126627. * Initializes the gamepad manager
  126628. * @param _scene BabylonJS scene
  126629. */
  126630. constructor(_scene?: Scene | undefined);
  126631. /**
  126632. * The gamepads in the game pad manager
  126633. */
  126634. get gamepads(): Gamepad[];
  126635. /**
  126636. * Get the gamepad controllers based on type
  126637. * @param type The type of gamepad controller
  126638. * @returns Nullable gamepad
  126639. */
  126640. getGamepadByType(type?: number): Nullable<Gamepad>;
  126641. /**
  126642. * Disposes the gamepad manager
  126643. */
  126644. dispose(): void;
  126645. private _addNewGamepad;
  126646. private _startMonitoringGamepads;
  126647. private _stopMonitoringGamepads;
  126648. /** @hidden */
  126649. _checkGamepadsStatus(): void;
  126650. private _updateGamepadObjects;
  126651. }
  126652. }
  126653. declare module BABYLON {
  126654. interface Scene {
  126655. /** @hidden */
  126656. _gamepadManager: Nullable<GamepadManager>;
  126657. /**
  126658. * Gets the gamepad manager associated with the scene
  126659. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  126660. */
  126661. gamepadManager: GamepadManager;
  126662. }
  126663. /**
  126664. * Interface representing a free camera inputs manager
  126665. */
  126666. interface FreeCameraInputsManager {
  126667. /**
  126668. * Adds gamepad input support to the FreeCameraInputsManager.
  126669. * @returns the FreeCameraInputsManager
  126670. */
  126671. addGamepad(): FreeCameraInputsManager;
  126672. }
  126673. /**
  126674. * Interface representing an arc rotate camera inputs manager
  126675. */
  126676. interface ArcRotateCameraInputsManager {
  126677. /**
  126678. * Adds gamepad input support to the ArcRotateCamera InputManager.
  126679. * @returns the camera inputs manager
  126680. */
  126681. addGamepad(): ArcRotateCameraInputsManager;
  126682. }
  126683. /**
  126684. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  126685. */
  126686. export class GamepadSystemSceneComponent implements ISceneComponent {
  126687. /**
  126688. * The component name helpfull to identify the component in the list of scene components.
  126689. */
  126690. readonly name: string;
  126691. /**
  126692. * The scene the component belongs to.
  126693. */
  126694. scene: Scene;
  126695. /**
  126696. * Creates a new instance of the component for the given scene
  126697. * @param scene Defines the scene to register the component in
  126698. */
  126699. constructor(scene: Scene);
  126700. /**
  126701. * Registers the component in a given scene
  126702. */
  126703. register(): void;
  126704. /**
  126705. * Rebuilds the elements related to this component in case of
  126706. * context lost for instance.
  126707. */
  126708. rebuild(): void;
  126709. /**
  126710. * Disposes the component and the associated ressources
  126711. */
  126712. dispose(): void;
  126713. private _beforeCameraUpdate;
  126714. }
  126715. }
  126716. declare module BABYLON {
  126717. /**
  126718. * 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,
  126719. * which still works and will still be found in many Playgrounds.
  126720. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126721. */
  126722. export class UniversalCamera extends TouchCamera {
  126723. /**
  126724. * Defines the gamepad rotation sensiblity.
  126725. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  126726. */
  126727. get gamepadAngularSensibility(): number;
  126728. set gamepadAngularSensibility(value: number);
  126729. /**
  126730. * Defines the gamepad move sensiblity.
  126731. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  126732. */
  126733. get gamepadMoveSensibility(): number;
  126734. set gamepadMoveSensibility(value: number);
  126735. /**
  126736. * 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,
  126737. * which still works and will still be found in many Playgrounds.
  126738. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126739. * @param name Define the name of the camera in the scene
  126740. * @param position Define the start position of the camera in the scene
  126741. * @param scene Define the scene the camera belongs to
  126742. */
  126743. constructor(name: string, position: Vector3, scene: Scene);
  126744. /**
  126745. * Gets the current object class name.
  126746. * @return the class name
  126747. */
  126748. getClassName(): string;
  126749. }
  126750. }
  126751. declare module BABYLON {
  126752. /**
  126753. * This represents a FPS type of camera. This is only here for back compat purpose.
  126754. * Please use the UniversalCamera instead as both are identical.
  126755. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126756. */
  126757. export class GamepadCamera extends UniversalCamera {
  126758. /**
  126759. * Instantiates a new Gamepad Camera
  126760. * This represents a FPS type of camera. This is only here for back compat purpose.
  126761. * Please use the UniversalCamera instead as both are identical.
  126762. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126763. * @param name Define the name of the camera in the scene
  126764. * @param position Define the start position of the camera in the scene
  126765. * @param scene Define the scene the camera belongs to
  126766. */
  126767. constructor(name: string, position: Vector3, scene: Scene);
  126768. /**
  126769. * Gets the current object class name.
  126770. * @return the class name
  126771. */
  126772. getClassName(): string;
  126773. }
  126774. }
  126775. declare module BABYLON {
  126776. /** @hidden */
  126777. export var passPixelShader: {
  126778. name: string;
  126779. shader: string;
  126780. };
  126781. }
  126782. declare module BABYLON {
  126783. /** @hidden */
  126784. export var passCubePixelShader: {
  126785. name: string;
  126786. shader: string;
  126787. };
  126788. }
  126789. declare module BABYLON {
  126790. /**
  126791. * PassPostProcess which produces an output the same as it's input
  126792. */
  126793. export class PassPostProcess extends PostProcess {
  126794. /**
  126795. * Gets a string identifying the name of the class
  126796. * @returns "PassPostProcess" string
  126797. */
  126798. getClassName(): string;
  126799. /**
  126800. * Creates the PassPostProcess
  126801. * @param name The name of the effect.
  126802. * @param options The required width/height ratio to downsize to before computing the render pass.
  126803. * @param camera The camera to apply the render pass to.
  126804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126805. * @param engine The engine which the post process will be applied. (default: current engine)
  126806. * @param reusable If the post process can be reused on the same frame. (default: false)
  126807. * @param textureType The type of texture to be used when performing the post processing.
  126808. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  126809. */
  126810. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126811. /** @hidden */
  126812. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  126813. }
  126814. /**
  126815. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  126816. */
  126817. export class PassCubePostProcess extends PostProcess {
  126818. private _face;
  126819. /**
  126820. * Gets or sets the cube face to display.
  126821. * * 0 is +X
  126822. * * 1 is -X
  126823. * * 2 is +Y
  126824. * * 3 is -Y
  126825. * * 4 is +Z
  126826. * * 5 is -Z
  126827. */
  126828. get face(): number;
  126829. set face(value: number);
  126830. /**
  126831. * Gets a string identifying the name of the class
  126832. * @returns "PassCubePostProcess" string
  126833. */
  126834. getClassName(): string;
  126835. /**
  126836. * Creates the PassCubePostProcess
  126837. * @param name The name of the effect.
  126838. * @param options The required width/height ratio to downsize to before computing the render pass.
  126839. * @param camera The camera to apply the render pass to.
  126840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126841. * @param engine The engine which the post process will be applied. (default: current engine)
  126842. * @param reusable If the post process can be reused on the same frame. (default: false)
  126843. * @param textureType The type of texture to be used when performing the post processing.
  126844. * @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)
  126845. */
  126846. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126847. /** @hidden */
  126848. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  126849. }
  126850. }
  126851. declare module BABYLON {
  126852. /** @hidden */
  126853. export var anaglyphPixelShader: {
  126854. name: string;
  126855. shader: string;
  126856. };
  126857. }
  126858. declare module BABYLON {
  126859. /**
  126860. * Postprocess used to generate anaglyphic rendering
  126861. */
  126862. export class AnaglyphPostProcess extends PostProcess {
  126863. private _passedProcess;
  126864. /**
  126865. * Gets a string identifying the name of the class
  126866. * @returns "AnaglyphPostProcess" string
  126867. */
  126868. getClassName(): string;
  126869. /**
  126870. * Creates a new AnaglyphPostProcess
  126871. * @param name defines postprocess name
  126872. * @param options defines creation options or target ratio scale
  126873. * @param rigCameras defines cameras using this postprocess
  126874. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  126875. * @param engine defines hosting engine
  126876. * @param reusable defines if the postprocess will be reused multiple times per frame
  126877. */
  126878. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  126879. }
  126880. }
  126881. declare module BABYLON {
  126882. /**
  126883. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  126884. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126885. */
  126886. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  126887. /**
  126888. * Creates a new AnaglyphArcRotateCamera
  126889. * @param name defines camera name
  126890. * @param alpha defines alpha angle (in radians)
  126891. * @param beta defines beta angle (in radians)
  126892. * @param radius defines radius
  126893. * @param target defines camera target
  126894. * @param interaxialDistance defines distance between each color axis
  126895. * @param scene defines the hosting scene
  126896. */
  126897. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  126898. /**
  126899. * Gets camera class name
  126900. * @returns AnaglyphArcRotateCamera
  126901. */
  126902. getClassName(): string;
  126903. }
  126904. }
  126905. declare module BABYLON {
  126906. /**
  126907. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  126908. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126909. */
  126910. export class AnaglyphFreeCamera extends FreeCamera {
  126911. /**
  126912. * Creates a new AnaglyphFreeCamera
  126913. * @param name defines camera name
  126914. * @param position defines initial position
  126915. * @param interaxialDistance defines distance between each color axis
  126916. * @param scene defines the hosting scene
  126917. */
  126918. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126919. /**
  126920. * Gets camera class name
  126921. * @returns AnaglyphFreeCamera
  126922. */
  126923. getClassName(): string;
  126924. }
  126925. }
  126926. declare module BABYLON {
  126927. /**
  126928. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  126929. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126930. */
  126931. export class AnaglyphGamepadCamera extends GamepadCamera {
  126932. /**
  126933. * Creates a new AnaglyphGamepadCamera
  126934. * @param name defines camera name
  126935. * @param position defines initial position
  126936. * @param interaxialDistance defines distance between each color axis
  126937. * @param scene defines the hosting scene
  126938. */
  126939. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126940. /**
  126941. * Gets camera class name
  126942. * @returns AnaglyphGamepadCamera
  126943. */
  126944. getClassName(): string;
  126945. }
  126946. }
  126947. declare module BABYLON {
  126948. /**
  126949. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  126950. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126951. */
  126952. export class AnaglyphUniversalCamera extends UniversalCamera {
  126953. /**
  126954. * Creates a new AnaglyphUniversalCamera
  126955. * @param name defines camera name
  126956. * @param position defines initial position
  126957. * @param interaxialDistance defines distance between each color axis
  126958. * @param scene defines the hosting scene
  126959. */
  126960. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126961. /**
  126962. * Gets camera class name
  126963. * @returns AnaglyphUniversalCamera
  126964. */
  126965. getClassName(): string;
  126966. }
  126967. }
  126968. declare module BABYLON {
  126969. /**
  126970. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126971. * @see https://doc.babylonjs.com/features/cameras
  126972. */
  126973. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126974. /**
  126975. * Creates a new StereoscopicArcRotateCamera
  126976. * @param name defines camera name
  126977. * @param alpha defines alpha angle (in radians)
  126978. * @param beta defines beta angle (in radians)
  126979. * @param radius defines radius
  126980. * @param target defines camera target
  126981. * @param interaxialDistance defines distance between each color axis
  126982. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126983. * @param scene defines the hosting scene
  126984. */
  126985. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126986. /**
  126987. * Gets camera class name
  126988. * @returns StereoscopicArcRotateCamera
  126989. */
  126990. getClassName(): string;
  126991. }
  126992. }
  126993. declare module BABYLON {
  126994. /**
  126995. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126996. * @see https://doc.babylonjs.com/features/cameras
  126997. */
  126998. export class StereoscopicFreeCamera extends FreeCamera {
  126999. /**
  127000. * Creates a new StereoscopicFreeCamera
  127001. * @param name defines camera name
  127002. * @param position defines initial position
  127003. * @param interaxialDistance defines distance between each color axis
  127004. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  127005. * @param scene defines the hosting scene
  127006. */
  127007. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  127008. /**
  127009. * Gets camera class name
  127010. * @returns StereoscopicFreeCamera
  127011. */
  127012. getClassName(): string;
  127013. }
  127014. }
  127015. declare module BABYLON {
  127016. /**
  127017. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  127018. * @see https://doc.babylonjs.com/features/cameras
  127019. */
  127020. export class StereoscopicGamepadCamera extends GamepadCamera {
  127021. /**
  127022. * Creates a new StereoscopicGamepadCamera
  127023. * @param name defines camera name
  127024. * @param position defines initial position
  127025. * @param interaxialDistance defines distance between each color axis
  127026. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  127027. * @param scene defines the hosting scene
  127028. */
  127029. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  127030. /**
  127031. * Gets camera class name
  127032. * @returns StereoscopicGamepadCamera
  127033. */
  127034. getClassName(): string;
  127035. }
  127036. }
  127037. declare module BABYLON {
  127038. /**
  127039. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  127040. * @see https://doc.babylonjs.com/features/cameras
  127041. */
  127042. export class StereoscopicUniversalCamera extends UniversalCamera {
  127043. /**
  127044. * Creates a new StereoscopicUniversalCamera
  127045. * @param name defines camera name
  127046. * @param position defines initial position
  127047. * @param interaxialDistance defines distance between each color axis
  127048. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  127049. * @param scene defines the hosting scene
  127050. */
  127051. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  127052. /**
  127053. * Gets camera class name
  127054. * @returns StereoscopicUniversalCamera
  127055. */
  127056. getClassName(): string;
  127057. }
  127058. }
  127059. declare module BABYLON {
  127060. /**
  127061. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  127062. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  127063. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  127064. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  127065. */
  127066. export class VirtualJoysticksCamera extends FreeCamera {
  127067. /**
  127068. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  127069. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  127070. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  127071. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  127072. * @param name Define the name of the camera in the scene
  127073. * @param position Define the start position of the camera in the scene
  127074. * @param scene Define the scene the camera belongs to
  127075. */
  127076. constructor(name: string, position: Vector3, scene: Scene);
  127077. /**
  127078. * Gets the current object class name.
  127079. * @return the class name
  127080. */
  127081. getClassName(): string;
  127082. }
  127083. }
  127084. declare module BABYLON {
  127085. /**
  127086. * This represents all the required metrics to create a VR camera.
  127087. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  127088. */
  127089. export class VRCameraMetrics {
  127090. /**
  127091. * Define the horizontal resolution off the screen.
  127092. */
  127093. hResolution: number;
  127094. /**
  127095. * Define the vertical resolution off the screen.
  127096. */
  127097. vResolution: number;
  127098. /**
  127099. * Define the horizontal screen size.
  127100. */
  127101. hScreenSize: number;
  127102. /**
  127103. * Define the vertical screen size.
  127104. */
  127105. vScreenSize: number;
  127106. /**
  127107. * Define the vertical screen center position.
  127108. */
  127109. vScreenCenter: number;
  127110. /**
  127111. * Define the distance of the eyes to the screen.
  127112. */
  127113. eyeToScreenDistance: number;
  127114. /**
  127115. * Define the distance between both lenses
  127116. */
  127117. lensSeparationDistance: number;
  127118. /**
  127119. * Define the distance between both viewer's eyes.
  127120. */
  127121. interpupillaryDistance: number;
  127122. /**
  127123. * Define the distortion factor of the VR postprocess.
  127124. * Please, touch with care.
  127125. */
  127126. distortionK: number[];
  127127. /**
  127128. * Define the chromatic aberration correction factors for the VR post process.
  127129. */
  127130. chromaAbCorrection: number[];
  127131. /**
  127132. * Define the scale factor of the post process.
  127133. * The smaller the better but the slower.
  127134. */
  127135. postProcessScaleFactor: number;
  127136. /**
  127137. * Define an offset for the lens center.
  127138. */
  127139. lensCenterOffset: number;
  127140. /**
  127141. * Define if the current vr camera should compensate the distortion of the lense or not.
  127142. */
  127143. compensateDistortion: boolean;
  127144. /**
  127145. * Defines if multiview should be enabled when rendering (Default: false)
  127146. */
  127147. multiviewEnabled: boolean;
  127148. /**
  127149. * Gets the rendering aspect ratio based on the provided resolutions.
  127150. */
  127151. get aspectRatio(): number;
  127152. /**
  127153. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  127154. */
  127155. get aspectRatioFov(): number;
  127156. /**
  127157. * @hidden
  127158. */
  127159. get leftHMatrix(): Matrix;
  127160. /**
  127161. * @hidden
  127162. */
  127163. get rightHMatrix(): Matrix;
  127164. /**
  127165. * @hidden
  127166. */
  127167. get leftPreViewMatrix(): Matrix;
  127168. /**
  127169. * @hidden
  127170. */
  127171. get rightPreViewMatrix(): Matrix;
  127172. /**
  127173. * Get the default VRMetrics based on the most generic setup.
  127174. * @returns the default vr metrics
  127175. */
  127176. static GetDefault(): VRCameraMetrics;
  127177. }
  127178. }
  127179. declare module BABYLON {
  127180. /** @hidden */
  127181. export var vrDistortionCorrectionPixelShader: {
  127182. name: string;
  127183. shader: string;
  127184. };
  127185. }
  127186. declare module BABYLON {
  127187. /**
  127188. * VRDistortionCorrectionPostProcess used for mobile VR
  127189. */
  127190. export class VRDistortionCorrectionPostProcess extends PostProcess {
  127191. private _isRightEye;
  127192. private _distortionFactors;
  127193. private _postProcessScaleFactor;
  127194. private _lensCenterOffset;
  127195. private _scaleIn;
  127196. private _scaleFactor;
  127197. private _lensCenter;
  127198. /**
  127199. * Gets a string identifying the name of the class
  127200. * @returns "VRDistortionCorrectionPostProcess" string
  127201. */
  127202. getClassName(): string;
  127203. /**
  127204. * Initializes the VRDistortionCorrectionPostProcess
  127205. * @param name The name of the effect.
  127206. * @param camera The camera to apply the render pass to.
  127207. * @param isRightEye If this is for the right eye distortion
  127208. * @param vrMetrics All the required metrics for the VR camera
  127209. */
  127210. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  127211. }
  127212. }
  127213. declare module BABYLON {
  127214. /**
  127215. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  127216. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  127217. */
  127218. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  127219. /**
  127220. * Creates a new VRDeviceOrientationArcRotateCamera
  127221. * @param name defines camera name
  127222. * @param alpha defines the camera rotation along the logitudinal axis
  127223. * @param beta defines the camera rotation along the latitudinal axis
  127224. * @param radius defines the camera distance from its target
  127225. * @param target defines the camera target
  127226. * @param scene defines the scene the camera belongs to
  127227. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  127228. * @param vrCameraMetrics defines the vr metrics associated to the camera
  127229. */
  127230. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  127231. /**
  127232. * Gets camera class name
  127233. * @returns VRDeviceOrientationArcRotateCamera
  127234. */
  127235. getClassName(): string;
  127236. }
  127237. }
  127238. declare module BABYLON {
  127239. /**
  127240. * Camera used to simulate VR rendering (based on FreeCamera)
  127241. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  127242. */
  127243. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  127244. /**
  127245. * Creates a new VRDeviceOrientationFreeCamera
  127246. * @param name defines camera name
  127247. * @param position defines the start position of the camera
  127248. * @param scene defines the scene the camera belongs to
  127249. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  127250. * @param vrCameraMetrics defines the vr metrics associated to the camera
  127251. */
  127252. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  127253. /**
  127254. * Gets camera class name
  127255. * @returns VRDeviceOrientationFreeCamera
  127256. */
  127257. getClassName(): string;
  127258. }
  127259. }
  127260. declare module BABYLON {
  127261. /**
  127262. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  127263. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  127264. */
  127265. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  127266. /**
  127267. * Creates a new VRDeviceOrientationGamepadCamera
  127268. * @param name defines camera name
  127269. * @param position defines the start position of the camera
  127270. * @param scene defines the scene the camera belongs to
  127271. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  127272. * @param vrCameraMetrics defines the vr metrics associated to the camera
  127273. */
  127274. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  127275. /**
  127276. * Gets camera class name
  127277. * @returns VRDeviceOrientationGamepadCamera
  127278. */
  127279. getClassName(): string;
  127280. }
  127281. }
  127282. declare module BABYLON {
  127283. /**
  127284. * A class extending Texture allowing drawing on a texture
  127285. * @see https://doc.babylonjs.com/how_to/dynamictexture
  127286. */
  127287. export class DynamicTexture extends Texture {
  127288. private _generateMipMaps;
  127289. private _canvas;
  127290. private _context;
  127291. /**
  127292. * Creates a DynamicTexture
  127293. * @param name defines the name of the texture
  127294. * @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
  127295. * @param scene defines the scene where you want the texture
  127296. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  127297. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127298. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  127299. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  127300. */
  127301. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  127302. /**
  127303. * Get the current class name of the texture useful for serialization or dynamic coding.
  127304. * @returns "DynamicTexture"
  127305. */
  127306. getClassName(): string;
  127307. /**
  127308. * Gets the current state of canRescale
  127309. */
  127310. get canRescale(): boolean;
  127311. private _recreate;
  127312. /**
  127313. * Scales the texture
  127314. * @param ratio the scale factor to apply to both width and height
  127315. */
  127316. scale(ratio: number): void;
  127317. /**
  127318. * Resizes the texture
  127319. * @param width the new width
  127320. * @param height the new height
  127321. */
  127322. scaleTo(width: number, height: number): void;
  127323. /**
  127324. * Gets the context of the canvas used by the texture
  127325. * @returns the canvas context of the dynamic texture
  127326. */
  127327. getContext(): CanvasRenderingContext2D;
  127328. /**
  127329. * Clears the texture
  127330. */
  127331. clear(): void;
  127332. /**
  127333. * Updates the texture
  127334. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  127335. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  127336. */
  127337. update(invertY?: boolean, premulAlpha?: boolean): void;
  127338. /**
  127339. * Draws text onto the texture
  127340. * @param text defines the text to be drawn
  127341. * @param x defines the placement of the text from the left
  127342. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  127343. * @param font defines the font to be used with font-style, font-size, font-name
  127344. * @param color defines the color used for the text
  127345. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  127346. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  127347. * @param update defines whether texture is immediately update (default is true)
  127348. */
  127349. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  127350. /**
  127351. * Clones the texture
  127352. * @returns the clone of the texture.
  127353. */
  127354. clone(): DynamicTexture;
  127355. /**
  127356. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  127357. * @returns a serialized dynamic texture object
  127358. */
  127359. serialize(): any;
  127360. private _IsCanvasElement;
  127361. /** @hidden */
  127362. _rebuild(): void;
  127363. }
  127364. }
  127365. declare module BABYLON {
  127366. /**
  127367. * Class containing static functions to help procedurally build meshes
  127368. */
  127369. export class GroundBuilder {
  127370. /**
  127371. * Creates a ground mesh
  127372. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127373. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127375. * @param name defines the name of the mesh
  127376. * @param options defines the options used to create the mesh
  127377. * @param scene defines the hosting scene
  127378. * @returns the ground mesh
  127379. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127380. */
  127381. static CreateGround(name: string, options: {
  127382. width?: number;
  127383. height?: number;
  127384. subdivisions?: number;
  127385. subdivisionsX?: number;
  127386. subdivisionsY?: number;
  127387. updatable?: boolean;
  127388. }, scene: any): Mesh;
  127389. /**
  127390. * Creates a tiled ground mesh
  127391. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127392. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127393. * * 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
  127394. * * 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
  127395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127396. * @param name defines the name of the mesh
  127397. * @param options defines the options used to create the mesh
  127398. * @param scene defines the hosting scene
  127399. * @returns the tiled ground mesh
  127400. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127401. */
  127402. static CreateTiledGround(name: string, options: {
  127403. xmin: number;
  127404. zmin: number;
  127405. xmax: number;
  127406. zmax: number;
  127407. subdivisions?: {
  127408. w: number;
  127409. h: number;
  127410. };
  127411. precision?: {
  127412. w: number;
  127413. h: number;
  127414. };
  127415. updatable?: boolean;
  127416. }, scene?: Nullable<Scene>): Mesh;
  127417. /**
  127418. * Creates a ground mesh from a height map
  127419. * * The parameter `url` sets the URL of the height map image resource.
  127420. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127421. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127422. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127423. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127424. * * 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.
  127425. * * 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).
  127426. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127428. * @param name defines the name of the mesh
  127429. * @param url defines the url to the height map
  127430. * @param options defines the options used to create the mesh
  127431. * @param scene defines the hosting scene
  127432. * @returns the ground mesh
  127433. * @see https://doc.babylonjs.com/babylon101/height_map
  127434. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127435. */
  127436. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127437. width?: number;
  127438. height?: number;
  127439. subdivisions?: number;
  127440. minHeight?: number;
  127441. maxHeight?: number;
  127442. colorFilter?: Color3;
  127443. alphaFilter?: number;
  127444. updatable?: boolean;
  127445. onReady?: (mesh: GroundMesh) => void;
  127446. }, scene?: Nullable<Scene>): GroundMesh;
  127447. }
  127448. }
  127449. declare module BABYLON {
  127450. /**
  127451. * Class containing static functions to help procedurally build meshes
  127452. */
  127453. export class TorusBuilder {
  127454. /**
  127455. * Creates a torus mesh
  127456. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127457. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127458. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127462. * @param name defines the name of the mesh
  127463. * @param options defines the options used to create the mesh
  127464. * @param scene defines the hosting scene
  127465. * @returns the torus mesh
  127466. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127467. */
  127468. static CreateTorus(name: string, options: {
  127469. diameter?: number;
  127470. thickness?: number;
  127471. tessellation?: number;
  127472. updatable?: boolean;
  127473. sideOrientation?: number;
  127474. frontUVs?: Vector4;
  127475. backUVs?: Vector4;
  127476. }, scene: any): Mesh;
  127477. }
  127478. }
  127479. declare module BABYLON {
  127480. /**
  127481. * Class containing static functions to help procedurally build meshes
  127482. */
  127483. export class CylinderBuilder {
  127484. /**
  127485. * Creates a cylinder or a cone mesh
  127486. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127487. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127488. * * 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.
  127489. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127490. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127491. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127492. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127493. * * 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).
  127494. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127495. * * 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).
  127496. * * 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
  127497. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127498. * * 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
  127499. * * 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.
  127500. * * If `enclose` is false, a ring surface is one element.
  127501. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127502. * * 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
  127503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127506. * @param name defines the name of the mesh
  127507. * @param options defines the options used to create the mesh
  127508. * @param scene defines the hosting scene
  127509. * @returns the cylinder mesh
  127510. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127511. */
  127512. static CreateCylinder(name: string, options: {
  127513. height?: number;
  127514. diameterTop?: number;
  127515. diameterBottom?: number;
  127516. diameter?: number;
  127517. tessellation?: number;
  127518. subdivisions?: number;
  127519. arc?: number;
  127520. faceColors?: Color4[];
  127521. faceUV?: Vector4[];
  127522. updatable?: boolean;
  127523. hasRings?: boolean;
  127524. enclose?: boolean;
  127525. cap?: number;
  127526. sideOrientation?: number;
  127527. frontUVs?: Vector4;
  127528. backUVs?: Vector4;
  127529. }, scene: any): Mesh;
  127530. }
  127531. }
  127532. declare module BABYLON {
  127533. /**
  127534. * States of the webXR experience
  127535. */
  127536. export enum WebXRState {
  127537. /**
  127538. * Transitioning to being in XR mode
  127539. */
  127540. ENTERING_XR = 0,
  127541. /**
  127542. * Transitioning to non XR mode
  127543. */
  127544. EXITING_XR = 1,
  127545. /**
  127546. * In XR mode and presenting
  127547. */
  127548. IN_XR = 2,
  127549. /**
  127550. * Not entered XR mode
  127551. */
  127552. NOT_IN_XR = 3
  127553. }
  127554. /**
  127555. * Abstraction of the XR render target
  127556. */
  127557. export interface WebXRRenderTarget extends IDisposable {
  127558. /**
  127559. * xrpresent context of the canvas which can be used to display/mirror xr content
  127560. */
  127561. canvasContext: WebGLRenderingContext;
  127562. /**
  127563. * xr layer for the canvas
  127564. */
  127565. xrLayer: Nullable<XRWebGLLayer>;
  127566. /**
  127567. * Initializes the xr layer for the session
  127568. * @param xrSession xr session
  127569. * @returns a promise that will resolve once the XR Layer has been created
  127570. */
  127571. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127572. }
  127573. }
  127574. declare module BABYLON {
  127575. /**
  127576. * COnfiguration object for WebXR output canvas
  127577. */
  127578. export class WebXRManagedOutputCanvasOptions {
  127579. /**
  127580. * An optional canvas in case you wish to create it yourself and provide it here.
  127581. * If not provided, a new canvas will be created
  127582. */
  127583. canvasElement?: HTMLCanvasElement;
  127584. /**
  127585. * Options for this XR Layer output
  127586. */
  127587. canvasOptions?: XRWebGLLayerOptions;
  127588. /**
  127589. * CSS styling for a newly created canvas (if not provided)
  127590. */
  127591. newCanvasCssStyle?: string;
  127592. /**
  127593. * Get the default values of the configuration object
  127594. * @param engine defines the engine to use (can be null)
  127595. * @returns default values of this configuration object
  127596. */
  127597. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  127598. }
  127599. /**
  127600. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  127601. */
  127602. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  127603. private _options;
  127604. private _canvas;
  127605. private _engine;
  127606. private _originalCanvasSize;
  127607. /**
  127608. * Rendering context of the canvas which can be used to display/mirror xr content
  127609. */
  127610. canvasContext: WebGLRenderingContext;
  127611. /**
  127612. * xr layer for the canvas
  127613. */
  127614. xrLayer: Nullable<XRWebGLLayer>;
  127615. /**
  127616. * Obseervers registered here will be triggered when the xr layer was initialized
  127617. */
  127618. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  127619. /**
  127620. * Initializes the canvas to be added/removed upon entering/exiting xr
  127621. * @param _xrSessionManager The XR Session manager
  127622. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  127623. */
  127624. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  127625. /**
  127626. * Disposes of the object
  127627. */
  127628. dispose(): void;
  127629. /**
  127630. * Initializes the xr layer for the session
  127631. * @param xrSession xr session
  127632. * @returns a promise that will resolve once the XR Layer has been created
  127633. */
  127634. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127635. private _addCanvas;
  127636. private _removeCanvas;
  127637. private _setCanvasSize;
  127638. private _setManagedOutputCanvas;
  127639. }
  127640. }
  127641. declare module BABYLON {
  127642. /**
  127643. * Manages an XRSession to work with Babylon's engine
  127644. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  127645. */
  127646. export class WebXRSessionManager implements IDisposable {
  127647. /** The scene which the session should be created for */
  127648. scene: Scene;
  127649. private _referenceSpace;
  127650. private _rttProvider;
  127651. private _sessionEnded;
  127652. private _xrNavigator;
  127653. private baseLayer;
  127654. /**
  127655. * The base reference space from which the session started. good if you want to reset your
  127656. * reference space
  127657. */
  127658. baseReferenceSpace: XRReferenceSpace;
  127659. /**
  127660. * Current XR frame
  127661. */
  127662. currentFrame: Nullable<XRFrame>;
  127663. /** WebXR timestamp updated every frame */
  127664. currentTimestamp: number;
  127665. /**
  127666. * Used just in case of a failure to initialize an immersive session.
  127667. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  127668. */
  127669. defaultHeightCompensation: number;
  127670. /**
  127671. * Fires every time a new xrFrame arrives which can be used to update the camera
  127672. */
  127673. onXRFrameObservable: Observable<XRFrame>;
  127674. /**
  127675. * Fires when the reference space changed
  127676. */
  127677. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  127678. /**
  127679. * Fires when the xr session is ended either by the device or manually done
  127680. */
  127681. onXRSessionEnded: Observable<any>;
  127682. /**
  127683. * Fires when the xr session is ended either by the device or manually done
  127684. */
  127685. onXRSessionInit: Observable<XRSession>;
  127686. /**
  127687. * Underlying xr session
  127688. */
  127689. session: XRSession;
  127690. /**
  127691. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  127692. * or get the offset the player is currently at.
  127693. */
  127694. viewerReferenceSpace: XRReferenceSpace;
  127695. /**
  127696. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  127697. * @param scene The scene which the session should be created for
  127698. */
  127699. constructor(
  127700. /** The scene which the session should be created for */
  127701. scene: Scene);
  127702. /**
  127703. * The current reference space used in this session. This reference space can constantly change!
  127704. * It is mainly used to offset the camera's position.
  127705. */
  127706. get referenceSpace(): XRReferenceSpace;
  127707. /**
  127708. * Set a new reference space and triggers the observable
  127709. */
  127710. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  127711. /**
  127712. * Disposes of the session manager
  127713. */
  127714. dispose(): void;
  127715. /**
  127716. * Stops the xrSession and restores the render loop
  127717. * @returns Promise which resolves after it exits XR
  127718. */
  127719. exitXRAsync(): Promise<void>;
  127720. /**
  127721. * Gets the correct render target texture to be rendered this frame for this eye
  127722. * @param eye the eye for which to get the render target
  127723. * @returns the render target for the specified eye
  127724. */
  127725. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  127726. /**
  127727. * Creates a WebXRRenderTarget object for the XR session
  127728. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  127729. * @param options optional options to provide when creating a new render target
  127730. * @returns a WebXR render target to which the session can render
  127731. */
  127732. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  127733. /**
  127734. * Initializes the manager
  127735. * After initialization enterXR can be called to start an XR session
  127736. * @returns Promise which resolves after it is initialized
  127737. */
  127738. initializeAsync(): Promise<void>;
  127739. /**
  127740. * Initializes an xr session
  127741. * @param xrSessionMode mode to initialize
  127742. * @param xrSessionInit defines optional and required values to pass to the session builder
  127743. * @returns a promise which will resolve once the session has been initialized
  127744. */
  127745. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  127746. /**
  127747. * Checks if a session would be supported for the creation options specified
  127748. * @param sessionMode session mode to check if supported eg. immersive-vr
  127749. * @returns A Promise that resolves to true if supported and false if not
  127750. */
  127751. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127752. /**
  127753. * Resets the reference space to the one started the session
  127754. */
  127755. resetReferenceSpace(): void;
  127756. /**
  127757. * Starts rendering to the xr layer
  127758. */
  127759. runXRRenderLoop(): void;
  127760. /**
  127761. * Sets the reference space on the xr session
  127762. * @param referenceSpaceType space to set
  127763. * @returns a promise that will resolve once the reference space has been set
  127764. */
  127765. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  127766. /**
  127767. * Updates the render state of the session
  127768. * @param state state to set
  127769. * @returns a promise that resolves once the render state has been updated
  127770. */
  127771. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  127772. /**
  127773. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  127774. * @param sessionMode defines the session to test
  127775. * @returns a promise with boolean as final value
  127776. */
  127777. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127778. private _createRenderTargetTexture;
  127779. }
  127780. }
  127781. declare module BABYLON {
  127782. /**
  127783. * WebXR Camera which holds the views for the xrSession
  127784. * @see https://doc.babylonjs.com/how_to/webxr_camera
  127785. */
  127786. export class WebXRCamera extends FreeCamera {
  127787. private _xrSessionManager;
  127788. private _firstFrame;
  127789. private _referenceQuaternion;
  127790. private _referencedPosition;
  127791. private _xrInvPositionCache;
  127792. private _xrInvQuaternionCache;
  127793. /**
  127794. * Observable raised before camera teleportation
  127795. */
  127796. onBeforeCameraTeleport: Observable<Vector3>;
  127797. /**
  127798. * Observable raised after camera teleportation
  127799. */
  127800. onAfterCameraTeleport: Observable<Vector3>;
  127801. /**
  127802. * Should position compensation execute on first frame.
  127803. * This is used when copying the position from a native (non XR) camera
  127804. */
  127805. compensateOnFirstFrame: boolean;
  127806. /**
  127807. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  127808. * @param name the name of the camera
  127809. * @param scene the scene to add the camera to
  127810. * @param _xrSessionManager a constructed xr session manager
  127811. */
  127812. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  127813. /**
  127814. * Return the user's height, unrelated to the current ground.
  127815. * This will be the y position of this camera, when ground level is 0.
  127816. */
  127817. get realWorldHeight(): number;
  127818. /** @hidden */
  127819. _updateForDualEyeDebugging(): void;
  127820. /**
  127821. * Sets this camera's transformation based on a non-vr camera
  127822. * @param otherCamera the non-vr camera to copy the transformation from
  127823. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  127824. */
  127825. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  127826. /**
  127827. * Gets the current instance class name ("WebXRCamera").
  127828. * @returns the class name
  127829. */
  127830. getClassName(): string;
  127831. private _rotate180;
  127832. private _updateFromXRSession;
  127833. private _updateNumberOfRigCameras;
  127834. private _updateReferenceSpace;
  127835. private _updateReferenceSpaceOffset;
  127836. }
  127837. }
  127838. declare module BABYLON {
  127839. /**
  127840. * Defining the interface required for a (webxr) feature
  127841. */
  127842. export interface IWebXRFeature extends IDisposable {
  127843. /**
  127844. * Is this feature attached
  127845. */
  127846. attached: boolean;
  127847. /**
  127848. * Should auto-attach be disabled?
  127849. */
  127850. disableAutoAttach: boolean;
  127851. /**
  127852. * Attach the feature to the session
  127853. * Will usually be called by the features manager
  127854. *
  127855. * @param force should attachment be forced (even when already attached)
  127856. * @returns true if successful.
  127857. */
  127858. attach(force?: boolean): boolean;
  127859. /**
  127860. * Detach the feature from the session
  127861. * Will usually be called by the features manager
  127862. *
  127863. * @returns true if successful.
  127864. */
  127865. detach(): boolean;
  127866. /**
  127867. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127868. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127869. *
  127870. * @returns whether or not the feature is compatible in this environment
  127871. */
  127872. isCompatible(): boolean;
  127873. /**
  127874. * Was this feature disposed;
  127875. */
  127876. isDisposed: boolean;
  127877. /**
  127878. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  127879. */
  127880. xrNativeFeatureName?: string;
  127881. /**
  127882. * A list of (Babylon WebXR) features this feature depends on
  127883. */
  127884. dependsOn?: string[];
  127885. }
  127886. /**
  127887. * A list of the currently available features without referencing them
  127888. */
  127889. export class WebXRFeatureName {
  127890. /**
  127891. * The name of the anchor system feature
  127892. */
  127893. static readonly ANCHOR_SYSTEM: string;
  127894. /**
  127895. * The name of the background remover feature
  127896. */
  127897. static readonly BACKGROUND_REMOVER: string;
  127898. /**
  127899. * The name of the hit test feature
  127900. */
  127901. static readonly HIT_TEST: string;
  127902. /**
  127903. * physics impostors for xr controllers feature
  127904. */
  127905. static readonly PHYSICS_CONTROLLERS: string;
  127906. /**
  127907. * The name of the plane detection feature
  127908. */
  127909. static readonly PLANE_DETECTION: string;
  127910. /**
  127911. * The name of the pointer selection feature
  127912. */
  127913. static readonly POINTER_SELECTION: string;
  127914. /**
  127915. * The name of the teleportation feature
  127916. */
  127917. static readonly TELEPORTATION: string;
  127918. /**
  127919. * The name of the feature points feature.
  127920. */
  127921. static readonly FEATURE_POINTS: string;
  127922. /**
  127923. * The name of the hand tracking feature.
  127924. */
  127925. static readonly HAND_TRACKING: string;
  127926. }
  127927. /**
  127928. * Defining the constructor of a feature. Used to register the modules.
  127929. */
  127930. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  127931. /**
  127932. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  127933. * It is mainly used in AR sessions.
  127934. *
  127935. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  127936. */
  127937. export class WebXRFeaturesManager implements IDisposable {
  127938. private _xrSessionManager;
  127939. private static readonly _AvailableFeatures;
  127940. private _features;
  127941. /**
  127942. * constructs a new features manages.
  127943. *
  127944. * @param _xrSessionManager an instance of WebXRSessionManager
  127945. */
  127946. constructor(_xrSessionManager: WebXRSessionManager);
  127947. /**
  127948. * Used to register a module. After calling this function a developer can use this feature in the scene.
  127949. * Mainly used internally.
  127950. *
  127951. * @param featureName the name of the feature to register
  127952. * @param constructorFunction the function used to construct the module
  127953. * @param version the (babylon) version of the module
  127954. * @param stable is that a stable version of this module
  127955. */
  127956. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  127957. /**
  127958. * Returns a constructor of a specific feature.
  127959. *
  127960. * @param featureName the name of the feature to construct
  127961. * @param version the version of the feature to load
  127962. * @param xrSessionManager the xrSessionManager. Used to construct the module
  127963. * @param options optional options provided to the module.
  127964. * @returns a function that, when called, will return a new instance of this feature
  127965. */
  127966. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  127967. /**
  127968. * Can be used to return the list of features currently registered
  127969. *
  127970. * @returns an Array of available features
  127971. */
  127972. static GetAvailableFeatures(): string[];
  127973. /**
  127974. * Gets the versions available for a specific feature
  127975. * @param featureName the name of the feature
  127976. * @returns an array with the available versions
  127977. */
  127978. static GetAvailableVersions(featureName: string): string[];
  127979. /**
  127980. * Return the latest unstable version of this feature
  127981. * @param featureName the name of the feature to search
  127982. * @returns the version number. if not found will return -1
  127983. */
  127984. static GetLatestVersionOfFeature(featureName: string): number;
  127985. /**
  127986. * Return the latest stable version of this feature
  127987. * @param featureName the name of the feature to search
  127988. * @returns the version number. if not found will return -1
  127989. */
  127990. static GetStableVersionOfFeature(featureName: string): number;
  127991. /**
  127992. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127993. * Can be used during a session to start a feature
  127994. * @param featureName the name of feature to attach
  127995. */
  127996. attachFeature(featureName: string): void;
  127997. /**
  127998. * Can be used inside a session or when the session ends to detach a specific feature
  127999. * @param featureName the name of the feature to detach
  128000. */
  128001. detachFeature(featureName: string): void;
  128002. /**
  128003. * Used to disable an already-enabled feature
  128004. * The feature will be disposed and will be recreated once enabled.
  128005. * @param featureName the feature to disable
  128006. * @returns true if disable was successful
  128007. */
  128008. disableFeature(featureName: string | {
  128009. Name: string;
  128010. }): boolean;
  128011. /**
  128012. * dispose this features manager
  128013. */
  128014. dispose(): void;
  128015. /**
  128016. * 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.
  128017. * 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.
  128018. *
  128019. * @param featureName the name of the feature to load or the class of the feature
  128020. * @param version optional version to load. if not provided the latest version will be enabled
  128021. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  128022. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  128023. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  128024. * @returns a new constructed feature or throws an error if feature not found.
  128025. */
  128026. enableFeature(featureName: string | {
  128027. Name: string;
  128028. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  128029. /**
  128030. * get the implementation of an enabled feature.
  128031. * @param featureName the name of the feature to load
  128032. * @returns the feature class, if found
  128033. */
  128034. getEnabledFeature(featureName: string): IWebXRFeature;
  128035. /**
  128036. * Get the list of enabled features
  128037. * @returns an array of enabled features
  128038. */
  128039. getEnabledFeatures(): string[];
  128040. /**
  128041. * This function will exten the session creation configuration object with enabled features.
  128042. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  128043. * according to the defined "required" variable, provided during enableFeature call
  128044. * @param xrSessionInit the xr Session init object to extend
  128045. *
  128046. * @returns an extended XRSessionInit object
  128047. */
  128048. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  128049. }
  128050. }
  128051. declare module BABYLON {
  128052. /**
  128053. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  128054. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  128055. */
  128056. export class WebXRExperienceHelper implements IDisposable {
  128057. private scene;
  128058. private _nonVRCamera;
  128059. private _originalSceneAutoClear;
  128060. private _supported;
  128061. /**
  128062. * Camera used to render xr content
  128063. */
  128064. camera: WebXRCamera;
  128065. /** A features manager for this xr session */
  128066. featuresManager: WebXRFeaturesManager;
  128067. /**
  128068. * Observers registered here will be triggered after the camera's initial transformation is set
  128069. * This can be used to set a different ground level or an extra rotation.
  128070. *
  128071. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  128072. * to the position set after this observable is done executing.
  128073. */
  128074. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  128075. /**
  128076. * Fires when the state of the experience helper has changed
  128077. */
  128078. onStateChangedObservable: Observable<WebXRState>;
  128079. /** Session manager used to keep track of xr session */
  128080. sessionManager: WebXRSessionManager;
  128081. /**
  128082. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  128083. */
  128084. state: WebXRState;
  128085. /**
  128086. * Creates a WebXRExperienceHelper
  128087. * @param scene The scene the helper should be created in
  128088. */
  128089. private constructor();
  128090. /**
  128091. * Creates the experience helper
  128092. * @param scene the scene to attach the experience helper to
  128093. * @returns a promise for the experience helper
  128094. */
  128095. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  128096. /**
  128097. * Disposes of the experience helper
  128098. */
  128099. dispose(): void;
  128100. /**
  128101. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  128102. * @param sessionMode options for the XR session
  128103. * @param referenceSpaceType frame of reference of the XR session
  128104. * @param renderTarget the output canvas that will be used to enter XR mode
  128105. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  128106. * @returns promise that resolves after xr mode has entered
  128107. */
  128108. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  128109. /**
  128110. * Exits XR mode and returns the scene to its original state
  128111. * @returns promise that resolves after xr mode has exited
  128112. */
  128113. exitXRAsync(): Promise<void>;
  128114. private _nonXRToXRCamera;
  128115. private _setState;
  128116. }
  128117. }
  128118. declare module BABYLON {
  128119. /**
  128120. * X-Y values for axes in WebXR
  128121. */
  128122. export interface IWebXRMotionControllerAxesValue {
  128123. /**
  128124. * The value of the x axis
  128125. */
  128126. x: number;
  128127. /**
  128128. * The value of the y-axis
  128129. */
  128130. y: number;
  128131. }
  128132. /**
  128133. * changed / previous values for the values of this component
  128134. */
  128135. export interface IWebXRMotionControllerComponentChangesValues<T> {
  128136. /**
  128137. * current (this frame) value
  128138. */
  128139. current: T;
  128140. /**
  128141. * previous (last change) value
  128142. */
  128143. previous: T;
  128144. }
  128145. /**
  128146. * Represents changes in the component between current frame and last values recorded
  128147. */
  128148. export interface IWebXRMotionControllerComponentChanges {
  128149. /**
  128150. * will be populated with previous and current values if axes changed
  128151. */
  128152. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  128153. /**
  128154. * will be populated with previous and current values if pressed changed
  128155. */
  128156. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  128157. /**
  128158. * will be populated with previous and current values if touched changed
  128159. */
  128160. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  128161. /**
  128162. * will be populated with previous and current values if value changed
  128163. */
  128164. value?: IWebXRMotionControllerComponentChangesValues<number>;
  128165. }
  128166. /**
  128167. * This class represents a single component (for example button or thumbstick) of a motion controller
  128168. */
  128169. export class WebXRControllerComponent implements IDisposable {
  128170. /**
  128171. * the id of this component
  128172. */
  128173. id: string;
  128174. /**
  128175. * the type of the component
  128176. */
  128177. type: MotionControllerComponentType;
  128178. private _buttonIndex;
  128179. private _axesIndices;
  128180. private _axes;
  128181. private _changes;
  128182. private _currentValue;
  128183. private _hasChanges;
  128184. private _pressed;
  128185. private _touched;
  128186. /**
  128187. * button component type
  128188. */
  128189. static BUTTON_TYPE: MotionControllerComponentType;
  128190. /**
  128191. * squeeze component type
  128192. */
  128193. static SQUEEZE_TYPE: MotionControllerComponentType;
  128194. /**
  128195. * Thumbstick component type
  128196. */
  128197. static THUMBSTICK_TYPE: MotionControllerComponentType;
  128198. /**
  128199. * Touchpad component type
  128200. */
  128201. static TOUCHPAD_TYPE: MotionControllerComponentType;
  128202. /**
  128203. * trigger component type
  128204. */
  128205. static TRIGGER_TYPE: MotionControllerComponentType;
  128206. /**
  128207. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  128208. * the axes data changes
  128209. */
  128210. onAxisValueChangedObservable: Observable<{
  128211. x: number;
  128212. y: number;
  128213. }>;
  128214. /**
  128215. * Observers registered here will be triggered when the state of a button changes
  128216. * State change is either pressed / touched / value
  128217. */
  128218. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  128219. /**
  128220. * Creates a new component for a motion controller.
  128221. * It is created by the motion controller itself
  128222. *
  128223. * @param id the id of this component
  128224. * @param type the type of the component
  128225. * @param _buttonIndex index in the buttons array of the gamepad
  128226. * @param _axesIndices indices of the values in the axes array of the gamepad
  128227. */
  128228. constructor(
  128229. /**
  128230. * the id of this component
  128231. */
  128232. id: string,
  128233. /**
  128234. * the type of the component
  128235. */
  128236. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  128237. /**
  128238. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  128239. */
  128240. get axes(): IWebXRMotionControllerAxesValue;
  128241. /**
  128242. * Get the changes. Elements will be populated only if they changed with their previous and current value
  128243. */
  128244. get changes(): IWebXRMotionControllerComponentChanges;
  128245. /**
  128246. * Return whether or not the component changed the last frame
  128247. */
  128248. get hasChanges(): boolean;
  128249. /**
  128250. * is the button currently pressed
  128251. */
  128252. get pressed(): boolean;
  128253. /**
  128254. * is the button currently touched
  128255. */
  128256. get touched(): boolean;
  128257. /**
  128258. * Get the current value of this component
  128259. */
  128260. get value(): number;
  128261. /**
  128262. * Dispose this component
  128263. */
  128264. dispose(): void;
  128265. /**
  128266. * Are there axes correlating to this component
  128267. * @return true is axes data is available
  128268. */
  128269. isAxes(): boolean;
  128270. /**
  128271. * Is this component a button (hence - pressable)
  128272. * @returns true if can be pressed
  128273. */
  128274. isButton(): boolean;
  128275. /**
  128276. * update this component using the gamepad object it is in. Called on every frame
  128277. * @param nativeController the native gamepad controller object
  128278. */
  128279. update(nativeController: IMinimalMotionControllerObject): void;
  128280. }
  128281. }
  128282. declare module BABYLON {
  128283. /**
  128284. * Interface used to represent data loading progression
  128285. */
  128286. export interface ISceneLoaderProgressEvent {
  128287. /**
  128288. * Defines if data length to load can be evaluated
  128289. */
  128290. readonly lengthComputable: boolean;
  128291. /**
  128292. * Defines the loaded data length
  128293. */
  128294. readonly loaded: number;
  128295. /**
  128296. * Defines the data length to load
  128297. */
  128298. readonly total: number;
  128299. }
  128300. /**
  128301. * Interface used by SceneLoader plugins to define supported file extensions
  128302. */
  128303. export interface ISceneLoaderPluginExtensions {
  128304. /**
  128305. * Defines the list of supported extensions
  128306. */
  128307. [extension: string]: {
  128308. isBinary: boolean;
  128309. };
  128310. }
  128311. /**
  128312. * Interface used by SceneLoader plugin factory
  128313. */
  128314. export interface ISceneLoaderPluginFactory {
  128315. /**
  128316. * Defines the name of the factory
  128317. */
  128318. name: string;
  128319. /**
  128320. * Function called to create a new plugin
  128321. * @return the new plugin
  128322. */
  128323. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  128324. /**
  128325. * The callback that returns true if the data can be directly loaded.
  128326. * @param data string containing the file data
  128327. * @returns if the data can be loaded directly
  128328. */
  128329. canDirectLoad?(data: string): boolean;
  128330. }
  128331. /**
  128332. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  128333. */
  128334. export interface ISceneLoaderPluginBase {
  128335. /**
  128336. * The friendly name of this plugin.
  128337. */
  128338. name: string;
  128339. /**
  128340. * The file extensions supported by this plugin.
  128341. */
  128342. extensions: string | ISceneLoaderPluginExtensions;
  128343. /**
  128344. * The callback called when loading from a url.
  128345. * @param scene scene loading this url
  128346. * @param url url to load
  128347. * @param onSuccess callback called when the file successfully loads
  128348. * @param onProgress callback called while file is loading (if the server supports this mode)
  128349. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  128350. * @param onError callback called when the file fails to load
  128351. * @returns a file request object
  128352. */
  128353. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128354. /**
  128355. * The callback called when loading from a file object.
  128356. * @param scene scene loading this file
  128357. * @param file defines the file to load
  128358. * @param onSuccess defines the callback to call when data is loaded
  128359. * @param onProgress defines the callback to call during loading process
  128360. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  128361. * @param onError defines the callback to call when an error occurs
  128362. * @returns a file request object
  128363. */
  128364. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128365. /**
  128366. * The callback that returns true if the data can be directly loaded.
  128367. * @param data string containing the file data
  128368. * @returns if the data can be loaded directly
  128369. */
  128370. canDirectLoad?(data: string): boolean;
  128371. /**
  128372. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  128373. * @param scene scene loading this data
  128374. * @param data string containing the data
  128375. * @returns data to pass to the plugin
  128376. */
  128377. directLoad?(scene: Scene, data: string): any;
  128378. /**
  128379. * The callback that allows custom handling of the root url based on the response url.
  128380. * @param rootUrl the original root url
  128381. * @param responseURL the response url if available
  128382. * @returns the new root url
  128383. */
  128384. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  128385. }
  128386. /**
  128387. * Interface used to define a SceneLoader plugin
  128388. */
  128389. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  128390. /**
  128391. * Import meshes into a scene.
  128392. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128393. * @param scene The scene to import into
  128394. * @param data The data to import
  128395. * @param rootUrl The root url for scene and resources
  128396. * @param meshes The meshes array to import into
  128397. * @param particleSystems The particle systems array to import into
  128398. * @param skeletons The skeletons array to import into
  128399. * @param onError The callback when import fails
  128400. * @returns True if successful or false otherwise
  128401. */
  128402. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  128403. /**
  128404. * Load into a scene.
  128405. * @param scene The scene to load into
  128406. * @param data The data to import
  128407. * @param rootUrl The root url for scene and resources
  128408. * @param onError The callback when import fails
  128409. * @returns True if successful or false otherwise
  128410. */
  128411. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  128412. /**
  128413. * Load into an asset container.
  128414. * @param scene The scene to load into
  128415. * @param data The data to import
  128416. * @param rootUrl The root url for scene and resources
  128417. * @param onError The callback when import fails
  128418. * @returns The loaded asset container
  128419. */
  128420. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  128421. }
  128422. /**
  128423. * Interface used to define an async SceneLoader plugin
  128424. */
  128425. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  128426. /**
  128427. * Import meshes into a scene.
  128428. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128429. * @param scene The scene to import into
  128430. * @param data The data to import
  128431. * @param rootUrl The root url for scene and resources
  128432. * @param onProgress The callback when the load progresses
  128433. * @param fileName Defines the name of the file to load
  128434. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  128435. */
  128436. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  128437. meshes: AbstractMesh[];
  128438. particleSystems: IParticleSystem[];
  128439. skeletons: Skeleton[];
  128440. animationGroups: AnimationGroup[];
  128441. }>;
  128442. /**
  128443. * Load into a scene.
  128444. * @param scene The scene to load into
  128445. * @param data The data to import
  128446. * @param rootUrl The root url for scene and resources
  128447. * @param onProgress The callback when the load progresses
  128448. * @param fileName Defines the name of the file to load
  128449. * @returns Nothing
  128450. */
  128451. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  128452. /**
  128453. * Load into an asset container.
  128454. * @param scene The scene to load into
  128455. * @param data The data to import
  128456. * @param rootUrl The root url for scene and resources
  128457. * @param onProgress The callback when the load progresses
  128458. * @param fileName Defines the name of the file to load
  128459. * @returns The loaded asset container
  128460. */
  128461. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  128462. }
  128463. /**
  128464. * Mode that determines how to handle old animation groups before loading new ones.
  128465. */
  128466. export enum SceneLoaderAnimationGroupLoadingMode {
  128467. /**
  128468. * Reset all old animations to initial state then dispose them.
  128469. */
  128470. Clean = 0,
  128471. /**
  128472. * Stop all old animations.
  128473. */
  128474. Stop = 1,
  128475. /**
  128476. * Restart old animations from first frame.
  128477. */
  128478. Sync = 2,
  128479. /**
  128480. * Old animations remains untouched.
  128481. */
  128482. NoSync = 3
  128483. }
  128484. /**
  128485. * Defines a plugin registered by the SceneLoader
  128486. */
  128487. interface IRegisteredPlugin {
  128488. /**
  128489. * Defines the plugin to use
  128490. */
  128491. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128492. /**
  128493. * Defines if the plugin supports binary data
  128494. */
  128495. isBinary: boolean;
  128496. }
  128497. /**
  128498. * Class used to load scene from various file formats using registered plugins
  128499. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  128500. */
  128501. export class SceneLoader {
  128502. /**
  128503. * No logging while loading
  128504. */
  128505. static readonly NO_LOGGING: number;
  128506. /**
  128507. * Minimal logging while loading
  128508. */
  128509. static readonly MINIMAL_LOGGING: number;
  128510. /**
  128511. * Summary logging while loading
  128512. */
  128513. static readonly SUMMARY_LOGGING: number;
  128514. /**
  128515. * Detailled logging while loading
  128516. */
  128517. static readonly DETAILED_LOGGING: number;
  128518. /**
  128519. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  128520. */
  128521. static get ForceFullSceneLoadingForIncremental(): boolean;
  128522. static set ForceFullSceneLoadingForIncremental(value: boolean);
  128523. /**
  128524. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  128525. */
  128526. static get ShowLoadingScreen(): boolean;
  128527. static set ShowLoadingScreen(value: boolean);
  128528. /**
  128529. * Defines the current logging level (while loading the scene)
  128530. * @ignorenaming
  128531. */
  128532. static get loggingLevel(): number;
  128533. static set loggingLevel(value: number);
  128534. /**
  128535. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  128536. */
  128537. static get CleanBoneMatrixWeights(): boolean;
  128538. static set CleanBoneMatrixWeights(value: boolean);
  128539. /**
  128540. * Event raised when a plugin is used to load a scene
  128541. */
  128542. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  128543. private static _registeredPlugins;
  128544. private static _showingLoadingScreen;
  128545. /**
  128546. * Gets the default plugin (used to load Babylon files)
  128547. * @returns the .babylon plugin
  128548. */
  128549. static GetDefaultPlugin(): IRegisteredPlugin;
  128550. private static _GetPluginForExtension;
  128551. private static _GetPluginForDirectLoad;
  128552. private static _GetPluginForFilename;
  128553. private static _GetDirectLoad;
  128554. private static _LoadData;
  128555. private static _GetFileInfo;
  128556. /**
  128557. * Gets a plugin that can load the given extension
  128558. * @param extension defines the extension to load
  128559. * @returns a plugin or null if none works
  128560. */
  128561. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128562. /**
  128563. * Gets a boolean indicating that the given extension can be loaded
  128564. * @param extension defines the extension to load
  128565. * @returns true if the extension is supported
  128566. */
  128567. static IsPluginForExtensionAvailable(extension: string): boolean;
  128568. /**
  128569. * Adds a new plugin to the list of registered plugins
  128570. * @param plugin defines the plugin to add
  128571. */
  128572. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  128573. /**
  128574. * Import meshes into a scene
  128575. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128576. * @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)
  128577. * @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)
  128578. * @param scene the instance of BABYLON.Scene to append to
  128579. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  128580. * @param onProgress a callback with a progress event for each file being loaded
  128581. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128582. * @param pluginExtension the extension used to determine the plugin
  128583. * @returns The loaded plugin
  128584. */
  128585. 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>;
  128586. /**
  128587. * Import meshes into a scene
  128588. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128589. * @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)
  128590. * @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)
  128591. * @param scene the instance of BABYLON.Scene to append to
  128592. * @param onProgress a callback with a progress event for each file being loaded
  128593. * @param pluginExtension the extension used to determine the plugin
  128594. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  128595. */
  128596. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  128597. meshes: AbstractMesh[];
  128598. particleSystems: IParticleSystem[];
  128599. skeletons: Skeleton[];
  128600. animationGroups: AnimationGroup[];
  128601. }>;
  128602. /**
  128603. * Load a scene
  128604. * @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)
  128605. * @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)
  128606. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128607. * @param onSuccess a callback with the scene when import succeeds
  128608. * @param onProgress a callback with a progress event for each file being loaded
  128609. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128610. * @param pluginExtension the extension used to determine the plugin
  128611. * @returns The loaded plugin
  128612. */
  128613. 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>;
  128614. /**
  128615. * Load a scene
  128616. * @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)
  128617. * @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)
  128618. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128619. * @param onProgress a callback with a progress event for each file being loaded
  128620. * @param pluginExtension the extension used to determine the plugin
  128621. * @returns The loaded scene
  128622. */
  128623. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128624. /**
  128625. * Append a scene
  128626. * @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)
  128627. * @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)
  128628. * @param scene is the instance of BABYLON.Scene to append to
  128629. * @param onSuccess a callback with the scene when import succeeds
  128630. * @param onProgress a callback with a progress event for each file being loaded
  128631. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128632. * @param pluginExtension the extension used to determine the plugin
  128633. * @returns The loaded plugin
  128634. */
  128635. 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>;
  128636. /**
  128637. * Append a scene
  128638. * @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)
  128639. * @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)
  128640. * @param scene is the instance of BABYLON.Scene to append to
  128641. * @param onProgress a callback with a progress event for each file being loaded
  128642. * @param pluginExtension the extension used to determine the plugin
  128643. * @returns The given scene
  128644. */
  128645. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128646. /**
  128647. * Load a scene into an asset container
  128648. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  128649. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  128650. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128651. * @param onSuccess a callback with the scene when import succeeds
  128652. * @param onProgress a callback with a progress event for each file being loaded
  128653. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128654. * @param pluginExtension the extension used to determine the plugin
  128655. * @returns The loaded plugin
  128656. */
  128657. 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>;
  128658. /**
  128659. * Load a scene into an asset container
  128660. * @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)
  128661. * @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)
  128662. * @param scene is the instance of Scene to append to
  128663. * @param onProgress a callback with a progress event for each file being loaded
  128664. * @param pluginExtension the extension used to determine the plugin
  128665. * @returns The loaded asset container
  128666. */
  128667. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  128668. /**
  128669. * Import animations from a file into a scene
  128670. * @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)
  128671. * @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)
  128672. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128673. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128674. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128675. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128676. * @param onSuccess a callback with the scene when import succeeds
  128677. * @param onProgress a callback with a progress event for each file being loaded
  128678. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128679. * @param pluginExtension the extension used to determine the plugin
  128680. */
  128681. 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;
  128682. /**
  128683. * Import animations from a file into a scene
  128684. * @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)
  128685. * @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)
  128686. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128687. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128688. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128689. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128690. * @param onSuccess a callback with the scene when import succeeds
  128691. * @param onProgress a callback with a progress event for each file being loaded
  128692. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128693. * @param pluginExtension the extension used to determine the plugin
  128694. * @returns the updated scene with imported animations
  128695. */
  128696. 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>;
  128697. }
  128698. }
  128699. declare module BABYLON {
  128700. /**
  128701. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  128702. */
  128703. export type MotionControllerHandedness = "none" | "left" | "right";
  128704. /**
  128705. * The type of components available in motion controllers.
  128706. * This is not the name of the component.
  128707. */
  128708. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  128709. /**
  128710. * The state of a controller component
  128711. */
  128712. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  128713. /**
  128714. * The schema of motion controller layout.
  128715. * No object will be initialized using this interface
  128716. * This is used just to define the profile.
  128717. */
  128718. export interface IMotionControllerLayout {
  128719. /**
  128720. * Path to load the assets. Usually relative to the base path
  128721. */
  128722. assetPath: string;
  128723. /**
  128724. * Available components (unsorted)
  128725. */
  128726. components: {
  128727. /**
  128728. * A map of component Ids
  128729. */
  128730. [componentId: string]: {
  128731. /**
  128732. * The type of input the component outputs
  128733. */
  128734. type: MotionControllerComponentType;
  128735. /**
  128736. * The indices of this component in the gamepad object
  128737. */
  128738. gamepadIndices: {
  128739. /**
  128740. * Index of button
  128741. */
  128742. button?: number;
  128743. /**
  128744. * If available, index of x-axis
  128745. */
  128746. xAxis?: number;
  128747. /**
  128748. * If available, index of y-axis
  128749. */
  128750. yAxis?: number;
  128751. };
  128752. /**
  128753. * The mesh's root node name
  128754. */
  128755. rootNodeName: string;
  128756. /**
  128757. * Animation definitions for this model
  128758. */
  128759. visualResponses: {
  128760. [stateKey: string]: {
  128761. /**
  128762. * What property will be animated
  128763. */
  128764. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  128765. /**
  128766. * What states influence this visual response
  128767. */
  128768. states: MotionControllerComponentStateType[];
  128769. /**
  128770. * Type of animation - movement or visibility
  128771. */
  128772. valueNodeProperty: "transform" | "visibility";
  128773. /**
  128774. * Base node name to move. Its position will be calculated according to the min and max nodes
  128775. */
  128776. valueNodeName?: string;
  128777. /**
  128778. * Minimum movement node
  128779. */
  128780. minNodeName?: string;
  128781. /**
  128782. * Max movement node
  128783. */
  128784. maxNodeName?: string;
  128785. };
  128786. };
  128787. /**
  128788. * If touch enabled, what is the name of node to display user feedback
  128789. */
  128790. touchPointNodeName?: string;
  128791. };
  128792. };
  128793. /**
  128794. * Is it xr standard mapping or not
  128795. */
  128796. gamepadMapping: "" | "xr-standard";
  128797. /**
  128798. * Base root node of this entire model
  128799. */
  128800. rootNodeName: string;
  128801. /**
  128802. * Defines the main button component id
  128803. */
  128804. selectComponentId: string;
  128805. }
  128806. /**
  128807. * A definition for the layout map in the input profile
  128808. */
  128809. export interface IMotionControllerLayoutMap {
  128810. /**
  128811. * Layouts with handedness type as a key
  128812. */
  128813. [handedness: string]: IMotionControllerLayout;
  128814. }
  128815. /**
  128816. * The XR Input profile schema
  128817. * Profiles can be found here:
  128818. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  128819. */
  128820. export interface IMotionControllerProfile {
  128821. /**
  128822. * fallback profiles for this profileId
  128823. */
  128824. fallbackProfileIds: string[];
  128825. /**
  128826. * The layout map, with handedness as key
  128827. */
  128828. layouts: IMotionControllerLayoutMap;
  128829. /**
  128830. * The id of this profile
  128831. * correlates to the profile(s) in the xrInput.profiles array
  128832. */
  128833. profileId: string;
  128834. }
  128835. /**
  128836. * A helper-interface for the 3 meshes needed for controller button animation
  128837. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  128838. */
  128839. export interface IMotionControllerButtonMeshMap {
  128840. /**
  128841. * the mesh that defines the pressed value mesh position.
  128842. * This is used to find the max-position of this button
  128843. */
  128844. pressedMesh: AbstractMesh;
  128845. /**
  128846. * the mesh that defines the unpressed value mesh position.
  128847. * This is used to find the min (or initial) position of this button
  128848. */
  128849. unpressedMesh: AbstractMesh;
  128850. /**
  128851. * The mesh that will be changed when value changes
  128852. */
  128853. valueMesh: AbstractMesh;
  128854. }
  128855. /**
  128856. * A helper-interface for the 3 meshes needed for controller axis animation.
  128857. * This will be expanded when touchpad animations are fully supported
  128858. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  128859. */
  128860. export interface IMotionControllerMeshMap {
  128861. /**
  128862. * the mesh that defines the maximum value mesh position.
  128863. */
  128864. maxMesh?: AbstractMesh;
  128865. /**
  128866. * the mesh that defines the minimum value mesh position.
  128867. */
  128868. minMesh?: AbstractMesh;
  128869. /**
  128870. * The mesh that will be changed when axis value changes
  128871. */
  128872. valueMesh?: AbstractMesh;
  128873. }
  128874. /**
  128875. * The elements needed for change-detection of the gamepad objects in motion controllers
  128876. */
  128877. export interface IMinimalMotionControllerObject {
  128878. /**
  128879. * Available axes of this controller
  128880. */
  128881. axes: number[];
  128882. /**
  128883. * An array of available buttons
  128884. */
  128885. buttons: Array<{
  128886. /**
  128887. * Value of the button/trigger
  128888. */
  128889. value: number;
  128890. /**
  128891. * If the button/trigger is currently touched
  128892. */
  128893. touched: boolean;
  128894. /**
  128895. * If the button/trigger is currently pressed
  128896. */
  128897. pressed: boolean;
  128898. }>;
  128899. /**
  128900. * EXPERIMENTAL haptic support.
  128901. */
  128902. hapticActuators?: Array<{
  128903. pulse: (value: number, duration: number) => Promise<boolean>;
  128904. }>;
  128905. }
  128906. /**
  128907. * An Abstract Motion controller
  128908. * This class receives an xrInput and a profile layout and uses those to initialize the components
  128909. * Each component has an observable to check for changes in value and state
  128910. */
  128911. export abstract class WebXRAbstractMotionController implements IDisposable {
  128912. protected scene: Scene;
  128913. protected layout: IMotionControllerLayout;
  128914. /**
  128915. * The gamepad object correlating to this controller
  128916. */
  128917. gamepadObject: IMinimalMotionControllerObject;
  128918. /**
  128919. * handedness (left/right/none) of this controller
  128920. */
  128921. handedness: MotionControllerHandedness;
  128922. private _initComponent;
  128923. private _modelReady;
  128924. /**
  128925. * A map of components (WebXRControllerComponent) in this motion controller
  128926. * Components have a ComponentType and can also have both button and axis definitions
  128927. */
  128928. readonly components: {
  128929. [id: string]: WebXRControllerComponent;
  128930. };
  128931. /**
  128932. * Disable the model's animation. Can be set at any time.
  128933. */
  128934. disableAnimation: boolean;
  128935. /**
  128936. * Observers registered here will be triggered when the model of this controller is done loading
  128937. */
  128938. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  128939. /**
  128940. * The profile id of this motion controller
  128941. */
  128942. abstract profileId: string;
  128943. /**
  128944. * The root mesh of the model. It is null if the model was not yet initialized
  128945. */
  128946. rootMesh: Nullable<AbstractMesh>;
  128947. /**
  128948. * constructs a new abstract motion controller
  128949. * @param scene the scene to which the model of the controller will be added
  128950. * @param layout The profile layout to load
  128951. * @param gamepadObject The gamepad object correlating to this controller
  128952. * @param handedness handedness (left/right/none) of this controller
  128953. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  128954. */
  128955. constructor(scene: Scene, layout: IMotionControllerLayout,
  128956. /**
  128957. * The gamepad object correlating to this controller
  128958. */
  128959. gamepadObject: IMinimalMotionControllerObject,
  128960. /**
  128961. * handedness (left/right/none) of this controller
  128962. */
  128963. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  128964. /**
  128965. * Dispose this controller, the model mesh and all its components
  128966. */
  128967. dispose(): void;
  128968. /**
  128969. * Returns all components of specific type
  128970. * @param type the type to search for
  128971. * @return an array of components with this type
  128972. */
  128973. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128974. /**
  128975. * get a component based an its component id as defined in layout.components
  128976. * @param id the id of the component
  128977. * @returns the component correlates to the id or undefined if not found
  128978. */
  128979. getComponent(id: string): WebXRControllerComponent;
  128980. /**
  128981. * Get the list of components available in this motion controller
  128982. * @returns an array of strings correlating to available components
  128983. */
  128984. getComponentIds(): string[];
  128985. /**
  128986. * Get the first component of specific type
  128987. * @param type type of component to find
  128988. * @return a controller component or null if not found
  128989. */
  128990. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128991. /**
  128992. * Get the main (Select) component of this controller as defined in the layout
  128993. * @returns the main component of this controller
  128994. */
  128995. getMainComponent(): WebXRControllerComponent;
  128996. /**
  128997. * Loads the model correlating to this controller
  128998. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128999. * @returns A promise fulfilled with the result of the model loading
  129000. */
  129001. loadModel(): Promise<boolean>;
  129002. /**
  129003. * Update this model using the current XRFrame
  129004. * @param xrFrame the current xr frame to use and update the model
  129005. */
  129006. updateFromXRFrame(xrFrame: XRFrame): void;
  129007. /**
  129008. * Backwards compatibility due to a deeply-integrated typo
  129009. */
  129010. get handness(): XREye;
  129011. /**
  129012. * Pulse (vibrate) this controller
  129013. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  129014. * Consecutive calls to this function will cancel the last pulse call
  129015. *
  129016. * @param value the strength of the pulse in 0.0...1.0 range
  129017. * @param duration Duration of the pulse in milliseconds
  129018. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  129019. * @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
  129020. */
  129021. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  129022. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  129023. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  129024. /**
  129025. * Moves the axis on the controller mesh based on its current state
  129026. * @param axis the index of the axis
  129027. * @param axisValue the value of the axis which determines the meshes new position
  129028. * @hidden
  129029. */
  129030. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  129031. /**
  129032. * Update the model itself with the current frame data
  129033. * @param xrFrame the frame to use for updating the model mesh
  129034. */
  129035. protected updateModel(xrFrame: XRFrame): void;
  129036. /**
  129037. * Get the filename and path for this controller's model
  129038. * @returns a map of filename and path
  129039. */
  129040. protected abstract _getFilenameAndPath(): {
  129041. filename: string;
  129042. path: string;
  129043. };
  129044. /**
  129045. * This function is called before the mesh is loaded. It checks for loading constraints.
  129046. * For example, this function can check if the GLB loader is available
  129047. * If this function returns false, the generic controller will be loaded instead
  129048. * @returns Is the client ready to load the mesh
  129049. */
  129050. protected abstract _getModelLoadingConstraints(): boolean;
  129051. /**
  129052. * This function will be called after the model was successfully loaded and can be used
  129053. * for mesh transformations before it is available for the user
  129054. * @param meshes the loaded meshes
  129055. */
  129056. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  129057. /**
  129058. * Set the root mesh for this controller. Important for the WebXR controller class
  129059. * @param meshes the loaded meshes
  129060. */
  129061. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  129062. /**
  129063. * A function executed each frame that updates the mesh (if needed)
  129064. * @param xrFrame the current xrFrame
  129065. */
  129066. protected abstract _updateModel(xrFrame: XRFrame): void;
  129067. private _getGenericFilenameAndPath;
  129068. private _getGenericParentMesh;
  129069. }
  129070. }
  129071. declare module BABYLON {
  129072. /**
  129073. * A generic trigger-only motion controller for WebXR
  129074. */
  129075. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  129076. /**
  129077. * Static version of the profile id of this controller
  129078. */
  129079. static ProfileId: string;
  129080. profileId: string;
  129081. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  129082. protected _getFilenameAndPath(): {
  129083. filename: string;
  129084. path: string;
  129085. };
  129086. protected _getModelLoadingConstraints(): boolean;
  129087. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  129088. protected _setRootMesh(meshes: AbstractMesh[]): void;
  129089. protected _updateModel(): void;
  129090. }
  129091. }
  129092. declare module BABYLON {
  129093. /**
  129094. * Class containing static functions to help procedurally build meshes
  129095. */
  129096. export class SphereBuilder {
  129097. /**
  129098. * Creates a sphere mesh
  129099. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  129100. * * 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`)
  129101. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  129102. * * 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
  129103. * * 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)
  129104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129107. * @param name defines the name of the mesh
  129108. * @param options defines the options used to create the mesh
  129109. * @param scene defines the hosting scene
  129110. * @returns the sphere mesh
  129111. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  129112. */
  129113. static CreateSphere(name: string, options: {
  129114. segments?: number;
  129115. diameter?: number;
  129116. diameterX?: number;
  129117. diameterY?: number;
  129118. diameterZ?: number;
  129119. arc?: number;
  129120. slice?: number;
  129121. sideOrientation?: number;
  129122. frontUVs?: Vector4;
  129123. backUVs?: Vector4;
  129124. updatable?: boolean;
  129125. }, scene?: Nullable<Scene>): Mesh;
  129126. }
  129127. }
  129128. declare module BABYLON {
  129129. /**
  129130. * A profiled motion controller has its profile loaded from an online repository.
  129131. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  129132. */
  129133. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  129134. private _repositoryUrl;
  129135. private _buttonMeshMapping;
  129136. private _touchDots;
  129137. /**
  129138. * The profile ID of this controller. Will be populated when the controller initializes.
  129139. */
  129140. profileId: string;
  129141. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  129142. dispose(): void;
  129143. protected _getFilenameAndPath(): {
  129144. filename: string;
  129145. path: string;
  129146. };
  129147. protected _getModelLoadingConstraints(): boolean;
  129148. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  129149. protected _setRootMesh(meshes: AbstractMesh[]): void;
  129150. protected _updateModel(_xrFrame: XRFrame): void;
  129151. }
  129152. }
  129153. declare module BABYLON {
  129154. /**
  129155. * A construction function type to create a new controller based on an xrInput object
  129156. */
  129157. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  129158. /**
  129159. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  129160. *
  129161. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  129162. * it should be replaced with auto-loaded controllers.
  129163. *
  129164. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  129165. */
  129166. export class WebXRMotionControllerManager {
  129167. private static _AvailableControllers;
  129168. private static _Fallbacks;
  129169. private static _ProfileLoadingPromises;
  129170. private static _ProfilesList;
  129171. /**
  129172. * The base URL of the online controller repository. Can be changed at any time.
  129173. */
  129174. static BaseRepositoryUrl: string;
  129175. /**
  129176. * Which repository gets priority - local or online
  129177. */
  129178. static PrioritizeOnlineRepository: boolean;
  129179. /**
  129180. * Use the online repository, or use only locally-defined controllers
  129181. */
  129182. static UseOnlineRepository: boolean;
  129183. /**
  129184. * Clear the cache used for profile loading and reload when requested again
  129185. */
  129186. static ClearProfilesCache(): void;
  129187. /**
  129188. * Register the default fallbacks.
  129189. * This function is called automatically when this file is imported.
  129190. */
  129191. static DefaultFallbacks(): void;
  129192. /**
  129193. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  129194. * @param profileId the profile to which a fallback needs to be found
  129195. * @return an array with corresponding fallback profiles
  129196. */
  129197. static FindFallbackWithProfileId(profileId: string): string[];
  129198. /**
  129199. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  129200. * The order of search:
  129201. *
  129202. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  129203. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  129204. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  129205. * 4) return the generic trigger controller if none were found
  129206. *
  129207. * @param xrInput the xrInput to which a new controller is initialized
  129208. * @param scene the scene to which the model will be added
  129209. * @param forceProfile force a certain profile for this controller
  129210. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  129211. */
  129212. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  129213. /**
  129214. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  129215. *
  129216. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  129217. *
  129218. * @param type the profile type to register
  129219. * @param constructFunction the function to be called when loading this profile
  129220. */
  129221. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  129222. /**
  129223. * Register a fallback to a specific profile.
  129224. * @param profileId the profileId that will receive the fallbacks
  129225. * @param fallbacks A list of fallback profiles
  129226. */
  129227. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  129228. /**
  129229. * Will update the list of profiles available in the repository
  129230. * @return a promise that resolves to a map of profiles available online
  129231. */
  129232. static UpdateProfilesList(): Promise<{
  129233. [profile: string]: string;
  129234. }>;
  129235. private static _LoadProfileFromRepository;
  129236. private static _LoadProfilesFromAvailableControllers;
  129237. }
  129238. }
  129239. declare module BABYLON {
  129240. /**
  129241. * Configuration options for the WebXR controller creation
  129242. */
  129243. export interface IWebXRControllerOptions {
  129244. /**
  129245. * Should the controller mesh be animated when a user interacts with it
  129246. * The pressed buttons / thumbstick and touchpad animations will be disabled
  129247. */
  129248. disableMotionControllerAnimation?: boolean;
  129249. /**
  129250. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  129251. */
  129252. doNotLoadControllerMesh?: boolean;
  129253. /**
  129254. * Force a specific controller type for this controller.
  129255. * This can be used when creating your own profile or when testing different controllers
  129256. */
  129257. forceControllerProfile?: string;
  129258. /**
  129259. * Defines a rendering group ID for meshes that will be loaded.
  129260. * This is for the default controllers only.
  129261. */
  129262. renderingGroupId?: number;
  129263. }
  129264. /**
  129265. * Represents an XR controller
  129266. */
  129267. export class WebXRInputSource {
  129268. private _scene;
  129269. /** The underlying input source for the controller */
  129270. inputSource: XRInputSource;
  129271. private _options;
  129272. private _tmpVector;
  129273. private _uniqueId;
  129274. private _disposed;
  129275. /**
  129276. * 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
  129277. */
  129278. grip?: AbstractMesh;
  129279. /**
  129280. * If available, this is the gamepad object related to this controller.
  129281. * Using this object it is possible to get click events and trackpad changes of the
  129282. * webxr controller that is currently being used.
  129283. */
  129284. motionController?: WebXRAbstractMotionController;
  129285. /**
  129286. * Event that fires when the controller is removed/disposed.
  129287. * The object provided as event data is this controller, after associated assets were disposed.
  129288. * uniqueId is still available.
  129289. */
  129290. onDisposeObservable: Observable<WebXRInputSource>;
  129291. /**
  129292. * Will be triggered when the mesh associated with the motion controller is done loading.
  129293. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  129294. * A shortened version of controller -> motion controller -> on mesh loaded.
  129295. */
  129296. onMeshLoadedObservable: Observable<AbstractMesh>;
  129297. /**
  129298. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  129299. */
  129300. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  129301. /**
  129302. * Pointer which can be used to select objects or attach a visible laser to
  129303. */
  129304. pointer: AbstractMesh;
  129305. /**
  129306. * Creates the input source object
  129307. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  129308. * @param _scene the scene which the controller should be associated to
  129309. * @param inputSource the underlying input source for the controller
  129310. * @param _options options for this controller creation
  129311. */
  129312. constructor(_scene: Scene,
  129313. /** The underlying input source for the controller */
  129314. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  129315. /**
  129316. * Get this controllers unique id
  129317. */
  129318. get uniqueId(): string;
  129319. /**
  129320. * Disposes of the object
  129321. */
  129322. dispose(): void;
  129323. /**
  129324. * Gets a world space ray coming from the pointer or grip
  129325. * @param result the resulting ray
  129326. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  129327. */
  129328. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  129329. /**
  129330. * Updates the controller pose based on the given XRFrame
  129331. * @param xrFrame xr frame to update the pose with
  129332. * @param referenceSpace reference space to use
  129333. */
  129334. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  129335. }
  129336. }
  129337. declare module BABYLON {
  129338. /**
  129339. * The schema for initialization options of the XR Input class
  129340. */
  129341. export interface IWebXRInputOptions {
  129342. /**
  129343. * If set to true no model will be automatically loaded
  129344. */
  129345. doNotLoadControllerMeshes?: boolean;
  129346. /**
  129347. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  129348. * If not found, the xr input profile data will be used.
  129349. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  129350. */
  129351. forceInputProfile?: string;
  129352. /**
  129353. * Do not send a request to the controller repository to load the profile.
  129354. *
  129355. * Instead, use the controllers available in babylon itself.
  129356. */
  129357. disableOnlineControllerRepository?: boolean;
  129358. /**
  129359. * A custom URL for the controllers repository
  129360. */
  129361. customControllersRepositoryURL?: string;
  129362. /**
  129363. * Should the controller model's components not move according to the user input
  129364. */
  129365. disableControllerAnimation?: boolean;
  129366. /**
  129367. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  129368. */
  129369. controllerOptions?: IWebXRControllerOptions;
  129370. }
  129371. /**
  129372. * XR input used to track XR inputs such as controllers/rays
  129373. */
  129374. export class WebXRInput implements IDisposable {
  129375. /**
  129376. * the xr session manager for this session
  129377. */
  129378. xrSessionManager: WebXRSessionManager;
  129379. /**
  129380. * the WebXR camera for this session. Mainly used for teleportation
  129381. */
  129382. xrCamera: WebXRCamera;
  129383. private readonly options;
  129384. /**
  129385. * XR controllers being tracked
  129386. */
  129387. controllers: Array<WebXRInputSource>;
  129388. private _frameObserver;
  129389. private _sessionEndedObserver;
  129390. private _sessionInitObserver;
  129391. /**
  129392. * Event when a controller has been connected/added
  129393. */
  129394. onControllerAddedObservable: Observable<WebXRInputSource>;
  129395. /**
  129396. * Event when a controller has been removed/disconnected
  129397. */
  129398. onControllerRemovedObservable: Observable<WebXRInputSource>;
  129399. /**
  129400. * Initializes the WebXRInput
  129401. * @param xrSessionManager the xr session manager for this session
  129402. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  129403. * @param options = initialization options for this xr input
  129404. */
  129405. constructor(
  129406. /**
  129407. * the xr session manager for this session
  129408. */
  129409. xrSessionManager: WebXRSessionManager,
  129410. /**
  129411. * the WebXR camera for this session. Mainly used for teleportation
  129412. */
  129413. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  129414. private _onInputSourcesChange;
  129415. private _addAndRemoveControllers;
  129416. /**
  129417. * Disposes of the object
  129418. */
  129419. dispose(): void;
  129420. }
  129421. }
  129422. declare module BABYLON {
  129423. /**
  129424. * This is the base class for all WebXR features.
  129425. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  129426. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  129427. */
  129428. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  129429. protected _xrSessionManager: WebXRSessionManager;
  129430. private _attached;
  129431. private _removeOnDetach;
  129432. /**
  129433. * Is this feature disposed?
  129434. */
  129435. isDisposed: boolean;
  129436. /**
  129437. * Should auto-attach be disabled?
  129438. */
  129439. disableAutoAttach: boolean;
  129440. /**
  129441. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  129442. */
  129443. xrNativeFeatureName: string;
  129444. /**
  129445. * Construct a new (abstract) WebXR feature
  129446. * @param _xrSessionManager the xr session manager for this feature
  129447. */
  129448. constructor(_xrSessionManager: WebXRSessionManager);
  129449. /**
  129450. * Is this feature attached
  129451. */
  129452. get attached(): boolean;
  129453. /**
  129454. * attach this feature
  129455. *
  129456. * @param force should attachment be forced (even when already attached)
  129457. * @returns true if successful, false is failed or already attached
  129458. */
  129459. attach(force?: boolean): boolean;
  129460. /**
  129461. * detach this feature.
  129462. *
  129463. * @returns true if successful, false if failed or already detached
  129464. */
  129465. detach(): boolean;
  129466. /**
  129467. * Dispose this feature and all of the resources attached
  129468. */
  129469. dispose(): void;
  129470. /**
  129471. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  129472. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  129473. *
  129474. * @returns whether or not the feature is compatible in this environment
  129475. */
  129476. isCompatible(): boolean;
  129477. /**
  129478. * This is used to register callbacks that will automatically be removed when detach is called.
  129479. * @param observable the observable to which the observer will be attached
  129480. * @param callback the callback to register
  129481. */
  129482. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  129483. /**
  129484. * Code in this function will be executed on each xrFrame received from the browser.
  129485. * This function will not execute after the feature is detached.
  129486. * @param _xrFrame the current frame
  129487. */
  129488. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  129489. }
  129490. }
  129491. declare module BABYLON {
  129492. /**
  129493. * Renders a layer on top of an existing scene
  129494. */
  129495. export class UtilityLayerRenderer implements IDisposable {
  129496. /** the original scene that will be rendered on top of */
  129497. originalScene: Scene;
  129498. private _pointerCaptures;
  129499. private _lastPointerEvents;
  129500. private static _DefaultUtilityLayer;
  129501. private static _DefaultKeepDepthUtilityLayer;
  129502. private _sharedGizmoLight;
  129503. private _renderCamera;
  129504. /**
  129505. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  129506. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  129507. * @returns the camera that is used when rendering the utility layer
  129508. */
  129509. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  129510. /**
  129511. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  129512. * @param cam the camera that should be used when rendering the utility layer
  129513. */
  129514. setRenderCamera(cam: Nullable<Camera>): void;
  129515. /**
  129516. * @hidden
  129517. * Light which used by gizmos to get light shading
  129518. */
  129519. _getSharedGizmoLight(): HemisphericLight;
  129520. /**
  129521. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  129522. */
  129523. pickUtilitySceneFirst: boolean;
  129524. /**
  129525. * 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)
  129526. */
  129527. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  129528. /**
  129529. * 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)
  129530. */
  129531. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  129532. /**
  129533. * The scene that is rendered on top of the original scene
  129534. */
  129535. utilityLayerScene: Scene;
  129536. /**
  129537. * If the utility layer should automatically be rendered on top of existing scene
  129538. */
  129539. shouldRender: boolean;
  129540. /**
  129541. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  129542. */
  129543. onlyCheckPointerDownEvents: boolean;
  129544. /**
  129545. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  129546. */
  129547. processAllEvents: boolean;
  129548. /**
  129549. * Observable raised when the pointer move from the utility layer scene to the main scene
  129550. */
  129551. onPointerOutObservable: Observable<number>;
  129552. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  129553. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  129554. private _afterRenderObserver;
  129555. private _sceneDisposeObserver;
  129556. private _originalPointerObserver;
  129557. /**
  129558. * Instantiates a UtilityLayerRenderer
  129559. * @param originalScene the original scene that will be rendered on top of
  129560. * @param handleEvents boolean indicating if the utility layer should handle events
  129561. */
  129562. constructor(
  129563. /** the original scene that will be rendered on top of */
  129564. originalScene: Scene, handleEvents?: boolean);
  129565. private _notifyObservers;
  129566. /**
  129567. * Renders the utility layers scene on top of the original scene
  129568. */
  129569. render(): void;
  129570. /**
  129571. * Disposes of the renderer
  129572. */
  129573. dispose(): void;
  129574. private _updateCamera;
  129575. }
  129576. }
  129577. declare module BABYLON {
  129578. /**
  129579. * Options interface for the pointer selection module
  129580. */
  129581. export interface IWebXRControllerPointerSelectionOptions {
  129582. /**
  129583. * if provided, this scene will be used to render meshes.
  129584. */
  129585. customUtilityLayerScene?: Scene;
  129586. /**
  129587. * 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)
  129588. * If not disabled, the last picked point will be used to execute a pointer up event
  129589. * If disabled, pointer up event will be triggered right after the pointer down event.
  129590. * Used in screen and gaze target ray mode only
  129591. */
  129592. disablePointerUpOnTouchOut: boolean;
  129593. /**
  129594. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  129595. */
  129596. forceGazeMode: boolean;
  129597. /**
  129598. * 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
  129599. * to start a new countdown to the pointer down event.
  129600. * Defaults to 1.
  129601. */
  129602. gazeModePointerMovedFactor?: number;
  129603. /**
  129604. * Different button type to use instead of the main component
  129605. */
  129606. overrideButtonId?: string;
  129607. /**
  129608. * use this rendering group id for the meshes (optional)
  129609. */
  129610. renderingGroupId?: number;
  129611. /**
  129612. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  129613. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  129614. * 3000 means 3 seconds between pointing at something and selecting it
  129615. */
  129616. timeToSelect?: number;
  129617. /**
  129618. * Should meshes created here be added to a utility layer or the main scene
  129619. */
  129620. useUtilityLayer?: boolean;
  129621. /**
  129622. * Optional WebXR camera to be used for gaze selection
  129623. */
  129624. gazeCamera?: WebXRCamera;
  129625. /**
  129626. * the xr input to use with this pointer selection
  129627. */
  129628. xrInput: WebXRInput;
  129629. }
  129630. /**
  129631. * A module that will enable pointer selection for motion controllers of XR Input Sources
  129632. */
  129633. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  129634. private readonly _options;
  129635. private static _idCounter;
  129636. private _attachController;
  129637. private _controllers;
  129638. private _scene;
  129639. private _tmpVectorForPickCompare;
  129640. /**
  129641. * The module's name
  129642. */
  129643. static readonly Name: string;
  129644. /**
  129645. * The (Babylon) version of this module.
  129646. * This is an integer representing the implementation version.
  129647. * This number does not correspond to the WebXR specs version
  129648. */
  129649. static readonly Version: number;
  129650. /**
  129651. * Disable lighting on the laser pointer (so it will always be visible)
  129652. */
  129653. disablePointerLighting: boolean;
  129654. /**
  129655. * Disable lighting on the selection mesh (so it will always be visible)
  129656. */
  129657. disableSelectionMeshLighting: boolean;
  129658. /**
  129659. * Should the laser pointer be displayed
  129660. */
  129661. displayLaserPointer: boolean;
  129662. /**
  129663. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  129664. */
  129665. displaySelectionMesh: boolean;
  129666. /**
  129667. * This color will be set to the laser pointer when selection is triggered
  129668. */
  129669. laserPointerPickedColor: Color3;
  129670. /**
  129671. * Default color of the laser pointer
  129672. */
  129673. laserPointerDefaultColor: Color3;
  129674. /**
  129675. * default color of the selection ring
  129676. */
  129677. selectionMeshDefaultColor: Color3;
  129678. /**
  129679. * This color will be applied to the selection ring when selection is triggered
  129680. */
  129681. selectionMeshPickedColor: Color3;
  129682. /**
  129683. * Optional filter to be used for ray selection. This predicate shares behavior with
  129684. * scene.pointerMovePredicate which takes priority if it is also assigned.
  129685. */
  129686. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129687. /**
  129688. * constructs a new background remover module
  129689. * @param _xrSessionManager the session manager for this module
  129690. * @param _options read-only options to be used in this module
  129691. */
  129692. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  129693. /**
  129694. * attach this feature
  129695. * Will usually be called by the features manager
  129696. *
  129697. * @returns true if successful.
  129698. */
  129699. attach(): boolean;
  129700. /**
  129701. * detach this feature.
  129702. * Will usually be called by the features manager
  129703. *
  129704. * @returns true if successful.
  129705. */
  129706. detach(): boolean;
  129707. /**
  129708. * Will get the mesh under a specific pointer.
  129709. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  129710. * @param controllerId the controllerId to check
  129711. * @returns The mesh under pointer or null if no mesh is under the pointer
  129712. */
  129713. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  129714. /**
  129715. * Get the xr controller that correlates to the pointer id in the pointer event
  129716. *
  129717. * @param id the pointer id to search for
  129718. * @returns the controller that correlates to this id or null if not found
  129719. */
  129720. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  129721. protected _onXRFrame(_xrFrame: XRFrame): void;
  129722. private _attachGazeMode;
  129723. private _attachScreenRayMode;
  129724. private _attachTrackedPointerRayMode;
  129725. private _convertNormalToDirectionOfRay;
  129726. private _detachController;
  129727. private _generateNewMeshPair;
  129728. private _pickingMoved;
  129729. private _updatePointerDistance;
  129730. /** @hidden */
  129731. get lasterPointerDefaultColor(): Color3;
  129732. }
  129733. }
  129734. declare module BABYLON {
  129735. /**
  129736. * Button which can be used to enter a different mode of XR
  129737. */
  129738. export class WebXREnterExitUIButton {
  129739. /** button element */
  129740. element: HTMLElement;
  129741. /** XR initialization options for the button */
  129742. sessionMode: XRSessionMode;
  129743. /** Reference space type */
  129744. referenceSpaceType: XRReferenceSpaceType;
  129745. /**
  129746. * Creates a WebXREnterExitUIButton
  129747. * @param element button element
  129748. * @param sessionMode XR initialization session mode
  129749. * @param referenceSpaceType the type of reference space to be used
  129750. */
  129751. constructor(
  129752. /** button element */
  129753. element: HTMLElement,
  129754. /** XR initialization options for the button */
  129755. sessionMode: XRSessionMode,
  129756. /** Reference space type */
  129757. referenceSpaceType: XRReferenceSpaceType);
  129758. /**
  129759. * Extendable function which can be used to update the button's visuals when the state changes
  129760. * @param activeButton the current active button in the UI
  129761. */
  129762. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  129763. }
  129764. /**
  129765. * Options to create the webXR UI
  129766. */
  129767. export class WebXREnterExitUIOptions {
  129768. /**
  129769. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  129770. */
  129771. customButtons?: Array<WebXREnterExitUIButton>;
  129772. /**
  129773. * A reference space type to use when creating the default button.
  129774. * Default is local-floor
  129775. */
  129776. referenceSpaceType?: XRReferenceSpaceType;
  129777. /**
  129778. * Context to enter xr with
  129779. */
  129780. renderTarget?: Nullable<WebXRRenderTarget>;
  129781. /**
  129782. * A session mode to use when creating the default button.
  129783. * Default is immersive-vr
  129784. */
  129785. sessionMode?: XRSessionMode;
  129786. /**
  129787. * A list of optional features to init the session with
  129788. */
  129789. optionalFeatures?: string[];
  129790. /**
  129791. * A list of optional features to init the session with
  129792. */
  129793. requiredFeatures?: string[];
  129794. }
  129795. /**
  129796. * UI to allow the user to enter/exit XR mode
  129797. */
  129798. export class WebXREnterExitUI implements IDisposable {
  129799. private scene;
  129800. /** version of the options passed to this UI */
  129801. options: WebXREnterExitUIOptions;
  129802. private _activeButton;
  129803. private _buttons;
  129804. /**
  129805. * The HTML Div Element to which buttons are added.
  129806. */
  129807. readonly overlay: HTMLDivElement;
  129808. /**
  129809. * Fired every time the active button is changed.
  129810. *
  129811. * When xr is entered via a button that launches xr that button will be the callback parameter
  129812. *
  129813. * When exiting xr the callback parameter will be null)
  129814. */
  129815. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  129816. /**
  129817. *
  129818. * @param scene babylon scene object to use
  129819. * @param options (read-only) version of the options passed to this UI
  129820. */
  129821. private constructor();
  129822. /**
  129823. * Creates UI to allow the user to enter/exit XR mode
  129824. * @param scene the scene to add the ui to
  129825. * @param helper the xr experience helper to enter/exit xr with
  129826. * @param options options to configure the UI
  129827. * @returns the created ui
  129828. */
  129829. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  129830. /**
  129831. * Disposes of the XR UI component
  129832. */
  129833. dispose(): void;
  129834. private _updateButtons;
  129835. }
  129836. }
  129837. declare module BABYLON {
  129838. /**
  129839. * Class containing static functions to help procedurally build meshes
  129840. */
  129841. export class LinesBuilder {
  129842. /**
  129843. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129844. * * 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
  129845. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129846. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129847. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129848. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129849. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129850. * * 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
  129851. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  129852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129853. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  129854. * @param name defines the name of the new line system
  129855. * @param options defines the options used to create the line system
  129856. * @param scene defines the hosting scene
  129857. * @returns a new line system mesh
  129858. */
  129859. static CreateLineSystem(name: string, options: {
  129860. lines: Vector3[][];
  129861. updatable?: boolean;
  129862. instance?: Nullable<LinesMesh>;
  129863. colors?: Nullable<Color4[][]>;
  129864. useVertexAlpha?: boolean;
  129865. }, scene: Nullable<Scene>): LinesMesh;
  129866. /**
  129867. * Creates a line mesh
  129868. * 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
  129869. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129870. * * The parameter `points` is an array successive Vector3
  129871. * * 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
  129872. * * The optional parameter `colors` is an array of successive Color4, one per line point
  129873. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  129874. * * When updating an instance, remember that only point positions can change, not the number of points
  129875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129876. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  129877. * @param name defines the name of the new line system
  129878. * @param options defines the options used to create the line system
  129879. * @param scene defines the hosting scene
  129880. * @returns a new line mesh
  129881. */
  129882. static CreateLines(name: string, options: {
  129883. points: Vector3[];
  129884. updatable?: boolean;
  129885. instance?: Nullable<LinesMesh>;
  129886. colors?: Color4[];
  129887. useVertexAlpha?: boolean;
  129888. }, scene?: Nullable<Scene>): LinesMesh;
  129889. /**
  129890. * Creates a dashed line mesh
  129891. * * 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
  129892. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129893. * * The parameter `points` is an array successive Vector3
  129894. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  129895. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  129896. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  129897. * * 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
  129898. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129899. * * When updating an instance, remember that only point positions can change, not the number of points
  129900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129901. * @param name defines the name of the mesh
  129902. * @param options defines the options used to create the mesh
  129903. * @param scene defines the hosting scene
  129904. * @returns the dashed line mesh
  129905. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  129906. */
  129907. static CreateDashedLines(name: string, options: {
  129908. points: Vector3[];
  129909. dashSize?: number;
  129910. gapSize?: number;
  129911. dashNb?: number;
  129912. updatable?: boolean;
  129913. instance?: LinesMesh;
  129914. useVertexAlpha?: boolean;
  129915. }, scene?: Nullable<Scene>): LinesMesh;
  129916. }
  129917. }
  129918. declare module BABYLON {
  129919. /**
  129920. * Construction options for a timer
  129921. */
  129922. export interface ITimerOptions<T> {
  129923. /**
  129924. * Time-to-end
  129925. */
  129926. timeout: number;
  129927. /**
  129928. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  129929. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  129930. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  129931. */
  129932. contextObservable: Observable<T>;
  129933. /**
  129934. * Optional parameters when adding an observer to the observable
  129935. */
  129936. observableParameters?: {
  129937. mask?: number;
  129938. insertFirst?: boolean;
  129939. scope?: any;
  129940. };
  129941. /**
  129942. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  129943. */
  129944. breakCondition?: (data?: ITimerData<T>) => boolean;
  129945. /**
  129946. * Will be triggered when the time condition has met
  129947. */
  129948. onEnded?: (data: ITimerData<any>) => void;
  129949. /**
  129950. * Will be triggered when the break condition has met (prematurely ended)
  129951. */
  129952. onAborted?: (data: ITimerData<any>) => void;
  129953. /**
  129954. * Optional function to execute on each tick (or count)
  129955. */
  129956. onTick?: (data: ITimerData<any>) => void;
  129957. }
  129958. /**
  129959. * An interface defining the data sent by the timer
  129960. */
  129961. export interface ITimerData<T> {
  129962. /**
  129963. * When did it start
  129964. */
  129965. startTime: number;
  129966. /**
  129967. * Time now
  129968. */
  129969. currentTime: number;
  129970. /**
  129971. * Time passed since started
  129972. */
  129973. deltaTime: number;
  129974. /**
  129975. * How much is completed, in [0.0...1.0].
  129976. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129977. */
  129978. completeRate: number;
  129979. /**
  129980. * What the registered observable sent in the last count
  129981. */
  129982. payload: T;
  129983. }
  129984. /**
  129985. * The current state of the timer
  129986. */
  129987. export enum TimerState {
  129988. /**
  129989. * Timer initialized, not yet started
  129990. */
  129991. INIT = 0,
  129992. /**
  129993. * Timer started and counting
  129994. */
  129995. STARTED = 1,
  129996. /**
  129997. * Timer ended (whether aborted or time reached)
  129998. */
  129999. ENDED = 2
  130000. }
  130001. /**
  130002. * A simple version of the timer. Will take options and start the timer immediately after calling it
  130003. *
  130004. * @param options options with which to initialize this timer
  130005. */
  130006. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  130007. /**
  130008. * An advanced implementation of a timer class
  130009. */
  130010. export class AdvancedTimer<T = any> implements IDisposable {
  130011. /**
  130012. * Will notify each time the timer calculates the remaining time
  130013. */
  130014. onEachCountObservable: Observable<ITimerData<T>>;
  130015. /**
  130016. * Will trigger when the timer was aborted due to the break condition
  130017. */
  130018. onTimerAbortedObservable: Observable<ITimerData<T>>;
  130019. /**
  130020. * Will trigger when the timer ended successfully
  130021. */
  130022. onTimerEndedObservable: Observable<ITimerData<T>>;
  130023. /**
  130024. * Will trigger when the timer state has changed
  130025. */
  130026. onStateChangedObservable: Observable<TimerState>;
  130027. private _observer;
  130028. private _contextObservable;
  130029. private _observableParameters;
  130030. private _startTime;
  130031. private _timer;
  130032. private _state;
  130033. private _breakCondition;
  130034. private _timeToEnd;
  130035. private _breakOnNextTick;
  130036. /**
  130037. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  130038. * @param options construction options for this advanced timer
  130039. */
  130040. constructor(options: ITimerOptions<T>);
  130041. /**
  130042. * set a breaking condition for this timer. Default is to never break during count
  130043. * @param predicate the new break condition. Returns true to break, false otherwise
  130044. */
  130045. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  130046. /**
  130047. * Reset ALL associated observables in this advanced timer
  130048. */
  130049. clearObservables(): void;
  130050. /**
  130051. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  130052. *
  130053. * @param timeToEnd how much time to measure until timer ended
  130054. */
  130055. start(timeToEnd?: number): void;
  130056. /**
  130057. * Will force a stop on the next tick.
  130058. */
  130059. stop(): void;
  130060. /**
  130061. * Dispose this timer, clearing all resources
  130062. */
  130063. dispose(): void;
  130064. private _setState;
  130065. private _tick;
  130066. private _stop;
  130067. }
  130068. }
  130069. declare module BABYLON {
  130070. /**
  130071. * The options container for the teleportation module
  130072. */
  130073. export interface IWebXRTeleportationOptions {
  130074. /**
  130075. * if provided, this scene will be used to render meshes.
  130076. */
  130077. customUtilityLayerScene?: Scene;
  130078. /**
  130079. * Values to configure the default target mesh
  130080. */
  130081. defaultTargetMeshOptions?: {
  130082. /**
  130083. * Fill color of the teleportation area
  130084. */
  130085. teleportationFillColor?: string;
  130086. /**
  130087. * Border color for the teleportation area
  130088. */
  130089. teleportationBorderColor?: string;
  130090. /**
  130091. * Disable the mesh's animation sequence
  130092. */
  130093. disableAnimation?: boolean;
  130094. /**
  130095. * Disable lighting on the material or the ring and arrow
  130096. */
  130097. disableLighting?: boolean;
  130098. /**
  130099. * Override the default material of the torus and arrow
  130100. */
  130101. torusArrowMaterial?: Material;
  130102. };
  130103. /**
  130104. * A list of meshes to use as floor meshes.
  130105. * Meshes can be added and removed after initializing the feature using the
  130106. * addFloorMesh and removeFloorMesh functions
  130107. * If empty, rotation will still work
  130108. */
  130109. floorMeshes?: AbstractMesh[];
  130110. /**
  130111. * use this rendering group id for the meshes (optional)
  130112. */
  130113. renderingGroupId?: number;
  130114. /**
  130115. * Should teleportation move only to snap points
  130116. */
  130117. snapPointsOnly?: boolean;
  130118. /**
  130119. * An array of points to which the teleportation will snap to.
  130120. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  130121. */
  130122. snapPositions?: Vector3[];
  130123. /**
  130124. * How close should the teleportation ray be in order to snap to position.
  130125. * Default to 0.8 units (meters)
  130126. */
  130127. snapToPositionRadius?: number;
  130128. /**
  130129. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  130130. * If you want to support rotation, make sure your mesh has a direction indicator.
  130131. *
  130132. * When left untouched, the default mesh will be initialized.
  130133. */
  130134. teleportationTargetMesh?: AbstractMesh;
  130135. /**
  130136. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  130137. */
  130138. timeToTeleport?: number;
  130139. /**
  130140. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  130141. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  130142. */
  130143. useMainComponentOnly?: boolean;
  130144. /**
  130145. * Should meshes created here be added to a utility layer or the main scene
  130146. */
  130147. useUtilityLayer?: boolean;
  130148. /**
  130149. * Babylon XR Input class for controller
  130150. */
  130151. xrInput: WebXRInput;
  130152. /**
  130153. * Meshes that the teleportation ray cannot go through
  130154. */
  130155. pickBlockerMeshes?: AbstractMesh[];
  130156. }
  130157. /**
  130158. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  130159. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  130160. * the input of the attached controllers.
  130161. */
  130162. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  130163. private _options;
  130164. private _controllers;
  130165. private _currentTeleportationControllerId;
  130166. private _floorMeshes;
  130167. private _quadraticBezierCurve;
  130168. private _selectionFeature;
  130169. private _snapToPositions;
  130170. private _snappedToPoint;
  130171. private _teleportationRingMaterial?;
  130172. private _tmpRay;
  130173. private _tmpVector;
  130174. private _tmpQuaternion;
  130175. /**
  130176. * The module's name
  130177. */
  130178. static readonly Name: string;
  130179. /**
  130180. * The (Babylon) version of this module.
  130181. * This is an integer representing the implementation version.
  130182. * This number does not correspond to the webxr specs version
  130183. */
  130184. static readonly Version: number;
  130185. /**
  130186. * Is movement backwards enabled
  130187. */
  130188. backwardsMovementEnabled: boolean;
  130189. /**
  130190. * Distance to travel when moving backwards
  130191. */
  130192. backwardsTeleportationDistance: number;
  130193. /**
  130194. * The distance from the user to the inspection point in the direction of the controller
  130195. * A higher number will allow the user to move further
  130196. * defaults to 5 (meters, in xr units)
  130197. */
  130198. parabolicCheckRadius: number;
  130199. /**
  130200. * Should the module support parabolic ray on top of direct ray
  130201. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  130202. * Very helpful when moving between floors / different heights
  130203. */
  130204. parabolicRayEnabled: boolean;
  130205. /**
  130206. * How much rotation should be applied when rotating right and left
  130207. */
  130208. rotationAngle: number;
  130209. /**
  130210. * Is rotation enabled when moving forward?
  130211. * Disabling this feature will prevent the user from deciding the direction when teleporting
  130212. */
  130213. rotationEnabled: boolean;
  130214. /**
  130215. * constructs a new anchor system
  130216. * @param _xrSessionManager an instance of WebXRSessionManager
  130217. * @param _options configuration object for this feature
  130218. */
  130219. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  130220. /**
  130221. * Get the snapPointsOnly flag
  130222. */
  130223. get snapPointsOnly(): boolean;
  130224. /**
  130225. * Sets the snapPointsOnly flag
  130226. * @param snapToPoints should teleportation be exclusively to snap points
  130227. */
  130228. set snapPointsOnly(snapToPoints: boolean);
  130229. /**
  130230. * Add a new mesh to the floor meshes array
  130231. * @param mesh the mesh to use as floor mesh
  130232. */
  130233. addFloorMesh(mesh: AbstractMesh): void;
  130234. /**
  130235. * Add a new snap-to point to fix teleportation to this position
  130236. * @param newSnapPoint The new Snap-To point
  130237. */
  130238. addSnapPoint(newSnapPoint: Vector3): void;
  130239. attach(): boolean;
  130240. detach(): boolean;
  130241. dispose(): void;
  130242. /**
  130243. * Remove a mesh from the floor meshes array
  130244. * @param mesh the mesh to remove
  130245. */
  130246. removeFloorMesh(mesh: AbstractMesh): void;
  130247. /**
  130248. * Remove a mesh from the floor meshes array using its name
  130249. * @param name the mesh name to remove
  130250. */
  130251. removeFloorMeshByName(name: string): void;
  130252. /**
  130253. * 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
  130254. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  130255. * @returns was the point found and removed or not
  130256. */
  130257. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  130258. /**
  130259. * This function sets a selection feature that will be disabled when
  130260. * the forward ray is shown and will be reattached when hidden.
  130261. * This is used to remove the selection rays when moving.
  130262. * @param selectionFeature the feature to disable when forward movement is enabled
  130263. */
  130264. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  130265. protected _onXRFrame(_xrFrame: XRFrame): void;
  130266. private _attachController;
  130267. private _createDefaultTargetMesh;
  130268. private _detachController;
  130269. private _findClosestSnapPointWithRadius;
  130270. private _setTargetMeshPosition;
  130271. private _setTargetMeshVisibility;
  130272. private _showParabolicPath;
  130273. private _teleportForward;
  130274. }
  130275. }
  130276. declare module BABYLON {
  130277. /**
  130278. * Options for the default xr helper
  130279. */
  130280. export class WebXRDefaultExperienceOptions {
  130281. /**
  130282. * Enable or disable default UI to enter XR
  130283. */
  130284. disableDefaultUI?: boolean;
  130285. /**
  130286. * Should teleportation not initialize. defaults to false.
  130287. */
  130288. disableTeleportation?: boolean;
  130289. /**
  130290. * Floor meshes that will be used for teleport
  130291. */
  130292. floorMeshes?: Array<AbstractMesh>;
  130293. /**
  130294. * If set to true, the first frame will not be used to reset position
  130295. * The first frame is mainly used when copying transformation from the old camera
  130296. * Mainly used in AR
  130297. */
  130298. ignoreNativeCameraTransformation?: boolean;
  130299. /**
  130300. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  130301. */
  130302. inputOptions?: IWebXRInputOptions;
  130303. /**
  130304. * optional configuration for the output canvas
  130305. */
  130306. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  130307. /**
  130308. * optional UI options. This can be used among other to change session mode and reference space type
  130309. */
  130310. uiOptions?: WebXREnterExitUIOptions;
  130311. /**
  130312. * When loading teleportation and pointer select, use stable versions instead of latest.
  130313. */
  130314. useStablePlugins?: boolean;
  130315. /**
  130316. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  130317. */
  130318. renderingGroupId?: number;
  130319. /**
  130320. * A list of optional features to init the session with
  130321. * If set to true, all features we support will be added
  130322. */
  130323. optionalFeatures?: boolean | string[];
  130324. }
  130325. /**
  130326. * Default experience which provides a similar setup to the previous webVRExperience
  130327. */
  130328. export class WebXRDefaultExperience {
  130329. /**
  130330. * Base experience
  130331. */
  130332. baseExperience: WebXRExperienceHelper;
  130333. /**
  130334. * Enables ui for entering/exiting xr
  130335. */
  130336. enterExitUI: WebXREnterExitUI;
  130337. /**
  130338. * Input experience extension
  130339. */
  130340. input: WebXRInput;
  130341. /**
  130342. * Enables laser pointer and selection
  130343. */
  130344. pointerSelection: WebXRControllerPointerSelection;
  130345. /**
  130346. * Default target xr should render to
  130347. */
  130348. renderTarget: WebXRRenderTarget;
  130349. /**
  130350. * Enables teleportation
  130351. */
  130352. teleportation: WebXRMotionControllerTeleportation;
  130353. private constructor();
  130354. /**
  130355. * Creates the default xr experience
  130356. * @param scene scene
  130357. * @param options options for basic configuration
  130358. * @returns resulting WebXRDefaultExperience
  130359. */
  130360. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  130361. /**
  130362. * DIsposes of the experience helper
  130363. */
  130364. dispose(): void;
  130365. }
  130366. }
  130367. declare module BABYLON {
  130368. /**
  130369. * Options to modify the vr teleportation behavior.
  130370. */
  130371. export interface VRTeleportationOptions {
  130372. /**
  130373. * The name of the mesh which should be used as the teleportation floor. (default: null)
  130374. */
  130375. floorMeshName?: string;
  130376. /**
  130377. * A list of meshes to be used as the teleportation floor. (default: empty)
  130378. */
  130379. floorMeshes?: Mesh[];
  130380. /**
  130381. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  130382. */
  130383. teleportationMode?: number;
  130384. /**
  130385. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  130386. */
  130387. teleportationTime?: number;
  130388. /**
  130389. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  130390. */
  130391. teleportationSpeed?: number;
  130392. /**
  130393. * The easing function used in the animation or null for Linear. (default CircleEase)
  130394. */
  130395. easingFunction?: EasingFunction;
  130396. }
  130397. /**
  130398. * Options to modify the vr experience helper's behavior.
  130399. */
  130400. export interface VRExperienceHelperOptions extends WebVROptions {
  130401. /**
  130402. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  130403. */
  130404. createDeviceOrientationCamera?: boolean;
  130405. /**
  130406. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  130407. */
  130408. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  130409. /**
  130410. * Uses the main button on the controller to toggle the laser casted. (default: true)
  130411. */
  130412. laserToggle?: boolean;
  130413. /**
  130414. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  130415. */
  130416. floorMeshes?: Mesh[];
  130417. /**
  130418. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  130419. */
  130420. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  130421. /**
  130422. * Defines if WebXR should be used instead of WebVR (if available)
  130423. */
  130424. useXR?: boolean;
  130425. }
  130426. /**
  130427. * Event containing information after VR has been entered
  130428. */
  130429. export class OnAfterEnteringVRObservableEvent {
  130430. /**
  130431. * If entering vr was successful
  130432. */
  130433. success: boolean;
  130434. }
  130435. /**
  130436. * Helps to quickly add VR support to an existing scene.
  130437. * See https://doc.babylonjs.com/how_to/webvr_helper
  130438. */
  130439. export class VRExperienceHelper {
  130440. /** Options to modify the vr experience helper's behavior. */
  130441. webVROptions: VRExperienceHelperOptions;
  130442. private _scene;
  130443. private _position;
  130444. private _btnVR;
  130445. private _btnVRDisplayed;
  130446. private _webVRsupported;
  130447. private _webVRready;
  130448. private _webVRrequesting;
  130449. private _webVRpresenting;
  130450. private _hasEnteredVR;
  130451. private _fullscreenVRpresenting;
  130452. private _inputElement;
  130453. private _webVRCamera;
  130454. private _vrDeviceOrientationCamera;
  130455. private _deviceOrientationCamera;
  130456. private _existingCamera;
  130457. private _onKeyDown;
  130458. private _onVrDisplayPresentChange;
  130459. private _onVRDisplayChanged;
  130460. private _onVRRequestPresentStart;
  130461. private _onVRRequestPresentComplete;
  130462. /**
  130463. * 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)
  130464. */
  130465. enableGazeEvenWhenNoPointerLock: boolean;
  130466. /**
  130467. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  130468. */
  130469. exitVROnDoubleTap: boolean;
  130470. /**
  130471. * Observable raised right before entering VR.
  130472. */
  130473. onEnteringVRObservable: Observable<VRExperienceHelper>;
  130474. /**
  130475. * Observable raised when entering VR has completed.
  130476. */
  130477. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  130478. /**
  130479. * Observable raised when exiting VR.
  130480. */
  130481. onExitingVRObservable: Observable<VRExperienceHelper>;
  130482. /**
  130483. * Observable raised when controller mesh is loaded.
  130484. */
  130485. onControllerMeshLoadedObservable: Observable<WebVRController>;
  130486. /** Return this.onEnteringVRObservable
  130487. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  130488. */
  130489. get onEnteringVR(): Observable<VRExperienceHelper>;
  130490. /** Return this.onExitingVRObservable
  130491. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  130492. */
  130493. get onExitingVR(): Observable<VRExperienceHelper>;
  130494. /** Return this.onControllerMeshLoadedObservable
  130495. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  130496. */
  130497. get onControllerMeshLoaded(): Observable<WebVRController>;
  130498. private _rayLength;
  130499. private _useCustomVRButton;
  130500. private _teleportationRequested;
  130501. private _teleportActive;
  130502. private _floorMeshName;
  130503. private _floorMeshesCollection;
  130504. private _teleportationMode;
  130505. private _teleportationTime;
  130506. private _teleportationSpeed;
  130507. private _teleportationEasing;
  130508. private _rotationAllowed;
  130509. private _teleportBackwardsVector;
  130510. private _teleportationTarget;
  130511. private _isDefaultTeleportationTarget;
  130512. private _postProcessMove;
  130513. private _teleportationFillColor;
  130514. private _teleportationBorderColor;
  130515. private _rotationAngle;
  130516. private _haloCenter;
  130517. private _cameraGazer;
  130518. private _padSensibilityUp;
  130519. private _padSensibilityDown;
  130520. private _leftController;
  130521. private _rightController;
  130522. private _gazeColor;
  130523. private _laserColor;
  130524. private _pickedLaserColor;
  130525. private _pickedGazeColor;
  130526. /**
  130527. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  130528. */
  130529. onNewMeshSelected: Observable<AbstractMesh>;
  130530. /**
  130531. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  130532. * This observable will provide the mesh and the controller used to select the mesh
  130533. */
  130534. onMeshSelectedWithController: Observable<{
  130535. mesh: AbstractMesh;
  130536. controller: WebVRController;
  130537. }>;
  130538. /**
  130539. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  130540. */
  130541. onNewMeshPicked: Observable<PickingInfo>;
  130542. private _circleEase;
  130543. /**
  130544. * Observable raised before camera teleportation
  130545. */
  130546. onBeforeCameraTeleport: Observable<Vector3>;
  130547. /**
  130548. * Observable raised after camera teleportation
  130549. */
  130550. onAfterCameraTeleport: Observable<Vector3>;
  130551. /**
  130552. * Observable raised when current selected mesh gets unselected
  130553. */
  130554. onSelectedMeshUnselected: Observable<AbstractMesh>;
  130555. private _raySelectionPredicate;
  130556. /**
  130557. * To be optionaly changed by user to define custom ray selection
  130558. */
  130559. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  130560. /**
  130561. * To be optionaly changed by user to define custom selection logic (after ray selection)
  130562. */
  130563. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130564. /**
  130565. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  130566. */
  130567. teleportationEnabled: boolean;
  130568. private _defaultHeight;
  130569. private _teleportationInitialized;
  130570. private _interactionsEnabled;
  130571. private _interactionsRequested;
  130572. private _displayGaze;
  130573. private _displayLaserPointer;
  130574. /**
  130575. * The mesh used to display where the user is going to teleport.
  130576. */
  130577. get teleportationTarget(): Mesh;
  130578. /**
  130579. * Sets the mesh to be used to display where the user is going to teleport.
  130580. */
  130581. set teleportationTarget(value: Mesh);
  130582. /**
  130583. * 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
  130584. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  130585. * See https://doc.babylonjs.com/resources/baking_transformations
  130586. */
  130587. get gazeTrackerMesh(): Mesh;
  130588. set gazeTrackerMesh(value: Mesh);
  130589. /**
  130590. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  130591. */
  130592. updateGazeTrackerScale: boolean;
  130593. /**
  130594. * If the gaze trackers color should be updated when selecting meshes
  130595. */
  130596. updateGazeTrackerColor: boolean;
  130597. /**
  130598. * If the controller laser color should be updated when selecting meshes
  130599. */
  130600. updateControllerLaserColor: boolean;
  130601. /**
  130602. * The gaze tracking mesh corresponding to the left controller
  130603. */
  130604. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  130605. /**
  130606. * The gaze tracking mesh corresponding to the right controller
  130607. */
  130608. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  130609. /**
  130610. * If the ray of the gaze should be displayed.
  130611. */
  130612. get displayGaze(): boolean;
  130613. /**
  130614. * Sets if the ray of the gaze should be displayed.
  130615. */
  130616. set displayGaze(value: boolean);
  130617. /**
  130618. * If the ray of the LaserPointer should be displayed.
  130619. */
  130620. get displayLaserPointer(): boolean;
  130621. /**
  130622. * Sets if the ray of the LaserPointer should be displayed.
  130623. */
  130624. set displayLaserPointer(value: boolean);
  130625. /**
  130626. * The deviceOrientationCamera used as the camera when not in VR.
  130627. */
  130628. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  130629. /**
  130630. * Based on the current WebVR support, returns the current VR camera used.
  130631. */
  130632. get currentVRCamera(): Nullable<Camera>;
  130633. /**
  130634. * The webVRCamera which is used when in VR.
  130635. */
  130636. get webVRCamera(): WebVRFreeCamera;
  130637. /**
  130638. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  130639. */
  130640. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  130641. /**
  130642. * The html button that is used to trigger entering into VR.
  130643. */
  130644. get vrButton(): Nullable<HTMLButtonElement>;
  130645. private get _teleportationRequestInitiated();
  130646. /**
  130647. * Defines whether or not Pointer lock should be requested when switching to
  130648. * full screen.
  130649. */
  130650. requestPointerLockOnFullScreen: boolean;
  130651. /**
  130652. * If asking to force XR, this will be populated with the default xr experience
  130653. */
  130654. xr: WebXRDefaultExperience;
  130655. /**
  130656. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  130657. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  130658. */
  130659. xrTestDone: boolean;
  130660. /**
  130661. * Instantiates a VRExperienceHelper.
  130662. * Helps to quickly add VR support to an existing scene.
  130663. * @param scene The scene the VRExperienceHelper belongs to.
  130664. * @param webVROptions Options to modify the vr experience helper's behavior.
  130665. */
  130666. constructor(scene: Scene,
  130667. /** Options to modify the vr experience helper's behavior. */
  130668. webVROptions?: VRExperienceHelperOptions);
  130669. private completeVRInit;
  130670. private _onDefaultMeshLoaded;
  130671. private _onResize;
  130672. private _onFullscreenChange;
  130673. /**
  130674. * Gets a value indicating if we are currently in VR mode.
  130675. */
  130676. get isInVRMode(): boolean;
  130677. private onVrDisplayPresentChange;
  130678. private onVRDisplayChanged;
  130679. private moveButtonToBottomRight;
  130680. private displayVRButton;
  130681. private updateButtonVisibility;
  130682. private _cachedAngularSensibility;
  130683. /**
  130684. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  130685. * Otherwise, will use the fullscreen API.
  130686. */
  130687. enterVR(): void;
  130688. /**
  130689. * Attempt to exit VR, or fullscreen.
  130690. */
  130691. exitVR(): void;
  130692. /**
  130693. * The position of the vr experience helper.
  130694. */
  130695. get position(): Vector3;
  130696. /**
  130697. * Sets the position of the vr experience helper.
  130698. */
  130699. set position(value: Vector3);
  130700. /**
  130701. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  130702. */
  130703. enableInteractions(): void;
  130704. private get _noControllerIsActive();
  130705. private beforeRender;
  130706. private _isTeleportationFloor;
  130707. /**
  130708. * Adds a floor mesh to be used for teleportation.
  130709. * @param floorMesh the mesh to be used for teleportation.
  130710. */
  130711. addFloorMesh(floorMesh: Mesh): void;
  130712. /**
  130713. * Removes a floor mesh from being used for teleportation.
  130714. * @param floorMesh the mesh to be removed.
  130715. */
  130716. removeFloorMesh(floorMesh: Mesh): void;
  130717. /**
  130718. * Enables interactions and teleportation using the VR controllers and gaze.
  130719. * @param vrTeleportationOptions options to modify teleportation behavior.
  130720. */
  130721. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  130722. private _onNewGamepadConnected;
  130723. private _tryEnableInteractionOnController;
  130724. private _onNewGamepadDisconnected;
  130725. private _enableInteractionOnController;
  130726. private _checkTeleportWithRay;
  130727. private _checkRotate;
  130728. private _checkTeleportBackwards;
  130729. private _enableTeleportationOnController;
  130730. private _createTeleportationCircles;
  130731. private _displayTeleportationTarget;
  130732. private _hideTeleportationTarget;
  130733. private _rotateCamera;
  130734. private _moveTeleportationSelectorTo;
  130735. private _workingVector;
  130736. private _workingQuaternion;
  130737. private _workingMatrix;
  130738. /**
  130739. * Time Constant Teleportation Mode
  130740. */
  130741. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  130742. /**
  130743. * Speed Constant Teleportation Mode
  130744. */
  130745. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  130746. /**
  130747. * Teleports the users feet to the desired location
  130748. * @param location The location where the user's feet should be placed
  130749. */
  130750. teleportCamera(location: Vector3): void;
  130751. private _convertNormalToDirectionOfRay;
  130752. private _castRayAndSelectObject;
  130753. private _notifySelectedMeshUnselected;
  130754. /**
  130755. * Permanently set new colors for the laser pointer
  130756. * @param color the new laser color
  130757. * @param pickedColor the new laser color when picked mesh detected
  130758. */
  130759. setLaserColor(color: Color3, pickedColor?: Color3): void;
  130760. /**
  130761. * Set lighting enabled / disabled on the laser pointer of both controllers
  130762. * @param enabled should the lighting be enabled on the laser pointer
  130763. */
  130764. setLaserLightingState(enabled?: boolean): void;
  130765. /**
  130766. * Permanently set new colors for the gaze pointer
  130767. * @param color the new gaze color
  130768. * @param pickedColor the new gaze color when picked mesh detected
  130769. */
  130770. setGazeColor(color: Color3, pickedColor?: Color3): void;
  130771. /**
  130772. * Sets the color of the laser ray from the vr controllers.
  130773. * @param color new color for the ray.
  130774. */
  130775. changeLaserColor(color: Color3): void;
  130776. /**
  130777. * Sets the color of the ray from the vr headsets gaze.
  130778. * @param color new color for the ray.
  130779. */
  130780. changeGazeColor(color: Color3): void;
  130781. /**
  130782. * Exits VR and disposes of the vr experience helper
  130783. */
  130784. dispose(): void;
  130785. /**
  130786. * Gets the name of the VRExperienceHelper class
  130787. * @returns "VRExperienceHelper"
  130788. */
  130789. getClassName(): string;
  130790. }
  130791. }
  130792. declare module BABYLON {
  130793. /**
  130794. * Contains an array of blocks representing the octree
  130795. */
  130796. export interface IOctreeContainer<T> {
  130797. /**
  130798. * Blocks within the octree
  130799. */
  130800. blocks: Array<OctreeBlock<T>>;
  130801. }
  130802. /**
  130803. * Class used to store a cell in an octree
  130804. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130805. */
  130806. export class OctreeBlock<T> {
  130807. /**
  130808. * Gets the content of the current block
  130809. */
  130810. entries: T[];
  130811. /**
  130812. * Gets the list of block children
  130813. */
  130814. blocks: Array<OctreeBlock<T>>;
  130815. private _depth;
  130816. private _maxDepth;
  130817. private _capacity;
  130818. private _minPoint;
  130819. private _maxPoint;
  130820. private _boundingVectors;
  130821. private _creationFunc;
  130822. /**
  130823. * Creates a new block
  130824. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  130825. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  130826. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130827. * @param depth defines the current depth of this block in the octree
  130828. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  130829. * @param creationFunc defines a callback to call when an element is added to the block
  130830. */
  130831. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  130832. /**
  130833. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130834. */
  130835. get capacity(): number;
  130836. /**
  130837. * Gets the minimum vector (in world space) of the block's bounding box
  130838. */
  130839. get minPoint(): Vector3;
  130840. /**
  130841. * Gets the maximum vector (in world space) of the block's bounding box
  130842. */
  130843. get maxPoint(): Vector3;
  130844. /**
  130845. * Add a new element to this block
  130846. * @param entry defines the element to add
  130847. */
  130848. addEntry(entry: T): void;
  130849. /**
  130850. * Remove an element from this block
  130851. * @param entry defines the element to remove
  130852. */
  130853. removeEntry(entry: T): void;
  130854. /**
  130855. * Add an array of elements to this block
  130856. * @param entries defines the array of elements to add
  130857. */
  130858. addEntries(entries: T[]): void;
  130859. /**
  130860. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  130861. * @param frustumPlanes defines the frustum planes to test
  130862. * @param selection defines the array to store current content if selection is positive
  130863. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130864. */
  130865. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130866. /**
  130867. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  130868. * @param sphereCenter defines the bounding sphere center
  130869. * @param sphereRadius defines the bounding sphere radius
  130870. * @param selection defines the array to store current content if selection is positive
  130871. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130872. */
  130873. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130874. /**
  130875. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  130876. * @param ray defines the ray to test with
  130877. * @param selection defines the array to store current content if selection is positive
  130878. */
  130879. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  130880. /**
  130881. * Subdivide the content into child blocks (this block will then be empty)
  130882. */
  130883. createInnerBlocks(): void;
  130884. /**
  130885. * @hidden
  130886. */
  130887. 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;
  130888. }
  130889. }
  130890. declare module BABYLON {
  130891. /**
  130892. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  130893. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130894. */
  130895. export class Octree<T> {
  130896. /** 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.) */
  130897. maxDepth: number;
  130898. /**
  130899. * Blocks within the octree containing objects
  130900. */
  130901. blocks: Array<OctreeBlock<T>>;
  130902. /**
  130903. * Content stored in the octree
  130904. */
  130905. dynamicContent: T[];
  130906. private _maxBlockCapacity;
  130907. private _selectionContent;
  130908. private _creationFunc;
  130909. /**
  130910. * Creates a octree
  130911. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130912. * @param creationFunc function to be used to instatiate the octree
  130913. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  130914. * @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.)
  130915. */
  130916. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  130917. /** 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.) */
  130918. maxDepth?: number);
  130919. /**
  130920. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  130921. * @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);
  130922. * @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);
  130923. * @param entries meshes to be added to the octree blocks
  130924. */
  130925. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  130926. /**
  130927. * Adds a mesh to the octree
  130928. * @param entry Mesh to add to the octree
  130929. */
  130930. addMesh(entry: T): void;
  130931. /**
  130932. * Remove an element from the octree
  130933. * @param entry defines the element to remove
  130934. */
  130935. removeMesh(entry: T): void;
  130936. /**
  130937. * Selects an array of meshes within the frustum
  130938. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  130939. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  130940. * @returns array of meshes within the frustum
  130941. */
  130942. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  130943. /**
  130944. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  130945. * @param sphereCenter defines the bounding sphere center
  130946. * @param sphereRadius defines the bounding sphere radius
  130947. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130948. * @returns an array of objects that intersect the sphere
  130949. */
  130950. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  130951. /**
  130952. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  130953. * @param ray defines the ray to test with
  130954. * @returns array of intersected objects
  130955. */
  130956. intersectsRay(ray: Ray): SmartArray<T>;
  130957. /**
  130958. * Adds a mesh into the octree block if it intersects the block
  130959. */
  130960. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  130961. /**
  130962. * Adds a submesh into the octree block if it intersects the block
  130963. */
  130964. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  130965. }
  130966. }
  130967. declare module BABYLON {
  130968. interface Scene {
  130969. /**
  130970. * @hidden
  130971. * Backing Filed
  130972. */
  130973. _selectionOctree: Octree<AbstractMesh>;
  130974. /**
  130975. * Gets the octree used to boost mesh selection (picking)
  130976. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130977. */
  130978. selectionOctree: Octree<AbstractMesh>;
  130979. /**
  130980. * Creates or updates the octree used to boost selection (picking)
  130981. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130982. * @param maxCapacity defines the maximum capacity per leaf
  130983. * @param maxDepth defines the maximum depth of the octree
  130984. * @returns an octree of AbstractMesh
  130985. */
  130986. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130987. }
  130988. interface AbstractMesh {
  130989. /**
  130990. * @hidden
  130991. * Backing Field
  130992. */
  130993. _submeshesOctree: Octree<SubMesh>;
  130994. /**
  130995. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130996. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130997. * @param maxCapacity defines the maximum size of each block (64 by default)
  130998. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130999. * @returns the new octree
  131000. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  131001. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  131002. */
  131003. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  131004. }
  131005. /**
  131006. * Defines the octree scene component responsible to manage any octrees
  131007. * in a given scene.
  131008. */
  131009. export class OctreeSceneComponent {
  131010. /**
  131011. * The component name help to identify the component in the list of scene components.
  131012. */
  131013. readonly name: string;
  131014. /**
  131015. * The scene the component belongs to.
  131016. */
  131017. scene: Scene;
  131018. /**
  131019. * Indicates if the meshes have been checked to make sure they are isEnabled()
  131020. */
  131021. readonly checksIsEnabled: boolean;
  131022. /**
  131023. * Creates a new instance of the component for the given scene
  131024. * @param scene Defines the scene to register the component in
  131025. */
  131026. constructor(scene: Scene);
  131027. /**
  131028. * Registers the component in a given scene
  131029. */
  131030. register(): void;
  131031. /**
  131032. * Return the list of active meshes
  131033. * @returns the list of active meshes
  131034. */
  131035. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  131036. /**
  131037. * Return the list of active sub meshes
  131038. * @param mesh The mesh to get the candidates sub meshes from
  131039. * @returns the list of active sub meshes
  131040. */
  131041. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  131042. private _tempRay;
  131043. /**
  131044. * Return the list of sub meshes intersecting with a given local ray
  131045. * @param mesh defines the mesh to find the submesh for
  131046. * @param localRay defines the ray in local space
  131047. * @returns the list of intersecting sub meshes
  131048. */
  131049. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  131050. /**
  131051. * Return the list of sub meshes colliding with a collider
  131052. * @param mesh defines the mesh to find the submesh for
  131053. * @param collider defines the collider to evaluate the collision against
  131054. * @returns the list of colliding sub meshes
  131055. */
  131056. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  131057. /**
  131058. * Rebuilds the elements related to this component in case of
  131059. * context lost for instance.
  131060. */
  131061. rebuild(): void;
  131062. /**
  131063. * Disposes the component and the associated ressources.
  131064. */
  131065. dispose(): void;
  131066. }
  131067. }
  131068. declare module BABYLON {
  131069. /**
  131070. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  131071. */
  131072. export class Gizmo implements IDisposable {
  131073. /** The utility layer the gizmo will be added to */
  131074. gizmoLayer: UtilityLayerRenderer;
  131075. /**
  131076. * The root mesh of the gizmo
  131077. */
  131078. _rootMesh: Mesh;
  131079. private _attachedMesh;
  131080. private _attachedNode;
  131081. /**
  131082. * Ratio for the scale of the gizmo (Default: 1)
  131083. */
  131084. protected _scaleRatio: number;
  131085. /**
  131086. * boolean updated by pointermove when a gizmo mesh is hovered
  131087. */
  131088. protected _isHovered: boolean;
  131089. /**
  131090. * Ratio for the scale of the gizmo (Default: 1)
  131091. */
  131092. set scaleRatio(value: number);
  131093. get scaleRatio(): number;
  131094. /**
  131095. * True when the mouse pointer is hovered a gizmo mesh
  131096. */
  131097. get isHovered(): boolean;
  131098. /**
  131099. * If a custom mesh has been set (Default: false)
  131100. */
  131101. protected _customMeshSet: boolean;
  131102. /**
  131103. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  131104. * * When set, interactions will be enabled
  131105. */
  131106. get attachedMesh(): Nullable<AbstractMesh>;
  131107. set attachedMesh(value: Nullable<AbstractMesh>);
  131108. /**
  131109. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  131110. * * When set, interactions will be enabled
  131111. */
  131112. get attachedNode(): Nullable<Node>;
  131113. set attachedNode(value: Nullable<Node>);
  131114. /**
  131115. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  131116. * @param mesh The mesh to replace the default mesh of the gizmo
  131117. */
  131118. setCustomMesh(mesh: Mesh): void;
  131119. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  131120. /**
  131121. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  131122. */
  131123. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  131124. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  131125. /**
  131126. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  131127. */
  131128. updateGizmoPositionToMatchAttachedMesh: boolean;
  131129. /**
  131130. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  131131. */
  131132. updateScale: boolean;
  131133. protected _interactionsEnabled: boolean;
  131134. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131135. private _beforeRenderObserver;
  131136. private _tempQuaternion;
  131137. private _tempVector;
  131138. private _tempVector2;
  131139. private _tempMatrix1;
  131140. private _tempMatrix2;
  131141. private _rightHandtoLeftHandMatrix;
  131142. /**
  131143. * Creates a gizmo
  131144. * @param gizmoLayer The utility layer the gizmo will be added to
  131145. */
  131146. constructor(
  131147. /** The utility layer the gizmo will be added to */
  131148. gizmoLayer?: UtilityLayerRenderer);
  131149. /**
  131150. * Updates the gizmo to match the attached mesh's position/rotation
  131151. */
  131152. protected _update(): void;
  131153. /**
  131154. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  131155. * @param value Node, TransformNode or mesh
  131156. */
  131157. protected _matrixChanged(): void;
  131158. /**
  131159. * Disposes of the gizmo
  131160. */
  131161. dispose(): void;
  131162. }
  131163. }
  131164. declare module BABYLON {
  131165. /**
  131166. * Single plane drag gizmo
  131167. */
  131168. export class PlaneDragGizmo extends Gizmo {
  131169. /**
  131170. * Drag behavior responsible for the gizmos dragging interactions
  131171. */
  131172. dragBehavior: PointerDragBehavior;
  131173. private _pointerObserver;
  131174. /**
  131175. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131176. */
  131177. snapDistance: number;
  131178. /**
  131179. * Event that fires each time the gizmo snaps to a new location.
  131180. * * snapDistance is the the change in distance
  131181. */
  131182. onSnapObservable: Observable<{
  131183. snapDistance: number;
  131184. }>;
  131185. private _plane;
  131186. private _coloredMaterial;
  131187. private _hoverMaterial;
  131188. private _isEnabled;
  131189. private _parent;
  131190. /** @hidden */
  131191. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  131192. /** @hidden */
  131193. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  131194. /**
  131195. * Creates a PlaneDragGizmo
  131196. * @param gizmoLayer The utility layer the gizmo will be added to
  131197. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  131198. * @param color The color of the gizmo
  131199. */
  131200. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  131201. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131202. /**
  131203. * If the gizmo is enabled
  131204. */
  131205. set isEnabled(value: boolean);
  131206. get isEnabled(): boolean;
  131207. /**
  131208. * Disposes of the gizmo
  131209. */
  131210. dispose(): void;
  131211. }
  131212. }
  131213. declare module BABYLON {
  131214. /**
  131215. * Gizmo that enables dragging a mesh along 3 axis
  131216. */
  131217. export class PositionGizmo extends Gizmo {
  131218. /**
  131219. * Internal gizmo used for interactions on the x axis
  131220. */
  131221. xGizmo: AxisDragGizmo;
  131222. /**
  131223. * Internal gizmo used for interactions on the y axis
  131224. */
  131225. yGizmo: AxisDragGizmo;
  131226. /**
  131227. * Internal gizmo used for interactions on the z axis
  131228. */
  131229. zGizmo: AxisDragGizmo;
  131230. /**
  131231. * Internal gizmo used for interactions on the yz plane
  131232. */
  131233. xPlaneGizmo: PlaneDragGizmo;
  131234. /**
  131235. * Internal gizmo used for interactions on the xz plane
  131236. */
  131237. yPlaneGizmo: PlaneDragGizmo;
  131238. /**
  131239. * Internal gizmo used for interactions on the xy plane
  131240. */
  131241. zPlaneGizmo: PlaneDragGizmo;
  131242. /**
  131243. * private variables
  131244. */
  131245. private _meshAttached;
  131246. private _nodeAttached;
  131247. private _snapDistance;
  131248. /** Fires an event when any of it's sub gizmos are dragged */
  131249. onDragStartObservable: Observable<unknown>;
  131250. /** Fires an event when any of it's sub gizmos are released from dragging */
  131251. onDragEndObservable: Observable<unknown>;
  131252. /**
  131253. * If set to true, planar drag is enabled
  131254. */
  131255. private _planarGizmoEnabled;
  131256. get attachedMesh(): Nullable<AbstractMesh>;
  131257. set attachedMesh(mesh: Nullable<AbstractMesh>);
  131258. get attachedNode(): Nullable<Node>;
  131259. set attachedNode(node: Nullable<Node>);
  131260. /**
  131261. * True when the mouse pointer is hovering a gizmo mesh
  131262. */
  131263. get isHovered(): boolean;
  131264. /**
  131265. * Creates a PositionGizmo
  131266. * @param gizmoLayer The utility layer the gizmo will be added to
  131267. @param thickness display gizmo axis thickness
  131268. */
  131269. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  131270. /**
  131271. * If the planar drag gizmo is enabled
  131272. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  131273. */
  131274. set planarGizmoEnabled(value: boolean);
  131275. get planarGizmoEnabled(): boolean;
  131276. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  131277. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  131278. /**
  131279. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131280. */
  131281. set snapDistance(value: number);
  131282. get snapDistance(): number;
  131283. /**
  131284. * Ratio for the scale of the gizmo (Default: 1)
  131285. */
  131286. set scaleRatio(value: number);
  131287. get scaleRatio(): number;
  131288. /**
  131289. * Disposes of the gizmo
  131290. */
  131291. dispose(): void;
  131292. /**
  131293. * CustomMeshes are not supported by this gizmo
  131294. * @param mesh The mesh to replace the default mesh of the gizmo
  131295. */
  131296. setCustomMesh(mesh: Mesh): void;
  131297. }
  131298. }
  131299. declare module BABYLON {
  131300. /**
  131301. * Single axis drag gizmo
  131302. */
  131303. export class AxisDragGizmo extends Gizmo {
  131304. /**
  131305. * Drag behavior responsible for the gizmos dragging interactions
  131306. */
  131307. dragBehavior: PointerDragBehavior;
  131308. private _pointerObserver;
  131309. /**
  131310. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131311. */
  131312. snapDistance: number;
  131313. /**
  131314. * Event that fires each time the gizmo snaps to a new location.
  131315. * * snapDistance is the the change in distance
  131316. */
  131317. onSnapObservable: Observable<{
  131318. snapDistance: number;
  131319. }>;
  131320. private _isEnabled;
  131321. private _parent;
  131322. private _arrow;
  131323. private _coloredMaterial;
  131324. private _hoverMaterial;
  131325. /** @hidden */
  131326. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  131327. /** @hidden */
  131328. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  131329. /**
  131330. * Creates an AxisDragGizmo
  131331. * @param gizmoLayer The utility layer the gizmo will be added to
  131332. * @param dragAxis The axis which the gizmo will be able to drag on
  131333. * @param color The color of the gizmo
  131334. * @param thickness display gizmo axis thickness
  131335. */
  131336. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  131337. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131338. /**
  131339. * If the gizmo is enabled
  131340. */
  131341. set isEnabled(value: boolean);
  131342. get isEnabled(): boolean;
  131343. /**
  131344. * Disposes of the gizmo
  131345. */
  131346. dispose(): void;
  131347. }
  131348. }
  131349. declare module BABYLON.Debug {
  131350. /**
  131351. * The Axes viewer will show 3 axes in a specific point in space
  131352. */
  131353. export class AxesViewer {
  131354. private _xAxis;
  131355. private _yAxis;
  131356. private _zAxis;
  131357. private _scaleLinesFactor;
  131358. private _instanced;
  131359. /**
  131360. * Gets the hosting scene
  131361. */
  131362. scene: Nullable<Scene>;
  131363. /**
  131364. * Gets or sets a number used to scale line length
  131365. */
  131366. scaleLines: number;
  131367. /** Gets the node hierarchy used to render x-axis */
  131368. get xAxis(): TransformNode;
  131369. /** Gets the node hierarchy used to render y-axis */
  131370. get yAxis(): TransformNode;
  131371. /** Gets the node hierarchy used to render z-axis */
  131372. get zAxis(): TransformNode;
  131373. /**
  131374. * Creates a new AxesViewer
  131375. * @param scene defines the hosting scene
  131376. * @param scaleLines defines a number used to scale line length (1 by default)
  131377. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  131378. * @param xAxis defines the node hierarchy used to render the x-axis
  131379. * @param yAxis defines the node hierarchy used to render the y-axis
  131380. * @param zAxis defines the node hierarchy used to render the z-axis
  131381. */
  131382. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  131383. /**
  131384. * Force the viewer to update
  131385. * @param position defines the position of the viewer
  131386. * @param xaxis defines the x axis of the viewer
  131387. * @param yaxis defines the y axis of the viewer
  131388. * @param zaxis defines the z axis of the viewer
  131389. */
  131390. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  131391. /**
  131392. * Creates an instance of this axes viewer.
  131393. * @returns a new axes viewer with instanced meshes
  131394. */
  131395. createInstance(): AxesViewer;
  131396. /** Releases resources */
  131397. dispose(): void;
  131398. private static _SetRenderingGroupId;
  131399. }
  131400. }
  131401. declare module BABYLON.Debug {
  131402. /**
  131403. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  131404. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  131405. */
  131406. export class BoneAxesViewer extends AxesViewer {
  131407. /**
  131408. * Gets or sets the target mesh where to display the axes viewer
  131409. */
  131410. mesh: Nullable<Mesh>;
  131411. /**
  131412. * Gets or sets the target bone where to display the axes viewer
  131413. */
  131414. bone: Nullable<Bone>;
  131415. /** Gets current position */
  131416. pos: Vector3;
  131417. /** Gets direction of X axis */
  131418. xaxis: Vector3;
  131419. /** Gets direction of Y axis */
  131420. yaxis: Vector3;
  131421. /** Gets direction of Z axis */
  131422. zaxis: Vector3;
  131423. /**
  131424. * Creates a new BoneAxesViewer
  131425. * @param scene defines the hosting scene
  131426. * @param bone defines the target bone
  131427. * @param mesh defines the target mesh
  131428. * @param scaleLines defines a scaling factor for line length (1 by default)
  131429. */
  131430. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  131431. /**
  131432. * Force the viewer to update
  131433. */
  131434. update(): void;
  131435. /** Releases resources */
  131436. dispose(): void;
  131437. }
  131438. }
  131439. declare module BABYLON {
  131440. /**
  131441. * Interface used to define scene explorer extensibility option
  131442. */
  131443. export interface IExplorerExtensibilityOption {
  131444. /**
  131445. * Define the option label
  131446. */
  131447. label: string;
  131448. /**
  131449. * Defines the action to execute on click
  131450. */
  131451. action: (entity: any) => void;
  131452. }
  131453. /**
  131454. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  131455. */
  131456. export interface IExplorerExtensibilityGroup {
  131457. /**
  131458. * Defines a predicate to test if a given type mut be extended
  131459. */
  131460. predicate: (entity: any) => boolean;
  131461. /**
  131462. * Gets the list of options added to a type
  131463. */
  131464. entries: IExplorerExtensibilityOption[];
  131465. }
  131466. /**
  131467. * Interface used to define the options to use to create the Inspector
  131468. */
  131469. export interface IInspectorOptions {
  131470. /**
  131471. * Display in overlay mode (default: false)
  131472. */
  131473. overlay?: boolean;
  131474. /**
  131475. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  131476. */
  131477. globalRoot?: HTMLElement;
  131478. /**
  131479. * Display the Scene explorer
  131480. */
  131481. showExplorer?: boolean;
  131482. /**
  131483. * Display the property inspector
  131484. */
  131485. showInspector?: boolean;
  131486. /**
  131487. * Display in embed mode (both panes on the right)
  131488. */
  131489. embedMode?: boolean;
  131490. /**
  131491. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  131492. */
  131493. handleResize?: boolean;
  131494. /**
  131495. * Allow the panes to popup (default: true)
  131496. */
  131497. enablePopup?: boolean;
  131498. /**
  131499. * Allow the panes to be closed by users (default: true)
  131500. */
  131501. enableClose?: boolean;
  131502. /**
  131503. * Optional list of extensibility entries
  131504. */
  131505. explorerExtensibility?: IExplorerExtensibilityGroup[];
  131506. /**
  131507. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  131508. */
  131509. inspectorURL?: string;
  131510. /**
  131511. * Optional initial tab (default to DebugLayerTab.Properties)
  131512. */
  131513. initialTab?: DebugLayerTab;
  131514. }
  131515. interface Scene {
  131516. /**
  131517. * @hidden
  131518. * Backing field
  131519. */
  131520. _debugLayer: DebugLayer;
  131521. /**
  131522. * Gets the debug layer (aka Inspector) associated with the scene
  131523. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131524. */
  131525. debugLayer: DebugLayer;
  131526. }
  131527. /**
  131528. * Enum of inspector action tab
  131529. */
  131530. export enum DebugLayerTab {
  131531. /**
  131532. * Properties tag (default)
  131533. */
  131534. Properties = 0,
  131535. /**
  131536. * Debug tab
  131537. */
  131538. Debug = 1,
  131539. /**
  131540. * Statistics tab
  131541. */
  131542. Statistics = 2,
  131543. /**
  131544. * Tools tab
  131545. */
  131546. Tools = 3,
  131547. /**
  131548. * Settings tab
  131549. */
  131550. Settings = 4
  131551. }
  131552. /**
  131553. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131554. * what is happening in your scene
  131555. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131556. */
  131557. export class DebugLayer {
  131558. /**
  131559. * Define the url to get the inspector script from.
  131560. * By default it uses the babylonjs CDN.
  131561. * @ignoreNaming
  131562. */
  131563. static InspectorURL: string;
  131564. private _scene;
  131565. private BJSINSPECTOR;
  131566. private _onPropertyChangedObservable?;
  131567. /**
  131568. * Observable triggered when a property is changed through the inspector.
  131569. */
  131570. get onPropertyChangedObservable(): any;
  131571. /**
  131572. * Instantiates a new debug layer.
  131573. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131574. * what is happening in your scene
  131575. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131576. * @param scene Defines the scene to inspect
  131577. */
  131578. constructor(scene: Scene);
  131579. /** Creates the inspector window. */
  131580. private _createInspector;
  131581. /**
  131582. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  131583. * @param entity defines the entity to select
  131584. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  131585. */
  131586. select(entity: any, lineContainerTitles?: string | string[]): void;
  131587. /** Get the inspector from bundle or global */
  131588. private _getGlobalInspector;
  131589. /**
  131590. * Get if the inspector is visible or not.
  131591. * @returns true if visible otherwise, false
  131592. */
  131593. isVisible(): boolean;
  131594. /**
  131595. * Hide the inspector and close its window.
  131596. */
  131597. hide(): void;
  131598. /**
  131599. * Update the scene in the inspector
  131600. */
  131601. setAsActiveScene(): void;
  131602. /**
  131603. * Launch the debugLayer.
  131604. * @param config Define the configuration of the inspector
  131605. * @return a promise fulfilled when the debug layer is visible
  131606. */
  131607. show(config?: IInspectorOptions): Promise<DebugLayer>;
  131608. }
  131609. }
  131610. declare module BABYLON {
  131611. /**
  131612. * Class containing static functions to help procedurally build meshes
  131613. */
  131614. export class BoxBuilder {
  131615. /**
  131616. * Creates a box mesh
  131617. * * The parameter `size` sets the size (float) of each box side (default 1)
  131618. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  131619. * * 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)
  131620. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131624. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131625. * @param name defines the name of the mesh
  131626. * @param options defines the options used to create the mesh
  131627. * @param scene defines the hosting scene
  131628. * @returns the box mesh
  131629. */
  131630. static CreateBox(name: string, options: {
  131631. size?: number;
  131632. width?: number;
  131633. height?: number;
  131634. depth?: number;
  131635. faceUV?: Vector4[];
  131636. faceColors?: Color4[];
  131637. sideOrientation?: number;
  131638. frontUVs?: Vector4;
  131639. backUVs?: Vector4;
  131640. wrap?: boolean;
  131641. topBaseAt?: number;
  131642. bottomBaseAt?: number;
  131643. updatable?: boolean;
  131644. }, scene?: Nullable<Scene>): Mesh;
  131645. }
  131646. }
  131647. declare module BABYLON.Debug {
  131648. /**
  131649. * Used to show the physics impostor around the specific mesh
  131650. */
  131651. export class PhysicsViewer {
  131652. /** @hidden */
  131653. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  131654. /** @hidden */
  131655. protected _meshes: Array<Nullable<AbstractMesh>>;
  131656. /** @hidden */
  131657. protected _scene: Nullable<Scene>;
  131658. /** @hidden */
  131659. protected _numMeshes: number;
  131660. /** @hidden */
  131661. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  131662. private _renderFunction;
  131663. private _utilityLayer;
  131664. private _debugBoxMesh;
  131665. private _debugSphereMesh;
  131666. private _debugCylinderMesh;
  131667. private _debugMaterial;
  131668. private _debugMeshMeshes;
  131669. /**
  131670. * Creates a new PhysicsViewer
  131671. * @param scene defines the hosting scene
  131672. */
  131673. constructor(scene: Scene);
  131674. /** @hidden */
  131675. protected _updateDebugMeshes(): void;
  131676. /**
  131677. * Renders a specified physic impostor
  131678. * @param impostor defines the impostor to render
  131679. * @param targetMesh defines the mesh represented by the impostor
  131680. * @returns the new debug mesh used to render the impostor
  131681. */
  131682. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  131683. /**
  131684. * Hides a specified physic impostor
  131685. * @param impostor defines the impostor to hide
  131686. */
  131687. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  131688. private _getDebugMaterial;
  131689. private _getDebugBoxMesh;
  131690. private _getDebugSphereMesh;
  131691. private _getDebugCylinderMesh;
  131692. private _getDebugMeshMesh;
  131693. private _getDebugMesh;
  131694. /** Releases all resources */
  131695. dispose(): void;
  131696. }
  131697. }
  131698. declare module BABYLON {
  131699. /**
  131700. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131701. * in order to better appreciate the issue one might have.
  131702. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131703. */
  131704. export class RayHelper {
  131705. /**
  131706. * Defines the ray we are currently tryin to visualize.
  131707. */
  131708. ray: Nullable<Ray>;
  131709. private _renderPoints;
  131710. private _renderLine;
  131711. private _renderFunction;
  131712. private _scene;
  131713. private _onAfterRenderObserver;
  131714. private _onAfterStepObserver;
  131715. private _attachedToMesh;
  131716. private _meshSpaceDirection;
  131717. private _meshSpaceOrigin;
  131718. /**
  131719. * Helper function to create a colored helper in a scene in one line.
  131720. * @param ray Defines the ray we are currently tryin to visualize
  131721. * @param scene Defines the scene the ray is used in
  131722. * @param color Defines the color we want to see the ray in
  131723. * @returns The newly created ray helper.
  131724. */
  131725. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  131726. /**
  131727. * Instantiate a new ray helper.
  131728. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131729. * in order to better appreciate the issue one might have.
  131730. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131731. * @param ray Defines the ray we are currently tryin to visualize
  131732. */
  131733. constructor(ray: Ray);
  131734. /**
  131735. * Shows the ray we are willing to debug.
  131736. * @param scene Defines the scene the ray needs to be rendered in
  131737. * @param color Defines the color the ray needs to be rendered in
  131738. */
  131739. show(scene: Scene, color?: Color3): void;
  131740. /**
  131741. * Hides the ray we are debugging.
  131742. */
  131743. hide(): void;
  131744. private _render;
  131745. /**
  131746. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  131747. * @param mesh Defines the mesh we want the helper attached to
  131748. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  131749. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  131750. * @param length Defines the length of the ray
  131751. */
  131752. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  131753. /**
  131754. * Detach the ray helper from the mesh it has previously been attached to.
  131755. */
  131756. detachFromMesh(): void;
  131757. private _updateToMesh;
  131758. /**
  131759. * Dispose the helper and release its associated resources.
  131760. */
  131761. dispose(): void;
  131762. }
  131763. }
  131764. declare module BABYLON {
  131765. /**
  131766. * Defines the options associated with the creation of a SkeletonViewer.
  131767. */
  131768. export interface ISkeletonViewerOptions {
  131769. /** Should the system pause animations before building the Viewer? */
  131770. pauseAnimations: boolean;
  131771. /** Should the system return the skeleton to rest before building? */
  131772. returnToRest: boolean;
  131773. /** public Display Mode of the Viewer */
  131774. displayMode: number;
  131775. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131776. displayOptions: ISkeletonViewerDisplayOptions;
  131777. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131778. computeBonesUsingShaders: boolean;
  131779. /** Flag ignore non weighted bones */
  131780. useAllBones: boolean;
  131781. }
  131782. /**
  131783. * Defines how to display the various bone meshes for the viewer.
  131784. */
  131785. export interface ISkeletonViewerDisplayOptions {
  131786. /** How far down to start tapering the bone spurs */
  131787. midStep?: number;
  131788. /** How big is the midStep? */
  131789. midStepFactor?: number;
  131790. /** Base for the Sphere Size */
  131791. sphereBaseSize?: number;
  131792. /** The ratio of the sphere to the longest bone in units */
  131793. sphereScaleUnit?: number;
  131794. /** Ratio for the Sphere Size */
  131795. sphereFactor?: number;
  131796. /** Whether a spur should attach its far end to the child bone position */
  131797. spurFollowsChild?: boolean;
  131798. /** Whether to show local axes or not */
  131799. showLocalAxes?: boolean;
  131800. /** Length of each local axis */
  131801. localAxesSize?: number;
  131802. }
  131803. /**
  131804. * Defines the constructor options for the BoneWeight Shader.
  131805. */
  131806. export interface IBoneWeightShaderOptions {
  131807. /** Skeleton to Map */
  131808. skeleton: Skeleton;
  131809. /** Colors for Uninfluenced bones */
  131810. colorBase?: Color3;
  131811. /** Colors for 0.0-0.25 Weight bones */
  131812. colorZero?: Color3;
  131813. /** Color for 0.25-0.5 Weight Influence */
  131814. colorQuarter?: Color3;
  131815. /** Color for 0.5-0.75 Weight Influence */
  131816. colorHalf?: Color3;
  131817. /** Color for 0.75-1 Weight Influence */
  131818. colorFull?: Color3;
  131819. /** Color for Zero Weight Influence */
  131820. targetBoneIndex?: number;
  131821. }
  131822. /**
  131823. * Simple structure of the gradient steps for the Color Map.
  131824. */
  131825. export interface ISkeletonMapShaderColorMapKnot {
  131826. /** Color of the Knot */
  131827. color: Color3;
  131828. /** Location of the Knot */
  131829. location: number;
  131830. }
  131831. /**
  131832. * Defines the constructor options for the SkeletonMap Shader.
  131833. */
  131834. export interface ISkeletonMapShaderOptions {
  131835. /** Skeleton to Map */
  131836. skeleton: Skeleton;
  131837. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  131838. colorMap?: ISkeletonMapShaderColorMapKnot[];
  131839. }
  131840. }
  131841. declare module BABYLON {
  131842. /**
  131843. * Class containing static functions to help procedurally build meshes
  131844. */
  131845. export class RibbonBuilder {
  131846. /**
  131847. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131848. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131849. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131850. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131851. * * 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
  131852. * * 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
  131853. * * 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
  131854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131856. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131857. * * 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
  131858. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131859. * * 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
  131860. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131862. * @param name defines the name of the mesh
  131863. * @param options defines the options used to create the mesh
  131864. * @param scene defines the hosting scene
  131865. * @returns the ribbon mesh
  131866. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131867. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131868. */
  131869. static CreateRibbon(name: string, options: {
  131870. pathArray: Vector3[][];
  131871. closeArray?: boolean;
  131872. closePath?: boolean;
  131873. offset?: number;
  131874. updatable?: boolean;
  131875. sideOrientation?: number;
  131876. frontUVs?: Vector4;
  131877. backUVs?: Vector4;
  131878. instance?: Mesh;
  131879. invertUV?: boolean;
  131880. uvs?: Vector2[];
  131881. colors?: Color4[];
  131882. }, scene?: Nullable<Scene>): Mesh;
  131883. }
  131884. }
  131885. declare module BABYLON {
  131886. /**
  131887. * Class containing static functions to help procedurally build meshes
  131888. */
  131889. export class ShapeBuilder {
  131890. /**
  131891. * 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.
  131892. * * 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.
  131893. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131894. * * 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.
  131895. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131896. * * 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
  131897. * * 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
  131898. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131901. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131903. * @param name defines the name of the mesh
  131904. * @param options defines the options used to create the mesh
  131905. * @param scene defines the hosting scene
  131906. * @returns the extruded shape mesh
  131907. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131909. */
  131910. static ExtrudeShape(name: string, options: {
  131911. shape: Vector3[];
  131912. path: Vector3[];
  131913. scale?: number;
  131914. rotation?: number;
  131915. cap?: number;
  131916. updatable?: boolean;
  131917. sideOrientation?: number;
  131918. frontUVs?: Vector4;
  131919. backUVs?: Vector4;
  131920. instance?: Mesh;
  131921. invertUV?: boolean;
  131922. }, scene?: Nullable<Scene>): Mesh;
  131923. /**
  131924. * Creates an custom extruded shape mesh.
  131925. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131926. * * 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.
  131927. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131928. * * 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
  131929. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131930. * * 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
  131931. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131932. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131933. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131934. * * 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
  131935. * * 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
  131936. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131938. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131939. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131941. * @param name defines the name of the mesh
  131942. * @param options defines the options used to create the mesh
  131943. * @param scene defines the hosting scene
  131944. * @returns the custom extruded shape mesh
  131945. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131946. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131947. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131948. */
  131949. static ExtrudeShapeCustom(name: string, options: {
  131950. shape: Vector3[];
  131951. path: Vector3[];
  131952. scaleFunction?: any;
  131953. rotationFunction?: any;
  131954. ribbonCloseArray?: boolean;
  131955. ribbonClosePath?: boolean;
  131956. cap?: number;
  131957. updatable?: boolean;
  131958. sideOrientation?: number;
  131959. frontUVs?: Vector4;
  131960. backUVs?: Vector4;
  131961. instance?: Mesh;
  131962. invertUV?: boolean;
  131963. }, scene?: Nullable<Scene>): Mesh;
  131964. private static _ExtrudeShapeGeneric;
  131965. }
  131966. }
  131967. declare module BABYLON.Debug {
  131968. /**
  131969. * Class used to render a debug view of a given skeleton
  131970. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  131971. */
  131972. export class SkeletonViewer {
  131973. /** defines the skeleton to render */
  131974. skeleton: Skeleton;
  131975. /** defines the mesh attached to the skeleton */
  131976. mesh: AbstractMesh;
  131977. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131978. autoUpdateBonesMatrices: boolean;
  131979. /** defines the rendering group id to use with the viewer */
  131980. renderingGroupId: number;
  131981. /** is the options for the viewer */
  131982. options: Partial<ISkeletonViewerOptions>;
  131983. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  131984. static readonly DISPLAY_LINES: number;
  131985. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  131986. static readonly DISPLAY_SPHERES: number;
  131987. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131988. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131989. /** public static method to create a BoneWeight Shader
  131990. * @param options The constructor options
  131991. * @param scene The scene that the shader is scoped to
  131992. * @returns The created ShaderMaterial
  131993. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131994. */
  131995. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131996. /** public static method to create a BoneWeight Shader
  131997. * @param options The constructor options
  131998. * @param scene The scene that the shader is scoped to
  131999. * @returns The created ShaderMaterial
  132000. */
  132001. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  132002. /** private static method to create a BoneWeight Shader
  132003. * @param size The size of the buffer to create (usually the bone count)
  132004. * @param colorMap The gradient data to generate
  132005. * @param scene The scene that the shader is scoped to
  132006. * @returns an Array of floats from the color gradient values
  132007. */
  132008. private static _CreateBoneMapColorBuffer;
  132009. /** If SkeletonViewer scene scope. */
  132010. private _scene;
  132011. /** Gets or sets the color used to render the skeleton */
  132012. color: Color3;
  132013. /** Array of the points of the skeleton fo the line view. */
  132014. private _debugLines;
  132015. /** The SkeletonViewers Mesh. */
  132016. private _debugMesh;
  132017. /** The local axes Meshes. */
  132018. private _localAxes;
  132019. /** If SkeletonViewer is enabled. */
  132020. private _isEnabled;
  132021. /** If SkeletonViewer is ready. */
  132022. private _ready;
  132023. /** SkeletonViewer render observable. */
  132024. private _obs;
  132025. /** The Utility Layer to render the gizmos in. */
  132026. private _utilityLayer;
  132027. private _boneIndices;
  132028. /** Gets the Scene. */
  132029. get scene(): Scene;
  132030. /** Gets the utilityLayer. */
  132031. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  132032. /** Checks Ready Status. */
  132033. get isReady(): Boolean;
  132034. /** Sets Ready Status. */
  132035. set ready(value: boolean);
  132036. /** Gets the debugMesh */
  132037. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  132038. /** Sets the debugMesh */
  132039. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  132040. /** Gets the displayMode */
  132041. get displayMode(): number;
  132042. /** Sets the displayMode */
  132043. set displayMode(value: number);
  132044. /**
  132045. * Creates a new SkeletonViewer
  132046. * @param skeleton defines the skeleton to render
  132047. * @param mesh defines the mesh attached to the skeleton
  132048. * @param scene defines the hosting scene
  132049. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  132050. * @param renderingGroupId defines the rendering group id to use with the viewer
  132051. * @param options All of the extra constructor options for the SkeletonViewer
  132052. */
  132053. constructor(
  132054. /** defines the skeleton to render */
  132055. skeleton: Skeleton,
  132056. /** defines the mesh attached to the skeleton */
  132057. mesh: AbstractMesh,
  132058. /** The Scene scope*/
  132059. scene: Scene,
  132060. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  132061. autoUpdateBonesMatrices?: boolean,
  132062. /** defines the rendering group id to use with the viewer */
  132063. renderingGroupId?: number,
  132064. /** is the options for the viewer */
  132065. options?: Partial<ISkeletonViewerOptions>);
  132066. /** The Dynamic bindings for the update functions */
  132067. private _bindObs;
  132068. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  132069. update(): void;
  132070. /** Gets or sets a boolean indicating if the viewer is enabled */
  132071. set isEnabled(value: boolean);
  132072. get isEnabled(): boolean;
  132073. private _getBonePosition;
  132074. private _getLinesForBonesWithLength;
  132075. private _getLinesForBonesNoLength;
  132076. /** function to revert the mesh and scene back to the initial state. */
  132077. private _revert;
  132078. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  132079. private _getAbsoluteBindPoseToRef;
  132080. /** function to build and bind sphere joint points and spur bone representations. */
  132081. private _buildSpheresAndSpurs;
  132082. private _buildLocalAxes;
  132083. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  132084. private _displayLinesUpdate;
  132085. /** Changes the displayMode of the skeleton viewer
  132086. * @param mode The displayMode numerical value
  132087. */
  132088. changeDisplayMode(mode: number): void;
  132089. /** Sets a display option of the skeleton viewer
  132090. *
  132091. * | Option | Type | Default | Description |
  132092. * | ---------------- | ------- | ------- | ----------- |
  132093. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  132094. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  132095. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  132096. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  132097. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  132098. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  132099. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  132100. *
  132101. * @param option String of the option name
  132102. * @param value The numerical option value
  132103. */
  132104. changeDisplayOptions(option: string, value: number): void;
  132105. /** Release associated resources */
  132106. dispose(): void;
  132107. }
  132108. }
  132109. declare module BABYLON {
  132110. /**
  132111. * Enum for Device Types
  132112. */
  132113. export enum DeviceType {
  132114. /** Generic */
  132115. Generic = 0,
  132116. /** Keyboard */
  132117. Keyboard = 1,
  132118. /** Mouse */
  132119. Mouse = 2,
  132120. /** Touch Pointers */
  132121. Touch = 3,
  132122. /** PS4 Dual Shock */
  132123. DualShock = 4,
  132124. /** Xbox */
  132125. Xbox = 5,
  132126. /** Switch Controller */
  132127. Switch = 6
  132128. }
  132129. /**
  132130. * Enum for All Pointers (Touch/Mouse)
  132131. */
  132132. export enum PointerInput {
  132133. /** Horizontal Axis */
  132134. Horizontal = 0,
  132135. /** Vertical Axis */
  132136. Vertical = 1,
  132137. /** Left Click or Touch */
  132138. LeftClick = 2,
  132139. /** Middle Click */
  132140. MiddleClick = 3,
  132141. /** Right Click */
  132142. RightClick = 4,
  132143. /** Browser Back */
  132144. BrowserBack = 5,
  132145. /** Browser Forward */
  132146. BrowserForward = 6
  132147. }
  132148. /**
  132149. * Enum for Dual Shock Gamepad
  132150. */
  132151. export enum DualShockInput {
  132152. /** Cross */
  132153. Cross = 0,
  132154. /** Circle */
  132155. Circle = 1,
  132156. /** Square */
  132157. Square = 2,
  132158. /** Triangle */
  132159. Triangle = 3,
  132160. /** L1 */
  132161. L1 = 4,
  132162. /** R1 */
  132163. R1 = 5,
  132164. /** L2 */
  132165. L2 = 6,
  132166. /** R2 */
  132167. R2 = 7,
  132168. /** Share */
  132169. Share = 8,
  132170. /** Options */
  132171. Options = 9,
  132172. /** L3 */
  132173. L3 = 10,
  132174. /** R3 */
  132175. R3 = 11,
  132176. /** DPadUp */
  132177. DPadUp = 12,
  132178. /** DPadDown */
  132179. DPadDown = 13,
  132180. /** DPadLeft */
  132181. DPadLeft = 14,
  132182. /** DRight */
  132183. DPadRight = 15,
  132184. /** Home */
  132185. Home = 16,
  132186. /** TouchPad */
  132187. TouchPad = 17,
  132188. /** LStickXAxis */
  132189. LStickXAxis = 18,
  132190. /** LStickYAxis */
  132191. LStickYAxis = 19,
  132192. /** RStickXAxis */
  132193. RStickXAxis = 20,
  132194. /** RStickYAxis */
  132195. RStickYAxis = 21
  132196. }
  132197. /**
  132198. * Enum for Xbox Gamepad
  132199. */
  132200. export enum XboxInput {
  132201. /** A */
  132202. A = 0,
  132203. /** B */
  132204. B = 1,
  132205. /** X */
  132206. X = 2,
  132207. /** Y */
  132208. Y = 3,
  132209. /** LB */
  132210. LB = 4,
  132211. /** RB */
  132212. RB = 5,
  132213. /** LT */
  132214. LT = 6,
  132215. /** RT */
  132216. RT = 7,
  132217. /** Back */
  132218. Back = 8,
  132219. /** Start */
  132220. Start = 9,
  132221. /** LS */
  132222. LS = 10,
  132223. /** RS */
  132224. RS = 11,
  132225. /** DPadUp */
  132226. DPadUp = 12,
  132227. /** DPadDown */
  132228. DPadDown = 13,
  132229. /** DPadLeft */
  132230. DPadLeft = 14,
  132231. /** DRight */
  132232. DPadRight = 15,
  132233. /** Home */
  132234. Home = 16,
  132235. /** LStickXAxis */
  132236. LStickXAxis = 17,
  132237. /** LStickYAxis */
  132238. LStickYAxis = 18,
  132239. /** RStickXAxis */
  132240. RStickXAxis = 19,
  132241. /** RStickYAxis */
  132242. RStickYAxis = 20
  132243. }
  132244. /**
  132245. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  132246. */
  132247. export enum SwitchInput {
  132248. /** B */
  132249. B = 0,
  132250. /** A */
  132251. A = 1,
  132252. /** Y */
  132253. Y = 2,
  132254. /** X */
  132255. X = 3,
  132256. /** L */
  132257. L = 4,
  132258. /** R */
  132259. R = 5,
  132260. /** ZL */
  132261. ZL = 6,
  132262. /** ZR */
  132263. ZR = 7,
  132264. /** Minus */
  132265. Minus = 8,
  132266. /** Plus */
  132267. Plus = 9,
  132268. /** LS */
  132269. LS = 10,
  132270. /** RS */
  132271. RS = 11,
  132272. /** DPadUp */
  132273. DPadUp = 12,
  132274. /** DPadDown */
  132275. DPadDown = 13,
  132276. /** DPadLeft */
  132277. DPadLeft = 14,
  132278. /** DRight */
  132279. DPadRight = 15,
  132280. /** Home */
  132281. Home = 16,
  132282. /** Capture */
  132283. Capture = 17,
  132284. /** LStickXAxis */
  132285. LStickXAxis = 18,
  132286. /** LStickYAxis */
  132287. LStickYAxis = 19,
  132288. /** RStickXAxis */
  132289. RStickXAxis = 20,
  132290. /** RStickYAxis */
  132291. RStickYAxis = 21
  132292. }
  132293. }
  132294. declare module BABYLON {
  132295. /**
  132296. * This class will take all inputs from Keyboard, Pointer, and
  132297. * any Gamepads and provide a polling system that all devices
  132298. * will use. This class assumes that there will only be one
  132299. * pointer device and one keyboard.
  132300. */
  132301. export class DeviceInputSystem implements IDisposable {
  132302. /**
  132303. * Callback to be triggered when a device is connected
  132304. */
  132305. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  132306. /**
  132307. * Callback to be triggered when a device is disconnected
  132308. */
  132309. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  132310. /**
  132311. * Callback to be triggered when event driven input is updated
  132312. */
  132313. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  132314. private _inputs;
  132315. private _gamepads;
  132316. private _keyboardActive;
  132317. private _pointerActive;
  132318. private _elementToAttachTo;
  132319. private _keyboardDownEvent;
  132320. private _keyboardUpEvent;
  132321. private _pointerMoveEvent;
  132322. private _pointerDownEvent;
  132323. private _pointerUpEvent;
  132324. private _gamepadConnectedEvent;
  132325. private _gamepadDisconnectedEvent;
  132326. private static _MAX_KEYCODES;
  132327. private static _MAX_POINTER_INPUTS;
  132328. private constructor();
  132329. /**
  132330. * Creates a new DeviceInputSystem instance
  132331. * @param engine Engine to pull input element from
  132332. * @returns The new instance
  132333. */
  132334. static Create(engine: Engine): DeviceInputSystem;
  132335. /**
  132336. * Checks for current device input value, given an id and input index
  132337. * @param deviceName Id of connected device
  132338. * @param inputIndex Index of device input
  132339. * @returns Current value of input
  132340. */
  132341. /**
  132342. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  132343. * @param deviceType Enum specifiying device type
  132344. * @param deviceSlot "Slot" or index that device is referenced in
  132345. * @param inputIndex Id of input to be checked
  132346. * @returns Current value of input
  132347. */
  132348. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  132349. /**
  132350. * Dispose of all the eventlisteners
  132351. */
  132352. dispose(): void;
  132353. /**
  132354. * Add device and inputs to device array
  132355. * @param deviceType Enum specifiying device type
  132356. * @param deviceSlot "Slot" or index that device is referenced in
  132357. * @param numberOfInputs Number of input entries to create for given device
  132358. */
  132359. private _registerDevice;
  132360. /**
  132361. * Given a specific device name, remove that device from the device map
  132362. * @param deviceType Enum specifiying device type
  132363. * @param deviceSlot "Slot" or index that device is referenced in
  132364. */
  132365. private _unregisterDevice;
  132366. /**
  132367. * Handle all actions that come from keyboard interaction
  132368. */
  132369. private _handleKeyActions;
  132370. /**
  132371. * Handle all actions that come from pointer interaction
  132372. */
  132373. private _handlePointerActions;
  132374. /**
  132375. * Handle all actions that come from gamepad interaction
  132376. */
  132377. private _handleGamepadActions;
  132378. /**
  132379. * Update all non-event based devices with each frame
  132380. * @param deviceType Enum specifiying device type
  132381. * @param deviceSlot "Slot" or index that device is referenced in
  132382. * @param inputIndex Id of input to be checked
  132383. */
  132384. private _updateDevice;
  132385. /**
  132386. * Gets DeviceType from the device name
  132387. * @param deviceName Name of Device from DeviceInputSystem
  132388. * @returns DeviceType enum value
  132389. */
  132390. private _getGamepadDeviceType;
  132391. }
  132392. }
  132393. declare module BABYLON {
  132394. /**
  132395. * Type to handle enforcement of inputs
  132396. */
  132397. 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;
  132398. }
  132399. declare module BABYLON {
  132400. /**
  132401. * Class that handles all input for a specific device
  132402. */
  132403. export class DeviceSource<T extends DeviceType> {
  132404. /** Type of device */
  132405. readonly deviceType: DeviceType;
  132406. /** "Slot" or index that device is referenced in */
  132407. readonly deviceSlot: number;
  132408. /**
  132409. * Observable to handle device input changes per device
  132410. */
  132411. readonly onInputChangedObservable: Observable<{
  132412. inputIndex: DeviceInput<T>;
  132413. previousState: Nullable<number>;
  132414. currentState: Nullable<number>;
  132415. }>;
  132416. private readonly _deviceInputSystem;
  132417. /**
  132418. * Default Constructor
  132419. * @param deviceInputSystem Reference to DeviceInputSystem
  132420. * @param deviceType Type of device
  132421. * @param deviceSlot "Slot" or index that device is referenced in
  132422. */
  132423. constructor(deviceInputSystem: DeviceInputSystem,
  132424. /** Type of device */
  132425. deviceType: DeviceType,
  132426. /** "Slot" or index that device is referenced in */
  132427. deviceSlot?: number);
  132428. /**
  132429. * Get input for specific input
  132430. * @param inputIndex index of specific input on device
  132431. * @returns Input value from DeviceInputSystem
  132432. */
  132433. getInput(inputIndex: DeviceInput<T>): number;
  132434. }
  132435. /**
  132436. * Class to keep track of devices
  132437. */
  132438. export class DeviceSourceManager implements IDisposable {
  132439. /**
  132440. * Observable to be triggered when before a device is connected
  132441. */
  132442. readonly onBeforeDeviceConnectedObservable: Observable<{
  132443. deviceType: DeviceType;
  132444. deviceSlot: number;
  132445. }>;
  132446. /**
  132447. * Observable to be triggered when before a device is disconnected
  132448. */
  132449. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  132450. deviceType: DeviceType;
  132451. deviceSlot: number;
  132452. }>;
  132453. /**
  132454. * Observable to be triggered when after a device is connected
  132455. */
  132456. readonly onAfterDeviceConnectedObservable: Observable<{
  132457. deviceType: DeviceType;
  132458. deviceSlot: number;
  132459. }>;
  132460. /**
  132461. * Observable to be triggered when after a device is disconnected
  132462. */
  132463. readonly onAfterDeviceDisconnectedObservable: Observable<{
  132464. deviceType: DeviceType;
  132465. deviceSlot: number;
  132466. }>;
  132467. private readonly _devices;
  132468. private readonly _firstDevice;
  132469. private readonly _deviceInputSystem;
  132470. /**
  132471. * Default Constructor
  132472. * @param engine engine to pull input element from
  132473. */
  132474. constructor(engine: Engine);
  132475. /**
  132476. * Gets a DeviceSource, given a type and slot
  132477. * @param deviceType Enum specifying device type
  132478. * @param deviceSlot "Slot" or index that device is referenced in
  132479. * @returns DeviceSource object
  132480. */
  132481. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  132482. /**
  132483. * Gets an array of DeviceSource objects for a given device type
  132484. * @param deviceType Enum specifying device type
  132485. * @returns Array of DeviceSource objects
  132486. */
  132487. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  132488. /**
  132489. * Dispose of DeviceInputSystem and other parts
  132490. */
  132491. dispose(): void;
  132492. /**
  132493. * Function to add device name to device list
  132494. * @param deviceType Enum specifying device type
  132495. * @param deviceSlot "Slot" or index that device is referenced in
  132496. */
  132497. private _addDevice;
  132498. /**
  132499. * Function to remove device name to device list
  132500. * @param deviceType Enum specifying device type
  132501. * @param deviceSlot "Slot" or index that device is referenced in
  132502. */
  132503. private _removeDevice;
  132504. /**
  132505. * Updates array storing first connected device of each type
  132506. * @param type Type of Device
  132507. */
  132508. private _updateFirstDevices;
  132509. }
  132510. }
  132511. declare module BABYLON {
  132512. /**
  132513. * Options to create the null engine
  132514. */
  132515. export class NullEngineOptions {
  132516. /**
  132517. * Render width (Default: 512)
  132518. */
  132519. renderWidth: number;
  132520. /**
  132521. * Render height (Default: 256)
  132522. */
  132523. renderHeight: number;
  132524. /**
  132525. * Texture size (Default: 512)
  132526. */
  132527. textureSize: number;
  132528. /**
  132529. * If delta time between frames should be constant
  132530. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132531. */
  132532. deterministicLockstep: boolean;
  132533. /**
  132534. * Maximum about of steps between frames (Default: 4)
  132535. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132536. */
  132537. lockstepMaxSteps: number;
  132538. /**
  132539. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  132540. */
  132541. useHighPrecisionMatrix?: boolean;
  132542. }
  132543. /**
  132544. * The null engine class provides support for headless version of babylon.js.
  132545. * This can be used in server side scenario or for testing purposes
  132546. */
  132547. export class NullEngine extends Engine {
  132548. private _options;
  132549. /**
  132550. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  132551. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132552. * @returns true if engine is in deterministic lock step mode
  132553. */
  132554. isDeterministicLockStep(): boolean;
  132555. /**
  132556. * Gets the max steps when engine is running in deterministic lock step
  132557. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132558. * @returns the max steps
  132559. */
  132560. getLockstepMaxSteps(): number;
  132561. /**
  132562. * Gets the current hardware scaling level.
  132563. * By default the hardware scaling level is computed from the window device ratio.
  132564. * 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.
  132565. * @returns a number indicating the current hardware scaling level
  132566. */
  132567. getHardwareScalingLevel(): number;
  132568. constructor(options?: NullEngineOptions);
  132569. /**
  132570. * Creates a vertex buffer
  132571. * @param vertices the data for the vertex buffer
  132572. * @returns the new WebGL static buffer
  132573. */
  132574. createVertexBuffer(vertices: FloatArray): DataBuffer;
  132575. /**
  132576. * Creates a new index buffer
  132577. * @param indices defines the content of the index buffer
  132578. * @param updatable defines if the index buffer must be updatable
  132579. * @returns a new webGL buffer
  132580. */
  132581. createIndexBuffer(indices: IndicesArray): DataBuffer;
  132582. /**
  132583. * Clear the current render buffer or the current render target (if any is set up)
  132584. * @param color defines the color to use
  132585. * @param backBuffer defines if the back buffer must be cleared
  132586. * @param depth defines if the depth buffer must be cleared
  132587. * @param stencil defines if the stencil buffer must be cleared
  132588. */
  132589. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132590. /**
  132591. * Gets the current render width
  132592. * @param useScreen defines if screen size must be used (or the current render target if any)
  132593. * @returns a number defining the current render width
  132594. */
  132595. getRenderWidth(useScreen?: boolean): number;
  132596. /**
  132597. * Gets the current render height
  132598. * @param useScreen defines if screen size must be used (or the current render target if any)
  132599. * @returns a number defining the current render height
  132600. */
  132601. getRenderHeight(useScreen?: boolean): number;
  132602. /**
  132603. * Set the WebGL's viewport
  132604. * @param viewport defines the viewport element to be used
  132605. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  132606. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  132607. */
  132608. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  132609. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  132610. /**
  132611. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  132612. * @param pipelineContext defines the pipeline context to use
  132613. * @param uniformsNames defines the list of uniform names
  132614. * @returns an array of webGL uniform locations
  132615. */
  132616. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  132617. /**
  132618. * Gets the lsit of active attributes for a given webGL program
  132619. * @param pipelineContext defines the pipeline context to use
  132620. * @param attributesNames defines the list of attribute names to get
  132621. * @returns an array of indices indicating the offset of each attribute
  132622. */
  132623. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132624. /**
  132625. * Binds an effect to the webGL context
  132626. * @param effect defines the effect to bind
  132627. */
  132628. bindSamplers(effect: Effect): void;
  132629. /**
  132630. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  132631. * @param effect defines the effect to activate
  132632. */
  132633. enableEffect(effect: Effect): void;
  132634. /**
  132635. * Set various states to the webGL context
  132636. * @param culling defines backface culling state
  132637. * @param zOffset defines the value to apply to zOffset (0 by default)
  132638. * @param force defines if states must be applied even if cache is up to date
  132639. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  132640. */
  132641. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132642. /**
  132643. * Set the value of an uniform to an array of int32
  132644. * @param uniform defines the webGL uniform location where to store the value
  132645. * @param array defines the array of int32 to store
  132646. * @returns true if value was set
  132647. */
  132648. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132649. /**
  132650. * Set the value of an uniform to an array of int32 (stored as vec2)
  132651. * @param uniform defines the webGL uniform location where to store the value
  132652. * @param array defines the array of int32 to store
  132653. * @returns true if value was set
  132654. */
  132655. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132656. /**
  132657. * Set the value of an uniform to an array of int32 (stored as vec3)
  132658. * @param uniform defines the webGL uniform location where to store the value
  132659. * @param array defines the array of int32 to store
  132660. * @returns true if value was set
  132661. */
  132662. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132663. /**
  132664. * Set the value of an uniform to an array of int32 (stored as vec4)
  132665. * @param uniform defines the webGL uniform location where to store the value
  132666. * @param array defines the array of int32 to store
  132667. * @returns true if value was set
  132668. */
  132669. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132670. /**
  132671. * Set the value of an uniform to an array of float32
  132672. * @param uniform defines the webGL uniform location where to store the value
  132673. * @param array defines the array of float32 to store
  132674. * @returns true if value was set
  132675. */
  132676. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132677. /**
  132678. * Set the value of an uniform to an array of float32 (stored as vec2)
  132679. * @param uniform defines the webGL uniform location where to store the value
  132680. * @param array defines the array of float32 to store
  132681. * @returns true if value was set
  132682. */
  132683. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132684. /**
  132685. * Set the value of an uniform to an array of float32 (stored as vec3)
  132686. * @param uniform defines the webGL uniform location where to store the value
  132687. * @param array defines the array of float32 to store
  132688. * @returns true if value was set
  132689. */
  132690. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132691. /**
  132692. * Set the value of an uniform to an array of float32 (stored as vec4)
  132693. * @param uniform defines the webGL uniform location where to store the value
  132694. * @param array defines the array of float32 to store
  132695. * @returns true if value was set
  132696. */
  132697. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132698. /**
  132699. * Set the value of an uniform to an array of number
  132700. * @param uniform defines the webGL uniform location where to store the value
  132701. * @param array defines the array of number to store
  132702. * @returns true if value was set
  132703. */
  132704. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  132705. /**
  132706. * Set the value of an uniform to an array of number (stored as vec2)
  132707. * @param uniform defines the webGL uniform location where to store the value
  132708. * @param array defines the array of number to store
  132709. * @returns true if value was set
  132710. */
  132711. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  132712. /**
  132713. * Set the value of an uniform to an array of number (stored as vec3)
  132714. * @param uniform defines the webGL uniform location where to store the value
  132715. * @param array defines the array of number to store
  132716. * @returns true if value was set
  132717. */
  132718. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  132719. /**
  132720. * Set the value of an uniform to an array of number (stored as vec4)
  132721. * @param uniform defines the webGL uniform location where to store the value
  132722. * @param array defines the array of number to store
  132723. * @returns true if value was set
  132724. */
  132725. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  132726. /**
  132727. * Set the value of an uniform to an array of float32 (stored as matrices)
  132728. * @param uniform defines the webGL uniform location where to store the value
  132729. * @param matrices defines the array of float32 to store
  132730. * @returns true if value was set
  132731. */
  132732. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  132733. /**
  132734. * Set the value of an uniform to a matrix (3x3)
  132735. * @param uniform defines the webGL uniform location where to store the value
  132736. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  132737. * @returns true if value was set
  132738. */
  132739. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132740. /**
  132741. * Set the value of an uniform to a matrix (2x2)
  132742. * @param uniform defines the webGL uniform location where to store the value
  132743. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  132744. * @returns true if value was set
  132745. */
  132746. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132747. /**
  132748. * Set the value of an uniform to a number (float)
  132749. * @param uniform defines the webGL uniform location where to store the value
  132750. * @param value defines the float number to store
  132751. * @returns true if value was set
  132752. */
  132753. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  132754. /**
  132755. * Set the value of an uniform to a vec2
  132756. * @param uniform defines the webGL uniform location where to store the value
  132757. * @param x defines the 1st component of the value
  132758. * @param y defines the 2nd component of the value
  132759. * @returns true if value was set
  132760. */
  132761. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  132762. /**
  132763. * Set the value of an uniform to a vec3
  132764. * @param uniform defines the webGL uniform location where to store the value
  132765. * @param x defines the 1st component of the value
  132766. * @param y defines the 2nd component of the value
  132767. * @param z defines the 3rd component of the value
  132768. * @returns true if value was set
  132769. */
  132770. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  132771. /**
  132772. * Set the value of an uniform to a boolean
  132773. * @param uniform defines the webGL uniform location where to store the value
  132774. * @param bool defines the boolean to store
  132775. * @returns true if value was set
  132776. */
  132777. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  132778. /**
  132779. * Set the value of an uniform to a vec4
  132780. * @param uniform defines the webGL uniform location where to store the value
  132781. * @param x defines the 1st component of the value
  132782. * @param y defines the 2nd component of the value
  132783. * @param z defines the 3rd component of the value
  132784. * @param w defines the 4th component of the value
  132785. * @returns true if value was set
  132786. */
  132787. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  132788. /**
  132789. * Sets the current alpha mode
  132790. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  132791. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132792. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132793. */
  132794. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132795. /**
  132796. * Bind webGl buffers directly to the webGL context
  132797. * @param vertexBuffers defines the vertex buffer to bind
  132798. * @param indexBuffer defines the index buffer to bind
  132799. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  132800. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  132801. * @param effect defines the effect associated with the vertex buffer
  132802. */
  132803. bindBuffers(vertexBuffers: {
  132804. [key: string]: VertexBuffer;
  132805. }, indexBuffer: DataBuffer, effect: Effect): void;
  132806. /**
  132807. * Force the entire cache to be cleared
  132808. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  132809. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  132810. */
  132811. wipeCaches(bruteForce?: boolean): void;
  132812. /**
  132813. * Send a draw order
  132814. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  132815. * @param indexStart defines the starting index
  132816. * @param indexCount defines the number of index to draw
  132817. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132818. */
  132819. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  132820. /**
  132821. * Draw a list of indexed primitives
  132822. * @param fillMode defines the primitive to use
  132823. * @param indexStart defines the starting index
  132824. * @param indexCount defines the number of index to draw
  132825. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132826. */
  132827. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132828. /**
  132829. * Draw a list of unindexed primitives
  132830. * @param fillMode defines the primitive to use
  132831. * @param verticesStart defines the index of first vertex to draw
  132832. * @param verticesCount defines the count of vertices to draw
  132833. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132834. */
  132835. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132836. /** @hidden */
  132837. _createTexture(): WebGLTexture;
  132838. /** @hidden */
  132839. _releaseTexture(texture: InternalTexture): void;
  132840. /**
  132841. * Usually called from Texture.ts.
  132842. * Passed information to create a WebGLTexture
  132843. * @param urlArg defines a value which contains one of the following:
  132844. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132845. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132846. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132847. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132848. * @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)
  132849. * @param scene needed for loading to the correct scene
  132850. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132851. * @param onLoad optional callback to be called upon successful completion
  132852. * @param onError optional callback to be called upon failure
  132853. * @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
  132854. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132855. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132856. * @param forcedExtension defines the extension to use to pick the right loader
  132857. * @param mimeType defines an optional mime type
  132858. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132859. */
  132860. 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;
  132861. /**
  132862. * Creates a new render target texture
  132863. * @param size defines the size of the texture
  132864. * @param options defines the options used to create the texture
  132865. * @returns a new render target texture stored in an InternalTexture
  132866. */
  132867. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  132868. /**
  132869. * Update the sampling mode of a given texture
  132870. * @param samplingMode defines the required sampling mode
  132871. * @param texture defines the texture to update
  132872. */
  132873. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132874. /**
  132875. * Binds the frame buffer to the specified texture.
  132876. * @param texture The texture to render to or null for the default canvas
  132877. * @param faceIndex The face of the texture to render to in case of cube texture
  132878. * @param requiredWidth The width of the target to render to
  132879. * @param requiredHeight The height of the target to render to
  132880. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  132881. * @param lodLevel defines le lod level to bind to the frame buffer
  132882. */
  132883. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132884. /**
  132885. * Unbind the current render target texture from the webGL context
  132886. * @param texture defines the render target texture to unbind
  132887. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  132888. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  132889. */
  132890. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132891. /**
  132892. * Creates a dynamic vertex buffer
  132893. * @param vertices the data for the dynamic vertex buffer
  132894. * @returns the new WebGL dynamic buffer
  132895. */
  132896. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  132897. /**
  132898. * Update the content of a dynamic texture
  132899. * @param texture defines the texture to update
  132900. * @param canvas defines the canvas containing the source
  132901. * @param invertY defines if data must be stored with Y axis inverted
  132902. * @param premulAlpha defines if alpha is stored as premultiplied
  132903. * @param format defines the format of the data
  132904. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  132905. */
  132906. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  132907. /**
  132908. * Gets a boolean indicating if all created effects are ready
  132909. * @returns true if all effects are ready
  132910. */
  132911. areAllEffectsReady(): boolean;
  132912. /**
  132913. * @hidden
  132914. * Get the current error code of the webGL context
  132915. * @returns the error code
  132916. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  132917. */
  132918. getError(): number;
  132919. /** @hidden */
  132920. _getUnpackAlignement(): number;
  132921. /** @hidden */
  132922. _unpackFlipY(value: boolean): void;
  132923. /**
  132924. * Update a dynamic index buffer
  132925. * @param indexBuffer defines the target index buffer
  132926. * @param indices defines the data to update
  132927. * @param offset defines the offset in the target index buffer where update should start
  132928. */
  132929. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  132930. /**
  132931. * Updates a dynamic vertex buffer.
  132932. * @param vertexBuffer the vertex buffer to update
  132933. * @param vertices the data used to update the vertex buffer
  132934. * @param byteOffset the byte offset of the data (optional)
  132935. * @param byteLength the byte length of the data (optional)
  132936. */
  132937. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  132938. /** @hidden */
  132939. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  132940. /** @hidden */
  132941. _bindTexture(channel: number, texture: InternalTexture): void;
  132942. protected _deleteBuffer(buffer: WebGLBuffer): void;
  132943. /**
  132944. * 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
  132945. */
  132946. releaseEffects(): void;
  132947. displayLoadingUI(): void;
  132948. hideLoadingUI(): void;
  132949. /** @hidden */
  132950. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132951. /** @hidden */
  132952. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132953. /** @hidden */
  132954. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132955. /** @hidden */
  132956. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132957. }
  132958. }
  132959. declare module BABYLON {
  132960. /**
  132961. * @hidden
  132962. **/
  132963. export class _TimeToken {
  132964. _startTimeQuery: Nullable<WebGLQuery>;
  132965. _endTimeQuery: Nullable<WebGLQuery>;
  132966. _timeElapsedQuery: Nullable<WebGLQuery>;
  132967. _timeElapsedQueryEnded: boolean;
  132968. }
  132969. }
  132970. declare module BABYLON {
  132971. /** @hidden */
  132972. export class _OcclusionDataStorage {
  132973. /** @hidden */
  132974. occlusionInternalRetryCounter: number;
  132975. /** @hidden */
  132976. isOcclusionQueryInProgress: boolean;
  132977. /** @hidden */
  132978. isOccluded: boolean;
  132979. /** @hidden */
  132980. occlusionRetryCount: number;
  132981. /** @hidden */
  132982. occlusionType: number;
  132983. /** @hidden */
  132984. occlusionQueryAlgorithmType: number;
  132985. }
  132986. interface Engine {
  132987. /**
  132988. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  132989. * @return the new query
  132990. */
  132991. createQuery(): WebGLQuery;
  132992. /**
  132993. * Delete and release a webGL query
  132994. * @param query defines the query to delete
  132995. * @return the current engine
  132996. */
  132997. deleteQuery(query: WebGLQuery): Engine;
  132998. /**
  132999. * Check if a given query has resolved and got its value
  133000. * @param query defines the query to check
  133001. * @returns true if the query got its value
  133002. */
  133003. isQueryResultAvailable(query: WebGLQuery): boolean;
  133004. /**
  133005. * Gets the value of a given query
  133006. * @param query defines the query to check
  133007. * @returns the value of the query
  133008. */
  133009. getQueryResult(query: WebGLQuery): number;
  133010. /**
  133011. * Initiates an occlusion query
  133012. * @param algorithmType defines the algorithm to use
  133013. * @param query defines the query to use
  133014. * @returns the current engine
  133015. * @see https://doc.babylonjs.com/features/occlusionquery
  133016. */
  133017. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  133018. /**
  133019. * Ends an occlusion query
  133020. * @see https://doc.babylonjs.com/features/occlusionquery
  133021. * @param algorithmType defines the algorithm to use
  133022. * @returns the current engine
  133023. */
  133024. endOcclusionQuery(algorithmType: number): Engine;
  133025. /**
  133026. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  133027. * Please note that only one query can be issued at a time
  133028. * @returns a time token used to track the time span
  133029. */
  133030. startTimeQuery(): Nullable<_TimeToken>;
  133031. /**
  133032. * Ends a time query
  133033. * @param token defines the token used to measure the time span
  133034. * @returns the time spent (in ns)
  133035. */
  133036. endTimeQuery(token: _TimeToken): int;
  133037. /** @hidden */
  133038. _currentNonTimestampToken: Nullable<_TimeToken>;
  133039. /** @hidden */
  133040. _createTimeQuery(): WebGLQuery;
  133041. /** @hidden */
  133042. _deleteTimeQuery(query: WebGLQuery): void;
  133043. /** @hidden */
  133044. _getGlAlgorithmType(algorithmType: number): number;
  133045. /** @hidden */
  133046. _getTimeQueryResult(query: WebGLQuery): any;
  133047. /** @hidden */
  133048. _getTimeQueryAvailability(query: WebGLQuery): any;
  133049. }
  133050. interface AbstractMesh {
  133051. /**
  133052. * Backing filed
  133053. * @hidden
  133054. */
  133055. __occlusionDataStorage: _OcclusionDataStorage;
  133056. /**
  133057. * Access property
  133058. * @hidden
  133059. */
  133060. _occlusionDataStorage: _OcclusionDataStorage;
  133061. /**
  133062. * 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.
  133063. * The default value is -1 which means don't break the query and wait till the result
  133064. * @see https://doc.babylonjs.com/features/occlusionquery
  133065. */
  133066. occlusionRetryCount: number;
  133067. /**
  133068. * 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:
  133069. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  133070. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  133071. * * 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.
  133072. * @see https://doc.babylonjs.com/features/occlusionquery
  133073. */
  133074. occlusionType: number;
  133075. /**
  133076. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  133077. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  133078. * * 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.
  133079. * @see https://doc.babylonjs.com/features/occlusionquery
  133080. */
  133081. occlusionQueryAlgorithmType: number;
  133082. /**
  133083. * 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
  133084. * @see https://doc.babylonjs.com/features/occlusionquery
  133085. */
  133086. isOccluded: boolean;
  133087. /**
  133088. * Flag to check the progress status of the query
  133089. * @see https://doc.babylonjs.com/features/occlusionquery
  133090. */
  133091. isOcclusionQueryInProgress: boolean;
  133092. }
  133093. }
  133094. declare module BABYLON {
  133095. /** @hidden */
  133096. export var _forceTransformFeedbackToBundle: boolean;
  133097. interface Engine {
  133098. /**
  133099. * Creates a webGL transform feedback object
  133100. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  133101. * @returns the webGL transform feedback object
  133102. */
  133103. createTransformFeedback(): WebGLTransformFeedback;
  133104. /**
  133105. * Delete a webGL transform feedback object
  133106. * @param value defines the webGL transform feedback object to delete
  133107. */
  133108. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  133109. /**
  133110. * Bind a webGL transform feedback object to the webgl context
  133111. * @param value defines the webGL transform feedback object to bind
  133112. */
  133113. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  133114. /**
  133115. * Begins a transform feedback operation
  133116. * @param usePoints defines if points or triangles must be used
  133117. */
  133118. beginTransformFeedback(usePoints: boolean): void;
  133119. /**
  133120. * Ends a transform feedback operation
  133121. */
  133122. endTransformFeedback(): void;
  133123. /**
  133124. * Specify the varyings to use with transform feedback
  133125. * @param program defines the associated webGL program
  133126. * @param value defines the list of strings representing the varying names
  133127. */
  133128. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  133129. /**
  133130. * Bind a webGL buffer for a transform feedback operation
  133131. * @param value defines the webGL buffer to bind
  133132. */
  133133. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  133134. }
  133135. }
  133136. declare module BABYLON {
  133137. /**
  133138. * Class used to define an additional view for the engine
  133139. * @see https://doc.babylonjs.com/how_to/multi_canvases
  133140. */
  133141. export class EngineView {
  133142. /** Defines the canvas where to render the view */
  133143. target: HTMLCanvasElement;
  133144. /** Defines an optional camera used to render the view (will use active camera else) */
  133145. camera?: Camera;
  133146. }
  133147. interface Engine {
  133148. /**
  133149. * Gets or sets the HTML element to use for attaching events
  133150. */
  133151. inputElement: Nullable<HTMLElement>;
  133152. /**
  133153. * Gets the current engine view
  133154. * @see https://doc.babylonjs.com/how_to/multi_canvases
  133155. */
  133156. activeView: Nullable<EngineView>;
  133157. /** Gets or sets the list of views */
  133158. views: EngineView[];
  133159. /**
  133160. * Register a new child canvas
  133161. * @param canvas defines the canvas to register
  133162. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  133163. * @returns the associated view
  133164. */
  133165. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  133166. /**
  133167. * Remove a registered child canvas
  133168. * @param canvas defines the canvas to remove
  133169. * @returns the current engine
  133170. */
  133171. unRegisterView(canvas: HTMLCanvasElement): Engine;
  133172. }
  133173. }
  133174. declare module BABYLON {
  133175. interface Engine {
  133176. /** @hidden */
  133177. _excludedCompressedTextures: string[];
  133178. /** @hidden */
  133179. _textureFormatInUse: string;
  133180. /**
  133181. * Gets the list of texture formats supported
  133182. */
  133183. readonly texturesSupported: Array<string>;
  133184. /**
  133185. * Gets the texture format in use
  133186. */
  133187. readonly textureFormatInUse: Nullable<string>;
  133188. /**
  133189. * Set the compressed texture extensions or file names to skip.
  133190. *
  133191. * @param skippedFiles defines the list of those texture files you want to skip
  133192. * Example: [".dds", ".env", "myfile.png"]
  133193. */
  133194. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  133195. /**
  133196. * Set the compressed texture format to use, based on the formats you have, and the formats
  133197. * supported by the hardware / browser.
  133198. *
  133199. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  133200. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  133201. * to API arguments needed to compressed textures. This puts the burden on the container
  133202. * generator to house the arcane code for determining these for current & future formats.
  133203. *
  133204. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  133205. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  133206. *
  133207. * Note: The result of this call is not taken into account when a texture is base64.
  133208. *
  133209. * @param formatsAvailable defines the list of those format families you have created
  133210. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  133211. *
  133212. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  133213. * @returns The extension selected.
  133214. */
  133215. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  133216. }
  133217. }
  133218. declare module BABYLON {
  133219. /**
  133220. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  133221. */
  133222. export interface CubeMapInfo {
  133223. /**
  133224. * The pixel array for the front face.
  133225. * This is stored in format, left to right, up to down format.
  133226. */
  133227. front: Nullable<ArrayBufferView>;
  133228. /**
  133229. * The pixel array for the back face.
  133230. * This is stored in format, left to right, up to down format.
  133231. */
  133232. back: Nullable<ArrayBufferView>;
  133233. /**
  133234. * The pixel array for the left face.
  133235. * This is stored in format, left to right, up to down format.
  133236. */
  133237. left: Nullable<ArrayBufferView>;
  133238. /**
  133239. * The pixel array for the right face.
  133240. * This is stored in format, left to right, up to down format.
  133241. */
  133242. right: Nullable<ArrayBufferView>;
  133243. /**
  133244. * The pixel array for the up face.
  133245. * This is stored in format, left to right, up to down format.
  133246. */
  133247. up: Nullable<ArrayBufferView>;
  133248. /**
  133249. * The pixel array for the down face.
  133250. * This is stored in format, left to right, up to down format.
  133251. */
  133252. down: Nullable<ArrayBufferView>;
  133253. /**
  133254. * The size of the cubemap stored.
  133255. *
  133256. * Each faces will be size * size pixels.
  133257. */
  133258. size: number;
  133259. /**
  133260. * The format of the texture.
  133261. *
  133262. * RGBA, RGB.
  133263. */
  133264. format: number;
  133265. /**
  133266. * The type of the texture data.
  133267. *
  133268. * UNSIGNED_INT, FLOAT.
  133269. */
  133270. type: number;
  133271. /**
  133272. * Specifies whether the texture is in gamma space.
  133273. */
  133274. gammaSpace: boolean;
  133275. }
  133276. /**
  133277. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  133278. */
  133279. export class PanoramaToCubeMapTools {
  133280. private static FACE_LEFT;
  133281. private static FACE_RIGHT;
  133282. private static FACE_FRONT;
  133283. private static FACE_BACK;
  133284. private static FACE_DOWN;
  133285. private static FACE_UP;
  133286. /**
  133287. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  133288. *
  133289. * @param float32Array The source data.
  133290. * @param inputWidth The width of the input panorama.
  133291. * @param inputHeight The height of the input panorama.
  133292. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  133293. * @return The cubemap data
  133294. */
  133295. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  133296. private static CreateCubemapTexture;
  133297. private static CalcProjectionSpherical;
  133298. }
  133299. }
  133300. declare module BABYLON {
  133301. /**
  133302. * Helper class dealing with the extraction of spherical polynomial dataArray
  133303. * from a cube map.
  133304. */
  133305. export class CubeMapToSphericalPolynomialTools {
  133306. private static FileFaces;
  133307. /**
  133308. * Converts a texture to the according Spherical Polynomial data.
  133309. * This extracts the first 3 orders only as they are the only one used in the lighting.
  133310. *
  133311. * @param texture The texture to extract the information from.
  133312. * @return The Spherical Polynomial data.
  133313. */
  133314. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  133315. /**
  133316. * Converts a cubemap to the according Spherical Polynomial data.
  133317. * This extracts the first 3 orders only as they are the only one used in the lighting.
  133318. *
  133319. * @param cubeInfo The Cube map to extract the information from.
  133320. * @return The Spherical Polynomial data.
  133321. */
  133322. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  133323. }
  133324. }
  133325. declare module BABYLON {
  133326. interface BaseTexture {
  133327. /**
  133328. * Get the polynomial representation of the texture data.
  133329. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  133330. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  133331. */
  133332. sphericalPolynomial: Nullable<SphericalPolynomial>;
  133333. }
  133334. }
  133335. declare module BABYLON {
  133336. /** @hidden */
  133337. export var rgbdEncodePixelShader: {
  133338. name: string;
  133339. shader: string;
  133340. };
  133341. }
  133342. declare module BABYLON {
  133343. /** @hidden */
  133344. export var rgbdDecodePixelShader: {
  133345. name: string;
  133346. shader: string;
  133347. };
  133348. }
  133349. declare module BABYLON {
  133350. /**
  133351. * Raw texture data and descriptor sufficient for WebGL texture upload
  133352. */
  133353. export interface EnvironmentTextureInfo {
  133354. /**
  133355. * Version of the environment map
  133356. */
  133357. version: number;
  133358. /**
  133359. * Width of image
  133360. */
  133361. width: number;
  133362. /**
  133363. * Irradiance information stored in the file.
  133364. */
  133365. irradiance: any;
  133366. /**
  133367. * Specular information stored in the file.
  133368. */
  133369. specular: any;
  133370. }
  133371. /**
  133372. * Defines One Image in the file. It requires only the position in the file
  133373. * as well as the length.
  133374. */
  133375. interface BufferImageData {
  133376. /**
  133377. * Length of the image data.
  133378. */
  133379. length: number;
  133380. /**
  133381. * Position of the data from the null terminator delimiting the end of the JSON.
  133382. */
  133383. position: number;
  133384. }
  133385. /**
  133386. * Defines the specular data enclosed in the file.
  133387. * This corresponds to the version 1 of the data.
  133388. */
  133389. export interface EnvironmentTextureSpecularInfoV1 {
  133390. /**
  133391. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  133392. */
  133393. specularDataPosition?: number;
  133394. /**
  133395. * This contains all the images data needed to reconstruct the cubemap.
  133396. */
  133397. mipmaps: Array<BufferImageData>;
  133398. /**
  133399. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  133400. */
  133401. lodGenerationScale: number;
  133402. }
  133403. /**
  133404. * Sets of helpers addressing the serialization and deserialization of environment texture
  133405. * stored in a BabylonJS env file.
  133406. * Those files are usually stored as .env files.
  133407. */
  133408. export class EnvironmentTextureTools {
  133409. /**
  133410. * Magic number identifying the env file.
  133411. */
  133412. private static _MagicBytes;
  133413. /**
  133414. * Gets the environment info from an env file.
  133415. * @param data The array buffer containing the .env bytes.
  133416. * @returns the environment file info (the json header) if successfully parsed.
  133417. */
  133418. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  133419. /**
  133420. * Creates an environment texture from a loaded cube texture.
  133421. * @param texture defines the cube texture to convert in env file
  133422. * @return a promise containing the environment data if succesfull.
  133423. */
  133424. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  133425. /**
  133426. * Creates a JSON representation of the spherical data.
  133427. * @param texture defines the texture containing the polynomials
  133428. * @return the JSON representation of the spherical info
  133429. */
  133430. private static _CreateEnvTextureIrradiance;
  133431. /**
  133432. * Creates the ArrayBufferViews used for initializing environment texture image data.
  133433. * @param data the image data
  133434. * @param info parameters that determine what views will be created for accessing the underlying buffer
  133435. * @return the views described by info providing access to the underlying buffer
  133436. */
  133437. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  133438. /**
  133439. * Uploads the texture info contained in the env file to the GPU.
  133440. * @param texture defines the internal texture to upload to
  133441. * @param data defines the data to load
  133442. * @param info defines the texture info retrieved through the GetEnvInfo method
  133443. * @returns a promise
  133444. */
  133445. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  133446. private static _OnImageReadyAsync;
  133447. /**
  133448. * Uploads the levels of image data to the GPU.
  133449. * @param texture defines the internal texture to upload to
  133450. * @param imageData defines the array buffer views of image data [mipmap][face]
  133451. * @returns a promise
  133452. */
  133453. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  133454. /**
  133455. * Uploads spherical polynomials information to the texture.
  133456. * @param texture defines the texture we are trying to upload the information to
  133457. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  133458. */
  133459. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  133460. /** @hidden */
  133461. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  133462. }
  133463. }
  133464. declare module BABYLON {
  133465. /**
  133466. * Class used to inline functions in shader code
  133467. */
  133468. export class ShaderCodeInliner {
  133469. private static readonly _RegexpFindFunctionNameAndType;
  133470. private _sourceCode;
  133471. private _functionDescr;
  133472. private _numMaxIterations;
  133473. /** Gets or sets the token used to mark the functions to inline */
  133474. inlineToken: string;
  133475. /** Gets or sets the debug mode */
  133476. debug: boolean;
  133477. /** Gets the code after the inlining process */
  133478. get code(): string;
  133479. /**
  133480. * Initializes the inliner
  133481. * @param sourceCode shader code source to inline
  133482. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  133483. */
  133484. constructor(sourceCode: string, numMaxIterations?: number);
  133485. /**
  133486. * Start the processing of the shader code
  133487. */
  133488. processCode(): void;
  133489. private _collectFunctions;
  133490. private _processInlining;
  133491. private _extractBetweenMarkers;
  133492. private _skipWhitespaces;
  133493. private _removeComments;
  133494. private _replaceFunctionCallsByCode;
  133495. private _findBackward;
  133496. private _escapeRegExp;
  133497. private _replaceNames;
  133498. }
  133499. }
  133500. declare module BABYLON {
  133501. /**
  133502. * Container for accessors for natively-stored mesh data buffers.
  133503. */
  133504. class NativeDataBuffer extends DataBuffer {
  133505. /**
  133506. * Accessor value used to identify/retrieve a natively-stored index buffer.
  133507. */
  133508. nativeIndexBuffer?: any;
  133509. /**
  133510. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  133511. */
  133512. nativeVertexBuffer?: any;
  133513. }
  133514. /** @hidden */
  133515. class NativeTexture extends InternalTexture {
  133516. getInternalTexture(): InternalTexture;
  133517. getViewCount(): number;
  133518. }
  133519. /** @hidden */
  133520. export class NativeEngine extends Engine {
  133521. private readonly _native;
  133522. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  133523. private readonly INVALID_HANDLE;
  133524. private _boundBuffersVertexArray;
  133525. private _currentDepthTest;
  133526. getHardwareScalingLevel(): number;
  133527. constructor();
  133528. dispose(): void;
  133529. /**
  133530. * Can be used to override the current requestAnimationFrame requester.
  133531. * @hidden
  133532. */
  133533. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  133534. /**
  133535. * Override default engine behavior.
  133536. * @param color
  133537. * @param backBuffer
  133538. * @param depth
  133539. * @param stencil
  133540. */
  133541. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  133542. /**
  133543. * Gets host document
  133544. * @returns the host document object
  133545. */
  133546. getHostDocument(): Nullable<Document>;
  133547. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  133548. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  133549. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  133550. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  133551. [key: string]: VertexBuffer;
  133552. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133553. bindBuffers(vertexBuffers: {
  133554. [key: string]: VertexBuffer;
  133555. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133556. recordVertexArrayObject(vertexBuffers: {
  133557. [key: string]: VertexBuffer;
  133558. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  133559. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133560. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133561. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  133562. /**
  133563. * Draw a list of indexed primitives
  133564. * @param fillMode defines the primitive to use
  133565. * @param indexStart defines the starting index
  133566. * @param indexCount defines the number of index to draw
  133567. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133568. */
  133569. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  133570. /**
  133571. * Draw a list of unindexed primitives
  133572. * @param fillMode defines the primitive to use
  133573. * @param verticesStart defines the index of first vertex to draw
  133574. * @param verticesCount defines the count of vertices to draw
  133575. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133576. */
  133577. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  133578. createPipelineContext(): IPipelineContext;
  133579. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  133580. /** @hidden */
  133581. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  133582. /** @hidden */
  133583. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  133584. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133585. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133586. protected _setProgram(program: WebGLProgram): void;
  133587. _releaseEffect(effect: Effect): void;
  133588. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  133589. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  133590. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  133591. bindSamplers(effect: Effect): void;
  133592. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  133593. getRenderWidth(useScreen?: boolean): number;
  133594. getRenderHeight(useScreen?: boolean): number;
  133595. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  133596. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  133597. /**
  133598. * Set the z offset to apply to current rendering
  133599. * @param value defines the offset to apply
  133600. */
  133601. setZOffset(value: number): void;
  133602. /**
  133603. * Gets the current value of the zOffset
  133604. * @returns the current zOffset state
  133605. */
  133606. getZOffset(): number;
  133607. /**
  133608. * Enable or disable depth buffering
  133609. * @param enable defines the state to set
  133610. */
  133611. setDepthBuffer(enable: boolean): void;
  133612. /**
  133613. * Gets a boolean indicating if depth writing is enabled
  133614. * @returns the current depth writing state
  133615. */
  133616. getDepthWrite(): boolean;
  133617. setDepthFunctionToGreater(): void;
  133618. setDepthFunctionToGreaterOrEqual(): void;
  133619. setDepthFunctionToLess(): void;
  133620. setDepthFunctionToLessOrEqual(): void;
  133621. /**
  133622. * Enable or disable depth writing
  133623. * @param enable defines the state to set
  133624. */
  133625. setDepthWrite(enable: boolean): void;
  133626. /**
  133627. * Enable or disable color writing
  133628. * @param enable defines the state to set
  133629. */
  133630. setColorWrite(enable: boolean): void;
  133631. /**
  133632. * Gets a boolean indicating if color writing is enabled
  133633. * @returns the current color writing state
  133634. */
  133635. getColorWrite(): boolean;
  133636. /**
  133637. * Sets alpha constants used by some alpha blending modes
  133638. * @param r defines the red component
  133639. * @param g defines the green component
  133640. * @param b defines the blue component
  133641. * @param a defines the alpha component
  133642. */
  133643. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  133644. /**
  133645. * Sets the current alpha mode
  133646. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  133647. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  133648. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133649. */
  133650. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  133651. /**
  133652. * Gets the current alpha mode
  133653. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133654. * @returns the current alpha mode
  133655. */
  133656. getAlphaMode(): number;
  133657. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  133658. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133659. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133660. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133661. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133662. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133663. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133664. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133665. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133666. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  133667. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  133668. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  133669. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  133670. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  133671. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133672. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133673. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  133674. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  133675. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  133676. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  133677. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  133678. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  133679. wipeCaches(bruteForce?: boolean): void;
  133680. _createTexture(): WebGLTexture;
  133681. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  133682. /**
  133683. * Update the content of a dynamic texture
  133684. * @param texture defines the texture to update
  133685. * @param canvas defines the canvas containing the source
  133686. * @param invertY defines if data must be stored with Y axis inverted
  133687. * @param premulAlpha defines if alpha is stored as premultiplied
  133688. * @param format defines the format of the data
  133689. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  133690. */
  133691. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  133692. /**
  133693. * Usually called from Texture.ts.
  133694. * Passed information to create a WebGLTexture
  133695. * @param url defines a value which contains one of the following:
  133696. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  133697. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  133698. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  133699. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  133700. * @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)
  133701. * @param scene needed for loading to the correct scene
  133702. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  133703. * @param onLoad optional callback to be called upon successful completion
  133704. * @param onError optional callback to be called upon failure
  133705. * @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
  133706. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  133707. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  133708. * @param forcedExtension defines the extension to use to pick the right loader
  133709. * @param mimeType defines an optional mime type
  133710. * @returns a InternalTexture for assignment back into BABYLON.Texture
  133711. */
  133712. 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;
  133713. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  133714. _releaseFramebufferObjects(texture: InternalTexture): void;
  133715. /**
  133716. * Creates a cube texture
  133717. * @param rootUrl defines the url where the files to load is located
  133718. * @param scene defines the current scene
  133719. * @param files defines the list of files to load (1 per face)
  133720. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  133721. * @param onLoad defines an optional callback raised when the texture is loaded
  133722. * @param onError defines an optional callback raised if there is an issue to load the texture
  133723. * @param format defines the format of the data
  133724. * @param forcedExtension defines the extension to use to pick the right loader
  133725. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  133726. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  133727. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  133728. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  133729. * @returns the cube texture as an InternalTexture
  133730. */
  133731. 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;
  133732. createRenderTargetTexture(size: number | {
  133733. width: number;
  133734. height: number;
  133735. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  133736. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  133737. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  133738. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  133739. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  133740. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  133741. /**
  133742. * Updates a dynamic vertex buffer.
  133743. * @param vertexBuffer the vertex buffer to update
  133744. * @param data the data used to update the vertex buffer
  133745. * @param byteOffset the byte offset of the data (optional)
  133746. * @param byteLength the byte length of the data (optional)
  133747. */
  133748. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  133749. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  133750. private _updateAnisotropicLevel;
  133751. private _getAddressMode;
  133752. /** @hidden */
  133753. _bindTexture(channel: number, texture: InternalTexture): void;
  133754. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  133755. releaseEffects(): void;
  133756. /** @hidden */
  133757. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133758. /** @hidden */
  133759. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133760. /** @hidden */
  133761. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133762. /** @hidden */
  133763. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  133764. private _getNativeSamplingMode;
  133765. private _getNativeTextureFormat;
  133766. private _getNativeAlphaMode;
  133767. private _getNativeAttribType;
  133768. }
  133769. }
  133770. declare module BABYLON {
  133771. /**
  133772. * Gather the list of clipboard event types as constants.
  133773. */
  133774. export class ClipboardEventTypes {
  133775. /**
  133776. * The clipboard event is fired when a copy command is active (pressed).
  133777. */
  133778. static readonly COPY: number;
  133779. /**
  133780. * The clipboard event is fired when a cut command is active (pressed).
  133781. */
  133782. static readonly CUT: number;
  133783. /**
  133784. * The clipboard event is fired when a paste command is active (pressed).
  133785. */
  133786. static readonly PASTE: number;
  133787. }
  133788. /**
  133789. * This class is used to store clipboard related info for the onClipboardObservable event.
  133790. */
  133791. export class ClipboardInfo {
  133792. /**
  133793. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133794. */
  133795. type: number;
  133796. /**
  133797. * Defines the related dom event
  133798. */
  133799. event: ClipboardEvent;
  133800. /**
  133801. *Creates an instance of ClipboardInfo.
  133802. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  133803. * @param event Defines the related dom event
  133804. */
  133805. constructor(
  133806. /**
  133807. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133808. */
  133809. type: number,
  133810. /**
  133811. * Defines the related dom event
  133812. */
  133813. event: ClipboardEvent);
  133814. /**
  133815. * Get the clipboard event's type from the keycode.
  133816. * @param keyCode Defines the keyCode for the current keyboard event.
  133817. * @return {number}
  133818. */
  133819. static GetTypeFromCharacter(keyCode: number): number;
  133820. }
  133821. }
  133822. declare module BABYLON {
  133823. /**
  133824. * Google Daydream controller
  133825. */
  133826. export class DaydreamController extends WebVRController {
  133827. /**
  133828. * Base Url for the controller model.
  133829. */
  133830. static MODEL_BASE_URL: string;
  133831. /**
  133832. * File name for the controller model.
  133833. */
  133834. static MODEL_FILENAME: string;
  133835. /**
  133836. * Gamepad Id prefix used to identify Daydream Controller.
  133837. */
  133838. static readonly GAMEPAD_ID_PREFIX: string;
  133839. /**
  133840. * Creates a new DaydreamController from a gamepad
  133841. * @param vrGamepad the gamepad that the controller should be created from
  133842. */
  133843. constructor(vrGamepad: any);
  133844. /**
  133845. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133846. * @param scene scene in which to add meshes
  133847. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133848. */
  133849. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133850. /**
  133851. * Called once for each button that changed state since the last frame
  133852. * @param buttonIdx Which button index changed
  133853. * @param state New state of the button
  133854. * @param changes Which properties on the state changed since last frame
  133855. */
  133856. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133857. }
  133858. }
  133859. declare module BABYLON {
  133860. /**
  133861. * Gear VR Controller
  133862. */
  133863. export class GearVRController extends WebVRController {
  133864. /**
  133865. * Base Url for the controller model.
  133866. */
  133867. static MODEL_BASE_URL: string;
  133868. /**
  133869. * File name for the controller model.
  133870. */
  133871. static MODEL_FILENAME: string;
  133872. /**
  133873. * Gamepad Id prefix used to identify this controller.
  133874. */
  133875. static readonly GAMEPAD_ID_PREFIX: string;
  133876. private readonly _buttonIndexToObservableNameMap;
  133877. /**
  133878. * Creates a new GearVRController from a gamepad
  133879. * @param vrGamepad the gamepad that the controller should be created from
  133880. */
  133881. constructor(vrGamepad: any);
  133882. /**
  133883. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133884. * @param scene scene in which to add meshes
  133885. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133886. */
  133887. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133888. /**
  133889. * Called once for each button that changed state since the last frame
  133890. * @param buttonIdx Which button index changed
  133891. * @param state New state of the button
  133892. * @param changes Which properties on the state changed since last frame
  133893. */
  133894. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133895. }
  133896. }
  133897. declare module BABYLON {
  133898. /**
  133899. * Generic Controller
  133900. */
  133901. export class GenericController extends WebVRController {
  133902. /**
  133903. * Base Url for the controller model.
  133904. */
  133905. static readonly MODEL_BASE_URL: string;
  133906. /**
  133907. * File name for the controller model.
  133908. */
  133909. static readonly MODEL_FILENAME: string;
  133910. /**
  133911. * Creates a new GenericController from a gamepad
  133912. * @param vrGamepad the gamepad that the controller should be created from
  133913. */
  133914. constructor(vrGamepad: any);
  133915. /**
  133916. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133917. * @param scene scene in which to add meshes
  133918. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133919. */
  133920. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133921. /**
  133922. * Called once for each button that changed state since the last frame
  133923. * @param buttonIdx Which button index changed
  133924. * @param state New state of the button
  133925. * @param changes Which properties on the state changed since last frame
  133926. */
  133927. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133928. }
  133929. }
  133930. declare module BABYLON {
  133931. /**
  133932. * Oculus Touch Controller
  133933. */
  133934. export class OculusTouchController extends WebVRController {
  133935. /**
  133936. * Base Url for the controller model.
  133937. */
  133938. static MODEL_BASE_URL: string;
  133939. /**
  133940. * File name for the left controller model.
  133941. */
  133942. static MODEL_LEFT_FILENAME: string;
  133943. /**
  133944. * File name for the right controller model.
  133945. */
  133946. static MODEL_RIGHT_FILENAME: string;
  133947. /**
  133948. * Base Url for the Quest controller model.
  133949. */
  133950. static QUEST_MODEL_BASE_URL: string;
  133951. /**
  133952. * @hidden
  133953. * If the controllers are running on a device that needs the updated Quest controller models
  133954. */
  133955. static _IsQuest: boolean;
  133956. /**
  133957. * Fired when the secondary trigger on this controller is modified
  133958. */
  133959. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  133960. /**
  133961. * Fired when the thumb rest on this controller is modified
  133962. */
  133963. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  133964. /**
  133965. * Creates a new OculusTouchController from a gamepad
  133966. * @param vrGamepad the gamepad that the controller should be created from
  133967. */
  133968. constructor(vrGamepad: any);
  133969. /**
  133970. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133971. * @param scene scene in which to add meshes
  133972. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133973. */
  133974. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133975. /**
  133976. * Fired when the A button on this controller is modified
  133977. */
  133978. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133979. /**
  133980. * Fired when the B button on this controller is modified
  133981. */
  133982. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133983. /**
  133984. * Fired when the X button on this controller is modified
  133985. */
  133986. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133987. /**
  133988. * Fired when the Y button on this controller is modified
  133989. */
  133990. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133991. /**
  133992. * Called once for each button that changed state since the last frame
  133993. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  133994. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  133995. * 2) secondary trigger (same)
  133996. * 3) A (right) X (left), touch, pressed = value
  133997. * 4) B / Y
  133998. * 5) thumb rest
  133999. * @param buttonIdx Which button index changed
  134000. * @param state New state of the button
  134001. * @param changes Which properties on the state changed since last frame
  134002. */
  134003. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  134004. }
  134005. }
  134006. declare module BABYLON {
  134007. /**
  134008. * Vive Controller
  134009. */
  134010. export class ViveController extends WebVRController {
  134011. /**
  134012. * Base Url for the controller model.
  134013. */
  134014. static MODEL_BASE_URL: string;
  134015. /**
  134016. * File name for the controller model.
  134017. */
  134018. static MODEL_FILENAME: string;
  134019. /**
  134020. * Creates a new ViveController from a gamepad
  134021. * @param vrGamepad the gamepad that the controller should be created from
  134022. */
  134023. constructor(vrGamepad: any);
  134024. /**
  134025. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  134026. * @param scene scene in which to add meshes
  134027. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  134028. */
  134029. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  134030. /**
  134031. * Fired when the left button on this controller is modified
  134032. */
  134033. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134034. /**
  134035. * Fired when the right button on this controller is modified
  134036. */
  134037. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134038. /**
  134039. * Fired when the menu button on this controller is modified
  134040. */
  134041. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134042. /**
  134043. * Called once for each button that changed state since the last frame
  134044. * Vive mapping:
  134045. * 0: touchpad
  134046. * 1: trigger
  134047. * 2: left AND right buttons
  134048. * 3: menu button
  134049. * @param buttonIdx Which button index changed
  134050. * @param state New state of the button
  134051. * @param changes Which properties on the state changed since last frame
  134052. */
  134053. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  134054. }
  134055. }
  134056. declare module BABYLON {
  134057. /**
  134058. * Defines the WindowsMotionController object that the state of the windows motion controller
  134059. */
  134060. export class WindowsMotionController extends WebVRController {
  134061. /**
  134062. * The base url used to load the left and right controller models
  134063. */
  134064. static MODEL_BASE_URL: string;
  134065. /**
  134066. * The name of the left controller model file
  134067. */
  134068. static MODEL_LEFT_FILENAME: string;
  134069. /**
  134070. * The name of the right controller model file
  134071. */
  134072. static MODEL_RIGHT_FILENAME: string;
  134073. /**
  134074. * The controller name prefix for this controller type
  134075. */
  134076. static readonly GAMEPAD_ID_PREFIX: string;
  134077. /**
  134078. * The controller id pattern for this controller type
  134079. */
  134080. private static readonly GAMEPAD_ID_PATTERN;
  134081. private _loadedMeshInfo;
  134082. protected readonly _mapping: {
  134083. buttons: string[];
  134084. buttonMeshNames: {
  134085. trigger: string;
  134086. menu: string;
  134087. grip: string;
  134088. thumbstick: string;
  134089. trackpad: string;
  134090. };
  134091. buttonObservableNames: {
  134092. trigger: string;
  134093. menu: string;
  134094. grip: string;
  134095. thumbstick: string;
  134096. trackpad: string;
  134097. };
  134098. axisMeshNames: string[];
  134099. pointingPoseMeshName: string;
  134100. };
  134101. /**
  134102. * Fired when the trackpad on this controller is clicked
  134103. */
  134104. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  134105. /**
  134106. * Fired when the trackpad on this controller is modified
  134107. */
  134108. onTrackpadValuesChangedObservable: Observable<StickValues>;
  134109. /**
  134110. * The current x and y values of this controller's trackpad
  134111. */
  134112. trackpad: StickValues;
  134113. /**
  134114. * Creates a new WindowsMotionController from a gamepad
  134115. * @param vrGamepad the gamepad that the controller should be created from
  134116. */
  134117. constructor(vrGamepad: any);
  134118. /**
  134119. * Fired when the trigger on this controller is modified
  134120. */
  134121. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134122. /**
  134123. * Fired when the menu button on this controller is modified
  134124. */
  134125. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134126. /**
  134127. * Fired when the grip button on this controller is modified
  134128. */
  134129. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134130. /**
  134131. * Fired when the thumbstick button on this controller is modified
  134132. */
  134133. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134134. /**
  134135. * Fired when the touchpad button on this controller is modified
  134136. */
  134137. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134138. /**
  134139. * Fired when the touchpad values on this controller are modified
  134140. */
  134141. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  134142. protected _updateTrackpad(): void;
  134143. /**
  134144. * Called once per frame by the engine.
  134145. */
  134146. update(): void;
  134147. /**
  134148. * Called once for each button that changed state since the last frame
  134149. * @param buttonIdx Which button index changed
  134150. * @param state New state of the button
  134151. * @param changes Which properties on the state changed since last frame
  134152. */
  134153. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  134154. /**
  134155. * Moves the buttons on the controller mesh based on their current state
  134156. * @param buttonName the name of the button to move
  134157. * @param buttonValue the value of the button which determines the buttons new position
  134158. */
  134159. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  134160. /**
  134161. * Moves the axis on the controller mesh based on its current state
  134162. * @param axis the index of the axis
  134163. * @param axisValue the value of the axis which determines the meshes new position
  134164. * @hidden
  134165. */
  134166. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  134167. /**
  134168. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  134169. * @param scene scene in which to add meshes
  134170. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  134171. */
  134172. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  134173. /**
  134174. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  134175. * can be transformed by button presses and axes values, based on this._mapping.
  134176. *
  134177. * @param scene scene in which the meshes exist
  134178. * @param meshes list of meshes that make up the controller model to process
  134179. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  134180. */
  134181. private processModel;
  134182. private createMeshInfo;
  134183. /**
  134184. * Gets the ray of the controller in the direction the controller is pointing
  134185. * @param length the length the resulting ray should be
  134186. * @returns a ray in the direction the controller is pointing
  134187. */
  134188. getForwardRay(length?: number): Ray;
  134189. /**
  134190. * Disposes of the controller
  134191. */
  134192. dispose(): void;
  134193. }
  134194. /**
  134195. * This class represents a new windows motion controller in XR.
  134196. */
  134197. export class XRWindowsMotionController extends WindowsMotionController {
  134198. /**
  134199. * Changing the original WIndowsMotionController mapping to fir the new mapping
  134200. */
  134201. protected readonly _mapping: {
  134202. buttons: string[];
  134203. buttonMeshNames: {
  134204. trigger: string;
  134205. menu: string;
  134206. grip: string;
  134207. thumbstick: string;
  134208. trackpad: string;
  134209. };
  134210. buttonObservableNames: {
  134211. trigger: string;
  134212. menu: string;
  134213. grip: string;
  134214. thumbstick: string;
  134215. trackpad: string;
  134216. };
  134217. axisMeshNames: string[];
  134218. pointingPoseMeshName: string;
  134219. };
  134220. /**
  134221. * Construct a new XR-Based windows motion controller
  134222. *
  134223. * @param gamepadInfo the gamepad object from the browser
  134224. */
  134225. constructor(gamepadInfo: any);
  134226. /**
  134227. * holds the thumbstick values (X,Y)
  134228. */
  134229. thumbstickValues: StickValues;
  134230. /**
  134231. * Fired when the thumbstick on this controller is clicked
  134232. */
  134233. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  134234. /**
  134235. * Fired when the thumbstick on this controller is modified
  134236. */
  134237. onThumbstickValuesChangedObservable: Observable<StickValues>;
  134238. /**
  134239. * Fired when the touchpad button on this controller is modified
  134240. */
  134241. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  134242. /**
  134243. * Fired when the touchpad values on this controller are modified
  134244. */
  134245. onTrackpadValuesChangedObservable: Observable<StickValues>;
  134246. /**
  134247. * Fired when the thumbstick button on this controller is modified
  134248. * here to prevent breaking changes
  134249. */
  134250. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134251. /**
  134252. * updating the thumbstick(!) and not the trackpad.
  134253. * This is named this way due to the difference between WebVR and XR and to avoid
  134254. * changing the parent class.
  134255. */
  134256. protected _updateTrackpad(): void;
  134257. /**
  134258. * Disposes the class with joy
  134259. */
  134260. dispose(): void;
  134261. }
  134262. }
  134263. declare module BABYLON {
  134264. /**
  134265. * Class containing static functions to help procedurally build meshes
  134266. */
  134267. export class PolyhedronBuilder {
  134268. /**
  134269. * Creates a polyhedron mesh
  134270. * * 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
  134271. * * The parameter `size` (positive float, default 1) sets the polygon size
  134272. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134273. * * 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`
  134274. * * 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
  134275. * * 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)`)
  134276. * * 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
  134277. * * 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
  134278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134281. * @param name defines the name of the mesh
  134282. * @param options defines the options used to create the mesh
  134283. * @param scene defines the hosting scene
  134284. * @returns the polyhedron mesh
  134285. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134286. */
  134287. static CreatePolyhedron(name: string, options: {
  134288. type?: number;
  134289. size?: number;
  134290. sizeX?: number;
  134291. sizeY?: number;
  134292. sizeZ?: number;
  134293. custom?: any;
  134294. faceUV?: Vector4[];
  134295. faceColors?: Color4[];
  134296. flat?: boolean;
  134297. updatable?: boolean;
  134298. sideOrientation?: number;
  134299. frontUVs?: Vector4;
  134300. backUVs?: Vector4;
  134301. }, scene?: Nullable<Scene>): Mesh;
  134302. }
  134303. }
  134304. declare module BABYLON {
  134305. /**
  134306. * Gizmo that enables scaling a mesh along 3 axis
  134307. */
  134308. export class ScaleGizmo extends Gizmo {
  134309. /**
  134310. * Internal gizmo used for interactions on the x axis
  134311. */
  134312. xGizmo: AxisScaleGizmo;
  134313. /**
  134314. * Internal gizmo used for interactions on the y axis
  134315. */
  134316. yGizmo: AxisScaleGizmo;
  134317. /**
  134318. * Internal gizmo used for interactions on the z axis
  134319. */
  134320. zGizmo: AxisScaleGizmo;
  134321. /**
  134322. * Internal gizmo used to scale all axis equally
  134323. */
  134324. uniformScaleGizmo: AxisScaleGizmo;
  134325. private _meshAttached;
  134326. private _nodeAttached;
  134327. private _snapDistance;
  134328. private _uniformScalingMesh;
  134329. private _octahedron;
  134330. private _sensitivity;
  134331. /** Fires an event when any of it's sub gizmos are dragged */
  134332. onDragStartObservable: Observable<unknown>;
  134333. /** Fires an event when any of it's sub gizmos are released from dragging */
  134334. onDragEndObservable: Observable<unknown>;
  134335. get attachedMesh(): Nullable<AbstractMesh>;
  134336. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134337. get attachedNode(): Nullable<Node>;
  134338. set attachedNode(node: Nullable<Node>);
  134339. /**
  134340. * True when the mouse pointer is hovering a gizmo mesh
  134341. */
  134342. get isHovered(): boolean;
  134343. /**
  134344. * Creates a ScaleGizmo
  134345. * @param gizmoLayer The utility layer the gizmo will be added to
  134346. * @param thickness display gizmo axis thickness
  134347. */
  134348. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  134349. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134350. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134351. /**
  134352. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134353. */
  134354. set snapDistance(value: number);
  134355. get snapDistance(): number;
  134356. /**
  134357. * Ratio for the scale of the gizmo (Default: 1)
  134358. */
  134359. set scaleRatio(value: number);
  134360. get scaleRatio(): number;
  134361. /**
  134362. * Sensitivity factor for dragging (Default: 1)
  134363. */
  134364. set sensitivity(value: number);
  134365. get sensitivity(): number;
  134366. /**
  134367. * Disposes of the gizmo
  134368. */
  134369. dispose(): void;
  134370. }
  134371. }
  134372. declare module BABYLON {
  134373. /**
  134374. * Single axis scale gizmo
  134375. */
  134376. export class AxisScaleGizmo extends Gizmo {
  134377. /**
  134378. * Drag behavior responsible for the gizmos dragging interactions
  134379. */
  134380. dragBehavior: PointerDragBehavior;
  134381. private _pointerObserver;
  134382. /**
  134383. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134384. */
  134385. snapDistance: number;
  134386. /**
  134387. * Event that fires each time the gizmo snaps to a new location.
  134388. * * snapDistance is the the change in distance
  134389. */
  134390. onSnapObservable: Observable<{
  134391. snapDistance: number;
  134392. }>;
  134393. /**
  134394. * If the scaling operation should be done on all axis (default: false)
  134395. */
  134396. uniformScaling: boolean;
  134397. /**
  134398. * Custom sensitivity value for the drag strength
  134399. */
  134400. sensitivity: number;
  134401. private _isEnabled;
  134402. private _parent;
  134403. private _arrow;
  134404. private _coloredMaterial;
  134405. private _hoverMaterial;
  134406. /**
  134407. * Creates an AxisScaleGizmo
  134408. * @param gizmoLayer The utility layer the gizmo will be added to
  134409. * @param dragAxis The axis which the gizmo will be able to scale on
  134410. * @param color The color of the gizmo
  134411. * @param thickness display gizmo axis thickness
  134412. */
  134413. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  134414. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134415. /**
  134416. * If the gizmo is enabled
  134417. */
  134418. set isEnabled(value: boolean);
  134419. get isEnabled(): boolean;
  134420. /**
  134421. * Disposes of the gizmo
  134422. */
  134423. dispose(): void;
  134424. /**
  134425. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134426. * @param mesh The mesh to replace the default mesh of the gizmo
  134427. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  134428. */
  134429. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  134430. }
  134431. }
  134432. declare module BABYLON {
  134433. /**
  134434. * Bounding box gizmo
  134435. */
  134436. export class BoundingBoxGizmo extends Gizmo {
  134437. private _lineBoundingBox;
  134438. private _rotateSpheresParent;
  134439. private _scaleBoxesParent;
  134440. private _boundingDimensions;
  134441. private _renderObserver;
  134442. private _pointerObserver;
  134443. private _scaleDragSpeed;
  134444. private _tmpQuaternion;
  134445. private _tmpVector;
  134446. private _tmpRotationMatrix;
  134447. /**
  134448. * 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)
  134449. */
  134450. ignoreChildren: boolean;
  134451. /**
  134452. * 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)
  134453. */
  134454. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  134455. /**
  134456. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  134457. */
  134458. rotationSphereSize: number;
  134459. /**
  134460. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  134461. */
  134462. scaleBoxSize: number;
  134463. /**
  134464. * 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)
  134465. */
  134466. fixedDragMeshScreenSize: boolean;
  134467. /**
  134468. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  134469. */
  134470. fixedDragMeshScreenSizeDistanceFactor: number;
  134471. /**
  134472. * Fired when a rotation sphere or scale box is dragged
  134473. */
  134474. onDragStartObservable: Observable<{}>;
  134475. /**
  134476. * Fired when a scale box is dragged
  134477. */
  134478. onScaleBoxDragObservable: Observable<{}>;
  134479. /**
  134480. * Fired when a scale box drag is ended
  134481. */
  134482. onScaleBoxDragEndObservable: Observable<{}>;
  134483. /**
  134484. * Fired when a rotation sphere is dragged
  134485. */
  134486. onRotationSphereDragObservable: Observable<{}>;
  134487. /**
  134488. * Fired when a rotation sphere drag is ended
  134489. */
  134490. onRotationSphereDragEndObservable: Observable<{}>;
  134491. /**
  134492. * 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)
  134493. */
  134494. scalePivot: Nullable<Vector3>;
  134495. /**
  134496. * Mesh used as a pivot to rotate the attached node
  134497. */
  134498. private _anchorMesh;
  134499. private _existingMeshScale;
  134500. private _dragMesh;
  134501. private pointerDragBehavior;
  134502. private coloredMaterial;
  134503. private hoverColoredMaterial;
  134504. /**
  134505. * Sets the color of the bounding box gizmo
  134506. * @param color the color to set
  134507. */
  134508. setColor(color: Color3): void;
  134509. /**
  134510. * Creates an BoundingBoxGizmo
  134511. * @param gizmoLayer The utility layer the gizmo will be added to
  134512. * @param color The color of the gizmo
  134513. */
  134514. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  134515. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  134516. private _selectNode;
  134517. /**
  134518. * Updates the bounding box information for the Gizmo
  134519. */
  134520. updateBoundingBox(): void;
  134521. private _updateRotationSpheres;
  134522. private _updateScaleBoxes;
  134523. /**
  134524. * Enables rotation on the specified axis and disables rotation on the others
  134525. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  134526. */
  134527. setEnabledRotationAxis(axis: string): void;
  134528. /**
  134529. * Enables/disables scaling
  134530. * @param enable if scaling should be enabled
  134531. * @param homogeneousScaling defines if scaling should only be homogeneous
  134532. */
  134533. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  134534. private _updateDummy;
  134535. /**
  134536. * Enables a pointer drag behavior on the bounding box of the gizmo
  134537. */
  134538. enableDragBehavior(): void;
  134539. /**
  134540. * Disposes of the gizmo
  134541. */
  134542. dispose(): void;
  134543. /**
  134544. * 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)
  134545. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  134546. * @returns the bounding box mesh with the passed in mesh as a child
  134547. */
  134548. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  134549. /**
  134550. * CustomMeshes are not supported by this gizmo
  134551. * @param mesh The mesh to replace the default mesh of the gizmo
  134552. */
  134553. setCustomMesh(mesh: Mesh): void;
  134554. }
  134555. }
  134556. declare module BABYLON {
  134557. /**
  134558. * Single plane rotation gizmo
  134559. */
  134560. export class PlaneRotationGizmo extends Gizmo {
  134561. /**
  134562. * Drag behavior responsible for the gizmos dragging interactions
  134563. */
  134564. dragBehavior: PointerDragBehavior;
  134565. private _pointerObserver;
  134566. /**
  134567. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  134568. */
  134569. snapDistance: number;
  134570. /**
  134571. * Event that fires each time the gizmo snaps to a new location.
  134572. * * snapDistance is the the change in distance
  134573. */
  134574. onSnapObservable: Observable<{
  134575. snapDistance: number;
  134576. }>;
  134577. private _isEnabled;
  134578. private _parent;
  134579. /**
  134580. * Creates a PlaneRotationGizmo
  134581. * @param gizmoLayer The utility layer the gizmo will be added to
  134582. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  134583. * @param color The color of the gizmo
  134584. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134585. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134586. * @param thickness display gizmo axis thickness
  134587. */
  134588. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  134589. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134590. /**
  134591. * If the gizmo is enabled
  134592. */
  134593. set isEnabled(value: boolean);
  134594. get isEnabled(): boolean;
  134595. /**
  134596. * Disposes of the gizmo
  134597. */
  134598. dispose(): void;
  134599. }
  134600. }
  134601. declare module BABYLON {
  134602. /**
  134603. * Gizmo that enables rotating a mesh along 3 axis
  134604. */
  134605. export class RotationGizmo extends Gizmo {
  134606. /**
  134607. * Internal gizmo used for interactions on the x axis
  134608. */
  134609. xGizmo: PlaneRotationGizmo;
  134610. /**
  134611. * Internal gizmo used for interactions on the y axis
  134612. */
  134613. yGizmo: PlaneRotationGizmo;
  134614. /**
  134615. * Internal gizmo used for interactions on the z axis
  134616. */
  134617. zGizmo: PlaneRotationGizmo;
  134618. /** Fires an event when any of it's sub gizmos are dragged */
  134619. onDragStartObservable: Observable<unknown>;
  134620. /** Fires an event when any of it's sub gizmos are released from dragging */
  134621. onDragEndObservable: Observable<unknown>;
  134622. private _meshAttached;
  134623. private _nodeAttached;
  134624. get attachedMesh(): Nullable<AbstractMesh>;
  134625. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134626. get attachedNode(): Nullable<Node>;
  134627. set attachedNode(node: Nullable<Node>);
  134628. /**
  134629. * True when the mouse pointer is hovering a gizmo mesh
  134630. */
  134631. get isHovered(): boolean;
  134632. /**
  134633. * Creates a RotationGizmo
  134634. * @param gizmoLayer The utility layer the gizmo will be added to
  134635. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134636. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134637. * @param thickness display gizmo axis thickness
  134638. */
  134639. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  134640. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134641. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134642. /**
  134643. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134644. */
  134645. set snapDistance(value: number);
  134646. get snapDistance(): number;
  134647. /**
  134648. * Ratio for the scale of the gizmo (Default: 1)
  134649. */
  134650. set scaleRatio(value: number);
  134651. get scaleRatio(): number;
  134652. /**
  134653. * Disposes of the gizmo
  134654. */
  134655. dispose(): void;
  134656. /**
  134657. * CustomMeshes are not supported by this gizmo
  134658. * @param mesh The mesh to replace the default mesh of the gizmo
  134659. */
  134660. setCustomMesh(mesh: Mesh): void;
  134661. }
  134662. }
  134663. declare module BABYLON {
  134664. /**
  134665. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  134666. */
  134667. export class GizmoManager implements IDisposable {
  134668. private scene;
  134669. /**
  134670. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  134671. */
  134672. gizmos: {
  134673. positionGizmo: Nullable<PositionGizmo>;
  134674. rotationGizmo: Nullable<RotationGizmo>;
  134675. scaleGizmo: Nullable<ScaleGizmo>;
  134676. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  134677. };
  134678. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  134679. clearGizmoOnEmptyPointerEvent: boolean;
  134680. /** Fires an event when the manager is attached to a mesh */
  134681. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  134682. /** Fires an event when the manager is attached to a node */
  134683. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  134684. private _gizmosEnabled;
  134685. private _pointerObserver;
  134686. private _attachedMesh;
  134687. private _attachedNode;
  134688. private _boundingBoxColor;
  134689. private _defaultUtilityLayer;
  134690. private _defaultKeepDepthUtilityLayer;
  134691. private _thickness;
  134692. /**
  134693. * When bounding box gizmo is enabled, this can be used to track drag/end events
  134694. */
  134695. boundingBoxDragBehavior: SixDofDragBehavior;
  134696. /**
  134697. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  134698. */
  134699. attachableMeshes: Nullable<Array<AbstractMesh>>;
  134700. /**
  134701. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  134702. */
  134703. attachableNodes: Nullable<Array<Node>>;
  134704. /**
  134705. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  134706. */
  134707. usePointerToAttachGizmos: boolean;
  134708. /**
  134709. * Utility layer that the bounding box gizmo belongs to
  134710. */
  134711. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  134712. /**
  134713. * Utility layer that all gizmos besides bounding box belong to
  134714. */
  134715. get utilityLayer(): UtilityLayerRenderer;
  134716. /**
  134717. * True when the mouse pointer is hovering a gizmo mesh
  134718. */
  134719. get isHovered(): boolean;
  134720. /**
  134721. * Instatiates a gizmo manager
  134722. * @param scene the scene to overlay the gizmos on top of
  134723. * @param thickness display gizmo axis thickness
  134724. */
  134725. constructor(scene: Scene, thickness?: number);
  134726. /**
  134727. * Attaches a set of gizmos to the specified mesh
  134728. * @param mesh The mesh the gizmo's should be attached to
  134729. */
  134730. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  134731. /**
  134732. * Attaches a set of gizmos to the specified node
  134733. * @param node The node the gizmo's should be attached to
  134734. */
  134735. attachToNode(node: Nullable<Node>): void;
  134736. /**
  134737. * If the position gizmo is enabled
  134738. */
  134739. set positionGizmoEnabled(value: boolean);
  134740. get positionGizmoEnabled(): boolean;
  134741. /**
  134742. * If the rotation gizmo is enabled
  134743. */
  134744. set rotationGizmoEnabled(value: boolean);
  134745. get rotationGizmoEnabled(): boolean;
  134746. /**
  134747. * If the scale gizmo is enabled
  134748. */
  134749. set scaleGizmoEnabled(value: boolean);
  134750. get scaleGizmoEnabled(): boolean;
  134751. /**
  134752. * If the boundingBox gizmo is enabled
  134753. */
  134754. set boundingBoxGizmoEnabled(value: boolean);
  134755. get boundingBoxGizmoEnabled(): boolean;
  134756. /**
  134757. * Disposes of the gizmo manager
  134758. */
  134759. dispose(): void;
  134760. }
  134761. }
  134762. declare module BABYLON {
  134763. /**
  134764. * A directional light is defined by a direction (what a surprise!).
  134765. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  134766. * 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.
  134767. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134768. */
  134769. export class DirectionalLight extends ShadowLight {
  134770. private _shadowFrustumSize;
  134771. /**
  134772. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  134773. */
  134774. get shadowFrustumSize(): number;
  134775. /**
  134776. * Specifies a fix frustum size for the shadow generation.
  134777. */
  134778. set shadowFrustumSize(value: number);
  134779. private _shadowOrthoScale;
  134780. /**
  134781. * Gets the shadow projection scale against the optimal computed one.
  134782. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134783. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134784. */
  134785. get shadowOrthoScale(): number;
  134786. /**
  134787. * Sets the shadow projection scale against the optimal computed one.
  134788. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134789. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134790. */
  134791. set shadowOrthoScale(value: number);
  134792. /**
  134793. * Automatically compute the projection matrix to best fit (including all the casters)
  134794. * on each frame.
  134795. */
  134796. autoUpdateExtends: boolean;
  134797. /**
  134798. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  134799. * on each frame. autoUpdateExtends must be set to true for this to work
  134800. */
  134801. autoCalcShadowZBounds: boolean;
  134802. private _orthoLeft;
  134803. private _orthoRight;
  134804. private _orthoTop;
  134805. private _orthoBottom;
  134806. /**
  134807. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  134808. * The directional light is emitted from everywhere in the given direction.
  134809. * It can cast shadows.
  134810. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134811. * @param name The friendly name of the light
  134812. * @param direction The direction of the light
  134813. * @param scene The scene the light belongs to
  134814. */
  134815. constructor(name: string, direction: Vector3, scene: Scene);
  134816. /**
  134817. * Returns the string "DirectionalLight".
  134818. * @return The class name
  134819. */
  134820. getClassName(): string;
  134821. /**
  134822. * Returns the integer 1.
  134823. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134824. */
  134825. getTypeID(): number;
  134826. /**
  134827. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  134828. * Returns the DirectionalLight Shadow projection matrix.
  134829. */
  134830. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134831. /**
  134832. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  134833. * Returns the DirectionalLight Shadow projection matrix.
  134834. */
  134835. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  134836. /**
  134837. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  134838. * Returns the DirectionalLight Shadow projection matrix.
  134839. */
  134840. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134841. protected _buildUniformLayout(): void;
  134842. /**
  134843. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  134844. * @param effect The effect to update
  134845. * @param lightIndex The index of the light in the effect to update
  134846. * @returns The directional light
  134847. */
  134848. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  134849. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  134850. /**
  134851. * Gets the minZ used for shadow according to both the scene and the light.
  134852. *
  134853. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134854. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134855. * @param activeCamera The camera we are returning the min for
  134856. * @returns the depth min z
  134857. */
  134858. getDepthMinZ(activeCamera: Camera): number;
  134859. /**
  134860. * Gets the maxZ used for shadow according to both the scene and the light.
  134861. *
  134862. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134863. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134864. * @param activeCamera The camera we are returning the max for
  134865. * @returns the depth max z
  134866. */
  134867. getDepthMaxZ(activeCamera: Camera): number;
  134868. /**
  134869. * Prepares the list of defines specific to the light type.
  134870. * @param defines the list of defines
  134871. * @param lightIndex defines the index of the light for the effect
  134872. */
  134873. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134874. }
  134875. }
  134876. declare module BABYLON {
  134877. /**
  134878. * Class containing static functions to help procedurally build meshes
  134879. */
  134880. export class HemisphereBuilder {
  134881. /**
  134882. * Creates a hemisphere mesh
  134883. * @param name defines the name of the mesh
  134884. * @param options defines the options used to create the mesh
  134885. * @param scene defines the hosting scene
  134886. * @returns the hemisphere mesh
  134887. */
  134888. static CreateHemisphere(name: string, options: {
  134889. segments?: number;
  134890. diameter?: number;
  134891. sideOrientation?: number;
  134892. }, scene: any): Mesh;
  134893. }
  134894. }
  134895. declare module BABYLON {
  134896. /**
  134897. * A spot light is defined by a position, a direction, an angle, and an exponent.
  134898. * These values define a cone of light starting from the position, emitting toward the direction.
  134899. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  134900. * and the exponent defines the speed of the decay of the light with distance (reach).
  134901. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134902. */
  134903. export class SpotLight extends ShadowLight {
  134904. private _angle;
  134905. private _innerAngle;
  134906. private _cosHalfAngle;
  134907. private _lightAngleScale;
  134908. private _lightAngleOffset;
  134909. /**
  134910. * Gets the cone angle of the spot light in Radians.
  134911. */
  134912. get angle(): number;
  134913. /**
  134914. * Sets the cone angle of the spot light in Radians.
  134915. */
  134916. set angle(value: number);
  134917. /**
  134918. * Only used in gltf falloff mode, this defines the angle where
  134919. * the directional falloff will start before cutting at angle which could be seen
  134920. * as outer angle.
  134921. */
  134922. get innerAngle(): number;
  134923. /**
  134924. * Only used in gltf falloff mode, this defines the angle where
  134925. * the directional falloff will start before cutting at angle which could be seen
  134926. * as outer angle.
  134927. */
  134928. set innerAngle(value: number);
  134929. private _shadowAngleScale;
  134930. /**
  134931. * Allows scaling the angle of the light for shadow generation only.
  134932. */
  134933. get shadowAngleScale(): number;
  134934. /**
  134935. * Allows scaling the angle of the light for shadow generation only.
  134936. */
  134937. set shadowAngleScale(value: number);
  134938. /**
  134939. * The light decay speed with the distance from the emission spot.
  134940. */
  134941. exponent: number;
  134942. private _projectionTextureMatrix;
  134943. /**
  134944. * Allows reading the projecton texture
  134945. */
  134946. get projectionTextureMatrix(): Matrix;
  134947. protected _projectionTextureLightNear: number;
  134948. /**
  134949. * Gets the near clip of the Spotlight for texture projection.
  134950. */
  134951. get projectionTextureLightNear(): number;
  134952. /**
  134953. * Sets the near clip of the Spotlight for texture projection.
  134954. */
  134955. set projectionTextureLightNear(value: number);
  134956. protected _projectionTextureLightFar: number;
  134957. /**
  134958. * Gets the far clip of the Spotlight for texture projection.
  134959. */
  134960. get projectionTextureLightFar(): number;
  134961. /**
  134962. * Sets the far clip of the Spotlight for texture projection.
  134963. */
  134964. set projectionTextureLightFar(value: number);
  134965. protected _projectionTextureUpDirection: Vector3;
  134966. /**
  134967. * Gets the Up vector of the Spotlight for texture projection.
  134968. */
  134969. get projectionTextureUpDirection(): Vector3;
  134970. /**
  134971. * Sets the Up vector of the Spotlight for texture projection.
  134972. */
  134973. set projectionTextureUpDirection(value: Vector3);
  134974. private _projectionTexture;
  134975. /**
  134976. * Gets the projection texture of the light.
  134977. */
  134978. get projectionTexture(): Nullable<BaseTexture>;
  134979. /**
  134980. * Sets the projection texture of the light.
  134981. */
  134982. set projectionTexture(value: Nullable<BaseTexture>);
  134983. private _projectionTextureViewLightDirty;
  134984. private _projectionTextureProjectionLightDirty;
  134985. private _projectionTextureDirty;
  134986. private _projectionTextureViewTargetVector;
  134987. private _projectionTextureViewLightMatrix;
  134988. private _projectionTextureProjectionLightMatrix;
  134989. private _projectionTextureScalingMatrix;
  134990. /**
  134991. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  134992. * It can cast shadows.
  134993. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134994. * @param name The light friendly name
  134995. * @param position The position of the spot light in the scene
  134996. * @param direction The direction of the light in the scene
  134997. * @param angle The cone angle of the light in Radians
  134998. * @param exponent The light decay speed with the distance from the emission spot
  134999. * @param scene The scene the lights belongs to
  135000. */
  135001. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  135002. /**
  135003. * Returns the string "SpotLight".
  135004. * @returns the class name
  135005. */
  135006. getClassName(): string;
  135007. /**
  135008. * Returns the integer 2.
  135009. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  135010. */
  135011. getTypeID(): number;
  135012. /**
  135013. * Overrides the direction setter to recompute the projection texture view light Matrix.
  135014. */
  135015. protected _setDirection(value: Vector3): void;
  135016. /**
  135017. * Overrides the position setter to recompute the projection texture view light Matrix.
  135018. */
  135019. protected _setPosition(value: Vector3): void;
  135020. /**
  135021. * 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.
  135022. * Returns the SpotLight.
  135023. */
  135024. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  135025. protected _computeProjectionTextureViewLightMatrix(): void;
  135026. protected _computeProjectionTextureProjectionLightMatrix(): void;
  135027. /**
  135028. * Main function for light texture projection matrix computing.
  135029. */
  135030. protected _computeProjectionTextureMatrix(): void;
  135031. protected _buildUniformLayout(): void;
  135032. private _computeAngleValues;
  135033. /**
  135034. * Sets the passed Effect "effect" with the Light textures.
  135035. * @param effect The effect to update
  135036. * @param lightIndex The index of the light in the effect to update
  135037. * @returns The light
  135038. */
  135039. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  135040. /**
  135041. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  135042. * @param effect The effect to update
  135043. * @param lightIndex The index of the light in the effect to update
  135044. * @returns The spot light
  135045. */
  135046. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  135047. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  135048. /**
  135049. * Disposes the light and the associated resources.
  135050. */
  135051. dispose(): void;
  135052. /**
  135053. * Prepares the list of defines specific to the light type.
  135054. * @param defines the list of defines
  135055. * @param lightIndex defines the index of the light for the effect
  135056. */
  135057. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  135058. }
  135059. }
  135060. declare module BABYLON {
  135061. /**
  135062. * Gizmo that enables viewing a light
  135063. */
  135064. export class LightGizmo extends Gizmo {
  135065. private _lightMesh;
  135066. private _material;
  135067. private _cachedPosition;
  135068. private _cachedForward;
  135069. private _attachedMeshParent;
  135070. private _pointerObserver;
  135071. /**
  135072. * Event that fires each time the gizmo is clicked
  135073. */
  135074. onClickedObservable: Observable<Light>;
  135075. /**
  135076. * Creates a LightGizmo
  135077. * @param gizmoLayer The utility layer the gizmo will be added to
  135078. */
  135079. constructor(gizmoLayer?: UtilityLayerRenderer);
  135080. private _light;
  135081. /**
  135082. * The light that the gizmo is attached to
  135083. */
  135084. set light(light: Nullable<Light>);
  135085. get light(): Nullable<Light>;
  135086. /**
  135087. * Gets the material used to render the light gizmo
  135088. */
  135089. get material(): StandardMaterial;
  135090. /**
  135091. * @hidden
  135092. * Updates the gizmo to match the attached mesh's position/rotation
  135093. */
  135094. protected _update(): void;
  135095. private static _Scale;
  135096. /**
  135097. * Creates the lines for a light mesh
  135098. */
  135099. private static _CreateLightLines;
  135100. /**
  135101. * Disposes of the light gizmo
  135102. */
  135103. dispose(): void;
  135104. private static _CreateHemisphericLightMesh;
  135105. private static _CreatePointLightMesh;
  135106. private static _CreateSpotLightMesh;
  135107. private static _CreateDirectionalLightMesh;
  135108. }
  135109. }
  135110. declare module BABYLON {
  135111. /**
  135112. * Gizmo that enables viewing a camera
  135113. */
  135114. export class CameraGizmo extends Gizmo {
  135115. private _cameraMesh;
  135116. private _cameraLinesMesh;
  135117. private _material;
  135118. private _pointerObserver;
  135119. /**
  135120. * Event that fires each time the gizmo is clicked
  135121. */
  135122. onClickedObservable: Observable<Camera>;
  135123. /**
  135124. * Creates a CameraGizmo
  135125. * @param gizmoLayer The utility layer the gizmo will be added to
  135126. */
  135127. constructor(gizmoLayer?: UtilityLayerRenderer);
  135128. private _camera;
  135129. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  135130. get displayFrustum(): boolean;
  135131. set displayFrustum(value: boolean);
  135132. /**
  135133. * The camera that the gizmo is attached to
  135134. */
  135135. set camera(camera: Nullable<Camera>);
  135136. get camera(): Nullable<Camera>;
  135137. /**
  135138. * Gets the material used to render the camera gizmo
  135139. */
  135140. get material(): StandardMaterial;
  135141. /**
  135142. * @hidden
  135143. * Updates the gizmo to match the attached mesh's position/rotation
  135144. */
  135145. protected _update(): void;
  135146. private static _Scale;
  135147. private _invProjection;
  135148. /**
  135149. * Disposes of the camera gizmo
  135150. */
  135151. dispose(): void;
  135152. private static _CreateCameraMesh;
  135153. private static _CreateCameraFrustum;
  135154. }
  135155. }
  135156. declare module BABYLON {
  135157. /** @hidden */
  135158. export var backgroundFragmentDeclaration: {
  135159. name: string;
  135160. shader: string;
  135161. };
  135162. }
  135163. declare module BABYLON {
  135164. /** @hidden */
  135165. export var backgroundUboDeclaration: {
  135166. name: string;
  135167. shader: string;
  135168. };
  135169. }
  135170. declare module BABYLON {
  135171. /** @hidden */
  135172. export var backgroundPixelShader: {
  135173. name: string;
  135174. shader: string;
  135175. };
  135176. }
  135177. declare module BABYLON {
  135178. /** @hidden */
  135179. export var backgroundVertexDeclaration: {
  135180. name: string;
  135181. shader: string;
  135182. };
  135183. }
  135184. declare module BABYLON {
  135185. /** @hidden */
  135186. export var backgroundVertexShader: {
  135187. name: string;
  135188. shader: string;
  135189. };
  135190. }
  135191. declare module BABYLON {
  135192. /**
  135193. * Background material used to create an efficient environement around your scene.
  135194. */
  135195. export class BackgroundMaterial extends PushMaterial {
  135196. /**
  135197. * Standard reflectance value at parallel view angle.
  135198. */
  135199. static StandardReflectance0: number;
  135200. /**
  135201. * Standard reflectance value at grazing angle.
  135202. */
  135203. static StandardReflectance90: number;
  135204. protected _primaryColor: Color3;
  135205. /**
  135206. * Key light Color (multiply against the environement texture)
  135207. */
  135208. primaryColor: Color3;
  135209. protected __perceptualColor: Nullable<Color3>;
  135210. /**
  135211. * Experimental Internal Use Only.
  135212. *
  135213. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  135214. * This acts as a helper to set the primary color to a more "human friendly" value.
  135215. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  135216. * output color as close as possible from the chosen value.
  135217. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  135218. * part of lighting setup.)
  135219. */
  135220. get _perceptualColor(): Nullable<Color3>;
  135221. set _perceptualColor(value: Nullable<Color3>);
  135222. protected _primaryColorShadowLevel: float;
  135223. /**
  135224. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  135225. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  135226. */
  135227. get primaryColorShadowLevel(): float;
  135228. set primaryColorShadowLevel(value: float);
  135229. protected _primaryColorHighlightLevel: float;
  135230. /**
  135231. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  135232. * The primary color is used at the level chosen to define what the white area would look.
  135233. */
  135234. get primaryColorHighlightLevel(): float;
  135235. set primaryColorHighlightLevel(value: float);
  135236. protected _reflectionTexture: Nullable<BaseTexture>;
  135237. /**
  135238. * Reflection Texture used in the material.
  135239. * Should be author in a specific way for the best result (refer to the documentation).
  135240. */
  135241. reflectionTexture: Nullable<BaseTexture>;
  135242. protected _reflectionBlur: float;
  135243. /**
  135244. * Reflection Texture level of blur.
  135245. *
  135246. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  135247. * texture twice.
  135248. */
  135249. reflectionBlur: float;
  135250. protected _diffuseTexture: Nullable<BaseTexture>;
  135251. /**
  135252. * Diffuse Texture used in the material.
  135253. * Should be author in a specific way for the best result (refer to the documentation).
  135254. */
  135255. diffuseTexture: Nullable<BaseTexture>;
  135256. protected _shadowLights: Nullable<IShadowLight[]>;
  135257. /**
  135258. * Specify the list of lights casting shadow on the material.
  135259. * All scene shadow lights will be included if null.
  135260. */
  135261. shadowLights: Nullable<IShadowLight[]>;
  135262. protected _shadowLevel: float;
  135263. /**
  135264. * Helps adjusting the shadow to a softer level if required.
  135265. * 0 means black shadows and 1 means no shadows.
  135266. */
  135267. shadowLevel: float;
  135268. protected _sceneCenter: Vector3;
  135269. /**
  135270. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  135271. * It is usually zero but might be interesting to modify according to your setup.
  135272. */
  135273. sceneCenter: Vector3;
  135274. protected _opacityFresnel: boolean;
  135275. /**
  135276. * This helps specifying that the material is falling off to the sky box at grazing angle.
  135277. * This helps ensuring a nice transition when the camera goes under the ground.
  135278. */
  135279. opacityFresnel: boolean;
  135280. protected _reflectionFresnel: boolean;
  135281. /**
  135282. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  135283. * This helps adding a mirror texture on the ground.
  135284. */
  135285. reflectionFresnel: boolean;
  135286. protected _reflectionFalloffDistance: number;
  135287. /**
  135288. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  135289. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  135290. */
  135291. reflectionFalloffDistance: number;
  135292. protected _reflectionAmount: number;
  135293. /**
  135294. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  135295. */
  135296. reflectionAmount: number;
  135297. protected _reflectionReflectance0: number;
  135298. /**
  135299. * This specifies the weight of the reflection at grazing angle.
  135300. */
  135301. reflectionReflectance0: number;
  135302. protected _reflectionReflectance90: number;
  135303. /**
  135304. * This specifies the weight of the reflection at a perpendicular point of view.
  135305. */
  135306. reflectionReflectance90: number;
  135307. /**
  135308. * Sets the reflection reflectance fresnel values according to the default standard
  135309. * empirically know to work well :-)
  135310. */
  135311. set reflectionStandardFresnelWeight(value: number);
  135312. protected _useRGBColor: boolean;
  135313. /**
  135314. * Helps to directly use the maps channels instead of their level.
  135315. */
  135316. useRGBColor: boolean;
  135317. protected _enableNoise: boolean;
  135318. /**
  135319. * This helps reducing the banding effect that could occur on the background.
  135320. */
  135321. enableNoise: boolean;
  135322. /**
  135323. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135324. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  135325. * Recommended to be keep at 1.0 except for special cases.
  135326. */
  135327. get fovMultiplier(): number;
  135328. set fovMultiplier(value: number);
  135329. private _fovMultiplier;
  135330. /**
  135331. * Enable the FOV adjustment feature controlled by fovMultiplier.
  135332. */
  135333. useEquirectangularFOV: boolean;
  135334. private _maxSimultaneousLights;
  135335. /**
  135336. * Number of Simultaneous lights allowed on the material.
  135337. */
  135338. maxSimultaneousLights: int;
  135339. private _shadowOnly;
  135340. /**
  135341. * Make the material only render shadows
  135342. */
  135343. shadowOnly: boolean;
  135344. /**
  135345. * Default configuration related to image processing available in the Background Material.
  135346. */
  135347. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  135348. /**
  135349. * Keep track of the image processing observer to allow dispose and replace.
  135350. */
  135351. private _imageProcessingObserver;
  135352. /**
  135353. * Attaches a new image processing configuration to the PBR Material.
  135354. * @param configuration (if null the scene configuration will be use)
  135355. */
  135356. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  135357. /**
  135358. * Gets the image processing configuration used either in this material.
  135359. */
  135360. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  135361. /**
  135362. * Sets the Default image processing configuration used either in the this material.
  135363. *
  135364. * If sets to null, the scene one is in use.
  135365. */
  135366. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  135367. /**
  135368. * Gets wether the color curves effect is enabled.
  135369. */
  135370. get cameraColorCurvesEnabled(): boolean;
  135371. /**
  135372. * Sets wether the color curves effect is enabled.
  135373. */
  135374. set cameraColorCurvesEnabled(value: boolean);
  135375. /**
  135376. * Gets wether the color grading effect is enabled.
  135377. */
  135378. get cameraColorGradingEnabled(): boolean;
  135379. /**
  135380. * Gets wether the color grading effect is enabled.
  135381. */
  135382. set cameraColorGradingEnabled(value: boolean);
  135383. /**
  135384. * Gets wether tonemapping is enabled or not.
  135385. */
  135386. get cameraToneMappingEnabled(): boolean;
  135387. /**
  135388. * Sets wether tonemapping is enabled or not
  135389. */
  135390. set cameraToneMappingEnabled(value: boolean);
  135391. /**
  135392. * The camera exposure used on this material.
  135393. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135394. * This corresponds to a photographic exposure.
  135395. */
  135396. get cameraExposure(): float;
  135397. /**
  135398. * The camera exposure used on this material.
  135399. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135400. * This corresponds to a photographic exposure.
  135401. */
  135402. set cameraExposure(value: float);
  135403. /**
  135404. * Gets The camera contrast used on this material.
  135405. */
  135406. get cameraContrast(): float;
  135407. /**
  135408. * Sets The camera contrast used on this material.
  135409. */
  135410. set cameraContrast(value: float);
  135411. /**
  135412. * Gets the Color Grading 2D Lookup Texture.
  135413. */
  135414. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  135415. /**
  135416. * Sets the Color Grading 2D Lookup Texture.
  135417. */
  135418. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  135419. /**
  135420. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135421. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135422. * 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;
  135423. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135424. */
  135425. get cameraColorCurves(): Nullable<ColorCurves>;
  135426. /**
  135427. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135428. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135429. * 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;
  135430. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135431. */
  135432. set cameraColorCurves(value: Nullable<ColorCurves>);
  135433. /**
  135434. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  135435. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  135436. */
  135437. switchToBGR: boolean;
  135438. private _renderTargets;
  135439. private _reflectionControls;
  135440. private _white;
  135441. private _primaryShadowColor;
  135442. private _primaryHighlightColor;
  135443. /**
  135444. * Instantiates a Background Material in the given scene
  135445. * @param name The friendly name of the material
  135446. * @param scene The scene to add the material to
  135447. */
  135448. constructor(name: string, scene: Scene);
  135449. /**
  135450. * Gets a boolean indicating that current material needs to register RTT
  135451. */
  135452. get hasRenderTargetTextures(): boolean;
  135453. /**
  135454. * The entire material has been created in order to prevent overdraw.
  135455. * @returns false
  135456. */
  135457. needAlphaTesting(): boolean;
  135458. /**
  135459. * The entire material has been created in order to prevent overdraw.
  135460. * @returns true if blending is enable
  135461. */
  135462. needAlphaBlending(): boolean;
  135463. /**
  135464. * Checks wether the material is ready to be rendered for a given mesh.
  135465. * @param mesh The mesh to render
  135466. * @param subMesh The submesh to check against
  135467. * @param useInstances Specify wether or not the material is used with instances
  135468. * @returns true if all the dependencies are ready (Textures, Effects...)
  135469. */
  135470. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135471. /**
  135472. * Compute the primary color according to the chosen perceptual color.
  135473. */
  135474. private _computePrimaryColorFromPerceptualColor;
  135475. /**
  135476. * Compute the highlights and shadow colors according to their chosen levels.
  135477. */
  135478. private _computePrimaryColors;
  135479. /**
  135480. * Build the uniform buffer used in the material.
  135481. */
  135482. buildUniformLayout(): void;
  135483. /**
  135484. * Unbind the material.
  135485. */
  135486. unbind(): void;
  135487. /**
  135488. * Bind only the world matrix to the material.
  135489. * @param world The world matrix to bind.
  135490. */
  135491. bindOnlyWorldMatrix(world: Matrix): void;
  135492. /**
  135493. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  135494. * @param world The world matrix to bind.
  135495. * @param subMesh The submesh to bind for.
  135496. */
  135497. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135498. /**
  135499. * Checks to see if a texture is used in the material.
  135500. * @param texture - Base texture to use.
  135501. * @returns - Boolean specifying if a texture is used in the material.
  135502. */
  135503. hasTexture(texture: BaseTexture): boolean;
  135504. /**
  135505. * Dispose the material.
  135506. * @param forceDisposeEffect Force disposal of the associated effect.
  135507. * @param forceDisposeTextures Force disposal of the associated textures.
  135508. */
  135509. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135510. /**
  135511. * Clones the material.
  135512. * @param name The cloned name.
  135513. * @returns The cloned material.
  135514. */
  135515. clone(name: string): BackgroundMaterial;
  135516. /**
  135517. * Serializes the current material to its JSON representation.
  135518. * @returns The JSON representation.
  135519. */
  135520. serialize(): any;
  135521. /**
  135522. * Gets the class name of the material
  135523. * @returns "BackgroundMaterial"
  135524. */
  135525. getClassName(): string;
  135526. /**
  135527. * Parse a JSON input to create back a background material.
  135528. * @param source The JSON data to parse
  135529. * @param scene The scene to create the parsed material in
  135530. * @param rootUrl The root url of the assets the material depends upon
  135531. * @returns the instantiated BackgroundMaterial.
  135532. */
  135533. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  135534. }
  135535. }
  135536. declare module BABYLON {
  135537. /**
  135538. * Represents the different options available during the creation of
  135539. * a Environment helper.
  135540. *
  135541. * This can control the default ground, skybox and image processing setup of your scene.
  135542. */
  135543. export interface IEnvironmentHelperOptions {
  135544. /**
  135545. * Specifies whether or not to create a ground.
  135546. * True by default.
  135547. */
  135548. createGround: boolean;
  135549. /**
  135550. * Specifies the ground size.
  135551. * 15 by default.
  135552. */
  135553. groundSize: number;
  135554. /**
  135555. * The texture used on the ground for the main color.
  135556. * Comes from the BabylonJS CDN by default.
  135557. *
  135558. * Remarks: Can be either a texture or a url.
  135559. */
  135560. groundTexture: string | BaseTexture;
  135561. /**
  135562. * The color mixed in the ground texture by default.
  135563. * BabylonJS clearColor by default.
  135564. */
  135565. groundColor: Color3;
  135566. /**
  135567. * Specifies the ground opacity.
  135568. * 1 by default.
  135569. */
  135570. groundOpacity: number;
  135571. /**
  135572. * Enables the ground to receive shadows.
  135573. * True by default.
  135574. */
  135575. enableGroundShadow: boolean;
  135576. /**
  135577. * Helps preventing the shadow to be fully black on the ground.
  135578. * 0.5 by default.
  135579. */
  135580. groundShadowLevel: number;
  135581. /**
  135582. * Creates a mirror texture attach to the ground.
  135583. * false by default.
  135584. */
  135585. enableGroundMirror: boolean;
  135586. /**
  135587. * Specifies the ground mirror size ratio.
  135588. * 0.3 by default as the default kernel is 64.
  135589. */
  135590. groundMirrorSizeRatio: number;
  135591. /**
  135592. * Specifies the ground mirror blur kernel size.
  135593. * 64 by default.
  135594. */
  135595. groundMirrorBlurKernel: number;
  135596. /**
  135597. * Specifies the ground mirror visibility amount.
  135598. * 1 by default
  135599. */
  135600. groundMirrorAmount: number;
  135601. /**
  135602. * Specifies the ground mirror reflectance weight.
  135603. * This uses the standard weight of the background material to setup the fresnel effect
  135604. * of the mirror.
  135605. * 1 by default.
  135606. */
  135607. groundMirrorFresnelWeight: number;
  135608. /**
  135609. * Specifies the ground mirror Falloff distance.
  135610. * This can helps reducing the size of the reflection.
  135611. * 0 by Default.
  135612. */
  135613. groundMirrorFallOffDistance: number;
  135614. /**
  135615. * Specifies the ground mirror texture type.
  135616. * Unsigned Int by Default.
  135617. */
  135618. groundMirrorTextureType: number;
  135619. /**
  135620. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  135621. * the shown objects.
  135622. */
  135623. groundYBias: number;
  135624. /**
  135625. * Specifies whether or not to create a skybox.
  135626. * True by default.
  135627. */
  135628. createSkybox: boolean;
  135629. /**
  135630. * Specifies the skybox size.
  135631. * 20 by default.
  135632. */
  135633. skyboxSize: number;
  135634. /**
  135635. * The texture used on the skybox for the main color.
  135636. * Comes from the BabylonJS CDN by default.
  135637. *
  135638. * Remarks: Can be either a texture or a url.
  135639. */
  135640. skyboxTexture: string | BaseTexture;
  135641. /**
  135642. * The color mixed in the skybox texture by default.
  135643. * BabylonJS clearColor by default.
  135644. */
  135645. skyboxColor: Color3;
  135646. /**
  135647. * The background rotation around the Y axis of the scene.
  135648. * This helps aligning the key lights of your scene with the background.
  135649. * 0 by default.
  135650. */
  135651. backgroundYRotation: number;
  135652. /**
  135653. * Compute automatically the size of the elements to best fit with the scene.
  135654. */
  135655. sizeAuto: boolean;
  135656. /**
  135657. * Default position of the rootMesh if autoSize is not true.
  135658. */
  135659. rootPosition: Vector3;
  135660. /**
  135661. * Sets up the image processing in the scene.
  135662. * true by default.
  135663. */
  135664. setupImageProcessing: boolean;
  135665. /**
  135666. * The texture used as your environment texture in the scene.
  135667. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  135668. *
  135669. * Remarks: Can be either a texture or a url.
  135670. */
  135671. environmentTexture: string | BaseTexture;
  135672. /**
  135673. * The value of the exposure to apply to the scene.
  135674. * 0.6 by default if setupImageProcessing is true.
  135675. */
  135676. cameraExposure: number;
  135677. /**
  135678. * The value of the contrast to apply to the scene.
  135679. * 1.6 by default if setupImageProcessing is true.
  135680. */
  135681. cameraContrast: number;
  135682. /**
  135683. * Specifies whether or not tonemapping should be enabled in the scene.
  135684. * true by default if setupImageProcessing is true.
  135685. */
  135686. toneMappingEnabled: boolean;
  135687. }
  135688. /**
  135689. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  135690. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  135691. * It also helps with the default setup of your imageProcessing configuration.
  135692. */
  135693. export class EnvironmentHelper {
  135694. /**
  135695. * Default ground texture URL.
  135696. */
  135697. private static _groundTextureCDNUrl;
  135698. /**
  135699. * Default skybox texture URL.
  135700. */
  135701. private static _skyboxTextureCDNUrl;
  135702. /**
  135703. * Default environment texture URL.
  135704. */
  135705. private static _environmentTextureCDNUrl;
  135706. /**
  135707. * Creates the default options for the helper.
  135708. */
  135709. private static _getDefaultOptions;
  135710. private _rootMesh;
  135711. /**
  135712. * Gets the root mesh created by the helper.
  135713. */
  135714. get rootMesh(): Mesh;
  135715. private _skybox;
  135716. /**
  135717. * Gets the skybox created by the helper.
  135718. */
  135719. get skybox(): Nullable<Mesh>;
  135720. private _skyboxTexture;
  135721. /**
  135722. * Gets the skybox texture created by the helper.
  135723. */
  135724. get skyboxTexture(): Nullable<BaseTexture>;
  135725. private _skyboxMaterial;
  135726. /**
  135727. * Gets the skybox material created by the helper.
  135728. */
  135729. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  135730. private _ground;
  135731. /**
  135732. * Gets the ground mesh created by the helper.
  135733. */
  135734. get ground(): Nullable<Mesh>;
  135735. private _groundTexture;
  135736. /**
  135737. * Gets the ground texture created by the helper.
  135738. */
  135739. get groundTexture(): Nullable<BaseTexture>;
  135740. private _groundMirror;
  135741. /**
  135742. * Gets the ground mirror created by the helper.
  135743. */
  135744. get groundMirror(): Nullable<MirrorTexture>;
  135745. /**
  135746. * Gets the ground mirror render list to helps pushing the meshes
  135747. * you wish in the ground reflection.
  135748. */
  135749. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  135750. private _groundMaterial;
  135751. /**
  135752. * Gets the ground material created by the helper.
  135753. */
  135754. get groundMaterial(): Nullable<BackgroundMaterial>;
  135755. /**
  135756. * Stores the creation options.
  135757. */
  135758. private readonly _scene;
  135759. private _options;
  135760. /**
  135761. * This observable will be notified with any error during the creation of the environment,
  135762. * mainly texture creation errors.
  135763. */
  135764. onErrorObservable: Observable<{
  135765. message?: string;
  135766. exception?: any;
  135767. }>;
  135768. /**
  135769. * constructor
  135770. * @param options Defines the options we want to customize the helper
  135771. * @param scene The scene to add the material to
  135772. */
  135773. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  135774. /**
  135775. * Updates the background according to the new options
  135776. * @param options
  135777. */
  135778. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  135779. /**
  135780. * Sets the primary color of all the available elements.
  135781. * @param color the main color to affect to the ground and the background
  135782. */
  135783. setMainColor(color: Color3): void;
  135784. /**
  135785. * Setup the image processing according to the specified options.
  135786. */
  135787. private _setupImageProcessing;
  135788. /**
  135789. * Setup the environment texture according to the specified options.
  135790. */
  135791. private _setupEnvironmentTexture;
  135792. /**
  135793. * Setup the background according to the specified options.
  135794. */
  135795. private _setupBackground;
  135796. /**
  135797. * Get the scene sizes according to the setup.
  135798. */
  135799. private _getSceneSize;
  135800. /**
  135801. * Setup the ground according to the specified options.
  135802. */
  135803. private _setupGround;
  135804. /**
  135805. * Setup the ground material according to the specified options.
  135806. */
  135807. private _setupGroundMaterial;
  135808. /**
  135809. * Setup the ground diffuse texture according to the specified options.
  135810. */
  135811. private _setupGroundDiffuseTexture;
  135812. /**
  135813. * Setup the ground mirror texture according to the specified options.
  135814. */
  135815. private _setupGroundMirrorTexture;
  135816. /**
  135817. * Setup the ground to receive the mirror texture.
  135818. */
  135819. private _setupMirrorInGroundMaterial;
  135820. /**
  135821. * Setup the skybox according to the specified options.
  135822. */
  135823. private _setupSkybox;
  135824. /**
  135825. * Setup the skybox material according to the specified options.
  135826. */
  135827. private _setupSkyboxMaterial;
  135828. /**
  135829. * Setup the skybox reflection texture according to the specified options.
  135830. */
  135831. private _setupSkyboxReflectionTexture;
  135832. private _errorHandler;
  135833. /**
  135834. * Dispose all the elements created by the Helper.
  135835. */
  135836. dispose(): void;
  135837. }
  135838. }
  135839. declare module BABYLON {
  135840. /**
  135841. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  135842. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  135843. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135844. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135845. */
  135846. export abstract class TextureDome<T extends Texture> extends TransformNode {
  135847. protected onError: Nullable<(message?: string, exception?: any) => void>;
  135848. /**
  135849. * Define the source as a Monoscopic panoramic 360/180.
  135850. */
  135851. static readonly MODE_MONOSCOPIC: number;
  135852. /**
  135853. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  135854. */
  135855. static readonly MODE_TOPBOTTOM: number;
  135856. /**
  135857. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  135858. */
  135859. static readonly MODE_SIDEBYSIDE: number;
  135860. private _halfDome;
  135861. protected _useDirectMapping: boolean;
  135862. /**
  135863. * The texture being displayed on the sphere
  135864. */
  135865. protected _texture: T;
  135866. /**
  135867. * Gets the texture being displayed on the sphere
  135868. */
  135869. get texture(): T;
  135870. /**
  135871. * Sets the texture being displayed on the sphere
  135872. */
  135873. set texture(newTexture: T);
  135874. /**
  135875. * The skybox material
  135876. */
  135877. protected _material: BackgroundMaterial;
  135878. /**
  135879. * The surface used for the dome
  135880. */
  135881. protected _mesh: Mesh;
  135882. /**
  135883. * Gets the mesh used for the dome.
  135884. */
  135885. get mesh(): Mesh;
  135886. /**
  135887. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  135888. */
  135889. private _halfDomeMask;
  135890. /**
  135891. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135892. * Also see the options.resolution property.
  135893. */
  135894. get fovMultiplier(): number;
  135895. set fovMultiplier(value: number);
  135896. protected _textureMode: number;
  135897. /**
  135898. * Gets or set the current texture mode for the texture. It can be:
  135899. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135900. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135901. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135902. */
  135903. get textureMode(): number;
  135904. /**
  135905. * Sets the current texture mode for the texture. It can be:
  135906. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135907. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135908. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135909. */
  135910. set textureMode(value: number);
  135911. /**
  135912. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  135913. */
  135914. get halfDome(): boolean;
  135915. /**
  135916. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135917. */
  135918. set halfDome(enabled: boolean);
  135919. /**
  135920. * Oberserver used in Stereoscopic VR Mode.
  135921. */
  135922. private _onBeforeCameraRenderObserver;
  135923. /**
  135924. * Observable raised when an error occured while loading the 360 image
  135925. */
  135926. onLoadErrorObservable: Observable<string>;
  135927. /**
  135928. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  135929. * @param name Element's name, child elements will append suffixes for their own names.
  135930. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  135931. * @param options An object containing optional or exposed sub element properties
  135932. */
  135933. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  135934. resolution?: number;
  135935. clickToPlay?: boolean;
  135936. autoPlay?: boolean;
  135937. loop?: boolean;
  135938. size?: number;
  135939. poster?: string;
  135940. faceForward?: boolean;
  135941. useDirectMapping?: boolean;
  135942. halfDomeMode?: boolean;
  135943. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  135944. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  135945. protected _changeTextureMode(value: number): void;
  135946. /**
  135947. * Releases resources associated with this node.
  135948. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135949. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135950. */
  135951. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135952. }
  135953. }
  135954. declare module BABYLON {
  135955. /**
  135956. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  135957. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  135958. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135959. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135960. */
  135961. export class PhotoDome extends TextureDome<Texture> {
  135962. /**
  135963. * Define the image as a Monoscopic panoramic 360 image.
  135964. */
  135965. static readonly MODE_MONOSCOPIC: number;
  135966. /**
  135967. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  135968. */
  135969. static readonly MODE_TOPBOTTOM: number;
  135970. /**
  135971. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  135972. */
  135973. static readonly MODE_SIDEBYSIDE: number;
  135974. /**
  135975. * Gets or sets the texture being displayed on the sphere
  135976. */
  135977. get photoTexture(): Texture;
  135978. /**
  135979. * sets the texture being displayed on the sphere
  135980. */
  135981. set photoTexture(value: Texture);
  135982. /**
  135983. * Gets the current video mode for the video. It can be:
  135984. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135985. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135986. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135987. */
  135988. get imageMode(): number;
  135989. /**
  135990. * Sets the current video mode for the video. It can be:
  135991. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135992. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135993. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135994. */
  135995. set imageMode(value: number);
  135996. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  135997. }
  135998. }
  135999. declare module BABYLON {
  136000. /**
  136001. * Class used to host RGBD texture specific utilities
  136002. */
  136003. export class RGBDTextureTools {
  136004. /**
  136005. * Expand the RGBD Texture from RGBD to Half Float if possible.
  136006. * @param texture the texture to expand.
  136007. */
  136008. static ExpandRGBDTexture(texture: Texture): void;
  136009. }
  136010. }
  136011. declare module BABYLON {
  136012. /**
  136013. * Class used to host texture specific utilities
  136014. */
  136015. export class BRDFTextureTools {
  136016. /**
  136017. * Prevents texture cache collision
  136018. */
  136019. private static _instanceNumber;
  136020. /**
  136021. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  136022. * @param scene defines the hosting scene
  136023. * @returns the environment BRDF texture
  136024. */
  136025. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  136026. private static _environmentBRDFBase64Texture;
  136027. }
  136028. }
  136029. declare module BABYLON {
  136030. /**
  136031. * @hidden
  136032. */
  136033. export interface IMaterialClearCoatDefines {
  136034. CLEARCOAT: boolean;
  136035. CLEARCOAT_DEFAULTIOR: boolean;
  136036. CLEARCOAT_TEXTURE: boolean;
  136037. CLEARCOAT_TEXTUREDIRECTUV: number;
  136038. CLEARCOAT_BUMP: boolean;
  136039. CLEARCOAT_BUMPDIRECTUV: number;
  136040. CLEARCOAT_REMAP_F0: boolean;
  136041. CLEARCOAT_TINT: boolean;
  136042. CLEARCOAT_TINT_TEXTURE: boolean;
  136043. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  136044. /** @hidden */
  136045. _areTexturesDirty: boolean;
  136046. }
  136047. /**
  136048. * Define the code related to the clear coat parameters of the pbr material.
  136049. */
  136050. export class PBRClearCoatConfiguration {
  136051. /**
  136052. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  136053. * The default fits with a polyurethane material.
  136054. */
  136055. private static readonly _DefaultIndexOfRefraction;
  136056. private _isEnabled;
  136057. /**
  136058. * Defines if the clear coat is enabled in the material.
  136059. */
  136060. isEnabled: boolean;
  136061. /**
  136062. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  136063. */
  136064. intensity: number;
  136065. /**
  136066. * Defines the clear coat layer roughness.
  136067. */
  136068. roughness: number;
  136069. private _indexOfRefraction;
  136070. /**
  136071. * Defines the index of refraction of the clear coat.
  136072. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  136073. * The default fits with a polyurethane material.
  136074. * Changing the default value is more performance intensive.
  136075. */
  136076. indexOfRefraction: number;
  136077. private _texture;
  136078. /**
  136079. * Stores the clear coat values in a texture.
  136080. */
  136081. texture: Nullable<BaseTexture>;
  136082. private _remapF0OnInterfaceChange;
  136083. /**
  136084. * Defines if the F0 value should be remapped to account for the interface change in the material.
  136085. */
  136086. remapF0OnInterfaceChange: boolean;
  136087. private _bumpTexture;
  136088. /**
  136089. * Define the clear coat specific bump texture.
  136090. */
  136091. bumpTexture: Nullable<BaseTexture>;
  136092. private _isTintEnabled;
  136093. /**
  136094. * Defines if the clear coat tint is enabled in the material.
  136095. */
  136096. isTintEnabled: boolean;
  136097. /**
  136098. * Defines the clear coat tint of the material.
  136099. * This is only use if tint is enabled
  136100. */
  136101. tintColor: Color3;
  136102. /**
  136103. * Defines the distance at which the tint color should be found in the
  136104. * clear coat media.
  136105. * This is only use if tint is enabled
  136106. */
  136107. tintColorAtDistance: number;
  136108. /**
  136109. * Defines the clear coat layer thickness.
  136110. * This is only use if tint is enabled
  136111. */
  136112. tintThickness: number;
  136113. private _tintTexture;
  136114. /**
  136115. * Stores the clear tint values in a texture.
  136116. * rgb is tint
  136117. * a is a thickness factor
  136118. */
  136119. tintTexture: Nullable<BaseTexture>;
  136120. /** @hidden */
  136121. private _internalMarkAllSubMeshesAsTexturesDirty;
  136122. /** @hidden */
  136123. _markAllSubMeshesAsTexturesDirty(): void;
  136124. /**
  136125. * Instantiate a new istance of clear coat configuration.
  136126. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136127. */
  136128. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136129. /**
  136130. * Gets wehter the submesh is ready to be used or not.
  136131. * @param defines the list of "defines" to update.
  136132. * @param scene defines the scene the material belongs to.
  136133. * @param engine defines the engine the material belongs to.
  136134. * @param disableBumpMap defines wether the material disables bump or not.
  136135. * @returns - boolean indicating that the submesh is ready or not.
  136136. */
  136137. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  136138. /**
  136139. * Checks to see if a texture is used in the material.
  136140. * @param defines the list of "defines" to update.
  136141. * @param scene defines the scene to the material belongs to.
  136142. */
  136143. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  136144. /**
  136145. * Binds the material data.
  136146. * @param uniformBuffer defines the Uniform buffer to fill in.
  136147. * @param scene defines the scene the material belongs to.
  136148. * @param engine defines the engine the material belongs to.
  136149. * @param disableBumpMap defines wether the material disables bump or not.
  136150. * @param isFrozen defines wether the material is frozen or not.
  136151. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  136152. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  136153. */
  136154. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  136155. /**
  136156. * Checks to see if a texture is used in the material.
  136157. * @param texture - Base texture to use.
  136158. * @returns - Boolean specifying if a texture is used in the material.
  136159. */
  136160. hasTexture(texture: BaseTexture): boolean;
  136161. /**
  136162. * Returns an array of the actively used textures.
  136163. * @param activeTextures Array of BaseTextures
  136164. */
  136165. getActiveTextures(activeTextures: BaseTexture[]): void;
  136166. /**
  136167. * Returns the animatable textures.
  136168. * @param animatables Array of animatable textures.
  136169. */
  136170. getAnimatables(animatables: IAnimatable[]): void;
  136171. /**
  136172. * Disposes the resources of the material.
  136173. * @param forceDisposeTextures - Forces the disposal of all textures.
  136174. */
  136175. dispose(forceDisposeTextures?: boolean): void;
  136176. /**
  136177. * Get the current class name of the texture useful for serialization or dynamic coding.
  136178. * @returns "PBRClearCoatConfiguration"
  136179. */
  136180. getClassName(): string;
  136181. /**
  136182. * Add fallbacks to the effect fallbacks list.
  136183. * @param defines defines the Base texture to use.
  136184. * @param fallbacks defines the current fallback list.
  136185. * @param currentRank defines the current fallback rank.
  136186. * @returns the new fallback rank.
  136187. */
  136188. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136189. /**
  136190. * Add the required uniforms to the current list.
  136191. * @param uniforms defines the current uniform list.
  136192. */
  136193. static AddUniforms(uniforms: string[]): void;
  136194. /**
  136195. * Add the required samplers to the current list.
  136196. * @param samplers defines the current sampler list.
  136197. */
  136198. static AddSamplers(samplers: string[]): void;
  136199. /**
  136200. * Add the required uniforms to the current buffer.
  136201. * @param uniformBuffer defines the current uniform buffer.
  136202. */
  136203. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136204. /**
  136205. * Makes a duplicate of the current configuration into another one.
  136206. * @param clearCoatConfiguration define the config where to copy the info
  136207. */
  136208. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  136209. /**
  136210. * Serializes this clear coat configuration.
  136211. * @returns - An object with the serialized config.
  136212. */
  136213. serialize(): any;
  136214. /**
  136215. * Parses a anisotropy Configuration from a serialized object.
  136216. * @param source - Serialized object.
  136217. * @param scene Defines the scene we are parsing for
  136218. * @param rootUrl Defines the rootUrl to load from
  136219. */
  136220. parse(source: any, scene: Scene, rootUrl: string): void;
  136221. }
  136222. }
  136223. declare module BABYLON {
  136224. /**
  136225. * @hidden
  136226. */
  136227. export interface IMaterialAnisotropicDefines {
  136228. ANISOTROPIC: boolean;
  136229. ANISOTROPIC_TEXTURE: boolean;
  136230. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136231. MAINUV1: boolean;
  136232. _areTexturesDirty: boolean;
  136233. _needUVs: boolean;
  136234. }
  136235. /**
  136236. * Define the code related to the anisotropic parameters of the pbr material.
  136237. */
  136238. export class PBRAnisotropicConfiguration {
  136239. private _isEnabled;
  136240. /**
  136241. * Defines if the anisotropy is enabled in the material.
  136242. */
  136243. isEnabled: boolean;
  136244. /**
  136245. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  136246. */
  136247. intensity: number;
  136248. /**
  136249. * Defines if the effect is along the tangents, bitangents or in between.
  136250. * By default, the effect is "strectching" the highlights along the tangents.
  136251. */
  136252. direction: Vector2;
  136253. private _texture;
  136254. /**
  136255. * Stores the anisotropy values in a texture.
  136256. * rg is direction (like normal from -1 to 1)
  136257. * b is a intensity
  136258. */
  136259. texture: Nullable<BaseTexture>;
  136260. /** @hidden */
  136261. private _internalMarkAllSubMeshesAsTexturesDirty;
  136262. /** @hidden */
  136263. _markAllSubMeshesAsTexturesDirty(): void;
  136264. /**
  136265. * Instantiate a new istance of anisotropy configuration.
  136266. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136267. */
  136268. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136269. /**
  136270. * Specifies that the submesh is ready to be used.
  136271. * @param defines the list of "defines" to update.
  136272. * @param scene defines the scene the material belongs to.
  136273. * @returns - boolean indicating that the submesh is ready or not.
  136274. */
  136275. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  136276. /**
  136277. * Checks to see if a texture is used in the material.
  136278. * @param defines the list of "defines" to update.
  136279. * @param mesh the mesh we are preparing the defines for.
  136280. * @param scene defines the scene the material belongs to.
  136281. */
  136282. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  136283. /**
  136284. * Binds the material data.
  136285. * @param uniformBuffer defines the Uniform buffer to fill in.
  136286. * @param scene defines the scene the material belongs to.
  136287. * @param isFrozen defines wether the material is frozen or not.
  136288. */
  136289. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  136290. /**
  136291. * Checks to see if a texture is used in the material.
  136292. * @param texture - Base texture to use.
  136293. * @returns - Boolean specifying if a texture is used in the material.
  136294. */
  136295. hasTexture(texture: BaseTexture): boolean;
  136296. /**
  136297. * Returns an array of the actively used textures.
  136298. * @param activeTextures Array of BaseTextures
  136299. */
  136300. getActiveTextures(activeTextures: BaseTexture[]): void;
  136301. /**
  136302. * Returns the animatable textures.
  136303. * @param animatables Array of animatable textures.
  136304. */
  136305. getAnimatables(animatables: IAnimatable[]): void;
  136306. /**
  136307. * Disposes the resources of the material.
  136308. * @param forceDisposeTextures - Forces the disposal of all textures.
  136309. */
  136310. dispose(forceDisposeTextures?: boolean): void;
  136311. /**
  136312. * Get the current class name of the texture useful for serialization or dynamic coding.
  136313. * @returns "PBRAnisotropicConfiguration"
  136314. */
  136315. getClassName(): string;
  136316. /**
  136317. * Add fallbacks to the effect fallbacks list.
  136318. * @param defines defines the Base texture to use.
  136319. * @param fallbacks defines the current fallback list.
  136320. * @param currentRank defines the current fallback rank.
  136321. * @returns the new fallback rank.
  136322. */
  136323. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136324. /**
  136325. * Add the required uniforms to the current list.
  136326. * @param uniforms defines the current uniform list.
  136327. */
  136328. static AddUniforms(uniforms: string[]): void;
  136329. /**
  136330. * Add the required uniforms to the current buffer.
  136331. * @param uniformBuffer defines the current uniform buffer.
  136332. */
  136333. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136334. /**
  136335. * Add the required samplers to the current list.
  136336. * @param samplers defines the current sampler list.
  136337. */
  136338. static AddSamplers(samplers: string[]): void;
  136339. /**
  136340. * Makes a duplicate of the current configuration into another one.
  136341. * @param anisotropicConfiguration define the config where to copy the info
  136342. */
  136343. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  136344. /**
  136345. * Serializes this anisotropy configuration.
  136346. * @returns - An object with the serialized config.
  136347. */
  136348. serialize(): any;
  136349. /**
  136350. * Parses a anisotropy Configuration from a serialized object.
  136351. * @param source - Serialized object.
  136352. * @param scene Defines the scene we are parsing for
  136353. * @param rootUrl Defines the rootUrl to load from
  136354. */
  136355. parse(source: any, scene: Scene, rootUrl: string): void;
  136356. }
  136357. }
  136358. declare module BABYLON {
  136359. /**
  136360. * @hidden
  136361. */
  136362. export interface IMaterialBRDFDefines {
  136363. BRDF_V_HEIGHT_CORRELATED: boolean;
  136364. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136365. SPHERICAL_HARMONICS: boolean;
  136366. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136367. /** @hidden */
  136368. _areMiscDirty: boolean;
  136369. }
  136370. /**
  136371. * Define the code related to the BRDF parameters of the pbr material.
  136372. */
  136373. export class PBRBRDFConfiguration {
  136374. /**
  136375. * Default value used for the energy conservation.
  136376. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136377. */
  136378. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  136379. /**
  136380. * Default value used for the Smith Visibility Height Correlated mode.
  136381. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136382. */
  136383. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  136384. /**
  136385. * Default value used for the IBL diffuse part.
  136386. * This can help switching back to the polynomials mode globally which is a tiny bit
  136387. * less GPU intensive at the drawback of a lower quality.
  136388. */
  136389. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  136390. /**
  136391. * Default value used for activating energy conservation for the specular workflow.
  136392. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136393. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136394. */
  136395. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  136396. private _useEnergyConservation;
  136397. /**
  136398. * Defines if the material uses energy conservation.
  136399. */
  136400. useEnergyConservation: boolean;
  136401. private _useSmithVisibilityHeightCorrelated;
  136402. /**
  136403. * LEGACY Mode set to false
  136404. * Defines if the material uses height smith correlated visibility term.
  136405. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  136406. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  136407. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  136408. * Not relying on height correlated will also disable energy conservation.
  136409. */
  136410. useSmithVisibilityHeightCorrelated: boolean;
  136411. private _useSphericalHarmonics;
  136412. /**
  136413. * LEGACY Mode set to false
  136414. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  136415. * diffuse part of the IBL.
  136416. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  136417. * to the ground truth.
  136418. */
  136419. useSphericalHarmonics: boolean;
  136420. private _useSpecularGlossinessInputEnergyConservation;
  136421. /**
  136422. * Defines if the material uses energy conservation, when the specular workflow is active.
  136423. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136424. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136425. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  136426. */
  136427. useSpecularGlossinessInputEnergyConservation: boolean;
  136428. /** @hidden */
  136429. private _internalMarkAllSubMeshesAsMiscDirty;
  136430. /** @hidden */
  136431. _markAllSubMeshesAsMiscDirty(): void;
  136432. /**
  136433. * Instantiate a new istance of clear coat configuration.
  136434. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  136435. */
  136436. constructor(markAllSubMeshesAsMiscDirty: () => void);
  136437. /**
  136438. * Checks to see if a texture is used in the material.
  136439. * @param defines the list of "defines" to update.
  136440. */
  136441. prepareDefines(defines: IMaterialBRDFDefines): void;
  136442. /**
  136443. * Get the current class name of the texture useful for serialization or dynamic coding.
  136444. * @returns "PBRClearCoatConfiguration"
  136445. */
  136446. getClassName(): string;
  136447. /**
  136448. * Makes a duplicate of the current configuration into another one.
  136449. * @param brdfConfiguration define the config where to copy the info
  136450. */
  136451. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  136452. /**
  136453. * Serializes this BRDF configuration.
  136454. * @returns - An object with the serialized config.
  136455. */
  136456. serialize(): any;
  136457. /**
  136458. * Parses a anisotropy Configuration from a serialized object.
  136459. * @param source - Serialized object.
  136460. * @param scene Defines the scene we are parsing for
  136461. * @param rootUrl Defines the rootUrl to load from
  136462. */
  136463. parse(source: any, scene: Scene, rootUrl: string): void;
  136464. }
  136465. }
  136466. declare module BABYLON {
  136467. /**
  136468. * @hidden
  136469. */
  136470. export interface IMaterialSheenDefines {
  136471. SHEEN: boolean;
  136472. SHEEN_TEXTURE: boolean;
  136473. SHEEN_TEXTUREDIRECTUV: number;
  136474. SHEEN_LINKWITHALBEDO: boolean;
  136475. SHEEN_ROUGHNESS: boolean;
  136476. SHEEN_ALBEDOSCALING: boolean;
  136477. /** @hidden */
  136478. _areTexturesDirty: boolean;
  136479. }
  136480. /**
  136481. * Define the code related to the Sheen parameters of the pbr material.
  136482. */
  136483. export class PBRSheenConfiguration {
  136484. private _isEnabled;
  136485. /**
  136486. * Defines if the material uses sheen.
  136487. */
  136488. isEnabled: boolean;
  136489. private _linkSheenWithAlbedo;
  136490. /**
  136491. * Defines if the sheen is linked to the sheen color.
  136492. */
  136493. linkSheenWithAlbedo: boolean;
  136494. /**
  136495. * Defines the sheen intensity.
  136496. */
  136497. intensity: number;
  136498. /**
  136499. * Defines the sheen color.
  136500. */
  136501. color: Color3;
  136502. private _texture;
  136503. /**
  136504. * Stores the sheen tint values in a texture.
  136505. * rgb is tint
  136506. * a is a intensity or roughness if roughness has been defined
  136507. */
  136508. texture: Nullable<BaseTexture>;
  136509. private _roughness;
  136510. /**
  136511. * Defines the sheen roughness.
  136512. * It is not taken into account if linkSheenWithAlbedo is true.
  136513. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  136514. */
  136515. roughness: Nullable<number>;
  136516. private _albedoScaling;
  136517. /**
  136518. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  136519. * It allows the strength of the sheen effect to not depend on the base color of the material,
  136520. * making it easier to setup and tweak the effect
  136521. */
  136522. albedoScaling: boolean;
  136523. /** @hidden */
  136524. private _internalMarkAllSubMeshesAsTexturesDirty;
  136525. /** @hidden */
  136526. _markAllSubMeshesAsTexturesDirty(): void;
  136527. /**
  136528. * Instantiate a new istance of clear coat configuration.
  136529. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136530. */
  136531. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136532. /**
  136533. * Specifies that the submesh is ready to be used.
  136534. * @param defines the list of "defines" to update.
  136535. * @param scene defines the scene the material belongs to.
  136536. * @returns - boolean indicating that the submesh is ready or not.
  136537. */
  136538. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  136539. /**
  136540. * Checks to see if a texture is used in the material.
  136541. * @param defines the list of "defines" to update.
  136542. * @param scene defines the scene the material belongs to.
  136543. */
  136544. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  136545. /**
  136546. * Binds the material data.
  136547. * @param uniformBuffer defines the Uniform buffer to fill in.
  136548. * @param scene defines the scene the material belongs to.
  136549. * @param isFrozen defines wether the material is frozen or not.
  136550. */
  136551. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  136552. /**
  136553. * Checks to see if a texture is used in the material.
  136554. * @param texture - Base texture to use.
  136555. * @returns - Boolean specifying if a texture is used in the material.
  136556. */
  136557. hasTexture(texture: BaseTexture): boolean;
  136558. /**
  136559. * Returns an array of the actively used textures.
  136560. * @param activeTextures Array of BaseTextures
  136561. */
  136562. getActiveTextures(activeTextures: BaseTexture[]): void;
  136563. /**
  136564. * Returns the animatable textures.
  136565. * @param animatables Array of animatable textures.
  136566. */
  136567. getAnimatables(animatables: IAnimatable[]): void;
  136568. /**
  136569. * Disposes the resources of the material.
  136570. * @param forceDisposeTextures - Forces the disposal of all textures.
  136571. */
  136572. dispose(forceDisposeTextures?: boolean): void;
  136573. /**
  136574. * Get the current class name of the texture useful for serialization or dynamic coding.
  136575. * @returns "PBRSheenConfiguration"
  136576. */
  136577. getClassName(): string;
  136578. /**
  136579. * Add fallbacks to the effect fallbacks list.
  136580. * @param defines defines the Base texture to use.
  136581. * @param fallbacks defines the current fallback list.
  136582. * @param currentRank defines the current fallback rank.
  136583. * @returns the new fallback rank.
  136584. */
  136585. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136586. /**
  136587. * Add the required uniforms to the current list.
  136588. * @param uniforms defines the current uniform list.
  136589. */
  136590. static AddUniforms(uniforms: string[]): void;
  136591. /**
  136592. * Add the required uniforms to the current buffer.
  136593. * @param uniformBuffer defines the current uniform buffer.
  136594. */
  136595. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136596. /**
  136597. * Add the required samplers to the current list.
  136598. * @param samplers defines the current sampler list.
  136599. */
  136600. static AddSamplers(samplers: string[]): void;
  136601. /**
  136602. * Makes a duplicate of the current configuration into another one.
  136603. * @param sheenConfiguration define the config where to copy the info
  136604. */
  136605. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  136606. /**
  136607. * Serializes this BRDF configuration.
  136608. * @returns - An object with the serialized config.
  136609. */
  136610. serialize(): any;
  136611. /**
  136612. * Parses a anisotropy Configuration from a serialized object.
  136613. * @param source - Serialized object.
  136614. * @param scene Defines the scene we are parsing for
  136615. * @param rootUrl Defines the rootUrl to load from
  136616. */
  136617. parse(source: any, scene: Scene, rootUrl: string): void;
  136618. }
  136619. }
  136620. declare module BABYLON {
  136621. /**
  136622. * @hidden
  136623. */
  136624. export interface IMaterialSubSurfaceDefines {
  136625. SUBSURFACE: boolean;
  136626. SS_REFRACTION: boolean;
  136627. SS_TRANSLUCENCY: boolean;
  136628. SS_SCATTERING: boolean;
  136629. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136630. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136631. SS_REFRACTIONMAP_3D: boolean;
  136632. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136633. SS_LODINREFRACTIONALPHA: boolean;
  136634. SS_GAMMAREFRACTION: boolean;
  136635. SS_RGBDREFRACTION: boolean;
  136636. SS_LINEARSPECULARREFRACTION: boolean;
  136637. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136638. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136639. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136640. /** @hidden */
  136641. _areTexturesDirty: boolean;
  136642. }
  136643. /**
  136644. * Define the code related to the sub surface parameters of the pbr material.
  136645. */
  136646. export class PBRSubSurfaceConfiguration {
  136647. private _isRefractionEnabled;
  136648. /**
  136649. * Defines if the refraction is enabled in the material.
  136650. */
  136651. isRefractionEnabled: boolean;
  136652. private _isTranslucencyEnabled;
  136653. /**
  136654. * Defines if the translucency is enabled in the material.
  136655. */
  136656. isTranslucencyEnabled: boolean;
  136657. private _isScatteringEnabled;
  136658. /**
  136659. * Defines if the sub surface scattering is enabled in the material.
  136660. */
  136661. isScatteringEnabled: boolean;
  136662. private _scatteringDiffusionProfileIndex;
  136663. /**
  136664. * Diffusion profile for subsurface scattering.
  136665. * Useful for better scattering in the skins or foliages.
  136666. */
  136667. get scatteringDiffusionProfile(): Nullable<Color3>;
  136668. set scatteringDiffusionProfile(c: Nullable<Color3>);
  136669. /**
  136670. * Defines the refraction intensity of the material.
  136671. * The refraction when enabled replaces the Diffuse part of the material.
  136672. * The intensity helps transitionning between diffuse and refraction.
  136673. */
  136674. refractionIntensity: number;
  136675. /**
  136676. * Defines the translucency intensity of the material.
  136677. * When translucency has been enabled, this defines how much of the "translucency"
  136678. * is addded to the diffuse part of the material.
  136679. */
  136680. translucencyIntensity: number;
  136681. /**
  136682. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  136683. */
  136684. useAlbedoToTintRefraction: boolean;
  136685. private _thicknessTexture;
  136686. /**
  136687. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  136688. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  136689. * 0 would mean minimumThickness
  136690. * 1 would mean maximumThickness
  136691. * The other channels might be use as a mask to vary the different effects intensity.
  136692. */
  136693. thicknessTexture: Nullable<BaseTexture>;
  136694. private _refractionTexture;
  136695. /**
  136696. * Defines the texture to use for refraction.
  136697. */
  136698. refractionTexture: Nullable<BaseTexture>;
  136699. private _indexOfRefraction;
  136700. /**
  136701. * Index of refraction of the material base layer.
  136702. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136703. *
  136704. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136705. *
  136706. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136707. */
  136708. indexOfRefraction: number;
  136709. private _volumeIndexOfRefraction;
  136710. /**
  136711. * Index of refraction of the material's volume.
  136712. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136713. *
  136714. * This ONLY impacts refraction. If not provided or given a non-valid value,
  136715. * the volume will use the same IOR as the surface.
  136716. */
  136717. get volumeIndexOfRefraction(): number;
  136718. set volumeIndexOfRefraction(value: number);
  136719. private _invertRefractionY;
  136720. /**
  136721. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136722. */
  136723. invertRefractionY: boolean;
  136724. private _linkRefractionWithTransparency;
  136725. /**
  136726. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136727. * Materials half opaque for instance using refraction could benefit from this control.
  136728. */
  136729. linkRefractionWithTransparency: boolean;
  136730. /**
  136731. * Defines the minimum thickness stored in the thickness map.
  136732. * If no thickness map is defined, this value will be used to simulate thickness.
  136733. */
  136734. minimumThickness: number;
  136735. /**
  136736. * Defines the maximum thickness stored in the thickness map.
  136737. */
  136738. maximumThickness: number;
  136739. /**
  136740. * Defines the volume tint of the material.
  136741. * This is used for both translucency and scattering.
  136742. */
  136743. tintColor: Color3;
  136744. /**
  136745. * Defines the distance at which the tint color should be found in the media.
  136746. * This is used for refraction only.
  136747. */
  136748. tintColorAtDistance: number;
  136749. /**
  136750. * Defines how far each channel transmit through the media.
  136751. * It is defined as a color to simplify it selection.
  136752. */
  136753. diffusionDistance: Color3;
  136754. private _useMaskFromThicknessTexture;
  136755. /**
  136756. * Stores the intensity of the different subsurface effects in the thickness texture.
  136757. * * the green channel is the translucency intensity.
  136758. * * the blue channel is the scattering intensity.
  136759. * * the alpha channel is the refraction intensity.
  136760. */
  136761. useMaskFromThicknessTexture: boolean;
  136762. private _scene;
  136763. /** @hidden */
  136764. private _internalMarkAllSubMeshesAsTexturesDirty;
  136765. private _internalMarkScenePrePassDirty;
  136766. /** @hidden */
  136767. _markAllSubMeshesAsTexturesDirty(): void;
  136768. /** @hidden */
  136769. _markScenePrePassDirty(): void;
  136770. /**
  136771. * Instantiate a new istance of sub surface configuration.
  136772. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136773. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  136774. * @param scene The scene
  136775. */
  136776. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  136777. /**
  136778. * Gets wehter the submesh is ready to be used or not.
  136779. * @param defines the list of "defines" to update.
  136780. * @param scene defines the scene the material belongs to.
  136781. * @returns - boolean indicating that the submesh is ready or not.
  136782. */
  136783. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  136784. /**
  136785. * Checks to see if a texture is used in the material.
  136786. * @param defines the list of "defines" to update.
  136787. * @param scene defines the scene to the material belongs to.
  136788. */
  136789. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  136790. /**
  136791. * Binds the material data.
  136792. * @param uniformBuffer defines the Uniform buffer to fill in.
  136793. * @param scene defines the scene the material belongs to.
  136794. * @param engine defines the engine the material belongs to.
  136795. * @param isFrozen defines whether the material is frozen or not.
  136796. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  136797. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  136798. */
  136799. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  136800. /**
  136801. * Unbinds the material from the mesh.
  136802. * @param activeEffect defines the effect that should be unbound from.
  136803. * @returns true if unbound, otherwise false
  136804. */
  136805. unbind(activeEffect: Effect): boolean;
  136806. /**
  136807. * Returns the texture used for refraction or null if none is used.
  136808. * @param scene defines the scene the material belongs to.
  136809. * @returns - Refraction texture if present. If no refraction texture and refraction
  136810. * is linked with transparency, returns environment texture. Otherwise, returns null.
  136811. */
  136812. private _getRefractionTexture;
  136813. /**
  136814. * Returns true if alpha blending should be disabled.
  136815. */
  136816. get disableAlphaBlending(): boolean;
  136817. /**
  136818. * Fills the list of render target textures.
  136819. * @param renderTargets the list of render targets to update
  136820. */
  136821. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  136822. /**
  136823. * Checks to see if a texture is used in the material.
  136824. * @param texture - Base texture to use.
  136825. * @returns - Boolean specifying if a texture is used in the material.
  136826. */
  136827. hasTexture(texture: BaseTexture): boolean;
  136828. /**
  136829. * Gets a boolean indicating that current material needs to register RTT
  136830. * @returns true if this uses a render target otherwise false.
  136831. */
  136832. hasRenderTargetTextures(): boolean;
  136833. /**
  136834. * Returns an array of the actively used textures.
  136835. * @param activeTextures Array of BaseTextures
  136836. */
  136837. getActiveTextures(activeTextures: BaseTexture[]): void;
  136838. /**
  136839. * Returns the animatable textures.
  136840. * @param animatables Array of animatable textures.
  136841. */
  136842. getAnimatables(animatables: IAnimatable[]): void;
  136843. /**
  136844. * Disposes the resources of the material.
  136845. * @param forceDisposeTextures - Forces the disposal of all textures.
  136846. */
  136847. dispose(forceDisposeTextures?: boolean): void;
  136848. /**
  136849. * Get the current class name of the texture useful for serialization or dynamic coding.
  136850. * @returns "PBRSubSurfaceConfiguration"
  136851. */
  136852. getClassName(): string;
  136853. /**
  136854. * Add fallbacks to the effect fallbacks list.
  136855. * @param defines defines the Base texture to use.
  136856. * @param fallbacks defines the current fallback list.
  136857. * @param currentRank defines the current fallback rank.
  136858. * @returns the new fallback rank.
  136859. */
  136860. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136861. /**
  136862. * Add the required uniforms to the current list.
  136863. * @param uniforms defines the current uniform list.
  136864. */
  136865. static AddUniforms(uniforms: string[]): void;
  136866. /**
  136867. * Add the required samplers to the current list.
  136868. * @param samplers defines the current sampler list.
  136869. */
  136870. static AddSamplers(samplers: string[]): void;
  136871. /**
  136872. * Add the required uniforms to the current buffer.
  136873. * @param uniformBuffer defines the current uniform buffer.
  136874. */
  136875. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136876. /**
  136877. * Makes a duplicate of the current configuration into another one.
  136878. * @param configuration define the config where to copy the info
  136879. */
  136880. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  136881. /**
  136882. * Serializes this Sub Surface configuration.
  136883. * @returns - An object with the serialized config.
  136884. */
  136885. serialize(): any;
  136886. /**
  136887. * Parses a anisotropy Configuration from a serialized object.
  136888. * @param source - Serialized object.
  136889. * @param scene Defines the scene we are parsing for
  136890. * @param rootUrl Defines the rootUrl to load from
  136891. */
  136892. parse(source: any, scene: Scene, rootUrl: string): void;
  136893. }
  136894. }
  136895. declare module BABYLON {
  136896. /** @hidden */
  136897. export var pbrFragmentDeclaration: {
  136898. name: string;
  136899. shader: string;
  136900. };
  136901. }
  136902. declare module BABYLON {
  136903. /** @hidden */
  136904. export var pbrUboDeclaration: {
  136905. name: string;
  136906. shader: string;
  136907. };
  136908. }
  136909. declare module BABYLON {
  136910. /** @hidden */
  136911. export var pbrFragmentExtraDeclaration: {
  136912. name: string;
  136913. shader: string;
  136914. };
  136915. }
  136916. declare module BABYLON {
  136917. /** @hidden */
  136918. export var pbrFragmentSamplersDeclaration: {
  136919. name: string;
  136920. shader: string;
  136921. };
  136922. }
  136923. declare module BABYLON {
  136924. /** @hidden */
  136925. export var subSurfaceScatteringFunctions: {
  136926. name: string;
  136927. shader: string;
  136928. };
  136929. }
  136930. declare module BABYLON {
  136931. /** @hidden */
  136932. export var importanceSampling: {
  136933. name: string;
  136934. shader: string;
  136935. };
  136936. }
  136937. declare module BABYLON {
  136938. /** @hidden */
  136939. export var pbrHelperFunctions: {
  136940. name: string;
  136941. shader: string;
  136942. };
  136943. }
  136944. declare module BABYLON {
  136945. /** @hidden */
  136946. export var harmonicsFunctions: {
  136947. name: string;
  136948. shader: string;
  136949. };
  136950. }
  136951. declare module BABYLON {
  136952. /** @hidden */
  136953. export var pbrDirectLightingSetupFunctions: {
  136954. name: string;
  136955. shader: string;
  136956. };
  136957. }
  136958. declare module BABYLON {
  136959. /** @hidden */
  136960. export var pbrDirectLightingFalloffFunctions: {
  136961. name: string;
  136962. shader: string;
  136963. };
  136964. }
  136965. declare module BABYLON {
  136966. /** @hidden */
  136967. export var pbrBRDFFunctions: {
  136968. name: string;
  136969. shader: string;
  136970. };
  136971. }
  136972. declare module BABYLON {
  136973. /** @hidden */
  136974. export var hdrFilteringFunctions: {
  136975. name: string;
  136976. shader: string;
  136977. };
  136978. }
  136979. declare module BABYLON {
  136980. /** @hidden */
  136981. export var pbrDirectLightingFunctions: {
  136982. name: string;
  136983. shader: string;
  136984. };
  136985. }
  136986. declare module BABYLON {
  136987. /** @hidden */
  136988. export var pbrIBLFunctions: {
  136989. name: string;
  136990. shader: string;
  136991. };
  136992. }
  136993. declare module BABYLON {
  136994. /** @hidden */
  136995. export var pbrBlockAlbedoOpacity: {
  136996. name: string;
  136997. shader: string;
  136998. };
  136999. }
  137000. declare module BABYLON {
  137001. /** @hidden */
  137002. export var pbrBlockReflectivity: {
  137003. name: string;
  137004. shader: string;
  137005. };
  137006. }
  137007. declare module BABYLON {
  137008. /** @hidden */
  137009. export var pbrBlockAmbientOcclusion: {
  137010. name: string;
  137011. shader: string;
  137012. };
  137013. }
  137014. declare module BABYLON {
  137015. /** @hidden */
  137016. export var pbrBlockAlphaFresnel: {
  137017. name: string;
  137018. shader: string;
  137019. };
  137020. }
  137021. declare module BABYLON {
  137022. /** @hidden */
  137023. export var pbrBlockAnisotropic: {
  137024. name: string;
  137025. shader: string;
  137026. };
  137027. }
  137028. declare module BABYLON {
  137029. /** @hidden */
  137030. export var pbrBlockReflection: {
  137031. name: string;
  137032. shader: string;
  137033. };
  137034. }
  137035. declare module BABYLON {
  137036. /** @hidden */
  137037. export var pbrBlockSheen: {
  137038. name: string;
  137039. shader: string;
  137040. };
  137041. }
  137042. declare module BABYLON {
  137043. /** @hidden */
  137044. export var pbrBlockClearcoat: {
  137045. name: string;
  137046. shader: string;
  137047. };
  137048. }
  137049. declare module BABYLON {
  137050. /** @hidden */
  137051. export var pbrBlockSubSurface: {
  137052. name: string;
  137053. shader: string;
  137054. };
  137055. }
  137056. declare module BABYLON {
  137057. /** @hidden */
  137058. export var pbrBlockNormalGeometric: {
  137059. name: string;
  137060. shader: string;
  137061. };
  137062. }
  137063. declare module BABYLON {
  137064. /** @hidden */
  137065. export var pbrBlockNormalFinal: {
  137066. name: string;
  137067. shader: string;
  137068. };
  137069. }
  137070. declare module BABYLON {
  137071. /** @hidden */
  137072. export var pbrBlockLightmapInit: {
  137073. name: string;
  137074. shader: string;
  137075. };
  137076. }
  137077. declare module BABYLON {
  137078. /** @hidden */
  137079. export var pbrBlockGeometryInfo: {
  137080. name: string;
  137081. shader: string;
  137082. };
  137083. }
  137084. declare module BABYLON {
  137085. /** @hidden */
  137086. export var pbrBlockReflectance0: {
  137087. name: string;
  137088. shader: string;
  137089. };
  137090. }
  137091. declare module BABYLON {
  137092. /** @hidden */
  137093. export var pbrBlockReflectance: {
  137094. name: string;
  137095. shader: string;
  137096. };
  137097. }
  137098. declare module BABYLON {
  137099. /** @hidden */
  137100. export var pbrBlockDirectLighting: {
  137101. name: string;
  137102. shader: string;
  137103. };
  137104. }
  137105. declare module BABYLON {
  137106. /** @hidden */
  137107. export var pbrBlockFinalLitComponents: {
  137108. name: string;
  137109. shader: string;
  137110. };
  137111. }
  137112. declare module BABYLON {
  137113. /** @hidden */
  137114. export var pbrBlockFinalUnlitComponents: {
  137115. name: string;
  137116. shader: string;
  137117. };
  137118. }
  137119. declare module BABYLON {
  137120. /** @hidden */
  137121. export var pbrBlockFinalColorComposition: {
  137122. name: string;
  137123. shader: string;
  137124. };
  137125. }
  137126. declare module BABYLON {
  137127. /** @hidden */
  137128. export var pbrBlockImageProcessing: {
  137129. name: string;
  137130. shader: string;
  137131. };
  137132. }
  137133. declare module BABYLON {
  137134. /** @hidden */
  137135. export var pbrDebug: {
  137136. name: string;
  137137. shader: string;
  137138. };
  137139. }
  137140. declare module BABYLON {
  137141. /** @hidden */
  137142. export var pbrPixelShader: {
  137143. name: string;
  137144. shader: string;
  137145. };
  137146. }
  137147. declare module BABYLON {
  137148. /** @hidden */
  137149. export var pbrVertexDeclaration: {
  137150. name: string;
  137151. shader: string;
  137152. };
  137153. }
  137154. declare module BABYLON {
  137155. /** @hidden */
  137156. export var pbrVertexShader: {
  137157. name: string;
  137158. shader: string;
  137159. };
  137160. }
  137161. declare module BABYLON {
  137162. /**
  137163. * Manages the defines for the PBR Material.
  137164. * @hidden
  137165. */
  137166. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  137167. PBR: boolean;
  137168. NUM_SAMPLES: string;
  137169. REALTIME_FILTERING: boolean;
  137170. MAINUV1: boolean;
  137171. MAINUV2: boolean;
  137172. UV1: boolean;
  137173. UV2: boolean;
  137174. ALBEDO: boolean;
  137175. GAMMAALBEDO: boolean;
  137176. ALBEDODIRECTUV: number;
  137177. VERTEXCOLOR: boolean;
  137178. DETAIL: boolean;
  137179. DETAILDIRECTUV: number;
  137180. DETAIL_NORMALBLENDMETHOD: number;
  137181. AMBIENT: boolean;
  137182. AMBIENTDIRECTUV: number;
  137183. AMBIENTINGRAYSCALE: boolean;
  137184. OPACITY: boolean;
  137185. VERTEXALPHA: boolean;
  137186. OPACITYDIRECTUV: number;
  137187. OPACITYRGB: boolean;
  137188. ALPHATEST: boolean;
  137189. DEPTHPREPASS: boolean;
  137190. ALPHABLEND: boolean;
  137191. ALPHAFROMALBEDO: boolean;
  137192. ALPHATESTVALUE: string;
  137193. SPECULAROVERALPHA: boolean;
  137194. RADIANCEOVERALPHA: boolean;
  137195. ALPHAFRESNEL: boolean;
  137196. LINEARALPHAFRESNEL: boolean;
  137197. PREMULTIPLYALPHA: boolean;
  137198. EMISSIVE: boolean;
  137199. EMISSIVEDIRECTUV: number;
  137200. REFLECTIVITY: boolean;
  137201. REFLECTIVITYDIRECTUV: number;
  137202. SPECULARTERM: boolean;
  137203. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  137204. MICROSURFACEAUTOMATIC: boolean;
  137205. LODBASEDMICROSFURACE: boolean;
  137206. MICROSURFACEMAP: boolean;
  137207. MICROSURFACEMAPDIRECTUV: number;
  137208. METALLICWORKFLOW: boolean;
  137209. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  137210. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  137211. METALLNESSSTOREINMETALMAPBLUE: boolean;
  137212. AOSTOREINMETALMAPRED: boolean;
  137213. METALLIC_REFLECTANCE: boolean;
  137214. METALLIC_REFLECTANCEDIRECTUV: number;
  137215. ENVIRONMENTBRDF: boolean;
  137216. ENVIRONMENTBRDF_RGBD: boolean;
  137217. NORMAL: boolean;
  137218. TANGENT: boolean;
  137219. BUMP: boolean;
  137220. BUMPDIRECTUV: number;
  137221. OBJECTSPACE_NORMALMAP: boolean;
  137222. PARALLAX: boolean;
  137223. PARALLAXOCCLUSION: boolean;
  137224. NORMALXYSCALE: boolean;
  137225. LIGHTMAP: boolean;
  137226. LIGHTMAPDIRECTUV: number;
  137227. USELIGHTMAPASSHADOWMAP: boolean;
  137228. GAMMALIGHTMAP: boolean;
  137229. RGBDLIGHTMAP: boolean;
  137230. REFLECTION: boolean;
  137231. REFLECTIONMAP_3D: boolean;
  137232. REFLECTIONMAP_SPHERICAL: boolean;
  137233. REFLECTIONMAP_PLANAR: boolean;
  137234. REFLECTIONMAP_CUBIC: boolean;
  137235. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  137236. REFLECTIONMAP_PROJECTION: boolean;
  137237. REFLECTIONMAP_SKYBOX: boolean;
  137238. REFLECTIONMAP_EXPLICIT: boolean;
  137239. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  137240. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  137241. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  137242. INVERTCUBICMAP: boolean;
  137243. USESPHERICALFROMREFLECTIONMAP: boolean;
  137244. USEIRRADIANCEMAP: boolean;
  137245. SPHERICAL_HARMONICS: boolean;
  137246. USESPHERICALINVERTEX: boolean;
  137247. REFLECTIONMAP_OPPOSITEZ: boolean;
  137248. LODINREFLECTIONALPHA: boolean;
  137249. GAMMAREFLECTION: boolean;
  137250. RGBDREFLECTION: boolean;
  137251. LINEARSPECULARREFLECTION: boolean;
  137252. RADIANCEOCCLUSION: boolean;
  137253. HORIZONOCCLUSION: boolean;
  137254. INSTANCES: boolean;
  137255. THIN_INSTANCES: boolean;
  137256. PREPASS: boolean;
  137257. PREPASS_IRRADIANCE: boolean;
  137258. PREPASS_IRRADIANCE_INDEX: number;
  137259. PREPASS_ALBEDO: boolean;
  137260. PREPASS_ALBEDO_INDEX: number;
  137261. PREPASS_DEPTHNORMAL: boolean;
  137262. PREPASS_DEPTHNORMAL_INDEX: number;
  137263. PREPASS_POSITION: boolean;
  137264. PREPASS_POSITION_INDEX: number;
  137265. PREPASS_VELOCITY: boolean;
  137266. PREPASS_VELOCITY_INDEX: number;
  137267. PREPASS_REFLECTIVITY: boolean;
  137268. PREPASS_REFLECTIVITY_INDEX: number;
  137269. SCENE_MRT_COUNT: number;
  137270. NUM_BONE_INFLUENCERS: number;
  137271. BonesPerMesh: number;
  137272. BONETEXTURE: boolean;
  137273. BONES_VELOCITY_ENABLED: boolean;
  137274. NONUNIFORMSCALING: boolean;
  137275. MORPHTARGETS: boolean;
  137276. MORPHTARGETS_NORMAL: boolean;
  137277. MORPHTARGETS_TANGENT: boolean;
  137278. MORPHTARGETS_UV: boolean;
  137279. NUM_MORPH_INFLUENCERS: number;
  137280. IMAGEPROCESSING: boolean;
  137281. VIGNETTE: boolean;
  137282. VIGNETTEBLENDMODEMULTIPLY: boolean;
  137283. VIGNETTEBLENDMODEOPAQUE: boolean;
  137284. TONEMAPPING: boolean;
  137285. TONEMAPPING_ACES: boolean;
  137286. CONTRAST: boolean;
  137287. COLORCURVES: boolean;
  137288. COLORGRADING: boolean;
  137289. COLORGRADING3D: boolean;
  137290. SAMPLER3DGREENDEPTH: boolean;
  137291. SAMPLER3DBGRMAP: boolean;
  137292. IMAGEPROCESSINGPOSTPROCESS: boolean;
  137293. EXPOSURE: boolean;
  137294. MULTIVIEW: boolean;
  137295. USEPHYSICALLIGHTFALLOFF: boolean;
  137296. USEGLTFLIGHTFALLOFF: boolean;
  137297. TWOSIDEDLIGHTING: boolean;
  137298. SHADOWFLOAT: boolean;
  137299. CLIPPLANE: boolean;
  137300. CLIPPLANE2: boolean;
  137301. CLIPPLANE3: boolean;
  137302. CLIPPLANE4: boolean;
  137303. CLIPPLANE5: boolean;
  137304. CLIPPLANE6: boolean;
  137305. POINTSIZE: boolean;
  137306. FOG: boolean;
  137307. LOGARITHMICDEPTH: boolean;
  137308. FORCENORMALFORWARD: boolean;
  137309. SPECULARAA: boolean;
  137310. CLEARCOAT: boolean;
  137311. CLEARCOAT_DEFAULTIOR: boolean;
  137312. CLEARCOAT_TEXTURE: boolean;
  137313. CLEARCOAT_TEXTUREDIRECTUV: number;
  137314. CLEARCOAT_BUMP: boolean;
  137315. CLEARCOAT_BUMPDIRECTUV: number;
  137316. CLEARCOAT_REMAP_F0: boolean;
  137317. CLEARCOAT_TINT: boolean;
  137318. CLEARCOAT_TINT_TEXTURE: boolean;
  137319. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  137320. ANISOTROPIC: boolean;
  137321. ANISOTROPIC_TEXTURE: boolean;
  137322. ANISOTROPIC_TEXTUREDIRECTUV: number;
  137323. BRDF_V_HEIGHT_CORRELATED: boolean;
  137324. MS_BRDF_ENERGY_CONSERVATION: boolean;
  137325. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  137326. SHEEN: boolean;
  137327. SHEEN_TEXTURE: boolean;
  137328. SHEEN_TEXTUREDIRECTUV: number;
  137329. SHEEN_LINKWITHALBEDO: boolean;
  137330. SHEEN_ROUGHNESS: boolean;
  137331. SHEEN_ALBEDOSCALING: boolean;
  137332. SUBSURFACE: boolean;
  137333. SS_REFRACTION: boolean;
  137334. SS_TRANSLUCENCY: boolean;
  137335. SS_SCATTERING: boolean;
  137336. SS_THICKNESSANDMASK_TEXTURE: boolean;
  137337. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  137338. SS_REFRACTIONMAP_3D: boolean;
  137339. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  137340. SS_LODINREFRACTIONALPHA: boolean;
  137341. SS_GAMMAREFRACTION: boolean;
  137342. SS_RGBDREFRACTION: boolean;
  137343. SS_LINEARSPECULARREFRACTION: boolean;
  137344. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  137345. SS_ALBEDOFORREFRACTIONTINT: boolean;
  137346. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  137347. UNLIT: boolean;
  137348. DEBUGMODE: number;
  137349. /**
  137350. * Initializes the PBR Material defines.
  137351. */
  137352. constructor();
  137353. /**
  137354. * Resets the PBR Material defines.
  137355. */
  137356. reset(): void;
  137357. }
  137358. /**
  137359. * The Physically based material base class of BJS.
  137360. *
  137361. * This offers the main features of a standard PBR material.
  137362. * For more information, please refer to the documentation :
  137363. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137364. */
  137365. export abstract class PBRBaseMaterial extends PushMaterial {
  137366. /**
  137367. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137368. */
  137369. static readonly PBRMATERIAL_OPAQUE: number;
  137370. /**
  137371. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137372. */
  137373. static readonly PBRMATERIAL_ALPHATEST: number;
  137374. /**
  137375. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137376. */
  137377. static readonly PBRMATERIAL_ALPHABLEND: number;
  137378. /**
  137379. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137380. * They are also discarded below the alpha cutoff threshold to improve performances.
  137381. */
  137382. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137383. /**
  137384. * Defines the default value of how much AO map is occluding the analytical lights
  137385. * (point spot...).
  137386. */
  137387. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137388. /**
  137389. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  137390. */
  137391. static readonly LIGHTFALLOFF_PHYSICAL: number;
  137392. /**
  137393. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  137394. * to enhance interoperability with other engines.
  137395. */
  137396. static readonly LIGHTFALLOFF_GLTF: number;
  137397. /**
  137398. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  137399. * to enhance interoperability with other materials.
  137400. */
  137401. static readonly LIGHTFALLOFF_STANDARD: number;
  137402. /**
  137403. * Intensity of the direct lights e.g. the four lights available in your scene.
  137404. * This impacts both the direct diffuse and specular highlights.
  137405. */
  137406. protected _directIntensity: number;
  137407. /**
  137408. * Intensity of the emissive part of the material.
  137409. * This helps controlling the emissive effect without modifying the emissive color.
  137410. */
  137411. protected _emissiveIntensity: number;
  137412. /**
  137413. * Intensity of the environment e.g. how much the environment will light the object
  137414. * either through harmonics for rough material or through the refelction for shiny ones.
  137415. */
  137416. protected _environmentIntensity: number;
  137417. /**
  137418. * This is a special control allowing the reduction of the specular highlights coming from the
  137419. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137420. */
  137421. protected _specularIntensity: number;
  137422. /**
  137423. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  137424. */
  137425. private _lightingInfos;
  137426. /**
  137427. * Debug Control allowing disabling the bump map on this material.
  137428. */
  137429. protected _disableBumpMap: boolean;
  137430. /**
  137431. * AKA Diffuse Texture in standard nomenclature.
  137432. */
  137433. protected _albedoTexture: Nullable<BaseTexture>;
  137434. /**
  137435. * AKA Occlusion Texture in other nomenclature.
  137436. */
  137437. protected _ambientTexture: Nullable<BaseTexture>;
  137438. /**
  137439. * AKA Occlusion Texture Intensity in other nomenclature.
  137440. */
  137441. protected _ambientTextureStrength: number;
  137442. /**
  137443. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137444. * 1 means it completely occludes it
  137445. * 0 mean it has no impact
  137446. */
  137447. protected _ambientTextureImpactOnAnalyticalLights: number;
  137448. /**
  137449. * Stores the alpha values in a texture.
  137450. */
  137451. protected _opacityTexture: Nullable<BaseTexture>;
  137452. /**
  137453. * Stores the reflection values in a texture.
  137454. */
  137455. protected _reflectionTexture: Nullable<BaseTexture>;
  137456. /**
  137457. * Stores the emissive values in a texture.
  137458. */
  137459. protected _emissiveTexture: Nullable<BaseTexture>;
  137460. /**
  137461. * AKA Specular texture in other nomenclature.
  137462. */
  137463. protected _reflectivityTexture: Nullable<BaseTexture>;
  137464. /**
  137465. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137466. */
  137467. protected _metallicTexture: Nullable<BaseTexture>;
  137468. /**
  137469. * Specifies the metallic scalar of the metallic/roughness workflow.
  137470. * Can also be used to scale the metalness values of the metallic texture.
  137471. */
  137472. protected _metallic: Nullable<number>;
  137473. /**
  137474. * Specifies the roughness scalar of the metallic/roughness workflow.
  137475. * Can also be used to scale the roughness values of the metallic texture.
  137476. */
  137477. protected _roughness: Nullable<number>;
  137478. /**
  137479. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137480. * By default the indexOfrefraction is used to compute F0;
  137481. *
  137482. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137483. *
  137484. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137485. * F90 = metallicReflectanceColor;
  137486. */
  137487. protected _metallicF0Factor: number;
  137488. /**
  137489. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137490. * By default the F90 is always 1;
  137491. *
  137492. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137493. *
  137494. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137495. * F90 = metallicReflectanceColor;
  137496. */
  137497. protected _metallicReflectanceColor: Color3;
  137498. /**
  137499. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137500. * This is multiply against the scalar values defined in the material.
  137501. */
  137502. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  137503. /**
  137504. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137505. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137506. */
  137507. protected _microSurfaceTexture: Nullable<BaseTexture>;
  137508. /**
  137509. * Stores surface normal data used to displace a mesh in a texture.
  137510. */
  137511. protected _bumpTexture: Nullable<BaseTexture>;
  137512. /**
  137513. * Stores the pre-calculated light information of a mesh in a texture.
  137514. */
  137515. protected _lightmapTexture: Nullable<BaseTexture>;
  137516. /**
  137517. * The color of a material in ambient lighting.
  137518. */
  137519. protected _ambientColor: Color3;
  137520. /**
  137521. * AKA Diffuse Color in other nomenclature.
  137522. */
  137523. protected _albedoColor: Color3;
  137524. /**
  137525. * AKA Specular Color in other nomenclature.
  137526. */
  137527. protected _reflectivityColor: Color3;
  137528. /**
  137529. * The color applied when light is reflected from a material.
  137530. */
  137531. protected _reflectionColor: Color3;
  137532. /**
  137533. * The color applied when light is emitted from a material.
  137534. */
  137535. protected _emissiveColor: Color3;
  137536. /**
  137537. * AKA Glossiness in other nomenclature.
  137538. */
  137539. protected _microSurface: number;
  137540. /**
  137541. * Specifies that the material will use the light map as a show map.
  137542. */
  137543. protected _useLightmapAsShadowmap: boolean;
  137544. /**
  137545. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137546. * makes the reflect vector face the model (under horizon).
  137547. */
  137548. protected _useHorizonOcclusion: boolean;
  137549. /**
  137550. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137551. * too much the area relying on ambient texture to define their ambient occlusion.
  137552. */
  137553. protected _useRadianceOcclusion: boolean;
  137554. /**
  137555. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137556. */
  137557. protected _useAlphaFromAlbedoTexture: boolean;
  137558. /**
  137559. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  137560. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137561. */
  137562. protected _useSpecularOverAlpha: boolean;
  137563. /**
  137564. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137565. */
  137566. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137567. /**
  137568. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137569. */
  137570. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  137571. /**
  137572. * Specifies if the metallic texture contains the roughness information in its green channel.
  137573. */
  137574. protected _useRoughnessFromMetallicTextureGreen: boolean;
  137575. /**
  137576. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137577. */
  137578. protected _useMetallnessFromMetallicTextureBlue: boolean;
  137579. /**
  137580. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137581. */
  137582. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  137583. /**
  137584. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137585. */
  137586. protected _useAmbientInGrayScale: boolean;
  137587. /**
  137588. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137589. * The material will try to infer what glossiness each pixel should be.
  137590. */
  137591. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  137592. /**
  137593. * Defines the falloff type used in this material.
  137594. * It by default is Physical.
  137595. */
  137596. protected _lightFalloff: number;
  137597. /**
  137598. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137599. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137600. */
  137601. protected _useRadianceOverAlpha: boolean;
  137602. /**
  137603. * Allows using an object space normal map (instead of tangent space).
  137604. */
  137605. protected _useObjectSpaceNormalMap: boolean;
  137606. /**
  137607. * Allows using the bump map in parallax mode.
  137608. */
  137609. protected _useParallax: boolean;
  137610. /**
  137611. * Allows using the bump map in parallax occlusion mode.
  137612. */
  137613. protected _useParallaxOcclusion: boolean;
  137614. /**
  137615. * Controls the scale bias of the parallax mode.
  137616. */
  137617. protected _parallaxScaleBias: number;
  137618. /**
  137619. * If sets to true, disables all the lights affecting the material.
  137620. */
  137621. protected _disableLighting: boolean;
  137622. /**
  137623. * Number of Simultaneous lights allowed on the material.
  137624. */
  137625. protected _maxSimultaneousLights: number;
  137626. /**
  137627. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  137628. */
  137629. protected _invertNormalMapX: boolean;
  137630. /**
  137631. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  137632. */
  137633. protected _invertNormalMapY: boolean;
  137634. /**
  137635. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137636. */
  137637. protected _twoSidedLighting: boolean;
  137638. /**
  137639. * Defines the alpha limits in alpha test mode.
  137640. */
  137641. protected _alphaCutOff: number;
  137642. /**
  137643. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137644. */
  137645. protected _forceAlphaTest: boolean;
  137646. /**
  137647. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137648. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137649. */
  137650. protected _useAlphaFresnel: boolean;
  137651. /**
  137652. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137653. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137654. */
  137655. protected _useLinearAlphaFresnel: boolean;
  137656. /**
  137657. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  137658. * from cos thetav and roughness:
  137659. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  137660. */
  137661. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  137662. /**
  137663. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137664. */
  137665. protected _forceIrradianceInFragment: boolean;
  137666. private _realTimeFiltering;
  137667. /**
  137668. * Enables realtime filtering on the texture.
  137669. */
  137670. get realTimeFiltering(): boolean;
  137671. set realTimeFiltering(b: boolean);
  137672. private _realTimeFilteringQuality;
  137673. /**
  137674. * Quality switch for realtime filtering
  137675. */
  137676. get realTimeFilteringQuality(): number;
  137677. set realTimeFilteringQuality(n: number);
  137678. /**
  137679. * Can this material render to several textures at once
  137680. */
  137681. get canRenderToMRT(): boolean;
  137682. /**
  137683. * Force normal to face away from face.
  137684. */
  137685. protected _forceNormalForward: boolean;
  137686. /**
  137687. * Enables specular anti aliasing in the PBR shader.
  137688. * It will both interacts on the Geometry for analytical and IBL lighting.
  137689. * It also prefilter the roughness map based on the bump values.
  137690. */
  137691. protected _enableSpecularAntiAliasing: boolean;
  137692. /**
  137693. * Default configuration related to image processing available in the PBR Material.
  137694. */
  137695. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  137696. /**
  137697. * Keep track of the image processing observer to allow dispose and replace.
  137698. */
  137699. private _imageProcessingObserver;
  137700. /**
  137701. * Attaches a new image processing configuration to the PBR Material.
  137702. * @param configuration
  137703. */
  137704. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  137705. /**
  137706. * Stores the available render targets.
  137707. */
  137708. private _renderTargets;
  137709. /**
  137710. * Sets the global ambient color for the material used in lighting calculations.
  137711. */
  137712. private _globalAmbientColor;
  137713. /**
  137714. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  137715. */
  137716. private _useLogarithmicDepth;
  137717. /**
  137718. * If set to true, no lighting calculations will be applied.
  137719. */
  137720. private _unlit;
  137721. private _debugMode;
  137722. /**
  137723. * @hidden
  137724. * This is reserved for the inspector.
  137725. * Defines the material debug mode.
  137726. * It helps seeing only some components of the material while troubleshooting.
  137727. */
  137728. debugMode: number;
  137729. /**
  137730. * @hidden
  137731. * This is reserved for the inspector.
  137732. * Specify from where on screen the debug mode should start.
  137733. * The value goes from -1 (full screen) to 1 (not visible)
  137734. * It helps with side by side comparison against the final render
  137735. * This defaults to -1
  137736. */
  137737. private debugLimit;
  137738. /**
  137739. * @hidden
  137740. * This is reserved for the inspector.
  137741. * As the default viewing range might not be enough (if the ambient is really small for instance)
  137742. * You can use the factor to better multiply the final value.
  137743. */
  137744. private debugFactor;
  137745. /**
  137746. * Defines the clear coat layer parameters for the material.
  137747. */
  137748. readonly clearCoat: PBRClearCoatConfiguration;
  137749. /**
  137750. * Defines the anisotropic parameters for the material.
  137751. */
  137752. readonly anisotropy: PBRAnisotropicConfiguration;
  137753. /**
  137754. * Defines the BRDF parameters for the material.
  137755. */
  137756. readonly brdf: PBRBRDFConfiguration;
  137757. /**
  137758. * Defines the Sheen parameters for the material.
  137759. */
  137760. readonly sheen: PBRSheenConfiguration;
  137761. /**
  137762. * Defines the SubSurface parameters for the material.
  137763. */
  137764. readonly subSurface: PBRSubSurfaceConfiguration;
  137765. /**
  137766. * Defines additionnal PrePass parameters for the material.
  137767. */
  137768. readonly prePassConfiguration: PrePassConfiguration;
  137769. /**
  137770. * Defines the detail map parameters for the material.
  137771. */
  137772. readonly detailMap: DetailMapConfiguration;
  137773. protected _rebuildInParallel: boolean;
  137774. /**
  137775. * Instantiates a new PBRMaterial instance.
  137776. *
  137777. * @param name The material name
  137778. * @param scene The scene the material will be use in.
  137779. */
  137780. constructor(name: string, scene: Scene);
  137781. /**
  137782. * Gets a boolean indicating that current material needs to register RTT
  137783. */
  137784. get hasRenderTargetTextures(): boolean;
  137785. /**
  137786. * Gets the name of the material class.
  137787. */
  137788. getClassName(): string;
  137789. /**
  137790. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137791. */
  137792. get useLogarithmicDepth(): boolean;
  137793. /**
  137794. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137795. */
  137796. set useLogarithmicDepth(value: boolean);
  137797. /**
  137798. * Returns true if alpha blending should be disabled.
  137799. */
  137800. protected get _disableAlphaBlending(): boolean;
  137801. /**
  137802. * Specifies whether or not this material should be rendered in alpha blend mode.
  137803. */
  137804. needAlphaBlending(): boolean;
  137805. /**
  137806. * Specifies whether or not this material should be rendered in alpha test mode.
  137807. */
  137808. needAlphaTesting(): boolean;
  137809. /**
  137810. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  137811. */
  137812. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  137813. /**
  137814. * Gets the texture used for the alpha test.
  137815. */
  137816. getAlphaTestTexture(): Nullable<BaseTexture>;
  137817. /**
  137818. * Specifies that the submesh is ready to be used.
  137819. * @param mesh - BJS mesh.
  137820. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  137821. * @param useInstances - Specifies that instances should be used.
  137822. * @returns - boolean indicating that the submesh is ready or not.
  137823. */
  137824. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  137825. /**
  137826. * Specifies if the material uses metallic roughness workflow.
  137827. * @returns boolean specifiying if the material uses metallic roughness workflow.
  137828. */
  137829. isMetallicWorkflow(): boolean;
  137830. private _prepareEffect;
  137831. private _prepareDefines;
  137832. /**
  137833. * Force shader compilation
  137834. */
  137835. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  137836. /**
  137837. * Initializes the uniform buffer layout for the shader.
  137838. */
  137839. buildUniformLayout(): void;
  137840. /**
  137841. * Unbinds the material from the mesh
  137842. */
  137843. unbind(): void;
  137844. /**
  137845. * Binds the submesh data.
  137846. * @param world - The world matrix.
  137847. * @param mesh - The BJS mesh.
  137848. * @param subMesh - A submesh of the BJS mesh.
  137849. */
  137850. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  137851. /**
  137852. * Returns the animatable textures.
  137853. * @returns - Array of animatable textures.
  137854. */
  137855. getAnimatables(): IAnimatable[];
  137856. /**
  137857. * Returns the texture used for reflections.
  137858. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  137859. */
  137860. private _getReflectionTexture;
  137861. /**
  137862. * Returns an array of the actively used textures.
  137863. * @returns - Array of BaseTextures
  137864. */
  137865. getActiveTextures(): BaseTexture[];
  137866. /**
  137867. * Checks to see if a texture is used in the material.
  137868. * @param texture - Base texture to use.
  137869. * @returns - Boolean specifying if a texture is used in the material.
  137870. */
  137871. hasTexture(texture: BaseTexture): boolean;
  137872. /**
  137873. * Sets the required values to the prepass renderer.
  137874. * @param prePassRenderer defines the prepass renderer to setup
  137875. */
  137876. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  137877. /**
  137878. * Disposes the resources of the material.
  137879. * @param forceDisposeEffect - Forces the disposal of effects.
  137880. * @param forceDisposeTextures - Forces the disposal of all textures.
  137881. */
  137882. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  137883. }
  137884. }
  137885. declare module BABYLON {
  137886. /**
  137887. * The Physically based material of BJS.
  137888. *
  137889. * This offers the main features of a standard PBR material.
  137890. * For more information, please refer to the documentation :
  137891. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137892. */
  137893. export class PBRMaterial extends PBRBaseMaterial {
  137894. /**
  137895. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137896. */
  137897. static readonly PBRMATERIAL_OPAQUE: number;
  137898. /**
  137899. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137900. */
  137901. static readonly PBRMATERIAL_ALPHATEST: number;
  137902. /**
  137903. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137904. */
  137905. static readonly PBRMATERIAL_ALPHABLEND: number;
  137906. /**
  137907. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137908. * They are also discarded below the alpha cutoff threshold to improve performances.
  137909. */
  137910. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137911. /**
  137912. * Defines the default value of how much AO map is occluding the analytical lights
  137913. * (point spot...).
  137914. */
  137915. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137916. /**
  137917. * Intensity of the direct lights e.g. the four lights available in your scene.
  137918. * This impacts both the direct diffuse and specular highlights.
  137919. */
  137920. directIntensity: number;
  137921. /**
  137922. * Intensity of the emissive part of the material.
  137923. * This helps controlling the emissive effect without modifying the emissive color.
  137924. */
  137925. emissiveIntensity: number;
  137926. /**
  137927. * Intensity of the environment e.g. how much the environment will light the object
  137928. * either through harmonics for rough material or through the refelction for shiny ones.
  137929. */
  137930. environmentIntensity: number;
  137931. /**
  137932. * This is a special control allowing the reduction of the specular highlights coming from the
  137933. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137934. */
  137935. specularIntensity: number;
  137936. /**
  137937. * Debug Control allowing disabling the bump map on this material.
  137938. */
  137939. disableBumpMap: boolean;
  137940. /**
  137941. * AKA Diffuse Texture in standard nomenclature.
  137942. */
  137943. albedoTexture: BaseTexture;
  137944. /**
  137945. * AKA Occlusion Texture in other nomenclature.
  137946. */
  137947. ambientTexture: BaseTexture;
  137948. /**
  137949. * AKA Occlusion Texture Intensity in other nomenclature.
  137950. */
  137951. ambientTextureStrength: number;
  137952. /**
  137953. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137954. * 1 means it completely occludes it
  137955. * 0 mean it has no impact
  137956. */
  137957. ambientTextureImpactOnAnalyticalLights: number;
  137958. /**
  137959. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  137960. */
  137961. opacityTexture: BaseTexture;
  137962. /**
  137963. * Stores the reflection values in a texture.
  137964. */
  137965. reflectionTexture: Nullable<BaseTexture>;
  137966. /**
  137967. * Stores the emissive values in a texture.
  137968. */
  137969. emissiveTexture: BaseTexture;
  137970. /**
  137971. * AKA Specular texture in other nomenclature.
  137972. */
  137973. reflectivityTexture: BaseTexture;
  137974. /**
  137975. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137976. */
  137977. metallicTexture: BaseTexture;
  137978. /**
  137979. * Specifies the metallic scalar of the metallic/roughness workflow.
  137980. * Can also be used to scale the metalness values of the metallic texture.
  137981. */
  137982. metallic: Nullable<number>;
  137983. /**
  137984. * Specifies the roughness scalar of the metallic/roughness workflow.
  137985. * Can also be used to scale the roughness values of the metallic texture.
  137986. */
  137987. roughness: Nullable<number>;
  137988. /**
  137989. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137990. * By default the indexOfrefraction is used to compute F0;
  137991. *
  137992. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137993. *
  137994. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137995. * F90 = metallicReflectanceColor;
  137996. */
  137997. metallicF0Factor: number;
  137998. /**
  137999. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  138000. * By default the F90 is always 1;
  138001. *
  138002. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  138003. *
  138004. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  138005. * F90 = metallicReflectanceColor;
  138006. */
  138007. metallicReflectanceColor: Color3;
  138008. /**
  138009. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  138010. * This is multiply against the scalar values defined in the material.
  138011. */
  138012. metallicReflectanceTexture: Nullable<BaseTexture>;
  138013. /**
  138014. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  138015. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  138016. */
  138017. microSurfaceTexture: BaseTexture;
  138018. /**
  138019. * Stores surface normal data used to displace a mesh in a texture.
  138020. */
  138021. bumpTexture: BaseTexture;
  138022. /**
  138023. * Stores the pre-calculated light information of a mesh in a texture.
  138024. */
  138025. lightmapTexture: BaseTexture;
  138026. /**
  138027. * Stores the refracted light information in a texture.
  138028. */
  138029. get refractionTexture(): Nullable<BaseTexture>;
  138030. set refractionTexture(value: Nullable<BaseTexture>);
  138031. /**
  138032. * The color of a material in ambient lighting.
  138033. */
  138034. ambientColor: Color3;
  138035. /**
  138036. * AKA Diffuse Color in other nomenclature.
  138037. */
  138038. albedoColor: Color3;
  138039. /**
  138040. * AKA Specular Color in other nomenclature.
  138041. */
  138042. reflectivityColor: Color3;
  138043. /**
  138044. * The color reflected from the material.
  138045. */
  138046. reflectionColor: Color3;
  138047. /**
  138048. * The color emitted from the material.
  138049. */
  138050. emissiveColor: Color3;
  138051. /**
  138052. * AKA Glossiness in other nomenclature.
  138053. */
  138054. microSurface: number;
  138055. /**
  138056. * Index of refraction of the material base layer.
  138057. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  138058. *
  138059. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  138060. *
  138061. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  138062. */
  138063. get indexOfRefraction(): number;
  138064. set indexOfRefraction(value: number);
  138065. /**
  138066. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  138067. */
  138068. get invertRefractionY(): boolean;
  138069. set invertRefractionY(value: boolean);
  138070. /**
  138071. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  138072. * Materials half opaque for instance using refraction could benefit from this control.
  138073. */
  138074. get linkRefractionWithTransparency(): boolean;
  138075. set linkRefractionWithTransparency(value: boolean);
  138076. /**
  138077. * If true, the light map contains occlusion information instead of lighting info.
  138078. */
  138079. useLightmapAsShadowmap: boolean;
  138080. /**
  138081. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  138082. */
  138083. useAlphaFromAlbedoTexture: boolean;
  138084. /**
  138085. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  138086. */
  138087. forceAlphaTest: boolean;
  138088. /**
  138089. * Defines the alpha limits in alpha test mode.
  138090. */
  138091. alphaCutOff: number;
  138092. /**
  138093. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  138094. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  138095. */
  138096. useSpecularOverAlpha: boolean;
  138097. /**
  138098. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  138099. */
  138100. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  138101. /**
  138102. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  138103. */
  138104. useRoughnessFromMetallicTextureAlpha: boolean;
  138105. /**
  138106. * Specifies if the metallic texture contains the roughness information in its green channel.
  138107. */
  138108. useRoughnessFromMetallicTextureGreen: boolean;
  138109. /**
  138110. * Specifies if the metallic texture contains the metallness information in its blue channel.
  138111. */
  138112. useMetallnessFromMetallicTextureBlue: boolean;
  138113. /**
  138114. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  138115. */
  138116. useAmbientOcclusionFromMetallicTextureRed: boolean;
  138117. /**
  138118. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  138119. */
  138120. useAmbientInGrayScale: boolean;
  138121. /**
  138122. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  138123. * The material will try to infer what glossiness each pixel should be.
  138124. */
  138125. useAutoMicroSurfaceFromReflectivityMap: boolean;
  138126. /**
  138127. * BJS is using an harcoded light falloff based on a manually sets up range.
  138128. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  138129. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  138130. */
  138131. get usePhysicalLightFalloff(): boolean;
  138132. /**
  138133. * BJS is using an harcoded light falloff based on a manually sets up range.
  138134. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  138135. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  138136. */
  138137. set usePhysicalLightFalloff(value: boolean);
  138138. /**
  138139. * In order to support the falloff compatibility with gltf, a special mode has been added
  138140. * to reproduce the gltf light falloff.
  138141. */
  138142. get useGLTFLightFalloff(): boolean;
  138143. /**
  138144. * In order to support the falloff compatibility with gltf, a special mode has been added
  138145. * to reproduce the gltf light falloff.
  138146. */
  138147. set useGLTFLightFalloff(value: boolean);
  138148. /**
  138149. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  138150. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  138151. */
  138152. useRadianceOverAlpha: boolean;
  138153. /**
  138154. * Allows using an object space normal map (instead of tangent space).
  138155. */
  138156. useObjectSpaceNormalMap: boolean;
  138157. /**
  138158. * Allows using the bump map in parallax mode.
  138159. */
  138160. useParallax: boolean;
  138161. /**
  138162. * Allows using the bump map in parallax occlusion mode.
  138163. */
  138164. useParallaxOcclusion: boolean;
  138165. /**
  138166. * Controls the scale bias of the parallax mode.
  138167. */
  138168. parallaxScaleBias: number;
  138169. /**
  138170. * If sets to true, disables all the lights affecting the material.
  138171. */
  138172. disableLighting: boolean;
  138173. /**
  138174. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  138175. */
  138176. forceIrradianceInFragment: boolean;
  138177. /**
  138178. * Number of Simultaneous lights allowed on the material.
  138179. */
  138180. maxSimultaneousLights: number;
  138181. /**
  138182. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  138183. */
  138184. invertNormalMapX: boolean;
  138185. /**
  138186. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  138187. */
  138188. invertNormalMapY: boolean;
  138189. /**
  138190. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  138191. */
  138192. twoSidedLighting: boolean;
  138193. /**
  138194. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  138195. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  138196. */
  138197. useAlphaFresnel: boolean;
  138198. /**
  138199. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  138200. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  138201. */
  138202. useLinearAlphaFresnel: boolean;
  138203. /**
  138204. * Let user defines the brdf lookup texture used for IBL.
  138205. * A default 8bit version is embedded but you could point at :
  138206. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  138207. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  138208. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  138209. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  138210. */
  138211. environmentBRDFTexture: Nullable<BaseTexture>;
  138212. /**
  138213. * Force normal to face away from face.
  138214. */
  138215. forceNormalForward: boolean;
  138216. /**
  138217. * Enables specular anti aliasing in the PBR shader.
  138218. * It will both interacts on the Geometry for analytical and IBL lighting.
  138219. * It also prefilter the roughness map based on the bump values.
  138220. */
  138221. enableSpecularAntiAliasing: boolean;
  138222. /**
  138223. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  138224. * makes the reflect vector face the model (under horizon).
  138225. */
  138226. useHorizonOcclusion: boolean;
  138227. /**
  138228. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  138229. * too much the area relying on ambient texture to define their ambient occlusion.
  138230. */
  138231. useRadianceOcclusion: boolean;
  138232. /**
  138233. * If set to true, no lighting calculations will be applied.
  138234. */
  138235. unlit: boolean;
  138236. /**
  138237. * Gets the image processing configuration used either in this material.
  138238. */
  138239. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  138240. /**
  138241. * Sets the Default image processing configuration used either in the this material.
  138242. *
  138243. * If sets to null, the scene one is in use.
  138244. */
  138245. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  138246. /**
  138247. * Gets wether the color curves effect is enabled.
  138248. */
  138249. get cameraColorCurvesEnabled(): boolean;
  138250. /**
  138251. * Sets wether the color curves effect is enabled.
  138252. */
  138253. set cameraColorCurvesEnabled(value: boolean);
  138254. /**
  138255. * Gets wether the color grading effect is enabled.
  138256. */
  138257. get cameraColorGradingEnabled(): boolean;
  138258. /**
  138259. * Gets wether the color grading effect is enabled.
  138260. */
  138261. set cameraColorGradingEnabled(value: boolean);
  138262. /**
  138263. * Gets wether tonemapping is enabled or not.
  138264. */
  138265. get cameraToneMappingEnabled(): boolean;
  138266. /**
  138267. * Sets wether tonemapping is enabled or not
  138268. */
  138269. set cameraToneMappingEnabled(value: boolean);
  138270. /**
  138271. * The camera exposure used on this material.
  138272. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138273. * This corresponds to a photographic exposure.
  138274. */
  138275. get cameraExposure(): number;
  138276. /**
  138277. * The camera exposure used on this material.
  138278. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138279. * This corresponds to a photographic exposure.
  138280. */
  138281. set cameraExposure(value: number);
  138282. /**
  138283. * Gets The camera contrast used on this material.
  138284. */
  138285. get cameraContrast(): number;
  138286. /**
  138287. * Sets The camera contrast used on this material.
  138288. */
  138289. set cameraContrast(value: number);
  138290. /**
  138291. * Gets the Color Grading 2D Lookup Texture.
  138292. */
  138293. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  138294. /**
  138295. * Sets the Color Grading 2D Lookup Texture.
  138296. */
  138297. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  138298. /**
  138299. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138301. * 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;
  138302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138303. */
  138304. get cameraColorCurves(): Nullable<ColorCurves>;
  138305. /**
  138306. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138307. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138308. * 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;
  138309. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138310. */
  138311. set cameraColorCurves(value: Nullable<ColorCurves>);
  138312. /**
  138313. * Instantiates a new PBRMaterial instance.
  138314. *
  138315. * @param name The material name
  138316. * @param scene The scene the material will be use in.
  138317. */
  138318. constructor(name: string, scene: Scene);
  138319. /**
  138320. * Returns the name of this material class.
  138321. */
  138322. getClassName(): string;
  138323. /**
  138324. * Makes a duplicate of the current material.
  138325. * @param name - name to use for the new material.
  138326. */
  138327. clone(name: string): PBRMaterial;
  138328. /**
  138329. * Serializes this PBR Material.
  138330. * @returns - An object with the serialized material.
  138331. */
  138332. serialize(): any;
  138333. /**
  138334. * Parses a PBR Material from a serialized object.
  138335. * @param source - Serialized object.
  138336. * @param scene - BJS scene instance.
  138337. * @param rootUrl - url for the scene object
  138338. * @returns - PBRMaterial
  138339. */
  138340. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  138341. }
  138342. }
  138343. declare module BABYLON {
  138344. /**
  138345. * Direct draw surface info
  138346. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  138347. */
  138348. export interface DDSInfo {
  138349. /**
  138350. * Width of the texture
  138351. */
  138352. width: number;
  138353. /**
  138354. * Width of the texture
  138355. */
  138356. height: number;
  138357. /**
  138358. * Number of Mipmaps for the texture
  138359. * @see https://en.wikipedia.org/wiki/Mipmap
  138360. */
  138361. mipmapCount: number;
  138362. /**
  138363. * If the textures format is a known fourCC format
  138364. * @see https://www.fourcc.org/
  138365. */
  138366. isFourCC: boolean;
  138367. /**
  138368. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  138369. */
  138370. isRGB: boolean;
  138371. /**
  138372. * If the texture is a lumincance format
  138373. */
  138374. isLuminance: boolean;
  138375. /**
  138376. * If this is a cube texture
  138377. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  138378. */
  138379. isCube: boolean;
  138380. /**
  138381. * If the texture is a compressed format eg. FOURCC_DXT1
  138382. */
  138383. isCompressed: boolean;
  138384. /**
  138385. * The dxgiFormat of the texture
  138386. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  138387. */
  138388. dxgiFormat: number;
  138389. /**
  138390. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  138391. */
  138392. textureType: number;
  138393. /**
  138394. * Sphericle polynomial created for the dds texture
  138395. */
  138396. sphericalPolynomial?: SphericalPolynomial;
  138397. }
  138398. /**
  138399. * Class used to provide DDS decompression tools
  138400. */
  138401. export class DDSTools {
  138402. /**
  138403. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  138404. */
  138405. static StoreLODInAlphaChannel: boolean;
  138406. /**
  138407. * Gets DDS information from an array buffer
  138408. * @param data defines the array buffer view to read data from
  138409. * @returns the DDS information
  138410. */
  138411. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  138412. private static _FloatView;
  138413. private static _Int32View;
  138414. private static _ToHalfFloat;
  138415. private static _FromHalfFloat;
  138416. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  138417. private static _GetHalfFloatRGBAArrayBuffer;
  138418. private static _GetFloatRGBAArrayBuffer;
  138419. private static _GetFloatAsUIntRGBAArrayBuffer;
  138420. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  138421. private static _GetRGBAArrayBuffer;
  138422. private static _ExtractLongWordOrder;
  138423. private static _GetRGBArrayBuffer;
  138424. private static _GetLuminanceArrayBuffer;
  138425. /**
  138426. * Uploads DDS Levels to a Babylon Texture
  138427. * @hidden
  138428. */
  138429. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  138430. }
  138431. interface ThinEngine {
  138432. /**
  138433. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  138434. * @param rootUrl defines the url where the file to load is located
  138435. * @param scene defines the current scene
  138436. * @param lodScale defines scale to apply to the mip map selection
  138437. * @param lodOffset defines offset to apply to the mip map selection
  138438. * @param onLoad defines an optional callback raised when the texture is loaded
  138439. * @param onError defines an optional callback raised if there is an issue to load the texture
  138440. * @param format defines the format of the data
  138441. * @param forcedExtension defines the extension to use to pick the right loader
  138442. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  138443. * @returns the cube texture as an InternalTexture
  138444. */
  138445. 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;
  138446. }
  138447. }
  138448. declare module BABYLON {
  138449. /**
  138450. * Implementation of the DDS Texture Loader.
  138451. * @hidden
  138452. */
  138453. export class _DDSTextureLoader implements IInternalTextureLoader {
  138454. /**
  138455. * Defines wether the loader supports cascade loading the different faces.
  138456. */
  138457. readonly supportCascades: boolean;
  138458. /**
  138459. * This returns if the loader support the current file information.
  138460. * @param extension defines the file extension of the file being loaded
  138461. * @returns true if the loader can load the specified file
  138462. */
  138463. canLoad(extension: string): boolean;
  138464. /**
  138465. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138466. * @param data contains the texture data
  138467. * @param texture defines the BabylonJS internal texture
  138468. * @param createPolynomials will be true if polynomials have been requested
  138469. * @param onLoad defines the callback to trigger once the texture is ready
  138470. * @param onError defines the callback to trigger in case of error
  138471. */
  138472. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138473. /**
  138474. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138475. * @param data contains the texture data
  138476. * @param texture defines the BabylonJS internal texture
  138477. * @param callback defines the method to call once ready to upload
  138478. */
  138479. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138480. }
  138481. }
  138482. declare module BABYLON {
  138483. /**
  138484. * Implementation of the ENV Texture Loader.
  138485. * @hidden
  138486. */
  138487. export class _ENVTextureLoader implements IInternalTextureLoader {
  138488. /**
  138489. * Defines wether the loader supports cascade loading the different faces.
  138490. */
  138491. readonly supportCascades: boolean;
  138492. /**
  138493. * This returns if the loader support the current file information.
  138494. * @param extension defines the file extension of the file being loaded
  138495. * @returns true if the loader can load the specified file
  138496. */
  138497. canLoad(extension: string): boolean;
  138498. /**
  138499. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138500. * @param data contains the texture data
  138501. * @param texture defines the BabylonJS internal texture
  138502. * @param createPolynomials will be true if polynomials have been requested
  138503. * @param onLoad defines the callback to trigger once the texture is ready
  138504. * @param onError defines the callback to trigger in case of error
  138505. */
  138506. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138507. /**
  138508. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138509. * @param data contains the texture data
  138510. * @param texture defines the BabylonJS internal texture
  138511. * @param callback defines the method to call once ready to upload
  138512. */
  138513. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138514. }
  138515. }
  138516. declare module BABYLON {
  138517. /**
  138518. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138519. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138520. */
  138521. export class KhronosTextureContainer {
  138522. /** contents of the KTX container file */
  138523. data: ArrayBufferView;
  138524. private static HEADER_LEN;
  138525. private static COMPRESSED_2D;
  138526. private static COMPRESSED_3D;
  138527. private static TEX_2D;
  138528. private static TEX_3D;
  138529. /**
  138530. * Gets the openGL type
  138531. */
  138532. glType: number;
  138533. /**
  138534. * Gets the openGL type size
  138535. */
  138536. glTypeSize: number;
  138537. /**
  138538. * Gets the openGL format
  138539. */
  138540. glFormat: number;
  138541. /**
  138542. * Gets the openGL internal format
  138543. */
  138544. glInternalFormat: number;
  138545. /**
  138546. * Gets the base internal format
  138547. */
  138548. glBaseInternalFormat: number;
  138549. /**
  138550. * Gets image width in pixel
  138551. */
  138552. pixelWidth: number;
  138553. /**
  138554. * Gets image height in pixel
  138555. */
  138556. pixelHeight: number;
  138557. /**
  138558. * Gets image depth in pixels
  138559. */
  138560. pixelDepth: number;
  138561. /**
  138562. * Gets the number of array elements
  138563. */
  138564. numberOfArrayElements: number;
  138565. /**
  138566. * Gets the number of faces
  138567. */
  138568. numberOfFaces: number;
  138569. /**
  138570. * Gets the number of mipmap levels
  138571. */
  138572. numberOfMipmapLevels: number;
  138573. /**
  138574. * Gets the bytes of key value data
  138575. */
  138576. bytesOfKeyValueData: number;
  138577. /**
  138578. * Gets the load type
  138579. */
  138580. loadType: number;
  138581. /**
  138582. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  138583. */
  138584. isInvalid: boolean;
  138585. /**
  138586. * Creates a new KhronosTextureContainer
  138587. * @param data contents of the KTX container file
  138588. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  138589. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  138590. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  138591. */
  138592. constructor(
  138593. /** contents of the KTX container file */
  138594. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  138595. /**
  138596. * Uploads KTX content to a Babylon Texture.
  138597. * It is assumed that the texture has already been created & is currently bound
  138598. * @hidden
  138599. */
  138600. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  138601. private _upload2DCompressedLevels;
  138602. /**
  138603. * Checks if the given data starts with a KTX file identifier.
  138604. * @param data the data to check
  138605. * @returns true if the data is a KTX file or false otherwise
  138606. */
  138607. static IsValid(data: ArrayBufferView): boolean;
  138608. }
  138609. }
  138610. declare module BABYLON {
  138611. /**
  138612. * Helper class to push actions to a pool of workers.
  138613. */
  138614. export class WorkerPool implements IDisposable {
  138615. private _workerInfos;
  138616. private _pendingActions;
  138617. /**
  138618. * Constructor
  138619. * @param workers Array of workers to use for actions
  138620. */
  138621. constructor(workers: Array<Worker>);
  138622. /**
  138623. * Terminates all workers and clears any pending actions.
  138624. */
  138625. dispose(): void;
  138626. /**
  138627. * Pushes an action to the worker pool. If all the workers are active, the action will be
  138628. * pended until a worker has completed its action.
  138629. * @param action The action to perform. Call onComplete when the action is complete.
  138630. */
  138631. push(action: (worker: Worker, onComplete: () => void) => void): void;
  138632. private _execute;
  138633. }
  138634. }
  138635. declare module BABYLON {
  138636. /**
  138637. * Class for loading KTX2 files
  138638. */
  138639. export class KhronosTextureContainer2 {
  138640. private static _WorkerPoolPromise?;
  138641. private static _Initialized;
  138642. private static _Ktx2Decoder;
  138643. /**
  138644. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  138645. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  138646. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  138647. * Urls you can change:
  138648. * URLConfig.jsDecoderModule
  138649. * URLConfig.wasmUASTCToASTC
  138650. * URLConfig.wasmUASTCToBC7
  138651. * URLConfig.jsMSCTranscoder
  138652. * URLConfig.wasmMSCTranscoder
  138653. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  138654. */
  138655. static URLConfig: {
  138656. jsDecoderModule: string;
  138657. wasmUASTCToASTC: null;
  138658. wasmUASTCToBC7: null;
  138659. jsMSCTranscoder: null;
  138660. wasmMSCTranscoder: null;
  138661. };
  138662. /**
  138663. * Default number of workers used to handle data decoding
  138664. */
  138665. static DefaultNumWorkers: number;
  138666. private static GetDefaultNumWorkers;
  138667. private _engine;
  138668. private static _CreateWorkerPool;
  138669. /**
  138670. * Constructor
  138671. * @param engine The engine to use
  138672. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138673. */
  138674. constructor(engine: ThinEngine, numWorkers?: number);
  138675. /** @hidden */
  138676. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  138677. /**
  138678. * Stop all async operations and release resources.
  138679. */
  138680. dispose(): void;
  138681. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  138682. /**
  138683. * Checks if the given data starts with a KTX2 file identifier.
  138684. * @param data the data to check
  138685. * @returns true if the data is a KTX2 file or false otherwise
  138686. */
  138687. static IsValid(data: ArrayBufferView): boolean;
  138688. }
  138689. }
  138690. declare module BABYLON {
  138691. /**
  138692. * Implementation of the KTX Texture Loader.
  138693. * @hidden
  138694. */
  138695. export class _KTXTextureLoader implements IInternalTextureLoader {
  138696. /**
  138697. * Defines wether the loader supports cascade loading the different faces.
  138698. */
  138699. readonly supportCascades: boolean;
  138700. /**
  138701. * This returns if the loader support the current file information.
  138702. * @param extension defines the file extension of the file being loaded
  138703. * @param mimeType defines the optional mime type of the file being loaded
  138704. * @returns true if the loader can load the specified file
  138705. */
  138706. canLoad(extension: string, mimeType?: string): boolean;
  138707. /**
  138708. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138709. * @param data contains the texture data
  138710. * @param texture defines the BabylonJS internal texture
  138711. * @param createPolynomials will be true if polynomials have been requested
  138712. * @param onLoad defines the callback to trigger once the texture is ready
  138713. * @param onError defines the callback to trigger in case of error
  138714. */
  138715. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138716. /**
  138717. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138718. * @param data contains the texture data
  138719. * @param texture defines the BabylonJS internal texture
  138720. * @param callback defines the method to call once ready to upload
  138721. */
  138722. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  138723. }
  138724. }
  138725. declare module BABYLON {
  138726. /** @hidden */
  138727. export var _forceSceneHelpersToBundle: boolean;
  138728. interface Scene {
  138729. /**
  138730. * Creates a default light for the scene.
  138731. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  138732. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  138733. */
  138734. createDefaultLight(replace?: boolean): void;
  138735. /**
  138736. * Creates a default camera for the scene.
  138737. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  138738. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138739. * @param replace has default false, when true replaces the active camera in the scene
  138740. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  138741. */
  138742. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138743. /**
  138744. * Creates a default camera and a default light.
  138745. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  138746. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138747. * @param replace has the default false, when true replaces the active camera/light in the scene
  138748. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  138749. */
  138750. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138751. /**
  138752. * Creates a new sky box
  138753. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  138754. * @param environmentTexture defines the texture to use as environment texture
  138755. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  138756. * @param scale defines the overall scale of the skybox
  138757. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  138758. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  138759. * @returns a new mesh holding the sky box
  138760. */
  138761. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  138762. /**
  138763. * Creates a new environment
  138764. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  138765. * @param options defines the options you can use to configure the environment
  138766. * @returns the new EnvironmentHelper
  138767. */
  138768. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  138769. /**
  138770. * Creates a new VREXperienceHelper
  138771. * @see https://doc.babylonjs.com/how_to/webvr_helper
  138772. * @param webVROptions defines the options used to create the new VREXperienceHelper
  138773. * @returns a new VREXperienceHelper
  138774. */
  138775. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  138776. /**
  138777. * Creates a new WebXRDefaultExperience
  138778. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  138779. * @param options experience options
  138780. * @returns a promise for a new WebXRDefaultExperience
  138781. */
  138782. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  138783. }
  138784. }
  138785. declare module BABYLON {
  138786. /**
  138787. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  138788. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  138789. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  138790. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138791. */
  138792. export class VideoDome extends TextureDome<VideoTexture> {
  138793. /**
  138794. * Define the video source as a Monoscopic panoramic 360 video.
  138795. */
  138796. static readonly MODE_MONOSCOPIC: number;
  138797. /**
  138798. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  138799. */
  138800. static readonly MODE_TOPBOTTOM: number;
  138801. /**
  138802. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  138803. */
  138804. static readonly MODE_SIDEBYSIDE: number;
  138805. /**
  138806. * Get the video texture associated with this video dome
  138807. */
  138808. get videoTexture(): VideoTexture;
  138809. /**
  138810. * Get the video mode of this dome
  138811. */
  138812. get videoMode(): number;
  138813. /**
  138814. * Set the video mode of this dome.
  138815. * @see textureMode
  138816. */
  138817. set videoMode(value: number);
  138818. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  138819. }
  138820. }
  138821. declare module BABYLON {
  138822. /**
  138823. * This class can be used to get instrumentation data from a Babylon engine
  138824. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138825. */
  138826. export class EngineInstrumentation implements IDisposable {
  138827. /**
  138828. * Define the instrumented engine.
  138829. */
  138830. engine: Engine;
  138831. private _captureGPUFrameTime;
  138832. private _gpuFrameTimeToken;
  138833. private _gpuFrameTime;
  138834. private _captureShaderCompilationTime;
  138835. private _shaderCompilationTime;
  138836. private _onBeginFrameObserver;
  138837. private _onEndFrameObserver;
  138838. private _onBeforeShaderCompilationObserver;
  138839. private _onAfterShaderCompilationObserver;
  138840. /**
  138841. * Gets the perf counter used for GPU frame time
  138842. */
  138843. get gpuFrameTimeCounter(): PerfCounter;
  138844. /**
  138845. * Gets the GPU frame time capture status
  138846. */
  138847. get captureGPUFrameTime(): boolean;
  138848. /**
  138849. * Enable or disable the GPU frame time capture
  138850. */
  138851. set captureGPUFrameTime(value: boolean);
  138852. /**
  138853. * Gets the perf counter used for shader compilation time
  138854. */
  138855. get shaderCompilationTimeCounter(): PerfCounter;
  138856. /**
  138857. * Gets the shader compilation time capture status
  138858. */
  138859. get captureShaderCompilationTime(): boolean;
  138860. /**
  138861. * Enable or disable the shader compilation time capture
  138862. */
  138863. set captureShaderCompilationTime(value: boolean);
  138864. /**
  138865. * Instantiates a new engine instrumentation.
  138866. * This class can be used to get instrumentation data from a Babylon engine
  138867. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138868. * @param engine Defines the engine to instrument
  138869. */
  138870. constructor(
  138871. /**
  138872. * Define the instrumented engine.
  138873. */
  138874. engine: Engine);
  138875. /**
  138876. * Dispose and release associated resources.
  138877. */
  138878. dispose(): void;
  138879. }
  138880. }
  138881. declare module BABYLON {
  138882. /**
  138883. * This class can be used to get instrumentation data from a Babylon engine
  138884. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138885. */
  138886. export class SceneInstrumentation implements IDisposable {
  138887. /**
  138888. * Defines the scene to instrument
  138889. */
  138890. scene: Scene;
  138891. private _captureActiveMeshesEvaluationTime;
  138892. private _activeMeshesEvaluationTime;
  138893. private _captureRenderTargetsRenderTime;
  138894. private _renderTargetsRenderTime;
  138895. private _captureFrameTime;
  138896. private _frameTime;
  138897. private _captureRenderTime;
  138898. private _renderTime;
  138899. private _captureInterFrameTime;
  138900. private _interFrameTime;
  138901. private _captureParticlesRenderTime;
  138902. private _particlesRenderTime;
  138903. private _captureSpritesRenderTime;
  138904. private _spritesRenderTime;
  138905. private _capturePhysicsTime;
  138906. private _physicsTime;
  138907. private _captureAnimationsTime;
  138908. private _animationsTime;
  138909. private _captureCameraRenderTime;
  138910. private _cameraRenderTime;
  138911. private _onBeforeActiveMeshesEvaluationObserver;
  138912. private _onAfterActiveMeshesEvaluationObserver;
  138913. private _onBeforeRenderTargetsRenderObserver;
  138914. private _onAfterRenderTargetsRenderObserver;
  138915. private _onAfterRenderObserver;
  138916. private _onBeforeDrawPhaseObserver;
  138917. private _onAfterDrawPhaseObserver;
  138918. private _onBeforeAnimationsObserver;
  138919. private _onBeforeParticlesRenderingObserver;
  138920. private _onAfterParticlesRenderingObserver;
  138921. private _onBeforeSpritesRenderingObserver;
  138922. private _onAfterSpritesRenderingObserver;
  138923. private _onBeforePhysicsObserver;
  138924. private _onAfterPhysicsObserver;
  138925. private _onAfterAnimationsObserver;
  138926. private _onBeforeCameraRenderObserver;
  138927. private _onAfterCameraRenderObserver;
  138928. /**
  138929. * Gets the perf counter used for active meshes evaluation time
  138930. */
  138931. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  138932. /**
  138933. * Gets the active meshes evaluation time capture status
  138934. */
  138935. get captureActiveMeshesEvaluationTime(): boolean;
  138936. /**
  138937. * Enable or disable the active meshes evaluation time capture
  138938. */
  138939. set captureActiveMeshesEvaluationTime(value: boolean);
  138940. /**
  138941. * Gets the perf counter used for render targets render time
  138942. */
  138943. get renderTargetsRenderTimeCounter(): PerfCounter;
  138944. /**
  138945. * Gets the render targets render time capture status
  138946. */
  138947. get captureRenderTargetsRenderTime(): boolean;
  138948. /**
  138949. * Enable or disable the render targets render time capture
  138950. */
  138951. set captureRenderTargetsRenderTime(value: boolean);
  138952. /**
  138953. * Gets the perf counter used for particles render time
  138954. */
  138955. get particlesRenderTimeCounter(): PerfCounter;
  138956. /**
  138957. * Gets the particles render time capture status
  138958. */
  138959. get captureParticlesRenderTime(): boolean;
  138960. /**
  138961. * Enable or disable the particles render time capture
  138962. */
  138963. set captureParticlesRenderTime(value: boolean);
  138964. /**
  138965. * Gets the perf counter used for sprites render time
  138966. */
  138967. get spritesRenderTimeCounter(): PerfCounter;
  138968. /**
  138969. * Gets the sprites render time capture status
  138970. */
  138971. get captureSpritesRenderTime(): boolean;
  138972. /**
  138973. * Enable or disable the sprites render time capture
  138974. */
  138975. set captureSpritesRenderTime(value: boolean);
  138976. /**
  138977. * Gets the perf counter used for physics time
  138978. */
  138979. get physicsTimeCounter(): PerfCounter;
  138980. /**
  138981. * Gets the physics time capture status
  138982. */
  138983. get capturePhysicsTime(): boolean;
  138984. /**
  138985. * Enable or disable the physics time capture
  138986. */
  138987. set capturePhysicsTime(value: boolean);
  138988. /**
  138989. * Gets the perf counter used for animations time
  138990. */
  138991. get animationsTimeCounter(): PerfCounter;
  138992. /**
  138993. * Gets the animations time capture status
  138994. */
  138995. get captureAnimationsTime(): boolean;
  138996. /**
  138997. * Enable or disable the animations time capture
  138998. */
  138999. set captureAnimationsTime(value: boolean);
  139000. /**
  139001. * Gets the perf counter used for frame time capture
  139002. */
  139003. get frameTimeCounter(): PerfCounter;
  139004. /**
  139005. * Gets the frame time capture status
  139006. */
  139007. get captureFrameTime(): boolean;
  139008. /**
  139009. * Enable or disable the frame time capture
  139010. */
  139011. set captureFrameTime(value: boolean);
  139012. /**
  139013. * Gets the perf counter used for inter-frames time capture
  139014. */
  139015. get interFrameTimeCounter(): PerfCounter;
  139016. /**
  139017. * Gets the inter-frames time capture status
  139018. */
  139019. get captureInterFrameTime(): boolean;
  139020. /**
  139021. * Enable or disable the inter-frames time capture
  139022. */
  139023. set captureInterFrameTime(value: boolean);
  139024. /**
  139025. * Gets the perf counter used for render time capture
  139026. */
  139027. get renderTimeCounter(): PerfCounter;
  139028. /**
  139029. * Gets the render time capture status
  139030. */
  139031. get captureRenderTime(): boolean;
  139032. /**
  139033. * Enable or disable the render time capture
  139034. */
  139035. set captureRenderTime(value: boolean);
  139036. /**
  139037. * Gets the perf counter used for camera render time capture
  139038. */
  139039. get cameraRenderTimeCounter(): PerfCounter;
  139040. /**
  139041. * Gets the camera render time capture status
  139042. */
  139043. get captureCameraRenderTime(): boolean;
  139044. /**
  139045. * Enable or disable the camera render time capture
  139046. */
  139047. set captureCameraRenderTime(value: boolean);
  139048. /**
  139049. * Gets the perf counter used for draw calls
  139050. */
  139051. get drawCallsCounter(): PerfCounter;
  139052. /**
  139053. * Instantiates a new scene instrumentation.
  139054. * This class can be used to get instrumentation data from a Babylon engine
  139055. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139056. * @param scene Defines the scene to instrument
  139057. */
  139058. constructor(
  139059. /**
  139060. * Defines the scene to instrument
  139061. */
  139062. scene: Scene);
  139063. /**
  139064. * Dispose and release associated resources.
  139065. */
  139066. dispose(): void;
  139067. }
  139068. }
  139069. declare module BABYLON {
  139070. /** @hidden */
  139071. export var glowMapGenerationPixelShader: {
  139072. name: string;
  139073. shader: string;
  139074. };
  139075. }
  139076. declare module BABYLON {
  139077. /** @hidden */
  139078. export var glowMapGenerationVertexShader: {
  139079. name: string;
  139080. shader: string;
  139081. };
  139082. }
  139083. declare module BABYLON {
  139084. /**
  139085. * Effect layer options. This helps customizing the behaviour
  139086. * of the effect layer.
  139087. */
  139088. export interface IEffectLayerOptions {
  139089. /**
  139090. * Multiplication factor apply to the canvas size to compute the render target size
  139091. * used to generated the objects (the smaller the faster).
  139092. */
  139093. mainTextureRatio: number;
  139094. /**
  139095. * Enforces a fixed size texture to ensure effect stability across devices.
  139096. */
  139097. mainTextureFixedSize?: number;
  139098. /**
  139099. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  139100. */
  139101. alphaBlendingMode: number;
  139102. /**
  139103. * The camera attached to the layer.
  139104. */
  139105. camera: Nullable<Camera>;
  139106. /**
  139107. * The rendering group to draw the layer in.
  139108. */
  139109. renderingGroupId: number;
  139110. }
  139111. /**
  139112. * The effect layer Helps adding post process effect blended with the main pass.
  139113. *
  139114. * This can be for instance use to generate glow or higlight effects on the scene.
  139115. *
  139116. * The effect layer class can not be used directly and is intented to inherited from to be
  139117. * customized per effects.
  139118. */
  139119. export abstract class EffectLayer {
  139120. private _vertexBuffers;
  139121. private _indexBuffer;
  139122. private _cachedDefines;
  139123. private _effectLayerMapGenerationEffect;
  139124. private _effectLayerOptions;
  139125. private _mergeEffect;
  139126. protected _scene: Scene;
  139127. protected _engine: Engine;
  139128. protected _maxSize: number;
  139129. protected _mainTextureDesiredSize: ISize;
  139130. protected _mainTexture: RenderTargetTexture;
  139131. protected _shouldRender: boolean;
  139132. protected _postProcesses: PostProcess[];
  139133. protected _textures: BaseTexture[];
  139134. protected _emissiveTextureAndColor: {
  139135. texture: Nullable<BaseTexture>;
  139136. color: Color4;
  139137. };
  139138. /**
  139139. * The name of the layer
  139140. */
  139141. name: string;
  139142. /**
  139143. * The clear color of the texture used to generate the glow map.
  139144. */
  139145. neutralColor: Color4;
  139146. /**
  139147. * Specifies whether the highlight layer is enabled or not.
  139148. */
  139149. isEnabled: boolean;
  139150. /**
  139151. * Gets the camera attached to the layer.
  139152. */
  139153. get camera(): Nullable<Camera>;
  139154. /**
  139155. * Gets the rendering group id the layer should render in.
  139156. */
  139157. get renderingGroupId(): number;
  139158. set renderingGroupId(renderingGroupId: number);
  139159. /**
  139160. * An event triggered when the effect layer has been disposed.
  139161. */
  139162. onDisposeObservable: Observable<EffectLayer>;
  139163. /**
  139164. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  139165. */
  139166. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  139167. /**
  139168. * An event triggered when the generated texture is being merged in the scene.
  139169. */
  139170. onBeforeComposeObservable: Observable<EffectLayer>;
  139171. /**
  139172. * An event triggered when the mesh is rendered into the effect render target.
  139173. */
  139174. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  139175. /**
  139176. * An event triggered after the mesh has been rendered into the effect render target.
  139177. */
  139178. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  139179. /**
  139180. * An event triggered when the generated texture has been merged in the scene.
  139181. */
  139182. onAfterComposeObservable: Observable<EffectLayer>;
  139183. /**
  139184. * An event triggered when the efffect layer changes its size.
  139185. */
  139186. onSizeChangedObservable: Observable<EffectLayer>;
  139187. /** @hidden */
  139188. static _SceneComponentInitialization: (scene: Scene) => void;
  139189. /**
  139190. * Instantiates a new effect Layer and references it in the scene.
  139191. * @param name The name of the layer
  139192. * @param scene The scene to use the layer in
  139193. */
  139194. constructor(
  139195. /** The Friendly of the effect in the scene */
  139196. name: string, scene: Scene);
  139197. /**
  139198. * Get the effect name of the layer.
  139199. * @return The effect name
  139200. */
  139201. abstract getEffectName(): string;
  139202. /**
  139203. * Checks for the readiness of the element composing the layer.
  139204. * @param subMesh the mesh to check for
  139205. * @param useInstances specify whether or not to use instances to render the mesh
  139206. * @return true if ready otherwise, false
  139207. */
  139208. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139209. /**
  139210. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139211. * @returns true if the effect requires stencil during the main canvas render pass.
  139212. */
  139213. abstract needStencil(): boolean;
  139214. /**
  139215. * Create the merge effect. This is the shader use to blit the information back
  139216. * to the main canvas at the end of the scene rendering.
  139217. * @returns The effect containing the shader used to merge the effect on the main canvas
  139218. */
  139219. protected abstract _createMergeEffect(): Effect;
  139220. /**
  139221. * Creates the render target textures and post processes used in the effect layer.
  139222. */
  139223. protected abstract _createTextureAndPostProcesses(): void;
  139224. /**
  139225. * Implementation specific of rendering the generating effect on the main canvas.
  139226. * @param effect The effect used to render through
  139227. */
  139228. protected abstract _internalRender(effect: Effect): void;
  139229. /**
  139230. * Sets the required values for both the emissive texture and and the main color.
  139231. */
  139232. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139233. /**
  139234. * Free any resources and references associated to a mesh.
  139235. * Internal use
  139236. * @param mesh The mesh to free.
  139237. */
  139238. abstract _disposeMesh(mesh: Mesh): void;
  139239. /**
  139240. * Serializes this layer (Glow or Highlight for example)
  139241. * @returns a serialized layer object
  139242. */
  139243. abstract serialize?(): any;
  139244. /**
  139245. * Initializes the effect layer with the required options.
  139246. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  139247. */
  139248. protected _init(options: Partial<IEffectLayerOptions>): void;
  139249. /**
  139250. * Generates the index buffer of the full screen quad blending to the main canvas.
  139251. */
  139252. private _generateIndexBuffer;
  139253. /**
  139254. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  139255. */
  139256. private _generateVertexBuffer;
  139257. /**
  139258. * Sets the main texture desired size which is the closest power of two
  139259. * of the engine canvas size.
  139260. */
  139261. private _setMainTextureSize;
  139262. /**
  139263. * Creates the main texture for the effect layer.
  139264. */
  139265. protected _createMainTexture(): void;
  139266. /**
  139267. * Adds specific effects defines.
  139268. * @param defines The defines to add specifics to.
  139269. */
  139270. protected _addCustomEffectDefines(defines: string[]): void;
  139271. /**
  139272. * Checks for the readiness of the element composing the layer.
  139273. * @param subMesh the mesh to check for
  139274. * @param useInstances specify whether or not to use instances to render the mesh
  139275. * @param emissiveTexture the associated emissive texture used to generate the glow
  139276. * @return true if ready otherwise, false
  139277. */
  139278. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  139279. /**
  139280. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  139281. */
  139282. render(): void;
  139283. /**
  139284. * Determine if a given mesh will be used in the current effect.
  139285. * @param mesh mesh to test
  139286. * @returns true if the mesh will be used
  139287. */
  139288. hasMesh(mesh: AbstractMesh): boolean;
  139289. /**
  139290. * Returns true if the layer contains information to display, otherwise false.
  139291. * @returns true if the glow layer should be rendered
  139292. */
  139293. shouldRender(): boolean;
  139294. /**
  139295. * Returns true if the mesh should render, otherwise false.
  139296. * @param mesh The mesh to render
  139297. * @returns true if it should render otherwise false
  139298. */
  139299. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  139300. /**
  139301. * Returns true if the mesh can be rendered, otherwise false.
  139302. * @param mesh The mesh to render
  139303. * @param material The material used on the mesh
  139304. * @returns true if it can be rendered otherwise false
  139305. */
  139306. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139307. /**
  139308. * Returns true if the mesh should render, otherwise false.
  139309. * @param mesh The mesh to render
  139310. * @returns true if it should render otherwise false
  139311. */
  139312. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  139313. /**
  139314. * Renders the submesh passed in parameter to the generation map.
  139315. */
  139316. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  139317. /**
  139318. * Defines whether the current material of the mesh should be use to render the effect.
  139319. * @param mesh defines the current mesh to render
  139320. */
  139321. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139322. /**
  139323. * Rebuild the required buffers.
  139324. * @hidden Internal use only.
  139325. */
  139326. _rebuild(): void;
  139327. /**
  139328. * Dispose only the render target textures and post process.
  139329. */
  139330. private _disposeTextureAndPostProcesses;
  139331. /**
  139332. * Dispose the highlight layer and free resources.
  139333. */
  139334. dispose(): void;
  139335. /**
  139336. * Gets the class name of the effect layer
  139337. * @returns the string with the class name of the effect layer
  139338. */
  139339. getClassName(): string;
  139340. /**
  139341. * Creates an effect layer from parsed effect layer data
  139342. * @param parsedEffectLayer defines effect layer data
  139343. * @param scene defines the current scene
  139344. * @param rootUrl defines the root URL containing the effect layer information
  139345. * @returns a parsed effect Layer
  139346. */
  139347. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  139348. }
  139349. }
  139350. declare module BABYLON {
  139351. interface AbstractScene {
  139352. /**
  139353. * The list of effect layers (highlights/glow) added to the scene
  139354. * @see https://doc.babylonjs.com/how_to/highlight_layer
  139355. * @see https://doc.babylonjs.com/how_to/glow_layer
  139356. */
  139357. effectLayers: Array<EffectLayer>;
  139358. /**
  139359. * Removes the given effect layer from this scene.
  139360. * @param toRemove defines the effect layer to remove
  139361. * @returns the index of the removed effect layer
  139362. */
  139363. removeEffectLayer(toRemove: EffectLayer): number;
  139364. /**
  139365. * Adds the given effect layer to this scene
  139366. * @param newEffectLayer defines the effect layer to add
  139367. */
  139368. addEffectLayer(newEffectLayer: EffectLayer): void;
  139369. }
  139370. /**
  139371. * Defines the layer scene component responsible to manage any effect layers
  139372. * in a given scene.
  139373. */
  139374. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  139375. /**
  139376. * The component name helpfull to identify the component in the list of scene components.
  139377. */
  139378. readonly name: string;
  139379. /**
  139380. * The scene the component belongs to.
  139381. */
  139382. scene: Scene;
  139383. private _engine;
  139384. private _renderEffects;
  139385. private _needStencil;
  139386. private _previousStencilState;
  139387. /**
  139388. * Creates a new instance of the component for the given scene
  139389. * @param scene Defines the scene to register the component in
  139390. */
  139391. constructor(scene: Scene);
  139392. /**
  139393. * Registers the component in a given scene
  139394. */
  139395. register(): void;
  139396. /**
  139397. * Rebuilds the elements related to this component in case of
  139398. * context lost for instance.
  139399. */
  139400. rebuild(): void;
  139401. /**
  139402. * Serializes the component data to the specified json object
  139403. * @param serializationObject The object to serialize to
  139404. */
  139405. serialize(serializationObject: any): void;
  139406. /**
  139407. * Adds all the elements from the container to the scene
  139408. * @param container the container holding the elements
  139409. */
  139410. addFromContainer(container: AbstractScene): void;
  139411. /**
  139412. * Removes all the elements in the container from the scene
  139413. * @param container contains the elements to remove
  139414. * @param dispose if the removed element should be disposed (default: false)
  139415. */
  139416. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139417. /**
  139418. * Disposes the component and the associated ressources.
  139419. */
  139420. dispose(): void;
  139421. private _isReadyForMesh;
  139422. private _renderMainTexture;
  139423. private _setStencil;
  139424. private _setStencilBack;
  139425. private _draw;
  139426. private _drawCamera;
  139427. private _drawRenderingGroup;
  139428. }
  139429. }
  139430. declare module BABYLON {
  139431. /** @hidden */
  139432. export var glowMapMergePixelShader: {
  139433. name: string;
  139434. shader: string;
  139435. };
  139436. }
  139437. declare module BABYLON {
  139438. /** @hidden */
  139439. export var glowMapMergeVertexShader: {
  139440. name: string;
  139441. shader: string;
  139442. };
  139443. }
  139444. declare module BABYLON {
  139445. interface AbstractScene {
  139446. /**
  139447. * Return a the first highlight layer of the scene with a given name.
  139448. * @param name The name of the highlight layer to look for.
  139449. * @return The highlight layer if found otherwise null.
  139450. */
  139451. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  139452. }
  139453. /**
  139454. * Glow layer options. This helps customizing the behaviour
  139455. * of the glow layer.
  139456. */
  139457. export interface IGlowLayerOptions {
  139458. /**
  139459. * Multiplication factor apply to the canvas size to compute the render target size
  139460. * used to generated the glowing objects (the smaller the faster).
  139461. */
  139462. mainTextureRatio: number;
  139463. /**
  139464. * Enforces a fixed size texture to ensure resize independant blur.
  139465. */
  139466. mainTextureFixedSize?: number;
  139467. /**
  139468. * How big is the kernel of the blur texture.
  139469. */
  139470. blurKernelSize: number;
  139471. /**
  139472. * The camera attached to the layer.
  139473. */
  139474. camera: Nullable<Camera>;
  139475. /**
  139476. * Enable MSAA by chosing the number of samples.
  139477. */
  139478. mainTextureSamples?: number;
  139479. /**
  139480. * The rendering group to draw the layer in.
  139481. */
  139482. renderingGroupId: number;
  139483. }
  139484. /**
  139485. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  139486. *
  139487. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  139488. *
  139489. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  139490. */
  139491. export class GlowLayer extends EffectLayer {
  139492. /**
  139493. * Effect Name of the layer.
  139494. */
  139495. static readonly EffectName: string;
  139496. /**
  139497. * The default blur kernel size used for the glow.
  139498. */
  139499. static DefaultBlurKernelSize: number;
  139500. /**
  139501. * The default texture size ratio used for the glow.
  139502. */
  139503. static DefaultTextureRatio: number;
  139504. /**
  139505. * Sets the kernel size of the blur.
  139506. */
  139507. set blurKernelSize(value: number);
  139508. /**
  139509. * Gets the kernel size of the blur.
  139510. */
  139511. get blurKernelSize(): number;
  139512. /**
  139513. * Sets the glow intensity.
  139514. */
  139515. set intensity(value: number);
  139516. /**
  139517. * Gets the glow intensity.
  139518. */
  139519. get intensity(): number;
  139520. private _options;
  139521. private _intensity;
  139522. private _horizontalBlurPostprocess1;
  139523. private _verticalBlurPostprocess1;
  139524. private _horizontalBlurPostprocess2;
  139525. private _verticalBlurPostprocess2;
  139526. private _blurTexture1;
  139527. private _blurTexture2;
  139528. private _postProcesses1;
  139529. private _postProcesses2;
  139530. private _includedOnlyMeshes;
  139531. private _excludedMeshes;
  139532. private _meshesUsingTheirOwnMaterials;
  139533. /**
  139534. * Callback used to let the user override the color selection on a per mesh basis
  139535. */
  139536. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  139537. /**
  139538. * Callback used to let the user override the texture selection on a per mesh basis
  139539. */
  139540. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  139541. /**
  139542. * Instantiates a new glow Layer and references it to the scene.
  139543. * @param name The name of the layer
  139544. * @param scene The scene to use the layer in
  139545. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  139546. */
  139547. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  139548. /**
  139549. * Get the effect name of the layer.
  139550. * @return The effect name
  139551. */
  139552. getEffectName(): string;
  139553. /**
  139554. * Create the merge effect. This is the shader use to blit the information back
  139555. * to the main canvas at the end of the scene rendering.
  139556. */
  139557. protected _createMergeEffect(): Effect;
  139558. /**
  139559. * Creates the render target textures and post processes used in the glow layer.
  139560. */
  139561. protected _createTextureAndPostProcesses(): void;
  139562. /**
  139563. * Checks for the readiness of the element composing the layer.
  139564. * @param subMesh the mesh to check for
  139565. * @param useInstances specify wether or not to use instances to render the mesh
  139566. * @param emissiveTexture the associated emissive texture used to generate the glow
  139567. * @return true if ready otherwise, false
  139568. */
  139569. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139570. /**
  139571. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139572. */
  139573. needStencil(): boolean;
  139574. /**
  139575. * Returns true if the mesh can be rendered, otherwise false.
  139576. * @param mesh The mesh to render
  139577. * @param material The material used on the mesh
  139578. * @returns true if it can be rendered otherwise false
  139579. */
  139580. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139581. /**
  139582. * Implementation specific of rendering the generating effect on the main canvas.
  139583. * @param effect The effect used to render through
  139584. */
  139585. protected _internalRender(effect: Effect): void;
  139586. /**
  139587. * Sets the required values for both the emissive texture and and the main color.
  139588. */
  139589. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139590. /**
  139591. * Returns true if the mesh should render, otherwise false.
  139592. * @param mesh The mesh to render
  139593. * @returns true if it should render otherwise false
  139594. */
  139595. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139596. /**
  139597. * Adds specific effects defines.
  139598. * @param defines The defines to add specifics to.
  139599. */
  139600. protected _addCustomEffectDefines(defines: string[]): void;
  139601. /**
  139602. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  139603. * @param mesh The mesh to exclude from the glow layer
  139604. */
  139605. addExcludedMesh(mesh: Mesh): void;
  139606. /**
  139607. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  139608. * @param mesh The mesh to remove
  139609. */
  139610. removeExcludedMesh(mesh: Mesh): void;
  139611. /**
  139612. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  139613. * @param mesh The mesh to include in the glow layer
  139614. */
  139615. addIncludedOnlyMesh(mesh: Mesh): void;
  139616. /**
  139617. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  139618. * @param mesh The mesh to remove
  139619. */
  139620. removeIncludedOnlyMesh(mesh: Mesh): void;
  139621. /**
  139622. * Determine if a given mesh will be used in the glow layer
  139623. * @param mesh The mesh to test
  139624. * @returns true if the mesh will be highlighted by the current glow layer
  139625. */
  139626. hasMesh(mesh: AbstractMesh): boolean;
  139627. /**
  139628. * Defines whether the current material of the mesh should be use to render the effect.
  139629. * @param mesh defines the current mesh to render
  139630. */
  139631. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139632. /**
  139633. * Add a mesh to be rendered through its own material and not with emissive only.
  139634. * @param mesh The mesh for which we need to use its material
  139635. */
  139636. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  139637. /**
  139638. * Remove a mesh from being rendered through its own material and not with emissive only.
  139639. * @param mesh The mesh for which we need to not use its material
  139640. */
  139641. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  139642. /**
  139643. * Free any resources and references associated to a mesh.
  139644. * Internal use
  139645. * @param mesh The mesh to free.
  139646. * @hidden
  139647. */
  139648. _disposeMesh(mesh: Mesh): void;
  139649. /**
  139650. * Gets the class name of the effect layer
  139651. * @returns the string with the class name of the effect layer
  139652. */
  139653. getClassName(): string;
  139654. /**
  139655. * Serializes this glow layer
  139656. * @returns a serialized glow layer object
  139657. */
  139658. serialize(): any;
  139659. /**
  139660. * Creates a Glow Layer from parsed glow layer data
  139661. * @param parsedGlowLayer defines glow layer data
  139662. * @param scene defines the current scene
  139663. * @param rootUrl defines the root URL containing the glow layer information
  139664. * @returns a parsed Glow Layer
  139665. */
  139666. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  139667. }
  139668. }
  139669. declare module BABYLON {
  139670. /** @hidden */
  139671. export var glowBlurPostProcessPixelShader: {
  139672. name: string;
  139673. shader: string;
  139674. };
  139675. }
  139676. declare module BABYLON {
  139677. interface AbstractScene {
  139678. /**
  139679. * Return a the first highlight layer of the scene with a given name.
  139680. * @param name The name of the highlight layer to look for.
  139681. * @return The highlight layer if found otherwise null.
  139682. */
  139683. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  139684. }
  139685. /**
  139686. * Highlight layer options. This helps customizing the behaviour
  139687. * of the highlight layer.
  139688. */
  139689. export interface IHighlightLayerOptions {
  139690. /**
  139691. * Multiplication factor apply to the canvas size to compute the render target size
  139692. * used to generated the glowing objects (the smaller the faster).
  139693. */
  139694. mainTextureRatio: number;
  139695. /**
  139696. * Enforces a fixed size texture to ensure resize independant blur.
  139697. */
  139698. mainTextureFixedSize?: number;
  139699. /**
  139700. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  139701. * of the picture to blur (the smaller the faster).
  139702. */
  139703. blurTextureSizeRatio: number;
  139704. /**
  139705. * How big in texel of the blur texture is the vertical blur.
  139706. */
  139707. blurVerticalSize: number;
  139708. /**
  139709. * How big in texel of the blur texture is the horizontal blur.
  139710. */
  139711. blurHorizontalSize: number;
  139712. /**
  139713. * Alpha blending mode used to apply the blur. Default is combine.
  139714. */
  139715. alphaBlendingMode: number;
  139716. /**
  139717. * The camera attached to the layer.
  139718. */
  139719. camera: Nullable<Camera>;
  139720. /**
  139721. * Should we display highlight as a solid stroke?
  139722. */
  139723. isStroke?: boolean;
  139724. /**
  139725. * The rendering group to draw the layer in.
  139726. */
  139727. renderingGroupId: number;
  139728. }
  139729. /**
  139730. * The highlight layer Helps adding a glow effect around a mesh.
  139731. *
  139732. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  139733. * glowy meshes to your scene.
  139734. *
  139735. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  139736. */
  139737. export class HighlightLayer extends EffectLayer {
  139738. name: string;
  139739. /**
  139740. * Effect Name of the highlight layer.
  139741. */
  139742. static readonly EffectName: string;
  139743. /**
  139744. * The neutral color used during the preparation of the glow effect.
  139745. * This is black by default as the blend operation is a blend operation.
  139746. */
  139747. static NeutralColor: Color4;
  139748. /**
  139749. * Stencil value used for glowing meshes.
  139750. */
  139751. static GlowingMeshStencilReference: number;
  139752. /**
  139753. * Stencil value used for the other meshes in the scene.
  139754. */
  139755. static NormalMeshStencilReference: number;
  139756. /**
  139757. * Specifies whether or not the inner glow is ACTIVE in the layer.
  139758. */
  139759. innerGlow: boolean;
  139760. /**
  139761. * Specifies whether or not the outer glow is ACTIVE in the layer.
  139762. */
  139763. outerGlow: boolean;
  139764. /**
  139765. * Specifies the horizontal size of the blur.
  139766. */
  139767. set blurHorizontalSize(value: number);
  139768. /**
  139769. * Specifies the vertical size of the blur.
  139770. */
  139771. set blurVerticalSize(value: number);
  139772. /**
  139773. * Gets the horizontal size of the blur.
  139774. */
  139775. get blurHorizontalSize(): number;
  139776. /**
  139777. * Gets the vertical size of the blur.
  139778. */
  139779. get blurVerticalSize(): number;
  139780. /**
  139781. * An event triggered when the highlight layer is being blurred.
  139782. */
  139783. onBeforeBlurObservable: Observable<HighlightLayer>;
  139784. /**
  139785. * An event triggered when the highlight layer has been blurred.
  139786. */
  139787. onAfterBlurObservable: Observable<HighlightLayer>;
  139788. private _instanceGlowingMeshStencilReference;
  139789. private _options;
  139790. private _downSamplePostprocess;
  139791. private _horizontalBlurPostprocess;
  139792. private _verticalBlurPostprocess;
  139793. private _blurTexture;
  139794. private _meshes;
  139795. private _excludedMeshes;
  139796. /**
  139797. * Instantiates a new highlight Layer and references it to the scene..
  139798. * @param name The name of the layer
  139799. * @param scene The scene to use the layer in
  139800. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  139801. */
  139802. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  139803. /**
  139804. * Get the effect name of the layer.
  139805. * @return The effect name
  139806. */
  139807. getEffectName(): string;
  139808. /**
  139809. * Create the merge effect. This is the shader use to blit the information back
  139810. * to the main canvas at the end of the scene rendering.
  139811. */
  139812. protected _createMergeEffect(): Effect;
  139813. /**
  139814. * Creates the render target textures and post processes used in the highlight layer.
  139815. */
  139816. protected _createTextureAndPostProcesses(): void;
  139817. /**
  139818. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  139819. */
  139820. needStencil(): boolean;
  139821. /**
  139822. * Checks for the readiness of the element composing the layer.
  139823. * @param subMesh the mesh to check for
  139824. * @param useInstances specify wether or not to use instances to render the mesh
  139825. * @param emissiveTexture the associated emissive texture used to generate the glow
  139826. * @return true if ready otherwise, false
  139827. */
  139828. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139829. /**
  139830. * Implementation specific of rendering the generating effect on the main canvas.
  139831. * @param effect The effect used to render through
  139832. */
  139833. protected _internalRender(effect: Effect): void;
  139834. /**
  139835. * Returns true if the layer contains information to display, otherwise false.
  139836. */
  139837. shouldRender(): boolean;
  139838. /**
  139839. * Returns true if the mesh should render, otherwise false.
  139840. * @param mesh The mesh to render
  139841. * @returns true if it should render otherwise false
  139842. */
  139843. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139844. /**
  139845. * Returns true if the mesh can be rendered, otherwise false.
  139846. * @param mesh The mesh to render
  139847. * @param material The material used on the mesh
  139848. * @returns true if it can be rendered otherwise false
  139849. */
  139850. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139851. /**
  139852. * Adds specific effects defines.
  139853. * @param defines The defines to add specifics to.
  139854. */
  139855. protected _addCustomEffectDefines(defines: string[]): void;
  139856. /**
  139857. * Sets the required values for both the emissive texture and and the main color.
  139858. */
  139859. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139860. /**
  139861. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  139862. * @param mesh The mesh to exclude from the highlight layer
  139863. */
  139864. addExcludedMesh(mesh: Mesh): void;
  139865. /**
  139866. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  139867. * @param mesh The mesh to highlight
  139868. */
  139869. removeExcludedMesh(mesh: Mesh): void;
  139870. /**
  139871. * Determine if a given mesh will be highlighted by the current HighlightLayer
  139872. * @param mesh mesh to test
  139873. * @returns true if the mesh will be highlighted by the current HighlightLayer
  139874. */
  139875. hasMesh(mesh: AbstractMesh): boolean;
  139876. /**
  139877. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  139878. * @param mesh The mesh to highlight
  139879. * @param color The color of the highlight
  139880. * @param glowEmissiveOnly Extract the glow from the emissive texture
  139881. */
  139882. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  139883. /**
  139884. * Remove a mesh from the highlight layer in order to make it stop glowing.
  139885. * @param mesh The mesh to highlight
  139886. */
  139887. removeMesh(mesh: Mesh): void;
  139888. /**
  139889. * Remove all the meshes currently referenced in the highlight layer
  139890. */
  139891. removeAllMeshes(): void;
  139892. /**
  139893. * Force the stencil to the normal expected value for none glowing parts
  139894. */
  139895. private _defaultStencilReference;
  139896. /**
  139897. * Free any resources and references associated to a mesh.
  139898. * Internal use
  139899. * @param mesh The mesh to free.
  139900. * @hidden
  139901. */
  139902. _disposeMesh(mesh: Mesh): void;
  139903. /**
  139904. * Dispose the highlight layer and free resources.
  139905. */
  139906. dispose(): void;
  139907. /**
  139908. * Gets the class name of the effect layer
  139909. * @returns the string with the class name of the effect layer
  139910. */
  139911. getClassName(): string;
  139912. /**
  139913. * Serializes this Highlight layer
  139914. * @returns a serialized Highlight layer object
  139915. */
  139916. serialize(): any;
  139917. /**
  139918. * Creates a Highlight layer from parsed Highlight layer data
  139919. * @param parsedHightlightLayer defines the Highlight layer data
  139920. * @param scene defines the current scene
  139921. * @param rootUrl defines the root URL containing the Highlight layer information
  139922. * @returns a parsed Highlight layer
  139923. */
  139924. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  139925. }
  139926. }
  139927. declare module BABYLON {
  139928. interface AbstractScene {
  139929. /**
  139930. * The list of layers (background and foreground) of the scene
  139931. */
  139932. layers: Array<Layer>;
  139933. }
  139934. /**
  139935. * Defines the layer scene component responsible to manage any layers
  139936. * in a given scene.
  139937. */
  139938. export class LayerSceneComponent implements ISceneComponent {
  139939. /**
  139940. * The component name helpfull to identify the component in the list of scene components.
  139941. */
  139942. readonly name: string;
  139943. /**
  139944. * The scene the component belongs to.
  139945. */
  139946. scene: Scene;
  139947. private _engine;
  139948. /**
  139949. * Creates a new instance of the component for the given scene
  139950. * @param scene Defines the scene to register the component in
  139951. */
  139952. constructor(scene: Scene);
  139953. /**
  139954. * Registers the component in a given scene
  139955. */
  139956. register(): void;
  139957. /**
  139958. * Rebuilds the elements related to this component in case of
  139959. * context lost for instance.
  139960. */
  139961. rebuild(): void;
  139962. /**
  139963. * Disposes the component and the associated ressources.
  139964. */
  139965. dispose(): void;
  139966. private _draw;
  139967. private _drawCameraPredicate;
  139968. private _drawCameraBackground;
  139969. private _drawCameraForeground;
  139970. private _drawRenderTargetPredicate;
  139971. private _drawRenderTargetBackground;
  139972. private _drawRenderTargetForeground;
  139973. /**
  139974. * Adds all the elements from the container to the scene
  139975. * @param container the container holding the elements
  139976. */
  139977. addFromContainer(container: AbstractScene): void;
  139978. /**
  139979. * Removes all the elements in the container from the scene
  139980. * @param container contains the elements to remove
  139981. * @param dispose if the removed element should be disposed (default: false)
  139982. */
  139983. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139984. }
  139985. }
  139986. declare module BABYLON {
  139987. /** @hidden */
  139988. export var layerPixelShader: {
  139989. name: string;
  139990. shader: string;
  139991. };
  139992. }
  139993. declare module BABYLON {
  139994. /** @hidden */
  139995. export var layerVertexShader: {
  139996. name: string;
  139997. shader: string;
  139998. };
  139999. }
  140000. declare module BABYLON {
  140001. /**
  140002. * This represents a full screen 2d layer.
  140003. * This can be useful to display a picture in the background of your scene for instance.
  140004. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140005. */
  140006. export class Layer {
  140007. /**
  140008. * Define the name of the layer.
  140009. */
  140010. name: string;
  140011. /**
  140012. * Define the texture the layer should display.
  140013. */
  140014. texture: Nullable<Texture>;
  140015. /**
  140016. * Is the layer in background or foreground.
  140017. */
  140018. isBackground: boolean;
  140019. /**
  140020. * Define the color of the layer (instead of texture).
  140021. */
  140022. color: Color4;
  140023. /**
  140024. * Define the scale of the layer in order to zoom in out of the texture.
  140025. */
  140026. scale: Vector2;
  140027. /**
  140028. * Define an offset for the layer in order to shift the texture.
  140029. */
  140030. offset: Vector2;
  140031. /**
  140032. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  140033. */
  140034. alphaBlendingMode: number;
  140035. /**
  140036. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  140037. * Alpha test will not mix with the background color in case of transparency.
  140038. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  140039. */
  140040. alphaTest: boolean;
  140041. /**
  140042. * Define a mask to restrict the layer to only some of the scene cameras.
  140043. */
  140044. layerMask: number;
  140045. /**
  140046. * Define the list of render target the layer is visible into.
  140047. */
  140048. renderTargetTextures: RenderTargetTexture[];
  140049. /**
  140050. * Define if the layer is only used in renderTarget or if it also
  140051. * renders in the main frame buffer of the canvas.
  140052. */
  140053. renderOnlyInRenderTargetTextures: boolean;
  140054. private _scene;
  140055. private _vertexBuffers;
  140056. private _indexBuffer;
  140057. private _effect;
  140058. private _previousDefines;
  140059. /**
  140060. * An event triggered when the layer is disposed.
  140061. */
  140062. onDisposeObservable: Observable<Layer>;
  140063. private _onDisposeObserver;
  140064. /**
  140065. * Back compatibility with callback before the onDisposeObservable existed.
  140066. * The set callback will be triggered when the layer has been disposed.
  140067. */
  140068. set onDispose(callback: () => void);
  140069. /**
  140070. * An event triggered before rendering the scene
  140071. */
  140072. onBeforeRenderObservable: Observable<Layer>;
  140073. private _onBeforeRenderObserver;
  140074. /**
  140075. * Back compatibility with callback before the onBeforeRenderObservable existed.
  140076. * The set callback will be triggered just before rendering the layer.
  140077. */
  140078. set onBeforeRender(callback: () => void);
  140079. /**
  140080. * An event triggered after rendering the scene
  140081. */
  140082. onAfterRenderObservable: Observable<Layer>;
  140083. private _onAfterRenderObserver;
  140084. /**
  140085. * Back compatibility with callback before the onAfterRenderObservable existed.
  140086. * The set callback will be triggered just after rendering the layer.
  140087. */
  140088. set onAfterRender(callback: () => void);
  140089. /**
  140090. * Instantiates a new layer.
  140091. * This represents a full screen 2d layer.
  140092. * This can be useful to display a picture in the background of your scene for instance.
  140093. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140094. * @param name Define the name of the layer in the scene
  140095. * @param imgUrl Define the url of the texture to display in the layer
  140096. * @param scene Define the scene the layer belongs to
  140097. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  140098. * @param color Defines a color for the layer
  140099. */
  140100. constructor(
  140101. /**
  140102. * Define the name of the layer.
  140103. */
  140104. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  140105. private _createIndexBuffer;
  140106. /** @hidden */
  140107. _rebuild(): void;
  140108. /**
  140109. * Renders the layer in the scene.
  140110. */
  140111. render(): void;
  140112. /**
  140113. * Disposes and releases the associated ressources.
  140114. */
  140115. dispose(): void;
  140116. }
  140117. }
  140118. declare module BABYLON {
  140119. /** @hidden */
  140120. export var lensFlarePixelShader: {
  140121. name: string;
  140122. shader: string;
  140123. };
  140124. }
  140125. declare module BABYLON {
  140126. /** @hidden */
  140127. export var lensFlareVertexShader: {
  140128. name: string;
  140129. shader: string;
  140130. };
  140131. }
  140132. declare module BABYLON {
  140133. /**
  140134. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140135. * It is usually composed of several `lensFlare`.
  140136. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140137. */
  140138. export class LensFlareSystem {
  140139. /**
  140140. * Define the name of the lens flare system
  140141. */
  140142. name: string;
  140143. /**
  140144. * List of lens flares used in this system.
  140145. */
  140146. lensFlares: LensFlare[];
  140147. /**
  140148. * Define a limit from the border the lens flare can be visible.
  140149. */
  140150. borderLimit: number;
  140151. /**
  140152. * Define a viewport border we do not want to see the lens flare in.
  140153. */
  140154. viewportBorder: number;
  140155. /**
  140156. * Define a predicate which could limit the list of meshes able to occlude the effect.
  140157. */
  140158. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  140159. /**
  140160. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  140161. */
  140162. layerMask: number;
  140163. /**
  140164. * Define the id of the lens flare system in the scene.
  140165. * (equal to name by default)
  140166. */
  140167. id: string;
  140168. private _scene;
  140169. private _emitter;
  140170. private _vertexBuffers;
  140171. private _indexBuffer;
  140172. private _effect;
  140173. private _positionX;
  140174. private _positionY;
  140175. private _isEnabled;
  140176. /** @hidden */
  140177. static _SceneComponentInitialization: (scene: Scene) => void;
  140178. /**
  140179. * Instantiates a lens flare system.
  140180. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140181. * It is usually composed of several `lensFlare`.
  140182. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140183. * @param name Define the name of the lens flare system in the scene
  140184. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  140185. * @param scene Define the scene the lens flare system belongs to
  140186. */
  140187. constructor(
  140188. /**
  140189. * Define the name of the lens flare system
  140190. */
  140191. name: string, emitter: any, scene: Scene);
  140192. /**
  140193. * Define if the lens flare system is enabled.
  140194. */
  140195. get isEnabled(): boolean;
  140196. set isEnabled(value: boolean);
  140197. /**
  140198. * Get the scene the effects belongs to.
  140199. * @returns the scene holding the lens flare system
  140200. */
  140201. getScene(): Scene;
  140202. /**
  140203. * Get the emitter of the lens flare system.
  140204. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140205. * @returns the emitter of the lens flare system
  140206. */
  140207. getEmitter(): any;
  140208. /**
  140209. * Set the emitter of the lens flare system.
  140210. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140211. * @param newEmitter Define the new emitter of the system
  140212. */
  140213. setEmitter(newEmitter: any): void;
  140214. /**
  140215. * Get the lens flare system emitter position.
  140216. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  140217. * @returns the position
  140218. */
  140219. getEmitterPosition(): Vector3;
  140220. /**
  140221. * @hidden
  140222. */
  140223. computeEffectivePosition(globalViewport: Viewport): boolean;
  140224. /** @hidden */
  140225. _isVisible(): boolean;
  140226. /**
  140227. * @hidden
  140228. */
  140229. render(): boolean;
  140230. /**
  140231. * Dispose and release the lens flare with its associated resources.
  140232. */
  140233. dispose(): void;
  140234. /**
  140235. * Parse a lens flare system from a JSON repressentation
  140236. * @param parsedLensFlareSystem Define the JSON to parse
  140237. * @param scene Define the scene the parsed system should be instantiated in
  140238. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  140239. * @returns the parsed system
  140240. */
  140241. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  140242. /**
  140243. * Serialize the current Lens Flare System into a JSON representation.
  140244. * @returns the serialized JSON
  140245. */
  140246. serialize(): any;
  140247. }
  140248. }
  140249. declare module BABYLON {
  140250. /**
  140251. * This represents one of the lens effect in a `lensFlareSystem`.
  140252. * It controls one of the indiviual texture used in the effect.
  140253. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140254. */
  140255. export class LensFlare {
  140256. /**
  140257. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140258. */
  140259. size: number;
  140260. /**
  140261. * 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.
  140262. */
  140263. position: number;
  140264. /**
  140265. * Define the lens color.
  140266. */
  140267. color: Color3;
  140268. /**
  140269. * Define the lens texture.
  140270. */
  140271. texture: Nullable<Texture>;
  140272. /**
  140273. * Define the alpha mode to render this particular lens.
  140274. */
  140275. alphaMode: number;
  140276. private _system;
  140277. /**
  140278. * Creates a new Lens Flare.
  140279. * This represents one of the lens effect in a `lensFlareSystem`.
  140280. * It controls one of the indiviual texture used in the effect.
  140281. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140282. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  140283. * @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.
  140284. * @param color Define the lens color
  140285. * @param imgUrl Define the lens texture url
  140286. * @param system Define the `lensFlareSystem` this flare is part of
  140287. * @returns The newly created Lens Flare
  140288. */
  140289. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  140290. /**
  140291. * Instantiates a new Lens Flare.
  140292. * This represents one of the lens effect in a `lensFlareSystem`.
  140293. * It controls one of the indiviual texture used in the effect.
  140294. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140295. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  140296. * @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.
  140297. * @param color Define the lens color
  140298. * @param imgUrl Define the lens texture url
  140299. * @param system Define the `lensFlareSystem` this flare is part of
  140300. */
  140301. constructor(
  140302. /**
  140303. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140304. */
  140305. size: number,
  140306. /**
  140307. * 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.
  140308. */
  140309. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  140310. /**
  140311. * Dispose and release the lens flare with its associated resources.
  140312. */
  140313. dispose(): void;
  140314. }
  140315. }
  140316. declare module BABYLON {
  140317. interface AbstractScene {
  140318. /**
  140319. * The list of lens flare system added to the scene
  140320. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140321. */
  140322. lensFlareSystems: Array<LensFlareSystem>;
  140323. /**
  140324. * Removes the given lens flare system from this scene.
  140325. * @param toRemove The lens flare system to remove
  140326. * @returns The index of the removed lens flare system
  140327. */
  140328. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  140329. /**
  140330. * Adds the given lens flare system to this scene
  140331. * @param newLensFlareSystem The lens flare system to add
  140332. */
  140333. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  140334. /**
  140335. * Gets a lens flare system using its name
  140336. * @param name defines the name to look for
  140337. * @returns the lens flare system or null if not found
  140338. */
  140339. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  140340. /**
  140341. * Gets a lens flare system using its id
  140342. * @param id defines the id to look for
  140343. * @returns the lens flare system or null if not found
  140344. */
  140345. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  140346. }
  140347. /**
  140348. * Defines the lens flare scene component responsible to manage any lens flares
  140349. * in a given scene.
  140350. */
  140351. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  140352. /**
  140353. * The component name helpfull to identify the component in the list of scene components.
  140354. */
  140355. readonly name: string;
  140356. /**
  140357. * The scene the component belongs to.
  140358. */
  140359. scene: Scene;
  140360. /**
  140361. * Creates a new instance of the component for the given scene
  140362. * @param scene Defines the scene to register the component in
  140363. */
  140364. constructor(scene: Scene);
  140365. /**
  140366. * Registers the component in a given scene
  140367. */
  140368. register(): void;
  140369. /**
  140370. * Rebuilds the elements related to this component in case of
  140371. * context lost for instance.
  140372. */
  140373. rebuild(): void;
  140374. /**
  140375. * Adds all the elements from the container to the scene
  140376. * @param container the container holding the elements
  140377. */
  140378. addFromContainer(container: AbstractScene): void;
  140379. /**
  140380. * Removes all the elements in the container from the scene
  140381. * @param container contains the elements to remove
  140382. * @param dispose if the removed element should be disposed (default: false)
  140383. */
  140384. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140385. /**
  140386. * Serializes the component data to the specified json object
  140387. * @param serializationObject The object to serialize to
  140388. */
  140389. serialize(serializationObject: any): void;
  140390. /**
  140391. * Disposes the component and the associated ressources.
  140392. */
  140393. dispose(): void;
  140394. private _draw;
  140395. }
  140396. }
  140397. declare module BABYLON {
  140398. /** @hidden */
  140399. export var depthPixelShader: {
  140400. name: string;
  140401. shader: string;
  140402. };
  140403. }
  140404. declare module BABYLON {
  140405. /** @hidden */
  140406. export var depthVertexShader: {
  140407. name: string;
  140408. shader: string;
  140409. };
  140410. }
  140411. declare module BABYLON {
  140412. /**
  140413. * This represents a depth renderer in Babylon.
  140414. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  140415. */
  140416. export class DepthRenderer {
  140417. private _scene;
  140418. private _depthMap;
  140419. private _effect;
  140420. private readonly _storeNonLinearDepth;
  140421. private readonly _clearColor;
  140422. /** Get if the depth renderer is using packed depth or not */
  140423. readonly isPacked: boolean;
  140424. private _cachedDefines;
  140425. private _camera;
  140426. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  140427. enabled: boolean;
  140428. /**
  140429. * Specifiess that the depth renderer will only be used within
  140430. * the camera it is created for.
  140431. * This can help forcing its rendering during the camera processing.
  140432. */
  140433. useOnlyInActiveCamera: boolean;
  140434. /** @hidden */
  140435. static _SceneComponentInitialization: (scene: Scene) => void;
  140436. /**
  140437. * Instantiates a depth renderer
  140438. * @param scene The scene the renderer belongs to
  140439. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  140440. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  140441. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140442. */
  140443. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  140444. /**
  140445. * Creates the depth rendering effect and checks if the effect is ready.
  140446. * @param subMesh The submesh to be used to render the depth map of
  140447. * @param useInstances If multiple world instances should be used
  140448. * @returns if the depth renderer is ready to render the depth map
  140449. */
  140450. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140451. /**
  140452. * Gets the texture which the depth map will be written to.
  140453. * @returns The depth map texture
  140454. */
  140455. getDepthMap(): RenderTargetTexture;
  140456. /**
  140457. * Disposes of the depth renderer.
  140458. */
  140459. dispose(): void;
  140460. }
  140461. }
  140462. declare module BABYLON {
  140463. /** @hidden */
  140464. export var minmaxReduxPixelShader: {
  140465. name: string;
  140466. shader: string;
  140467. };
  140468. }
  140469. declare module BABYLON {
  140470. /**
  140471. * This class computes a min/max reduction from a texture: it means it computes the minimum
  140472. * and maximum values from all values of the texture.
  140473. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  140474. * The source values are read from the red channel of the texture.
  140475. */
  140476. export class MinMaxReducer {
  140477. /**
  140478. * Observable triggered when the computation has been performed
  140479. */
  140480. onAfterReductionPerformed: Observable<{
  140481. min: number;
  140482. max: number;
  140483. }>;
  140484. protected _camera: Camera;
  140485. protected _sourceTexture: Nullable<RenderTargetTexture>;
  140486. protected _reductionSteps: Nullable<Array<PostProcess>>;
  140487. protected _postProcessManager: PostProcessManager;
  140488. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  140489. protected _forceFullscreenViewport: boolean;
  140490. /**
  140491. * Creates a min/max reducer
  140492. * @param camera The camera to use for the post processes
  140493. */
  140494. constructor(camera: Camera);
  140495. /**
  140496. * Gets the texture used to read the values from.
  140497. */
  140498. get sourceTexture(): Nullable<RenderTargetTexture>;
  140499. /**
  140500. * Sets the source texture to read the values from.
  140501. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  140502. * because in such textures '1' value must not be taken into account to compute the maximum
  140503. * as this value is used to clear the texture.
  140504. * Note that the computation is not activated by calling this function, you must call activate() for that!
  140505. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  140506. * @param depthRedux Indicates if the texture is a depth texture or not
  140507. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  140508. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140509. */
  140510. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140511. /**
  140512. * Defines the refresh rate of the computation.
  140513. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140514. */
  140515. get refreshRate(): number;
  140516. set refreshRate(value: number);
  140517. protected _activated: boolean;
  140518. /**
  140519. * Gets the activation status of the reducer
  140520. */
  140521. get activated(): boolean;
  140522. /**
  140523. * Activates the reduction computation.
  140524. * When activated, the observers registered in onAfterReductionPerformed are
  140525. * called after the compuation is performed
  140526. */
  140527. activate(): void;
  140528. /**
  140529. * Deactivates the reduction computation.
  140530. */
  140531. deactivate(): void;
  140532. /**
  140533. * Disposes the min/max reducer
  140534. * @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.
  140535. */
  140536. dispose(disposeAll?: boolean): void;
  140537. }
  140538. }
  140539. declare module BABYLON {
  140540. /**
  140541. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  140542. */
  140543. export class DepthReducer extends MinMaxReducer {
  140544. private _depthRenderer;
  140545. private _depthRendererId;
  140546. /**
  140547. * Gets the depth renderer used for the computation.
  140548. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  140549. */
  140550. get depthRenderer(): Nullable<DepthRenderer>;
  140551. /**
  140552. * Creates a depth reducer
  140553. * @param camera The camera used to render the depth texture
  140554. */
  140555. constructor(camera: Camera);
  140556. /**
  140557. * Sets the depth renderer to use to generate the depth map
  140558. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  140559. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  140560. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140561. */
  140562. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  140563. /** @hidden */
  140564. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140565. /**
  140566. * Activates the reduction computation.
  140567. * When activated, the observers registered in onAfterReductionPerformed are
  140568. * called after the compuation is performed
  140569. */
  140570. activate(): void;
  140571. /**
  140572. * Deactivates the reduction computation.
  140573. */
  140574. deactivate(): void;
  140575. /**
  140576. * Disposes the depth reducer
  140577. * @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.
  140578. */
  140579. dispose(disposeAll?: boolean): void;
  140580. }
  140581. }
  140582. declare module BABYLON {
  140583. /**
  140584. * A CSM implementation allowing casting shadows on large scenes.
  140585. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140586. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  140587. */
  140588. export class CascadedShadowGenerator extends ShadowGenerator {
  140589. private static readonly frustumCornersNDCSpace;
  140590. /**
  140591. * Name of the CSM class
  140592. */
  140593. static CLASSNAME: string;
  140594. /**
  140595. * Defines the default number of cascades used by the CSM.
  140596. */
  140597. static readonly DEFAULT_CASCADES_COUNT: number;
  140598. /**
  140599. * Defines the minimum number of cascades used by the CSM.
  140600. */
  140601. static readonly MIN_CASCADES_COUNT: number;
  140602. /**
  140603. * Defines the maximum number of cascades used by the CSM.
  140604. */
  140605. static readonly MAX_CASCADES_COUNT: number;
  140606. protected _validateFilter(filter: number): number;
  140607. /**
  140608. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  140609. */
  140610. penumbraDarkness: number;
  140611. private _numCascades;
  140612. /**
  140613. * Gets or set the number of cascades used by the CSM.
  140614. */
  140615. get numCascades(): number;
  140616. set numCascades(value: number);
  140617. /**
  140618. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  140619. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  140620. */
  140621. stabilizeCascades: boolean;
  140622. private _freezeShadowCastersBoundingInfo;
  140623. private _freezeShadowCastersBoundingInfoObservable;
  140624. /**
  140625. * Enables or disables the shadow casters bounding info computation.
  140626. * If your shadow casters don't move, you can disable this feature.
  140627. * If it is enabled, the bounding box computation is done every frame.
  140628. */
  140629. get freezeShadowCastersBoundingInfo(): boolean;
  140630. set freezeShadowCastersBoundingInfo(freeze: boolean);
  140631. private _scbiMin;
  140632. private _scbiMax;
  140633. protected _computeShadowCastersBoundingInfo(): void;
  140634. protected _shadowCastersBoundingInfo: BoundingInfo;
  140635. /**
  140636. * Gets or sets the shadow casters bounding info.
  140637. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  140638. * so that the system won't overwrite the bounds you provide
  140639. */
  140640. get shadowCastersBoundingInfo(): BoundingInfo;
  140641. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  140642. protected _breaksAreDirty: boolean;
  140643. protected _minDistance: number;
  140644. protected _maxDistance: number;
  140645. /**
  140646. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  140647. *
  140648. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  140649. * If you don't know these values, simply leave them to their defaults and don't call this function.
  140650. * @param min minimal distance for the breaks (default to 0.)
  140651. * @param max maximal distance for the breaks (default to 1.)
  140652. */
  140653. setMinMaxDistance(min: number, max: number): void;
  140654. /** Gets the minimal distance used in the cascade break computation */
  140655. get minDistance(): number;
  140656. /** Gets the maximal distance used in the cascade break computation */
  140657. get maxDistance(): number;
  140658. /**
  140659. * Gets the class name of that object
  140660. * @returns "CascadedShadowGenerator"
  140661. */
  140662. getClassName(): string;
  140663. private _cascadeMinExtents;
  140664. private _cascadeMaxExtents;
  140665. /**
  140666. * Gets a cascade minimum extents
  140667. * @param cascadeIndex index of the cascade
  140668. * @returns the minimum cascade extents
  140669. */
  140670. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  140671. /**
  140672. * Gets a cascade maximum extents
  140673. * @param cascadeIndex index of the cascade
  140674. * @returns the maximum cascade extents
  140675. */
  140676. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  140677. private _cascades;
  140678. private _currentLayer;
  140679. private _viewSpaceFrustumsZ;
  140680. private _viewMatrices;
  140681. private _projectionMatrices;
  140682. private _transformMatrices;
  140683. private _transformMatricesAsArray;
  140684. private _frustumLengths;
  140685. private _lightSizeUVCorrection;
  140686. private _depthCorrection;
  140687. private _frustumCornersWorldSpace;
  140688. private _frustumCenter;
  140689. private _shadowCameraPos;
  140690. private _shadowMaxZ;
  140691. /**
  140692. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  140693. * It defaults to camera.maxZ
  140694. */
  140695. get shadowMaxZ(): number;
  140696. /**
  140697. * Sets the shadow max z distance.
  140698. */
  140699. set shadowMaxZ(value: number);
  140700. protected _debug: boolean;
  140701. /**
  140702. * Gets or sets the debug flag.
  140703. * When enabled, the cascades are materialized by different colors on the screen.
  140704. */
  140705. get debug(): boolean;
  140706. set debug(dbg: boolean);
  140707. private _depthClamp;
  140708. /**
  140709. * Gets or sets the depth clamping value.
  140710. *
  140711. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  140712. * to account for the shadow casters far away.
  140713. *
  140714. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  140715. */
  140716. get depthClamp(): boolean;
  140717. set depthClamp(value: boolean);
  140718. private _cascadeBlendPercentage;
  140719. /**
  140720. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  140721. * It defaults to 0.1 (10% blending).
  140722. */
  140723. get cascadeBlendPercentage(): number;
  140724. set cascadeBlendPercentage(value: number);
  140725. private _lambda;
  140726. /**
  140727. * Gets or set the lambda parameter.
  140728. * This parameter is used to split the camera frustum and create the cascades.
  140729. * 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.
  140730. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  140731. */
  140732. get lambda(): number;
  140733. set lambda(value: number);
  140734. /**
  140735. * Gets the view matrix corresponding to a given cascade
  140736. * @param cascadeNum cascade to retrieve the view matrix from
  140737. * @returns the cascade view matrix
  140738. */
  140739. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  140740. /**
  140741. * Gets the projection matrix corresponding to a given cascade
  140742. * @param cascadeNum cascade to retrieve the projection matrix from
  140743. * @returns the cascade projection matrix
  140744. */
  140745. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  140746. /**
  140747. * Gets the transformation matrix corresponding to a given cascade
  140748. * @param cascadeNum cascade to retrieve the transformation matrix from
  140749. * @returns the cascade transformation matrix
  140750. */
  140751. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  140752. private _depthRenderer;
  140753. /**
  140754. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  140755. *
  140756. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  140757. *
  140758. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  140759. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  140760. * @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
  140761. */
  140762. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  140763. private _depthReducer;
  140764. private _autoCalcDepthBounds;
  140765. /**
  140766. * Gets or sets the autoCalcDepthBounds property.
  140767. *
  140768. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  140769. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  140770. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  140771. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  140772. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  140773. */
  140774. get autoCalcDepthBounds(): boolean;
  140775. set autoCalcDepthBounds(value: boolean);
  140776. /**
  140777. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  140778. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140779. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  140780. * for setting the refresh rate on the renderer yourself!
  140781. */
  140782. get autoCalcDepthBoundsRefreshRate(): number;
  140783. set autoCalcDepthBoundsRefreshRate(value: number);
  140784. /**
  140785. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  140786. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  140787. * you change the camera near/far planes!
  140788. */
  140789. splitFrustum(): void;
  140790. private _splitFrustum;
  140791. private _computeMatrices;
  140792. private _computeFrustumInWorldSpace;
  140793. private _computeCascadeFrustum;
  140794. /**
  140795. * Support test.
  140796. */
  140797. static get IsSupported(): boolean;
  140798. /** @hidden */
  140799. static _SceneComponentInitialization: (scene: Scene) => void;
  140800. /**
  140801. * Creates a Cascaded Shadow Generator object.
  140802. * A ShadowGenerator is the required tool to use the shadows.
  140803. * Each directional light casting shadows needs to use its own ShadowGenerator.
  140804. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140805. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  140806. * @param light The directional light object generating the shadows.
  140807. * @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.
  140808. */
  140809. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  140810. protected _initializeGenerator(): void;
  140811. protected _createTargetRenderTexture(): void;
  140812. protected _initializeShadowMap(): void;
  140813. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  140814. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  140815. /**
  140816. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  140817. * @param defines Defines of the material we want to update
  140818. * @param lightIndex Index of the light in the enabled light list of the material
  140819. */
  140820. prepareDefines(defines: any, lightIndex: number): void;
  140821. /**
  140822. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  140823. * defined in the generator but impacting the effect).
  140824. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  140825. * @param effect The effect we are binfing the information for
  140826. */
  140827. bindShadowLight(lightIndex: string, effect: Effect): void;
  140828. /**
  140829. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  140830. * (eq to view projection * shadow projection matrices)
  140831. * @returns The transform matrix used to create the shadow map
  140832. */
  140833. getTransformMatrix(): Matrix;
  140834. /**
  140835. * Disposes the ShadowGenerator.
  140836. * Returns nothing.
  140837. */
  140838. dispose(): void;
  140839. /**
  140840. * Serializes the shadow generator setup to a json object.
  140841. * @returns The serialized JSON object
  140842. */
  140843. serialize(): any;
  140844. /**
  140845. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  140846. * @param parsedShadowGenerator The JSON object to parse
  140847. * @param scene The scene to create the shadow map for
  140848. * @returns The parsed shadow generator
  140849. */
  140850. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  140851. }
  140852. }
  140853. declare module BABYLON {
  140854. /**
  140855. * Defines the shadow generator component responsible to manage any shadow generators
  140856. * in a given scene.
  140857. */
  140858. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  140859. /**
  140860. * The component name helpfull to identify the component in the list of scene components.
  140861. */
  140862. readonly name: string;
  140863. /**
  140864. * The scene the component belongs to.
  140865. */
  140866. scene: Scene;
  140867. /**
  140868. * Creates a new instance of the component for the given scene
  140869. * @param scene Defines the scene to register the component in
  140870. */
  140871. constructor(scene: Scene);
  140872. /**
  140873. * Registers the component in a given scene
  140874. */
  140875. register(): void;
  140876. /**
  140877. * Rebuilds the elements related to this component in case of
  140878. * context lost for instance.
  140879. */
  140880. rebuild(): void;
  140881. /**
  140882. * Serializes the component data to the specified json object
  140883. * @param serializationObject The object to serialize to
  140884. */
  140885. serialize(serializationObject: any): void;
  140886. /**
  140887. * Adds all the elements from the container to the scene
  140888. * @param container the container holding the elements
  140889. */
  140890. addFromContainer(container: AbstractScene): void;
  140891. /**
  140892. * Removes all the elements in the container from the scene
  140893. * @param container contains the elements to remove
  140894. * @param dispose if the removed element should be disposed (default: false)
  140895. */
  140896. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140897. /**
  140898. * Rebuilds the elements related to this component in case of
  140899. * context lost for instance.
  140900. */
  140901. dispose(): void;
  140902. private _gatherRenderTargets;
  140903. }
  140904. }
  140905. declare module BABYLON {
  140906. /**
  140907. * A point light is a light defined by an unique point in world space.
  140908. * The light is emitted in every direction from this point.
  140909. * A good example of a point light is a standard light bulb.
  140910. * Documentation: https://doc.babylonjs.com/babylon101/lights
  140911. */
  140912. export class PointLight extends ShadowLight {
  140913. private _shadowAngle;
  140914. /**
  140915. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140916. * This specifies what angle the shadow will use to be created.
  140917. *
  140918. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140919. */
  140920. get shadowAngle(): number;
  140921. /**
  140922. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140923. * This specifies what angle the shadow will use to be created.
  140924. *
  140925. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140926. */
  140927. set shadowAngle(value: number);
  140928. /**
  140929. * Gets the direction if it has been set.
  140930. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140931. */
  140932. get direction(): Vector3;
  140933. /**
  140934. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140935. */
  140936. set direction(value: Vector3);
  140937. /**
  140938. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  140939. * A PointLight emits the light in every direction.
  140940. * It can cast shadows.
  140941. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  140942. * ```javascript
  140943. * var pointLight = new PointLight("pl", camera.position, scene);
  140944. * ```
  140945. * Documentation : https://doc.babylonjs.com/babylon101/lights
  140946. * @param name The light friendly name
  140947. * @param position The position of the point light in the scene
  140948. * @param scene The scene the lights belongs to
  140949. */
  140950. constructor(name: string, position: Vector3, scene: Scene);
  140951. /**
  140952. * Returns the string "PointLight"
  140953. * @returns the class name
  140954. */
  140955. getClassName(): string;
  140956. /**
  140957. * Returns the integer 0.
  140958. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  140959. */
  140960. getTypeID(): number;
  140961. /**
  140962. * Specifies wether or not the shadowmap should be a cube texture.
  140963. * @returns true if the shadowmap needs to be a cube texture.
  140964. */
  140965. needCube(): boolean;
  140966. /**
  140967. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  140968. * @param faceIndex The index of the face we are computed the direction to generate shadow
  140969. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  140970. */
  140971. getShadowDirection(faceIndex?: number): Vector3;
  140972. /**
  140973. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  140974. * - fov = PI / 2
  140975. * - aspect ratio : 1.0
  140976. * - z-near and far equal to the active camera minZ and maxZ.
  140977. * Returns the PointLight.
  140978. */
  140979. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  140980. protected _buildUniformLayout(): void;
  140981. /**
  140982. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  140983. * @param effect The effect to update
  140984. * @param lightIndex The index of the light in the effect to update
  140985. * @returns The point light
  140986. */
  140987. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  140988. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  140989. /**
  140990. * Prepares the list of defines specific to the light type.
  140991. * @param defines the list of defines
  140992. * @param lightIndex defines the index of the light for the effect
  140993. */
  140994. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  140995. }
  140996. }
  140997. declare module BABYLON {
  140998. /**
  140999. * Header information of HDR texture files.
  141000. */
  141001. export interface HDRInfo {
  141002. /**
  141003. * The height of the texture in pixels.
  141004. */
  141005. height: number;
  141006. /**
  141007. * The width of the texture in pixels.
  141008. */
  141009. width: number;
  141010. /**
  141011. * The index of the beginning of the data in the binary file.
  141012. */
  141013. dataPosition: number;
  141014. }
  141015. /**
  141016. * This groups tools to convert HDR texture to native colors array.
  141017. */
  141018. export class HDRTools {
  141019. private static Ldexp;
  141020. private static Rgbe2float;
  141021. private static readStringLine;
  141022. /**
  141023. * Reads header information from an RGBE texture stored in a native array.
  141024. * More information on this format are available here:
  141025. * https://en.wikipedia.org/wiki/RGBE_image_format
  141026. *
  141027. * @param uint8array The binary file stored in native array.
  141028. * @return The header information.
  141029. */
  141030. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  141031. /**
  141032. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  141033. * This RGBE texture needs to store the information as a panorama.
  141034. *
  141035. * More information on this format are available here:
  141036. * https://en.wikipedia.org/wiki/RGBE_image_format
  141037. *
  141038. * @param buffer The binary file stored in an array buffer.
  141039. * @param size The expected size of the extracted cubemap.
  141040. * @return The Cube Map information.
  141041. */
  141042. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  141043. /**
  141044. * Returns the pixels data extracted from an RGBE texture.
  141045. * This pixels will be stored left to right up to down in the R G B order in one array.
  141046. *
  141047. * More information on this format are available here:
  141048. * https://en.wikipedia.org/wiki/RGBE_image_format
  141049. *
  141050. * @param uint8array The binary file stored in an array buffer.
  141051. * @param hdrInfo The header information of the file.
  141052. * @return The pixels data in RGB right to left up to down order.
  141053. */
  141054. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  141055. private static RGBE_ReadPixels_RLE;
  141056. private static RGBE_ReadPixels_NOT_RLE;
  141057. }
  141058. }
  141059. declare module BABYLON {
  141060. /**
  141061. * Effect Render Options
  141062. */
  141063. export interface IEffectRendererOptions {
  141064. /**
  141065. * Defines the vertices positions.
  141066. */
  141067. positions?: number[];
  141068. /**
  141069. * Defines the indices.
  141070. */
  141071. indices?: number[];
  141072. }
  141073. /**
  141074. * Helper class to render one or more effects.
  141075. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  141076. */
  141077. export class EffectRenderer {
  141078. private engine;
  141079. private static _DefaultOptions;
  141080. private _vertexBuffers;
  141081. private _indexBuffer;
  141082. private _fullscreenViewport;
  141083. /**
  141084. * Creates an effect renderer
  141085. * @param engine the engine to use for rendering
  141086. * @param options defines the options of the effect renderer
  141087. */
  141088. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  141089. /**
  141090. * Sets the current viewport in normalized coordinates 0-1
  141091. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  141092. */
  141093. setViewport(viewport?: Viewport): void;
  141094. /**
  141095. * Binds the embedded attributes buffer to the effect.
  141096. * @param effect Defines the effect to bind the attributes for
  141097. */
  141098. bindBuffers(effect: Effect): void;
  141099. /**
  141100. * Sets the current effect wrapper to use during draw.
  141101. * The effect needs to be ready before calling this api.
  141102. * This also sets the default full screen position attribute.
  141103. * @param effectWrapper Defines the effect to draw with
  141104. */
  141105. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  141106. /**
  141107. * Restores engine states
  141108. */
  141109. restoreStates(): void;
  141110. /**
  141111. * Draws a full screen quad.
  141112. */
  141113. draw(): void;
  141114. private isRenderTargetTexture;
  141115. /**
  141116. * renders one or more effects to a specified texture
  141117. * @param effectWrapper the effect to renderer
  141118. * @param outputTexture texture to draw to, if null it will render to the screen.
  141119. */
  141120. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  141121. /**
  141122. * Disposes of the effect renderer
  141123. */
  141124. dispose(): void;
  141125. }
  141126. /**
  141127. * Options to create an EffectWrapper
  141128. */
  141129. interface EffectWrapperCreationOptions {
  141130. /**
  141131. * Engine to use to create the effect
  141132. */
  141133. engine: ThinEngine;
  141134. /**
  141135. * Fragment shader for the effect
  141136. */
  141137. fragmentShader: string;
  141138. /**
  141139. * Use the shader store instead of direct source code
  141140. */
  141141. useShaderStore?: boolean;
  141142. /**
  141143. * Vertex shader for the effect
  141144. */
  141145. vertexShader?: string;
  141146. /**
  141147. * Attributes to use in the shader
  141148. */
  141149. attributeNames?: Array<string>;
  141150. /**
  141151. * Uniforms to use in the shader
  141152. */
  141153. uniformNames?: Array<string>;
  141154. /**
  141155. * Texture sampler names to use in the shader
  141156. */
  141157. samplerNames?: Array<string>;
  141158. /**
  141159. * Defines to use in the shader
  141160. */
  141161. defines?: Array<string>;
  141162. /**
  141163. * Callback when effect is compiled
  141164. */
  141165. onCompiled?: Nullable<(effect: Effect) => void>;
  141166. /**
  141167. * The friendly name of the effect displayed in Spector.
  141168. */
  141169. name?: string;
  141170. }
  141171. /**
  141172. * Wraps an effect to be used for rendering
  141173. */
  141174. export class EffectWrapper {
  141175. /**
  141176. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  141177. */
  141178. onApplyObservable: Observable<{}>;
  141179. /**
  141180. * The underlying effect
  141181. */
  141182. effect: Effect;
  141183. /**
  141184. * Creates an effect to be renderer
  141185. * @param creationOptions options to create the effect
  141186. */
  141187. constructor(creationOptions: EffectWrapperCreationOptions);
  141188. /**
  141189. * Disposes of the effect wrapper
  141190. */
  141191. dispose(): void;
  141192. }
  141193. }
  141194. declare module BABYLON {
  141195. /** @hidden */
  141196. export var hdrFilteringVertexShader: {
  141197. name: string;
  141198. shader: string;
  141199. };
  141200. }
  141201. declare module BABYLON {
  141202. /** @hidden */
  141203. export var hdrFilteringPixelShader: {
  141204. name: string;
  141205. shader: string;
  141206. };
  141207. }
  141208. declare module BABYLON {
  141209. /**
  141210. * Options for texture filtering
  141211. */
  141212. interface IHDRFilteringOptions {
  141213. /**
  141214. * Scales pixel intensity for the input HDR map.
  141215. */
  141216. hdrScale?: number;
  141217. /**
  141218. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  141219. */
  141220. quality?: number;
  141221. }
  141222. /**
  141223. * Filters HDR maps to get correct renderings of PBR reflections
  141224. */
  141225. export class HDRFiltering {
  141226. private _engine;
  141227. private _effectRenderer;
  141228. private _effectWrapper;
  141229. private _lodGenerationOffset;
  141230. private _lodGenerationScale;
  141231. /**
  141232. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  141233. * you care about baking speed.
  141234. */
  141235. quality: number;
  141236. /**
  141237. * Scales pixel intensity for the input HDR map.
  141238. */
  141239. hdrScale: number;
  141240. /**
  141241. * Instantiates HDR filter for reflection maps
  141242. *
  141243. * @param engine Thin engine
  141244. * @param options Options
  141245. */
  141246. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  141247. private _createRenderTarget;
  141248. private _prefilterInternal;
  141249. private _createEffect;
  141250. /**
  141251. * Get a value indicating if the filter is ready to be used
  141252. * @param texture Texture to filter
  141253. * @returns true if the filter is ready
  141254. */
  141255. isReady(texture: BaseTexture): boolean;
  141256. /**
  141257. * Prefilters a cube texture to have mipmap levels representing roughness values.
  141258. * Prefiltering will be invoked at the end of next rendering pass.
  141259. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  141260. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  141261. * @param texture Texture to filter
  141262. * @param onFinished Callback when filtering is done
  141263. * @return Promise called when prefiltering is done
  141264. */
  141265. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  141266. }
  141267. }
  141268. declare module BABYLON {
  141269. /**
  141270. * This represents a texture coming from an HDR input.
  141271. *
  141272. * The only supported format is currently panorama picture stored in RGBE format.
  141273. * Example of such files can be found on HDRLib: http://hdrlib.com/
  141274. */
  141275. export class HDRCubeTexture extends BaseTexture {
  141276. private static _facesMapping;
  141277. private _generateHarmonics;
  141278. private _noMipmap;
  141279. private _prefilterOnLoad;
  141280. private _textureMatrix;
  141281. private _size;
  141282. private _onLoad;
  141283. private _onError;
  141284. /**
  141285. * The texture URL.
  141286. */
  141287. url: string;
  141288. protected _isBlocking: boolean;
  141289. /**
  141290. * Sets wether or not the texture is blocking during loading.
  141291. */
  141292. set isBlocking(value: boolean);
  141293. /**
  141294. * Gets wether or not the texture is blocking during loading.
  141295. */
  141296. get isBlocking(): boolean;
  141297. protected _rotationY: number;
  141298. /**
  141299. * Sets texture matrix rotation angle around Y axis in radians.
  141300. */
  141301. set rotationY(value: number);
  141302. /**
  141303. * Gets texture matrix rotation angle around Y axis radians.
  141304. */
  141305. get rotationY(): number;
  141306. /**
  141307. * Gets or sets the center of the bounding box associated with the cube texture
  141308. * It must define where the camera used to render the texture was set
  141309. */
  141310. boundingBoxPosition: Vector3;
  141311. private _boundingBoxSize;
  141312. /**
  141313. * Gets or sets the size of the bounding box associated with the cube texture
  141314. * When defined, the cubemap will switch to local mode
  141315. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  141316. * @example https://www.babylonjs-playground.com/#RNASML
  141317. */
  141318. set boundingBoxSize(value: Vector3);
  141319. get boundingBoxSize(): Vector3;
  141320. /**
  141321. * Instantiates an HDRTexture from the following parameters.
  141322. *
  141323. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  141324. * @param sceneOrEngine The scene or engine the texture will be used in
  141325. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141326. * @param noMipmap Forces to not generate the mipmap if true
  141327. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  141328. * @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)
  141329. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  141330. */
  141331. 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>);
  141332. /**
  141333. * Get the current class name of the texture useful for serialization or dynamic coding.
  141334. * @returns "HDRCubeTexture"
  141335. */
  141336. getClassName(): string;
  141337. /**
  141338. * Occurs when the file is raw .hdr file.
  141339. */
  141340. private loadTexture;
  141341. clone(): HDRCubeTexture;
  141342. delayLoad(): void;
  141343. /**
  141344. * Get the texture reflection matrix used to rotate/transform the reflection.
  141345. * @returns the reflection matrix
  141346. */
  141347. getReflectionTextureMatrix(): Matrix;
  141348. /**
  141349. * Set the texture reflection matrix used to rotate/transform the reflection.
  141350. * @param value Define the reflection matrix to set
  141351. */
  141352. setReflectionTextureMatrix(value: Matrix): void;
  141353. /**
  141354. * Parses a JSON representation of an HDR Texture in order to create the texture
  141355. * @param parsedTexture Define the JSON representation
  141356. * @param scene Define the scene the texture should be created in
  141357. * @param rootUrl Define the root url in case we need to load relative dependencies
  141358. * @returns the newly created texture after parsing
  141359. */
  141360. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  141361. serialize(): any;
  141362. }
  141363. }
  141364. declare module BABYLON {
  141365. /**
  141366. * Class used to control physics engine
  141367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141368. */
  141369. export class PhysicsEngine implements IPhysicsEngine {
  141370. private _physicsPlugin;
  141371. /**
  141372. * Global value used to control the smallest number supported by the simulation
  141373. */
  141374. static Epsilon: number;
  141375. private _impostors;
  141376. private _joints;
  141377. private _subTimeStep;
  141378. /**
  141379. * Gets the gravity vector used by the simulation
  141380. */
  141381. gravity: Vector3;
  141382. /**
  141383. * Factory used to create the default physics plugin.
  141384. * @returns The default physics plugin
  141385. */
  141386. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  141387. /**
  141388. * Creates a new Physics Engine
  141389. * @param gravity defines the gravity vector used by the simulation
  141390. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  141391. */
  141392. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  141393. /**
  141394. * Sets the gravity vector used by the simulation
  141395. * @param gravity defines the gravity vector to use
  141396. */
  141397. setGravity(gravity: Vector3): void;
  141398. /**
  141399. * Set the time step of the physics engine.
  141400. * Default is 1/60.
  141401. * To slow it down, enter 1/600 for example.
  141402. * To speed it up, 1/30
  141403. * @param newTimeStep defines the new timestep to apply to this world.
  141404. */
  141405. setTimeStep(newTimeStep?: number): void;
  141406. /**
  141407. * Get the time step of the physics engine.
  141408. * @returns the current time step
  141409. */
  141410. getTimeStep(): number;
  141411. /**
  141412. * Set the sub time step of the physics engine.
  141413. * Default is 0 meaning there is no sub steps
  141414. * To increase physics resolution precision, set a small value (like 1 ms)
  141415. * @param subTimeStep defines the new sub timestep used for physics resolution.
  141416. */
  141417. setSubTimeStep(subTimeStep?: number): void;
  141418. /**
  141419. * Get the sub time step of the physics engine.
  141420. * @returns the current sub time step
  141421. */
  141422. getSubTimeStep(): number;
  141423. /**
  141424. * Release all resources
  141425. */
  141426. dispose(): void;
  141427. /**
  141428. * Gets the name of the current physics plugin
  141429. * @returns the name of the plugin
  141430. */
  141431. getPhysicsPluginName(): string;
  141432. /**
  141433. * Adding a new impostor for the impostor tracking.
  141434. * This will be done by the impostor itself.
  141435. * @param impostor the impostor to add
  141436. */
  141437. addImpostor(impostor: PhysicsImpostor): void;
  141438. /**
  141439. * Remove an impostor from the engine.
  141440. * This impostor and its mesh will not longer be updated by the physics engine.
  141441. * @param impostor the impostor to remove
  141442. */
  141443. removeImpostor(impostor: PhysicsImpostor): void;
  141444. /**
  141445. * Add a joint to the physics engine
  141446. * @param mainImpostor defines the main impostor to which the joint is added.
  141447. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  141448. * @param joint defines the joint that will connect both impostors.
  141449. */
  141450. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141451. /**
  141452. * Removes a joint from the simulation
  141453. * @param mainImpostor defines the impostor used with the joint
  141454. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  141455. * @param joint defines the joint to remove
  141456. */
  141457. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141458. /**
  141459. * Called by the scene. No need to call it.
  141460. * @param delta defines the timespam between frames
  141461. */
  141462. _step(delta: number): void;
  141463. /**
  141464. * Gets the current plugin used to run the simulation
  141465. * @returns current plugin
  141466. */
  141467. getPhysicsPlugin(): IPhysicsEnginePlugin;
  141468. /**
  141469. * Gets the list of physic impostors
  141470. * @returns an array of PhysicsImpostor
  141471. */
  141472. getImpostors(): Array<PhysicsImpostor>;
  141473. /**
  141474. * Gets the impostor for a physics enabled object
  141475. * @param object defines the object impersonated by the impostor
  141476. * @returns the PhysicsImpostor or null if not found
  141477. */
  141478. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  141479. /**
  141480. * Gets the impostor for a physics body object
  141481. * @param body defines physics body used by the impostor
  141482. * @returns the PhysicsImpostor or null if not found
  141483. */
  141484. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  141485. /**
  141486. * Does a raycast in the physics world
  141487. * @param from when should the ray start?
  141488. * @param to when should the ray end?
  141489. * @returns PhysicsRaycastResult
  141490. */
  141491. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141492. }
  141493. }
  141494. declare module BABYLON {
  141495. /** @hidden */
  141496. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  141497. private _useDeltaForWorldStep;
  141498. world: any;
  141499. name: string;
  141500. private _physicsMaterials;
  141501. private _fixedTimeStep;
  141502. private _cannonRaycastResult;
  141503. private _raycastResult;
  141504. private _physicsBodysToRemoveAfterStep;
  141505. private _firstFrame;
  141506. BJSCANNON: any;
  141507. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  141508. setGravity(gravity: Vector3): void;
  141509. setTimeStep(timeStep: number): void;
  141510. getTimeStep(): number;
  141511. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141512. private _removeMarkedPhysicsBodiesFromWorld;
  141513. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141514. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141515. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141516. private _processChildMeshes;
  141517. removePhysicsBody(impostor: PhysicsImpostor): void;
  141518. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141519. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141520. private _addMaterial;
  141521. private _checkWithEpsilon;
  141522. private _createShape;
  141523. private _createHeightmap;
  141524. private _minus90X;
  141525. private _plus90X;
  141526. private _tmpPosition;
  141527. private _tmpDeltaPosition;
  141528. private _tmpUnityRotation;
  141529. private _updatePhysicsBodyTransformation;
  141530. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141531. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141532. isSupported(): boolean;
  141533. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141534. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141535. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141536. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141537. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141538. getBodyMass(impostor: PhysicsImpostor): number;
  141539. getBodyFriction(impostor: PhysicsImpostor): number;
  141540. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141541. getBodyRestitution(impostor: PhysicsImpostor): number;
  141542. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141543. sleepBody(impostor: PhysicsImpostor): void;
  141544. wakeUpBody(impostor: PhysicsImpostor): void;
  141545. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  141546. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141547. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141548. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141549. getRadius(impostor: PhysicsImpostor): number;
  141550. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141551. dispose(): void;
  141552. private _extendNamespace;
  141553. /**
  141554. * Does a raycast in the physics world
  141555. * @param from when should the ray start?
  141556. * @param to when should the ray end?
  141557. * @returns PhysicsRaycastResult
  141558. */
  141559. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141560. }
  141561. }
  141562. declare module BABYLON {
  141563. /** @hidden */
  141564. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  141565. private _useDeltaForWorldStep;
  141566. world: any;
  141567. name: string;
  141568. BJSOIMO: any;
  141569. private _raycastResult;
  141570. private _fixedTimeStep;
  141571. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  141572. setGravity(gravity: Vector3): void;
  141573. setTimeStep(timeStep: number): void;
  141574. getTimeStep(): number;
  141575. private _tmpImpostorsArray;
  141576. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141577. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141578. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141579. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141580. private _tmpPositionVector;
  141581. removePhysicsBody(impostor: PhysicsImpostor): void;
  141582. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141583. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141584. isSupported(): boolean;
  141585. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141586. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141587. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141588. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141589. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141590. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141591. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141592. getBodyMass(impostor: PhysicsImpostor): number;
  141593. getBodyFriction(impostor: PhysicsImpostor): number;
  141594. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141595. getBodyRestitution(impostor: PhysicsImpostor): number;
  141596. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141597. sleepBody(impostor: PhysicsImpostor): void;
  141598. wakeUpBody(impostor: PhysicsImpostor): void;
  141599. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141600. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  141601. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  141602. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141603. getRadius(impostor: PhysicsImpostor): number;
  141604. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141605. dispose(): void;
  141606. /**
  141607. * Does a raycast in the physics world
  141608. * @param from when should the ray start?
  141609. * @param to when should the ray end?
  141610. * @returns PhysicsRaycastResult
  141611. */
  141612. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141613. }
  141614. }
  141615. declare module BABYLON {
  141616. /**
  141617. * AmmoJS Physics plugin
  141618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141619. * @see https://github.com/kripken/ammo.js/
  141620. */
  141621. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  141622. private _useDeltaForWorldStep;
  141623. /**
  141624. * Reference to the Ammo library
  141625. */
  141626. bjsAMMO: any;
  141627. /**
  141628. * Created ammoJS world which physics bodies are added to
  141629. */
  141630. world: any;
  141631. /**
  141632. * Name of the plugin
  141633. */
  141634. name: string;
  141635. private _timeStep;
  141636. private _fixedTimeStep;
  141637. private _maxSteps;
  141638. private _tmpQuaternion;
  141639. private _tmpAmmoTransform;
  141640. private _tmpAmmoQuaternion;
  141641. private _tmpAmmoConcreteContactResultCallback;
  141642. private _collisionConfiguration;
  141643. private _dispatcher;
  141644. private _overlappingPairCache;
  141645. private _solver;
  141646. private _softBodySolver;
  141647. private _tmpAmmoVectorA;
  141648. private _tmpAmmoVectorB;
  141649. private _tmpAmmoVectorC;
  141650. private _tmpAmmoVectorD;
  141651. private _tmpContactCallbackResult;
  141652. private _tmpAmmoVectorRCA;
  141653. private _tmpAmmoVectorRCB;
  141654. private _raycastResult;
  141655. private static readonly DISABLE_COLLISION_FLAG;
  141656. private static readonly KINEMATIC_FLAG;
  141657. private static readonly DISABLE_DEACTIVATION_FLAG;
  141658. /**
  141659. * Initializes the ammoJS plugin
  141660. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  141661. * @param ammoInjection can be used to inject your own ammo reference
  141662. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  141663. */
  141664. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  141665. /**
  141666. * Sets the gravity of the physics world (m/(s^2))
  141667. * @param gravity Gravity to set
  141668. */
  141669. setGravity(gravity: Vector3): void;
  141670. /**
  141671. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  141672. * @param timeStep timestep to use in seconds
  141673. */
  141674. setTimeStep(timeStep: number): void;
  141675. /**
  141676. * 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)
  141677. * @param fixedTimeStep fixedTimeStep to use in seconds
  141678. */
  141679. setFixedTimeStep(fixedTimeStep: number): void;
  141680. /**
  141681. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  141682. * @param maxSteps the maximum number of steps by the physics engine per frame
  141683. */
  141684. setMaxSteps(maxSteps: number): void;
  141685. /**
  141686. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  141687. * @returns the current timestep in seconds
  141688. */
  141689. getTimeStep(): number;
  141690. /**
  141691. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  141692. */
  141693. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  141694. private _isImpostorInContact;
  141695. private _isImpostorPairInContact;
  141696. private _stepSimulation;
  141697. /**
  141698. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  141699. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  141700. * After the step the babylon meshes are set to the position of the physics imposters
  141701. * @param delta amount of time to step forward
  141702. * @param impostors array of imposters to update before/after the step
  141703. */
  141704. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141705. /**
  141706. * Update babylon mesh to match physics world object
  141707. * @param impostor imposter to match
  141708. */
  141709. private _afterSoftStep;
  141710. /**
  141711. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141712. * @param impostor imposter to match
  141713. */
  141714. private _ropeStep;
  141715. /**
  141716. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141717. * @param impostor imposter to match
  141718. */
  141719. private _softbodyOrClothStep;
  141720. private _tmpMatrix;
  141721. /**
  141722. * Applies an impulse on the imposter
  141723. * @param impostor imposter to apply impulse to
  141724. * @param force amount of force to be applied to the imposter
  141725. * @param contactPoint the location to apply the impulse on the imposter
  141726. */
  141727. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141728. /**
  141729. * Applies a force on the imposter
  141730. * @param impostor imposter to apply force
  141731. * @param force amount of force to be applied to the imposter
  141732. * @param contactPoint the location to apply the force on the imposter
  141733. */
  141734. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141735. /**
  141736. * Creates a physics body using the plugin
  141737. * @param impostor the imposter to create the physics body on
  141738. */
  141739. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141740. /**
  141741. * Removes the physics body from the imposter and disposes of the body's memory
  141742. * @param impostor imposter to remove the physics body from
  141743. */
  141744. removePhysicsBody(impostor: PhysicsImpostor): void;
  141745. /**
  141746. * Generates a joint
  141747. * @param impostorJoint the imposter joint to create the joint with
  141748. */
  141749. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141750. /**
  141751. * Removes a joint
  141752. * @param impostorJoint the imposter joint to remove the joint from
  141753. */
  141754. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141755. private _addMeshVerts;
  141756. /**
  141757. * Initialise the soft body vertices to match its object's (mesh) vertices
  141758. * Softbody vertices (nodes) are in world space and to match this
  141759. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  141760. * @param impostor to create the softbody for
  141761. */
  141762. private _softVertexData;
  141763. /**
  141764. * Create an impostor's soft body
  141765. * @param impostor to create the softbody for
  141766. */
  141767. private _createSoftbody;
  141768. /**
  141769. * Create cloth for an impostor
  141770. * @param impostor to create the softbody for
  141771. */
  141772. private _createCloth;
  141773. /**
  141774. * Create rope for an impostor
  141775. * @param impostor to create the softbody for
  141776. */
  141777. private _createRope;
  141778. /**
  141779. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  141780. * @param impostor to create the custom physics shape for
  141781. */
  141782. private _createCustom;
  141783. private _addHullVerts;
  141784. private _createShape;
  141785. /**
  141786. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  141787. * @param impostor imposter containing the physics body and babylon object
  141788. */
  141789. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141790. /**
  141791. * Sets the babylon object's position/rotation from the physics body's position/rotation
  141792. * @param impostor imposter containing the physics body and babylon object
  141793. * @param newPosition new position
  141794. * @param newRotation new rotation
  141795. */
  141796. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141797. /**
  141798. * If this plugin is supported
  141799. * @returns true if its supported
  141800. */
  141801. isSupported(): boolean;
  141802. /**
  141803. * Sets the linear velocity of the physics body
  141804. * @param impostor imposter to set the velocity on
  141805. * @param velocity velocity to set
  141806. */
  141807. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141808. /**
  141809. * Sets the angular velocity of the physics body
  141810. * @param impostor imposter to set the velocity on
  141811. * @param velocity velocity to set
  141812. */
  141813. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141814. /**
  141815. * gets the linear velocity
  141816. * @param impostor imposter to get linear velocity from
  141817. * @returns linear velocity
  141818. */
  141819. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141820. /**
  141821. * gets the angular velocity
  141822. * @param impostor imposter to get angular velocity from
  141823. * @returns angular velocity
  141824. */
  141825. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141826. /**
  141827. * Sets the mass of physics body
  141828. * @param impostor imposter to set the mass on
  141829. * @param mass mass to set
  141830. */
  141831. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141832. /**
  141833. * Gets the mass of the physics body
  141834. * @param impostor imposter to get the mass from
  141835. * @returns mass
  141836. */
  141837. getBodyMass(impostor: PhysicsImpostor): number;
  141838. /**
  141839. * Gets friction of the impostor
  141840. * @param impostor impostor to get friction from
  141841. * @returns friction value
  141842. */
  141843. getBodyFriction(impostor: PhysicsImpostor): number;
  141844. /**
  141845. * Sets friction of the impostor
  141846. * @param impostor impostor to set friction on
  141847. * @param friction friction value
  141848. */
  141849. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141850. /**
  141851. * Gets restitution of the impostor
  141852. * @param impostor impostor to get restitution from
  141853. * @returns restitution value
  141854. */
  141855. getBodyRestitution(impostor: PhysicsImpostor): number;
  141856. /**
  141857. * Sets resitution of the impostor
  141858. * @param impostor impostor to set resitution on
  141859. * @param restitution resitution value
  141860. */
  141861. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141862. /**
  141863. * Gets pressure inside the impostor
  141864. * @param impostor impostor to get pressure from
  141865. * @returns pressure value
  141866. */
  141867. getBodyPressure(impostor: PhysicsImpostor): number;
  141868. /**
  141869. * Sets pressure inside a soft body impostor
  141870. * Cloth and rope must remain 0 pressure
  141871. * @param impostor impostor to set pressure on
  141872. * @param pressure pressure value
  141873. */
  141874. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  141875. /**
  141876. * Gets stiffness of the impostor
  141877. * @param impostor impostor to get stiffness from
  141878. * @returns pressure value
  141879. */
  141880. getBodyStiffness(impostor: PhysicsImpostor): number;
  141881. /**
  141882. * Sets stiffness of the impostor
  141883. * @param impostor impostor to set stiffness on
  141884. * @param stiffness stiffness value from 0 to 1
  141885. */
  141886. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  141887. /**
  141888. * Gets velocityIterations of the impostor
  141889. * @param impostor impostor to get velocity iterations from
  141890. * @returns velocityIterations value
  141891. */
  141892. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  141893. /**
  141894. * Sets velocityIterations of the impostor
  141895. * @param impostor impostor to set velocity iterations on
  141896. * @param velocityIterations velocityIterations value
  141897. */
  141898. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  141899. /**
  141900. * Gets positionIterations of the impostor
  141901. * @param impostor impostor to get position iterations from
  141902. * @returns positionIterations value
  141903. */
  141904. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  141905. /**
  141906. * Sets positionIterations of the impostor
  141907. * @param impostor impostor to set position on
  141908. * @param positionIterations positionIterations value
  141909. */
  141910. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  141911. /**
  141912. * Append an anchor to a cloth object
  141913. * @param impostor is the cloth impostor to add anchor to
  141914. * @param otherImpostor is the rigid impostor to anchor to
  141915. * @param width ratio across width from 0 to 1
  141916. * @param height ratio up height from 0 to 1
  141917. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  141918. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141919. */
  141920. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141921. /**
  141922. * Append an hook to a rope object
  141923. * @param impostor is the rope impostor to add hook to
  141924. * @param otherImpostor is the rigid impostor to hook to
  141925. * @param length ratio along the rope from 0 to 1
  141926. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  141927. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141928. */
  141929. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141930. /**
  141931. * Sleeps the physics body and stops it from being active
  141932. * @param impostor impostor to sleep
  141933. */
  141934. sleepBody(impostor: PhysicsImpostor): void;
  141935. /**
  141936. * Activates the physics body
  141937. * @param impostor impostor to activate
  141938. */
  141939. wakeUpBody(impostor: PhysicsImpostor): void;
  141940. /**
  141941. * Updates the distance parameters of the joint
  141942. * @param joint joint to update
  141943. * @param maxDistance maximum distance of the joint
  141944. * @param minDistance minimum distance of the joint
  141945. */
  141946. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141947. /**
  141948. * Sets a motor on the joint
  141949. * @param joint joint to set motor on
  141950. * @param speed speed of the motor
  141951. * @param maxForce maximum force of the motor
  141952. * @param motorIndex index of the motor
  141953. */
  141954. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141955. /**
  141956. * Sets the motors limit
  141957. * @param joint joint to set limit on
  141958. * @param upperLimit upper limit
  141959. * @param lowerLimit lower limit
  141960. */
  141961. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141962. /**
  141963. * Syncs the position and rotation of a mesh with the impostor
  141964. * @param mesh mesh to sync
  141965. * @param impostor impostor to update the mesh with
  141966. */
  141967. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141968. /**
  141969. * Gets the radius of the impostor
  141970. * @param impostor impostor to get radius from
  141971. * @returns the radius
  141972. */
  141973. getRadius(impostor: PhysicsImpostor): number;
  141974. /**
  141975. * Gets the box size of the impostor
  141976. * @param impostor impostor to get box size from
  141977. * @param result the resulting box size
  141978. */
  141979. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141980. /**
  141981. * Disposes of the impostor
  141982. */
  141983. dispose(): void;
  141984. /**
  141985. * Does a raycast in the physics world
  141986. * @param from when should the ray start?
  141987. * @param to when should the ray end?
  141988. * @returns PhysicsRaycastResult
  141989. */
  141990. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141991. }
  141992. }
  141993. declare module BABYLON {
  141994. interface AbstractScene {
  141995. /**
  141996. * The list of reflection probes added to the scene
  141997. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141998. */
  141999. reflectionProbes: Array<ReflectionProbe>;
  142000. /**
  142001. * Removes the given reflection probe from this scene.
  142002. * @param toRemove The reflection probe to remove
  142003. * @returns The index of the removed reflection probe
  142004. */
  142005. removeReflectionProbe(toRemove: ReflectionProbe): number;
  142006. /**
  142007. * Adds the given reflection probe to this scene.
  142008. * @param newReflectionProbe The reflection probe to add
  142009. */
  142010. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  142011. }
  142012. /**
  142013. * Class used to generate realtime reflection / refraction cube textures
  142014. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142015. */
  142016. export class ReflectionProbe {
  142017. /** defines the name of the probe */
  142018. name: string;
  142019. private _scene;
  142020. private _renderTargetTexture;
  142021. private _projectionMatrix;
  142022. private _viewMatrix;
  142023. private _target;
  142024. private _add;
  142025. private _attachedMesh;
  142026. private _invertYAxis;
  142027. /** Gets or sets probe position (center of the cube map) */
  142028. position: Vector3;
  142029. /**
  142030. * Creates a new reflection probe
  142031. * @param name defines the name of the probe
  142032. * @param size defines the texture resolution (for each face)
  142033. * @param scene defines the hosting scene
  142034. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  142035. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  142036. */
  142037. constructor(
  142038. /** defines the name of the probe */
  142039. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  142040. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  142041. get samples(): number;
  142042. set samples(value: number);
  142043. /** Gets or sets the refresh rate to use (on every frame by default) */
  142044. get refreshRate(): number;
  142045. set refreshRate(value: number);
  142046. /**
  142047. * Gets the hosting scene
  142048. * @returns a Scene
  142049. */
  142050. getScene(): Scene;
  142051. /** Gets the internal CubeTexture used to render to */
  142052. get cubeTexture(): RenderTargetTexture;
  142053. /** Gets the list of meshes to render */
  142054. get renderList(): Nullable<AbstractMesh[]>;
  142055. /**
  142056. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  142057. * @param mesh defines the mesh to attach to
  142058. */
  142059. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142060. /**
  142061. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  142062. * @param renderingGroupId The rendering group id corresponding to its index
  142063. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  142064. */
  142065. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  142066. /**
  142067. * Clean all associated resources
  142068. */
  142069. dispose(): void;
  142070. /**
  142071. * Converts the reflection probe information to a readable string for debug purpose.
  142072. * @param fullDetails Supports for multiple levels of logging within scene loading
  142073. * @returns the human readable reflection probe info
  142074. */
  142075. toString(fullDetails?: boolean): string;
  142076. /**
  142077. * Get the class name of the relfection probe.
  142078. * @returns "ReflectionProbe"
  142079. */
  142080. getClassName(): string;
  142081. /**
  142082. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  142083. * @returns The JSON representation of the texture
  142084. */
  142085. serialize(): any;
  142086. /**
  142087. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  142088. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  142089. * @param scene Define the scene the parsed reflection probe should be instantiated in
  142090. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  142091. * @returns The parsed reflection probe if successful
  142092. */
  142093. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  142094. }
  142095. }
  142096. declare module BABYLON {
  142097. /** @hidden */
  142098. export var _BabylonLoaderRegistered: boolean;
  142099. /**
  142100. * Helps setting up some configuration for the babylon file loader.
  142101. */
  142102. export class BabylonFileLoaderConfiguration {
  142103. /**
  142104. * The loader does not allow injecting custom physix engine into the plugins.
  142105. * Unfortunately in ES6, we need to manually inject them into the plugin.
  142106. * So you could set this variable to your engine import to make it work.
  142107. */
  142108. static LoaderInjectedPhysicsEngine: any;
  142109. }
  142110. }
  142111. declare module BABYLON {
  142112. /**
  142113. * The Physically based simple base material of BJS.
  142114. *
  142115. * This enables better naming and convention enforcements on top of the pbrMaterial.
  142116. * It is used as the base class for both the specGloss and metalRough conventions.
  142117. */
  142118. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  142119. /**
  142120. * Number of Simultaneous lights allowed on the material.
  142121. */
  142122. maxSimultaneousLights: number;
  142123. /**
  142124. * If sets to true, disables all the lights affecting the material.
  142125. */
  142126. disableLighting: boolean;
  142127. /**
  142128. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  142129. */
  142130. environmentTexture: BaseTexture;
  142131. /**
  142132. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  142133. */
  142134. invertNormalMapX: boolean;
  142135. /**
  142136. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  142137. */
  142138. invertNormalMapY: boolean;
  142139. /**
  142140. * Normal map used in the model.
  142141. */
  142142. normalTexture: BaseTexture;
  142143. /**
  142144. * Emissivie color used to self-illuminate the model.
  142145. */
  142146. emissiveColor: Color3;
  142147. /**
  142148. * Emissivie texture used to self-illuminate the model.
  142149. */
  142150. emissiveTexture: BaseTexture;
  142151. /**
  142152. * Occlusion Channel Strenght.
  142153. */
  142154. occlusionStrength: number;
  142155. /**
  142156. * Occlusion Texture of the material (adding extra occlusion effects).
  142157. */
  142158. occlusionTexture: BaseTexture;
  142159. /**
  142160. * Defines the alpha limits in alpha test mode.
  142161. */
  142162. alphaCutOff: number;
  142163. /**
  142164. * Gets the current double sided mode.
  142165. */
  142166. get doubleSided(): boolean;
  142167. /**
  142168. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  142169. */
  142170. set doubleSided(value: boolean);
  142171. /**
  142172. * Stores the pre-calculated light information of a mesh in a texture.
  142173. */
  142174. lightmapTexture: BaseTexture;
  142175. /**
  142176. * If true, the light map contains occlusion information instead of lighting info.
  142177. */
  142178. useLightmapAsShadowmap: boolean;
  142179. /**
  142180. * Instantiates a new PBRMaterial instance.
  142181. *
  142182. * @param name The material name
  142183. * @param scene The scene the material will be use in.
  142184. */
  142185. constructor(name: string, scene: Scene);
  142186. getClassName(): string;
  142187. }
  142188. }
  142189. declare module BABYLON {
  142190. /**
  142191. * The PBR material of BJS following the metal roughness convention.
  142192. *
  142193. * This fits to the PBR convention in the GLTF definition:
  142194. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  142195. */
  142196. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  142197. /**
  142198. * The base color has two different interpretations depending on the value of metalness.
  142199. * When the material is a metal, the base color is the specific measured reflectance value
  142200. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  142201. * of the material.
  142202. */
  142203. baseColor: Color3;
  142204. /**
  142205. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  142206. * well as opacity information in the alpha channel.
  142207. */
  142208. baseTexture: BaseTexture;
  142209. /**
  142210. * Specifies the metallic scalar value of the material.
  142211. * Can also be used to scale the metalness values of the metallic texture.
  142212. */
  142213. metallic: number;
  142214. /**
  142215. * Specifies the roughness scalar value of the material.
  142216. * Can also be used to scale the roughness values of the metallic texture.
  142217. */
  142218. roughness: number;
  142219. /**
  142220. * Texture containing both the metallic value in the B channel and the
  142221. * roughness value in the G channel to keep better precision.
  142222. */
  142223. metallicRoughnessTexture: BaseTexture;
  142224. /**
  142225. * Instantiates a new PBRMetalRoughnessMaterial instance.
  142226. *
  142227. * @param name The material name
  142228. * @param scene The scene the material will be use in.
  142229. */
  142230. constructor(name: string, scene: Scene);
  142231. /**
  142232. * Return the currrent class name of the material.
  142233. */
  142234. getClassName(): string;
  142235. /**
  142236. * Makes a duplicate of the current material.
  142237. * @param name - name to use for the new material.
  142238. */
  142239. clone(name: string): PBRMetallicRoughnessMaterial;
  142240. /**
  142241. * Serialize the material to a parsable JSON object.
  142242. */
  142243. serialize(): any;
  142244. /**
  142245. * Parses a JSON object correponding to the serialize function.
  142246. */
  142247. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  142248. }
  142249. }
  142250. declare module BABYLON {
  142251. /**
  142252. * The PBR material of BJS following the specular glossiness convention.
  142253. *
  142254. * This fits to the PBR convention in the GLTF definition:
  142255. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  142256. */
  142257. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  142258. /**
  142259. * Specifies the diffuse color of the material.
  142260. */
  142261. diffuseColor: Color3;
  142262. /**
  142263. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  142264. * channel.
  142265. */
  142266. diffuseTexture: BaseTexture;
  142267. /**
  142268. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  142269. */
  142270. specularColor: Color3;
  142271. /**
  142272. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  142273. */
  142274. glossiness: number;
  142275. /**
  142276. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  142277. */
  142278. specularGlossinessTexture: BaseTexture;
  142279. /**
  142280. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  142281. *
  142282. * @param name The material name
  142283. * @param scene The scene the material will be use in.
  142284. */
  142285. constructor(name: string, scene: Scene);
  142286. /**
  142287. * Return the currrent class name of the material.
  142288. */
  142289. getClassName(): string;
  142290. /**
  142291. * Makes a duplicate of the current material.
  142292. * @param name - name to use for the new material.
  142293. */
  142294. clone(name: string): PBRSpecularGlossinessMaterial;
  142295. /**
  142296. * Serialize the material to a parsable JSON object.
  142297. */
  142298. serialize(): any;
  142299. /**
  142300. * Parses a JSON object correponding to the serialize function.
  142301. */
  142302. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  142303. }
  142304. }
  142305. declare module BABYLON {
  142306. /**
  142307. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  142308. * It can help converting any input color in a desired output one. This can then be used to create effects
  142309. * from sepia, black and white to sixties or futuristic rendering...
  142310. *
  142311. * The only supported format is currently 3dl.
  142312. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  142313. */
  142314. export class ColorGradingTexture extends BaseTexture {
  142315. /**
  142316. * The texture URL.
  142317. */
  142318. url: string;
  142319. /**
  142320. * Empty line regex stored for GC.
  142321. */
  142322. private static _noneEmptyLineRegex;
  142323. private _textureMatrix;
  142324. private _onLoad;
  142325. /**
  142326. * Instantiates a ColorGradingTexture from the following parameters.
  142327. *
  142328. * @param url The location of the color gradind data (currently only supporting 3dl)
  142329. * @param sceneOrEngine The scene or engine the texture will be used in
  142330. * @param onLoad defines a callback triggered when the texture has been loaded
  142331. */
  142332. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  142333. /**
  142334. * Fires the onload event from the constructor if requested.
  142335. */
  142336. private _triggerOnLoad;
  142337. /**
  142338. * Returns the texture matrix used in most of the material.
  142339. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  142340. */
  142341. getTextureMatrix(): Matrix;
  142342. /**
  142343. * Occurs when the file being loaded is a .3dl LUT file.
  142344. */
  142345. private load3dlTexture;
  142346. /**
  142347. * Starts the loading process of the texture.
  142348. */
  142349. private loadTexture;
  142350. /**
  142351. * Clones the color gradind texture.
  142352. */
  142353. clone(): ColorGradingTexture;
  142354. /**
  142355. * Called during delayed load for textures.
  142356. */
  142357. delayLoad(): void;
  142358. /**
  142359. * Parses a color grading texture serialized by Babylon.
  142360. * @param parsedTexture The texture information being parsedTexture
  142361. * @param scene The scene to load the texture in
  142362. * @param rootUrl The root url of the data assets to load
  142363. * @return A color gradind texture
  142364. */
  142365. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  142366. /**
  142367. * Serializes the LUT texture to json format.
  142368. */
  142369. serialize(): any;
  142370. }
  142371. }
  142372. declare module BABYLON {
  142373. /**
  142374. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  142375. */
  142376. export class EquiRectangularCubeTexture extends BaseTexture {
  142377. /** The six faces of the cube. */
  142378. private static _FacesMapping;
  142379. private _noMipmap;
  142380. private _onLoad;
  142381. private _onError;
  142382. /** The size of the cubemap. */
  142383. private _size;
  142384. /** The buffer of the image. */
  142385. private _buffer;
  142386. /** The width of the input image. */
  142387. private _width;
  142388. /** The height of the input image. */
  142389. private _height;
  142390. /** The URL to the image. */
  142391. url: string;
  142392. /**
  142393. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  142394. * @param url The location of the image
  142395. * @param scene The scene the texture will be used in
  142396. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142397. * @param noMipmap Forces to not generate the mipmap if true
  142398. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142399. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142400. * @param onLoad — defines a callback called when texture is loaded
  142401. * @param onError — defines a callback called if there is an error
  142402. */
  142403. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  142404. /**
  142405. * Load the image data, by putting the image on a canvas and extracting its buffer.
  142406. */
  142407. private loadImage;
  142408. /**
  142409. * Convert the image buffer into a cubemap and create a CubeTexture.
  142410. */
  142411. private loadTexture;
  142412. /**
  142413. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  142414. * @param buffer The ArrayBuffer that should be converted.
  142415. * @returns The buffer as Float32Array.
  142416. */
  142417. private getFloat32ArrayFromArrayBuffer;
  142418. /**
  142419. * Get the current class name of the texture useful for serialization or dynamic coding.
  142420. * @returns "EquiRectangularCubeTexture"
  142421. */
  142422. getClassName(): string;
  142423. /**
  142424. * Create a clone of the current EquiRectangularCubeTexture and return it.
  142425. * @returns A clone of the current EquiRectangularCubeTexture.
  142426. */
  142427. clone(): EquiRectangularCubeTexture;
  142428. }
  142429. }
  142430. declare module BABYLON {
  142431. /**
  142432. * Defines the options related to the creation of an HtmlElementTexture
  142433. */
  142434. export interface IHtmlElementTextureOptions {
  142435. /**
  142436. * Defines wether mip maps should be created or not.
  142437. */
  142438. generateMipMaps?: boolean;
  142439. /**
  142440. * Defines the sampling mode of the texture.
  142441. */
  142442. samplingMode?: number;
  142443. /**
  142444. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  142445. */
  142446. engine: Nullable<ThinEngine>;
  142447. /**
  142448. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  142449. */
  142450. scene: Nullable<Scene>;
  142451. }
  142452. /**
  142453. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  142454. * To be as efficient as possible depending on your constraints nothing aside the first upload
  142455. * is automatically managed.
  142456. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  142457. * in your application.
  142458. *
  142459. * As the update is not automatic, you need to call them manually.
  142460. */
  142461. export class HtmlElementTexture extends BaseTexture {
  142462. /**
  142463. * The texture URL.
  142464. */
  142465. element: HTMLVideoElement | HTMLCanvasElement;
  142466. private static readonly DefaultOptions;
  142467. private _textureMatrix;
  142468. private _isVideo;
  142469. private _generateMipMaps;
  142470. private _samplingMode;
  142471. /**
  142472. * Instantiates a HtmlElementTexture from the following parameters.
  142473. *
  142474. * @param name Defines the name of the texture
  142475. * @param element Defines the video or canvas the texture is filled with
  142476. * @param options Defines the other none mandatory texture creation options
  142477. */
  142478. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  142479. private _createInternalTexture;
  142480. /**
  142481. * Returns the texture matrix used in most of the material.
  142482. */
  142483. getTextureMatrix(): Matrix;
  142484. /**
  142485. * Updates the content of the texture.
  142486. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  142487. */
  142488. update(invertY?: Nullable<boolean>): void;
  142489. }
  142490. }
  142491. declare module BABYLON {
  142492. /**
  142493. * Based on jsTGALoader - Javascript loader for TGA file
  142494. * By Vincent Thibault
  142495. * @see http://blog.robrowser.com/javascript-tga-loader.html
  142496. */
  142497. export class TGATools {
  142498. private static _TYPE_INDEXED;
  142499. private static _TYPE_RGB;
  142500. private static _TYPE_GREY;
  142501. private static _TYPE_RLE_INDEXED;
  142502. private static _TYPE_RLE_RGB;
  142503. private static _TYPE_RLE_GREY;
  142504. private static _ORIGIN_MASK;
  142505. private static _ORIGIN_SHIFT;
  142506. private static _ORIGIN_BL;
  142507. private static _ORIGIN_BR;
  142508. private static _ORIGIN_UL;
  142509. private static _ORIGIN_UR;
  142510. /**
  142511. * Gets the header of a TGA file
  142512. * @param data defines the TGA data
  142513. * @returns the header
  142514. */
  142515. static GetTGAHeader(data: Uint8Array): any;
  142516. /**
  142517. * Uploads TGA content to a Babylon Texture
  142518. * @hidden
  142519. */
  142520. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  142521. /** @hidden */
  142522. 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;
  142523. /** @hidden */
  142524. 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;
  142525. /** @hidden */
  142526. 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;
  142527. /** @hidden */
  142528. 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;
  142529. /** @hidden */
  142530. 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;
  142531. /** @hidden */
  142532. 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;
  142533. }
  142534. }
  142535. declare module BABYLON {
  142536. /**
  142537. * Implementation of the TGA Texture Loader.
  142538. * @hidden
  142539. */
  142540. export class _TGATextureLoader implements IInternalTextureLoader {
  142541. /**
  142542. * Defines wether the loader supports cascade loading the different faces.
  142543. */
  142544. readonly supportCascades: boolean;
  142545. /**
  142546. * This returns if the loader support the current file information.
  142547. * @param extension defines the file extension of the file being loaded
  142548. * @returns true if the loader can load the specified file
  142549. */
  142550. canLoad(extension: string): boolean;
  142551. /**
  142552. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142553. * @param data contains the texture data
  142554. * @param texture defines the BabylonJS internal texture
  142555. * @param createPolynomials will be true if polynomials have been requested
  142556. * @param onLoad defines the callback to trigger once the texture is ready
  142557. * @param onError defines the callback to trigger in case of error
  142558. */
  142559. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142560. /**
  142561. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142562. * @param data contains the texture data
  142563. * @param texture defines the BabylonJS internal texture
  142564. * @param callback defines the method to call once ready to upload
  142565. */
  142566. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142567. }
  142568. }
  142569. declare module BABYLON {
  142570. /**
  142571. * Info about the .basis files
  142572. */
  142573. class BasisFileInfo {
  142574. /**
  142575. * If the file has alpha
  142576. */
  142577. hasAlpha: boolean;
  142578. /**
  142579. * Info about each image of the basis file
  142580. */
  142581. images: Array<{
  142582. levels: Array<{
  142583. width: number;
  142584. height: number;
  142585. transcodedPixels: ArrayBufferView;
  142586. }>;
  142587. }>;
  142588. }
  142589. /**
  142590. * Result of transcoding a basis file
  142591. */
  142592. class TranscodeResult {
  142593. /**
  142594. * Info about the .basis file
  142595. */
  142596. fileInfo: BasisFileInfo;
  142597. /**
  142598. * Format to use when loading the file
  142599. */
  142600. format: number;
  142601. }
  142602. /**
  142603. * Configuration options for the Basis transcoder
  142604. */
  142605. export class BasisTranscodeConfiguration {
  142606. /**
  142607. * Supported compression formats used to determine the supported output format of the transcoder
  142608. */
  142609. supportedCompressionFormats?: {
  142610. /**
  142611. * etc1 compression format
  142612. */
  142613. etc1?: boolean;
  142614. /**
  142615. * s3tc compression format
  142616. */
  142617. s3tc?: boolean;
  142618. /**
  142619. * pvrtc compression format
  142620. */
  142621. pvrtc?: boolean;
  142622. /**
  142623. * etc2 compression format
  142624. */
  142625. etc2?: boolean;
  142626. };
  142627. /**
  142628. * If mipmap levels should be loaded for transcoded images (Default: true)
  142629. */
  142630. loadMipmapLevels?: boolean;
  142631. /**
  142632. * Index of a single image to load (Default: all images)
  142633. */
  142634. loadSingleImage?: number;
  142635. }
  142636. /**
  142637. * Used to load .Basis files
  142638. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  142639. */
  142640. export class BasisTools {
  142641. private static _IgnoreSupportedFormats;
  142642. /**
  142643. * URL to use when loading the basis transcoder
  142644. */
  142645. static JSModuleURL: string;
  142646. /**
  142647. * URL to use when loading the wasm module for the transcoder
  142648. */
  142649. static WasmModuleURL: string;
  142650. /**
  142651. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  142652. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  142653. * @returns internal format corresponding to the Basis format
  142654. */
  142655. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  142656. private static _WorkerPromise;
  142657. private static _Worker;
  142658. private static _actionId;
  142659. private static _CreateWorkerAsync;
  142660. /**
  142661. * Transcodes a loaded image file to compressed pixel data
  142662. * @param data image data to transcode
  142663. * @param config configuration options for the transcoding
  142664. * @returns a promise resulting in the transcoded image
  142665. */
  142666. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  142667. /**
  142668. * Loads a texture from the transcode result
  142669. * @param texture texture load to
  142670. * @param transcodeResult the result of transcoding the basis file to load from
  142671. */
  142672. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  142673. }
  142674. }
  142675. declare module BABYLON {
  142676. /**
  142677. * Loader for .basis file format
  142678. */
  142679. export class _BasisTextureLoader implements IInternalTextureLoader {
  142680. /**
  142681. * Defines whether the loader supports cascade loading the different faces.
  142682. */
  142683. readonly supportCascades: boolean;
  142684. /**
  142685. * This returns if the loader support the current file information.
  142686. * @param extension defines the file extension of the file being loaded
  142687. * @returns true if the loader can load the specified file
  142688. */
  142689. canLoad(extension: string): boolean;
  142690. /**
  142691. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142692. * @param data contains the texture data
  142693. * @param texture defines the BabylonJS internal texture
  142694. * @param createPolynomials will be true if polynomials have been requested
  142695. * @param onLoad defines the callback to trigger once the texture is ready
  142696. * @param onError defines the callback to trigger in case of error
  142697. */
  142698. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142699. /**
  142700. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142701. * @param data contains the texture data
  142702. * @param texture defines the BabylonJS internal texture
  142703. * @param callback defines the method to call once ready to upload
  142704. */
  142705. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142706. }
  142707. }
  142708. declare module BABYLON {
  142709. /**
  142710. * Defines the basic options interface of a TexturePacker Frame
  142711. */
  142712. export interface ITexturePackerFrame {
  142713. /**
  142714. * The frame ID
  142715. */
  142716. id: number;
  142717. /**
  142718. * The frames Scale
  142719. */
  142720. scale: Vector2;
  142721. /**
  142722. * The Frames offset
  142723. */
  142724. offset: Vector2;
  142725. }
  142726. /**
  142727. * This is a support class for frame Data on texture packer sets.
  142728. */
  142729. export class TexturePackerFrame implements ITexturePackerFrame {
  142730. /**
  142731. * The frame ID
  142732. */
  142733. id: number;
  142734. /**
  142735. * The frames Scale
  142736. */
  142737. scale: Vector2;
  142738. /**
  142739. * The Frames offset
  142740. */
  142741. offset: Vector2;
  142742. /**
  142743. * Initializes a texture package frame.
  142744. * @param id The numerical frame identifier
  142745. * @param scale Scalar Vector2 for UV frame
  142746. * @param offset Vector2 for the frame position in UV units.
  142747. * @returns TexturePackerFrame
  142748. */
  142749. constructor(id: number, scale: Vector2, offset: Vector2);
  142750. }
  142751. }
  142752. declare module BABYLON {
  142753. /**
  142754. * Defines the basic options interface of a TexturePacker
  142755. */
  142756. export interface ITexturePackerOptions {
  142757. /**
  142758. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  142759. */
  142760. map?: string[];
  142761. /**
  142762. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142763. */
  142764. uvsIn?: string;
  142765. /**
  142766. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142767. */
  142768. uvsOut?: string;
  142769. /**
  142770. * number representing the layout style. Defaults to LAYOUT_STRIP
  142771. */
  142772. layout?: number;
  142773. /**
  142774. * number of columns if using custom column count layout(2). This defaults to 4.
  142775. */
  142776. colnum?: number;
  142777. /**
  142778. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  142779. */
  142780. updateInputMeshes?: boolean;
  142781. /**
  142782. * boolean flag to dispose all the source textures. Defaults to true.
  142783. */
  142784. disposeSources?: boolean;
  142785. /**
  142786. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  142787. */
  142788. fillBlanks?: boolean;
  142789. /**
  142790. * string value representing the context fill style color. Defaults to 'black'.
  142791. */
  142792. customFillColor?: string;
  142793. /**
  142794. * Width and Height Value of each Frame in the TexturePacker Sets
  142795. */
  142796. frameSize?: number;
  142797. /**
  142798. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  142799. */
  142800. paddingRatio?: number;
  142801. /**
  142802. * Number that declares the fill method for the padding gutter.
  142803. */
  142804. paddingMode?: number;
  142805. /**
  142806. * If in SUBUV_COLOR padding mode what color to use.
  142807. */
  142808. paddingColor?: Color3 | Color4;
  142809. }
  142810. /**
  142811. * Defines the basic interface of a TexturePacker JSON File
  142812. */
  142813. export interface ITexturePackerJSON {
  142814. /**
  142815. * The frame ID
  142816. */
  142817. name: string;
  142818. /**
  142819. * The base64 channel data
  142820. */
  142821. sets: any;
  142822. /**
  142823. * The options of the Packer
  142824. */
  142825. options: ITexturePackerOptions;
  142826. /**
  142827. * The frame data of the Packer
  142828. */
  142829. frames: Array<number>;
  142830. }
  142831. /**
  142832. * This is a support class that generates a series of packed texture sets.
  142833. * @see https://doc.babylonjs.com/babylon101/materials
  142834. */
  142835. export class TexturePacker {
  142836. /** Packer Layout Constant 0 */
  142837. static readonly LAYOUT_STRIP: number;
  142838. /** Packer Layout Constant 1 */
  142839. static readonly LAYOUT_POWER2: number;
  142840. /** Packer Layout Constant 2 */
  142841. static readonly LAYOUT_COLNUM: number;
  142842. /** Packer Layout Constant 0 */
  142843. static readonly SUBUV_WRAP: number;
  142844. /** Packer Layout Constant 1 */
  142845. static readonly SUBUV_EXTEND: number;
  142846. /** Packer Layout Constant 2 */
  142847. static readonly SUBUV_COLOR: number;
  142848. /** The Name of the Texture Package */
  142849. name: string;
  142850. /** The scene scope of the TexturePacker */
  142851. scene: Scene;
  142852. /** The Meshes to target */
  142853. meshes: AbstractMesh[];
  142854. /** Arguments passed with the Constructor */
  142855. options: ITexturePackerOptions;
  142856. /** The promise that is started upon initialization */
  142857. promise: Nullable<Promise<TexturePacker | string>>;
  142858. /** The Container object for the channel sets that are generated */
  142859. sets: object;
  142860. /** The Container array for the frames that are generated */
  142861. frames: TexturePackerFrame[];
  142862. /** The expected number of textures the system is parsing. */
  142863. private _expecting;
  142864. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  142865. private _paddingValue;
  142866. /**
  142867. * Initializes a texture package series from an array of meshes or a single mesh.
  142868. * @param name The name of the package
  142869. * @param meshes The target meshes to compose the package from
  142870. * @param options The arguments that texture packer should follow while building.
  142871. * @param scene The scene which the textures are scoped to.
  142872. * @returns TexturePacker
  142873. */
  142874. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  142875. /**
  142876. * Starts the package process
  142877. * @param resolve The promises resolution function
  142878. * @returns TexturePacker
  142879. */
  142880. private _createFrames;
  142881. /**
  142882. * Calculates the Size of the Channel Sets
  142883. * @returns Vector2
  142884. */
  142885. private _calculateSize;
  142886. /**
  142887. * Calculates the UV data for the frames.
  142888. * @param baseSize the base frameSize
  142889. * @param padding the base frame padding
  142890. * @param dtSize size of the Dynamic Texture for that channel
  142891. * @param dtUnits is 1/dtSize
  142892. * @param update flag to update the input meshes
  142893. */
  142894. private _calculateMeshUVFrames;
  142895. /**
  142896. * Calculates the frames Offset.
  142897. * @param index of the frame
  142898. * @returns Vector2
  142899. */
  142900. private _getFrameOffset;
  142901. /**
  142902. * Updates a Mesh to the frame data
  142903. * @param mesh that is the target
  142904. * @param frameID or the frame index
  142905. */
  142906. private _updateMeshUV;
  142907. /**
  142908. * Updates a Meshes materials to use the texture packer channels
  142909. * @param m is the mesh to target
  142910. * @param force all channels on the packer to be set.
  142911. */
  142912. private _updateTextureReferences;
  142913. /**
  142914. * Public method to set a Mesh to a frame
  142915. * @param m that is the target
  142916. * @param frameID or the frame index
  142917. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  142918. */
  142919. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  142920. /**
  142921. * Starts the async promise to compile the texture packer.
  142922. * @returns Promise<void>
  142923. */
  142924. processAsync(): Promise<void>;
  142925. /**
  142926. * Disposes all textures associated with this packer
  142927. */
  142928. dispose(): void;
  142929. /**
  142930. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  142931. * @param imageType is the image type to use.
  142932. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  142933. */
  142934. download(imageType?: string, quality?: number): void;
  142935. /**
  142936. * Public method to load a texturePacker JSON file.
  142937. * @param data of the JSON file in string format.
  142938. */
  142939. updateFromJSON(data: string): void;
  142940. }
  142941. }
  142942. declare module BABYLON {
  142943. /**
  142944. * 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.
  142945. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142946. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142947. */
  142948. export class CustomProceduralTexture extends ProceduralTexture {
  142949. private _animate;
  142950. private _time;
  142951. private _config;
  142952. private _texturePath;
  142953. /**
  142954. * Instantiates a new Custom Procedural Texture.
  142955. * 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.
  142956. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142957. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142958. * @param name Define the name of the texture
  142959. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  142960. * @param size Define the size of the texture to create
  142961. * @param scene Define the scene the texture belongs to
  142962. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  142963. * @param generateMipMaps Define if the texture should creates mip maps or not
  142964. */
  142965. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142966. private _loadJson;
  142967. /**
  142968. * Is the texture ready to be used ? (rendered at least once)
  142969. * @returns true if ready, otherwise, false.
  142970. */
  142971. isReady(): boolean;
  142972. /**
  142973. * Render the texture to its associated render target.
  142974. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  142975. */
  142976. render(useCameraPostProcess?: boolean): void;
  142977. /**
  142978. * Update the list of dependant textures samplers in the shader.
  142979. */
  142980. updateTextures(): void;
  142981. /**
  142982. * Update the uniform values of the procedural texture in the shader.
  142983. */
  142984. updateShaderUniforms(): void;
  142985. /**
  142986. * Define if the texture animates or not.
  142987. */
  142988. get animate(): boolean;
  142989. set animate(value: boolean);
  142990. }
  142991. }
  142992. declare module BABYLON {
  142993. /** @hidden */
  142994. export var noisePixelShader: {
  142995. name: string;
  142996. shader: string;
  142997. };
  142998. }
  142999. declare module BABYLON {
  143000. /**
  143001. * Class used to generate noise procedural textures
  143002. */
  143003. export class NoiseProceduralTexture extends ProceduralTexture {
  143004. /** Gets or sets the start time (default is 0) */
  143005. time: number;
  143006. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  143007. brightness: number;
  143008. /** Defines the number of octaves to process */
  143009. octaves: number;
  143010. /** Defines the level of persistence (0.8 by default) */
  143011. persistence: number;
  143012. /** Gets or sets animation speed factor (default is 1) */
  143013. animationSpeedFactor: number;
  143014. /**
  143015. * Creates a new NoiseProceduralTexture
  143016. * @param name defines the name fo the texture
  143017. * @param size defines the size of the texture (default is 256)
  143018. * @param scene defines the hosting scene
  143019. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  143020. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  143021. */
  143022. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143023. private _updateShaderUniforms;
  143024. protected _getDefines(): string;
  143025. /** Generate the current state of the procedural texture */
  143026. render(useCameraPostProcess?: boolean): void;
  143027. /**
  143028. * Serializes this noise procedural texture
  143029. * @returns a serialized noise procedural texture object
  143030. */
  143031. serialize(): any;
  143032. /**
  143033. * Clone the texture.
  143034. * @returns the cloned texture
  143035. */
  143036. clone(): NoiseProceduralTexture;
  143037. /**
  143038. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  143039. * @param parsedTexture defines parsed texture data
  143040. * @param scene defines the current scene
  143041. * @param rootUrl defines the root URL containing noise procedural texture information
  143042. * @returns a parsed NoiseProceduralTexture
  143043. */
  143044. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  143045. }
  143046. }
  143047. declare module BABYLON {
  143048. /**
  143049. * Raw cube texture where the raw buffers are passed in
  143050. */
  143051. export class RawCubeTexture extends CubeTexture {
  143052. /**
  143053. * Creates a cube texture where the raw buffers are passed in.
  143054. * @param scene defines the scene the texture is attached to
  143055. * @param data defines the array of data to use to create each face
  143056. * @param size defines the size of the textures
  143057. * @param format defines the format of the data
  143058. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  143059. * @param generateMipMaps defines if the engine should generate the mip levels
  143060. * @param invertY defines if data must be stored with Y axis inverted
  143061. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  143062. * @param compression defines the compression used (null by default)
  143063. */
  143064. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  143065. /**
  143066. * Updates the raw cube texture.
  143067. * @param data defines the data to store
  143068. * @param format defines the data format
  143069. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  143070. * @param invertY defines if data must be stored with Y axis inverted
  143071. * @param compression defines the compression used (null by default)
  143072. * @param level defines which level of the texture to update
  143073. */
  143074. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  143075. /**
  143076. * Updates a raw cube texture with RGBD encoded data.
  143077. * @param data defines the array of data [mipmap][face] to use to create each face
  143078. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  143079. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  143080. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  143081. * @returns a promsie that resolves when the operation is complete
  143082. */
  143083. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  143084. /**
  143085. * Clones the raw cube texture.
  143086. * @return a new cube texture
  143087. */
  143088. clone(): CubeTexture;
  143089. /** @hidden */
  143090. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  143091. }
  143092. }
  143093. declare module BABYLON {
  143094. /**
  143095. * Class used to store 2D array textures containing user data
  143096. */
  143097. export class RawTexture2DArray extends Texture {
  143098. /** Gets or sets the texture format to use */
  143099. format: number;
  143100. /**
  143101. * Create a new RawTexture2DArray
  143102. * @param data defines the data of the texture
  143103. * @param width defines the width of the texture
  143104. * @param height defines the height of the texture
  143105. * @param depth defines the number of layers of the texture
  143106. * @param format defines the texture format to use
  143107. * @param scene defines the hosting scene
  143108. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143109. * @param invertY defines if texture must be stored with Y axis inverted
  143110. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143111. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143112. */
  143113. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143114. /** Gets or sets the texture format to use */
  143115. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143116. /**
  143117. * Update the texture with new data
  143118. * @param data defines the data to store in the texture
  143119. */
  143120. update(data: ArrayBufferView): void;
  143121. }
  143122. }
  143123. declare module BABYLON {
  143124. /**
  143125. * Class used to store 3D textures containing user data
  143126. */
  143127. export class RawTexture3D extends Texture {
  143128. /** Gets or sets the texture format to use */
  143129. format: number;
  143130. /**
  143131. * Create a new RawTexture3D
  143132. * @param data defines the data of the texture
  143133. * @param width defines the width of the texture
  143134. * @param height defines the height of the texture
  143135. * @param depth defines the depth of the texture
  143136. * @param format defines the texture format to use
  143137. * @param scene defines the hosting scene
  143138. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143139. * @param invertY defines if texture must be stored with Y axis inverted
  143140. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143141. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143142. */
  143143. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143144. /** Gets or sets the texture format to use */
  143145. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143146. /**
  143147. * Update the texture with new data
  143148. * @param data defines the data to store in the texture
  143149. */
  143150. update(data: ArrayBufferView): void;
  143151. }
  143152. }
  143153. declare module BABYLON {
  143154. /**
  143155. * Creates a refraction texture used by refraction channel of the standard material.
  143156. * It is like a mirror but to see through a material.
  143157. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143158. */
  143159. export class RefractionTexture extends RenderTargetTexture {
  143160. /**
  143161. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  143162. * 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.
  143163. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143164. */
  143165. refractionPlane: Plane;
  143166. /**
  143167. * Define how deep under the surface we should see.
  143168. */
  143169. depth: number;
  143170. /**
  143171. * Creates a refraction texture used by refraction channel of the standard material.
  143172. * It is like a mirror but to see through a material.
  143173. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143174. * @param name Define the texture name
  143175. * @param size Define the size of the underlying texture
  143176. * @param scene Define the scene the refraction belongs to
  143177. * @param generateMipMaps Define if we need to generate mips level for the refraction
  143178. */
  143179. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  143180. /**
  143181. * Clone the refraction texture.
  143182. * @returns the cloned texture
  143183. */
  143184. clone(): RefractionTexture;
  143185. /**
  143186. * Serialize the texture to a JSON representation you could use in Parse later on
  143187. * @returns the serialized JSON representation
  143188. */
  143189. serialize(): any;
  143190. }
  143191. }
  143192. declare module BABYLON {
  143193. /**
  143194. * Block used to add support for vertex skinning (bones)
  143195. */
  143196. export class BonesBlock extends NodeMaterialBlock {
  143197. /**
  143198. * Creates a new BonesBlock
  143199. * @param name defines the block name
  143200. */
  143201. constructor(name: string);
  143202. /**
  143203. * Initialize the block and prepare the context for build
  143204. * @param state defines the state that will be used for the build
  143205. */
  143206. initialize(state: NodeMaterialBuildState): void;
  143207. /**
  143208. * Gets the current class name
  143209. * @returns the class name
  143210. */
  143211. getClassName(): string;
  143212. /**
  143213. * Gets the matrix indices input component
  143214. */
  143215. get matricesIndices(): NodeMaterialConnectionPoint;
  143216. /**
  143217. * Gets the matrix weights input component
  143218. */
  143219. get matricesWeights(): NodeMaterialConnectionPoint;
  143220. /**
  143221. * Gets the extra matrix indices input component
  143222. */
  143223. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  143224. /**
  143225. * Gets the extra matrix weights input component
  143226. */
  143227. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  143228. /**
  143229. * Gets the world input component
  143230. */
  143231. get world(): NodeMaterialConnectionPoint;
  143232. /**
  143233. * Gets the output component
  143234. */
  143235. get output(): NodeMaterialConnectionPoint;
  143236. autoConfigure(material: NodeMaterial): void;
  143237. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  143238. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143239. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143240. protected _buildBlock(state: NodeMaterialBuildState): this;
  143241. }
  143242. }
  143243. declare module BABYLON {
  143244. /**
  143245. * Block used to add support for instances
  143246. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  143247. */
  143248. export class InstancesBlock extends NodeMaterialBlock {
  143249. /**
  143250. * Creates a new InstancesBlock
  143251. * @param name defines the block name
  143252. */
  143253. constructor(name: string);
  143254. /**
  143255. * Gets the current class name
  143256. * @returns the class name
  143257. */
  143258. getClassName(): string;
  143259. /**
  143260. * Gets the first world row input component
  143261. */
  143262. get world0(): NodeMaterialConnectionPoint;
  143263. /**
  143264. * Gets the second world row input component
  143265. */
  143266. get world1(): NodeMaterialConnectionPoint;
  143267. /**
  143268. * Gets the third world row input component
  143269. */
  143270. get world2(): NodeMaterialConnectionPoint;
  143271. /**
  143272. * Gets the forth world row input component
  143273. */
  143274. get world3(): NodeMaterialConnectionPoint;
  143275. /**
  143276. * Gets the world input component
  143277. */
  143278. get world(): NodeMaterialConnectionPoint;
  143279. /**
  143280. * Gets the output component
  143281. */
  143282. get output(): NodeMaterialConnectionPoint;
  143283. /**
  143284. * Gets the isntanceID component
  143285. */
  143286. get instanceID(): NodeMaterialConnectionPoint;
  143287. autoConfigure(material: NodeMaterial): void;
  143288. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  143289. protected _buildBlock(state: NodeMaterialBuildState): this;
  143290. }
  143291. }
  143292. declare module BABYLON {
  143293. /**
  143294. * Block used to add morph targets support to vertex shader
  143295. */
  143296. export class MorphTargetsBlock extends NodeMaterialBlock {
  143297. private _repeatableContentAnchor;
  143298. /**
  143299. * Create a new MorphTargetsBlock
  143300. * @param name defines the block name
  143301. */
  143302. constructor(name: string);
  143303. /**
  143304. * Gets the current class name
  143305. * @returns the class name
  143306. */
  143307. getClassName(): string;
  143308. /**
  143309. * Gets the position input component
  143310. */
  143311. get position(): NodeMaterialConnectionPoint;
  143312. /**
  143313. * Gets the normal input component
  143314. */
  143315. get normal(): NodeMaterialConnectionPoint;
  143316. /**
  143317. * Gets the tangent input component
  143318. */
  143319. get tangent(): NodeMaterialConnectionPoint;
  143320. /**
  143321. * Gets the tangent input component
  143322. */
  143323. get uv(): NodeMaterialConnectionPoint;
  143324. /**
  143325. * Gets the position output component
  143326. */
  143327. get positionOutput(): NodeMaterialConnectionPoint;
  143328. /**
  143329. * Gets the normal output component
  143330. */
  143331. get normalOutput(): NodeMaterialConnectionPoint;
  143332. /**
  143333. * Gets the tangent output component
  143334. */
  143335. get tangentOutput(): NodeMaterialConnectionPoint;
  143336. /**
  143337. * Gets the tangent output component
  143338. */
  143339. get uvOutput(): NodeMaterialConnectionPoint;
  143340. initialize(state: NodeMaterialBuildState): void;
  143341. autoConfigure(material: NodeMaterial): void;
  143342. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143344. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  143345. protected _buildBlock(state: NodeMaterialBuildState): this;
  143346. }
  143347. }
  143348. declare module BABYLON {
  143349. /**
  143350. * Block used to get data information from a light
  143351. */
  143352. export class LightInformationBlock extends NodeMaterialBlock {
  143353. private _lightDataUniformName;
  143354. private _lightColorUniformName;
  143355. private _lightTypeDefineName;
  143356. /**
  143357. * Gets or sets the light associated with this block
  143358. */
  143359. light: Nullable<Light>;
  143360. /**
  143361. * Creates a new LightInformationBlock
  143362. * @param name defines the block name
  143363. */
  143364. constructor(name: string);
  143365. /**
  143366. * Gets the current class name
  143367. * @returns the class name
  143368. */
  143369. getClassName(): string;
  143370. /**
  143371. * Gets the world position input component
  143372. */
  143373. get worldPosition(): NodeMaterialConnectionPoint;
  143374. /**
  143375. * Gets the direction output component
  143376. */
  143377. get direction(): NodeMaterialConnectionPoint;
  143378. /**
  143379. * Gets the direction output component
  143380. */
  143381. get color(): NodeMaterialConnectionPoint;
  143382. /**
  143383. * Gets the direction output component
  143384. */
  143385. get intensity(): NodeMaterialConnectionPoint;
  143386. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143387. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143388. protected _buildBlock(state: NodeMaterialBuildState): this;
  143389. serialize(): any;
  143390. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143391. }
  143392. }
  143393. declare module BABYLON {
  143394. /**
  143395. * Block used to add image processing support to fragment shader
  143396. */
  143397. export class ImageProcessingBlock extends NodeMaterialBlock {
  143398. /**
  143399. * Create a new ImageProcessingBlock
  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 color input component
  143410. */
  143411. get color(): NodeMaterialConnectionPoint;
  143412. /**
  143413. * Gets the output component
  143414. */
  143415. get output(): NodeMaterialConnectionPoint;
  143416. /**
  143417. * Initialize the block and prepare the context for build
  143418. * @param state defines the state that will be used for the build
  143419. */
  143420. initialize(state: NodeMaterialBuildState): void;
  143421. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  143422. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143423. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143424. protected _buildBlock(state: NodeMaterialBuildState): this;
  143425. }
  143426. }
  143427. declare module BABYLON {
  143428. /**
  143429. * Block used to pertub normals based on a normal map
  143430. */
  143431. export class PerturbNormalBlock extends NodeMaterialBlock {
  143432. private _tangentSpaceParameterName;
  143433. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143434. invertX: boolean;
  143435. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  143436. invertY: boolean;
  143437. /**
  143438. * Create a new PerturbNormalBlock
  143439. * @param name defines the block name
  143440. */
  143441. constructor(name: string);
  143442. /**
  143443. * Gets the current class name
  143444. * @returns the class name
  143445. */
  143446. getClassName(): string;
  143447. /**
  143448. * Gets the world position input component
  143449. */
  143450. get worldPosition(): NodeMaterialConnectionPoint;
  143451. /**
  143452. * Gets the world normal input component
  143453. */
  143454. get worldNormal(): NodeMaterialConnectionPoint;
  143455. /**
  143456. * Gets the world tangent input component
  143457. */
  143458. get worldTangent(): NodeMaterialConnectionPoint;
  143459. /**
  143460. * Gets the uv input component
  143461. */
  143462. get uv(): NodeMaterialConnectionPoint;
  143463. /**
  143464. * Gets the normal map color input component
  143465. */
  143466. get normalMapColor(): NodeMaterialConnectionPoint;
  143467. /**
  143468. * Gets the strength input component
  143469. */
  143470. get strength(): NodeMaterialConnectionPoint;
  143471. /**
  143472. * Gets the output component
  143473. */
  143474. get output(): NodeMaterialConnectionPoint;
  143475. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143476. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143477. autoConfigure(material: NodeMaterial): void;
  143478. protected _buildBlock(state: NodeMaterialBuildState): this;
  143479. protected _dumpPropertiesCode(): string;
  143480. serialize(): any;
  143481. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143482. }
  143483. }
  143484. declare module BABYLON {
  143485. /**
  143486. * Block used to discard a pixel if a value is smaller than a cutoff
  143487. */
  143488. export class DiscardBlock extends NodeMaterialBlock {
  143489. /**
  143490. * Create a new DiscardBlock
  143491. * @param name defines the block name
  143492. */
  143493. constructor(name: string);
  143494. /**
  143495. * Gets the current class name
  143496. * @returns the class name
  143497. */
  143498. getClassName(): string;
  143499. /**
  143500. * Gets the color input component
  143501. */
  143502. get value(): NodeMaterialConnectionPoint;
  143503. /**
  143504. * Gets the cutoff input component
  143505. */
  143506. get cutoff(): NodeMaterialConnectionPoint;
  143507. protected _buildBlock(state: NodeMaterialBuildState): this;
  143508. }
  143509. }
  143510. declare module BABYLON {
  143511. /**
  143512. * Block used to test if the fragment shader is front facing
  143513. */
  143514. export class FrontFacingBlock extends NodeMaterialBlock {
  143515. /**
  143516. * Creates a new FrontFacingBlock
  143517. * @param name defines the block name
  143518. */
  143519. constructor(name: string);
  143520. /**
  143521. * Gets the current class name
  143522. * @returns the class name
  143523. */
  143524. getClassName(): string;
  143525. /**
  143526. * Gets the output component
  143527. */
  143528. get output(): NodeMaterialConnectionPoint;
  143529. protected _buildBlock(state: NodeMaterialBuildState): this;
  143530. }
  143531. }
  143532. declare module BABYLON {
  143533. /**
  143534. * Block used to get the derivative value on x and y of a given input
  143535. */
  143536. export class DerivativeBlock extends NodeMaterialBlock {
  143537. /**
  143538. * Create a new DerivativeBlock
  143539. * @param name defines the block name
  143540. */
  143541. constructor(name: string);
  143542. /**
  143543. * Gets the current class name
  143544. * @returns the class name
  143545. */
  143546. getClassName(): string;
  143547. /**
  143548. * Gets the input component
  143549. */
  143550. get input(): NodeMaterialConnectionPoint;
  143551. /**
  143552. * Gets the derivative output on x
  143553. */
  143554. get dx(): NodeMaterialConnectionPoint;
  143555. /**
  143556. * Gets the derivative output on y
  143557. */
  143558. get dy(): NodeMaterialConnectionPoint;
  143559. protected _buildBlock(state: NodeMaterialBuildState): this;
  143560. }
  143561. }
  143562. declare module BABYLON {
  143563. /**
  143564. * Block used to make gl_FragCoord available
  143565. */
  143566. export class FragCoordBlock extends NodeMaterialBlock {
  143567. /**
  143568. * Creates a new FragCoordBlock
  143569. * @param name defines the block name
  143570. */
  143571. constructor(name: string);
  143572. /**
  143573. * Gets the current class name
  143574. * @returns the class name
  143575. */
  143576. getClassName(): string;
  143577. /**
  143578. * Gets the xy component
  143579. */
  143580. get xy(): NodeMaterialConnectionPoint;
  143581. /**
  143582. * Gets the xyz component
  143583. */
  143584. get xyz(): NodeMaterialConnectionPoint;
  143585. /**
  143586. * Gets the xyzw component
  143587. */
  143588. get xyzw(): NodeMaterialConnectionPoint;
  143589. /**
  143590. * Gets the x component
  143591. */
  143592. get x(): NodeMaterialConnectionPoint;
  143593. /**
  143594. * Gets the y component
  143595. */
  143596. get y(): NodeMaterialConnectionPoint;
  143597. /**
  143598. * Gets the z component
  143599. */
  143600. get z(): NodeMaterialConnectionPoint;
  143601. /**
  143602. * Gets the w component
  143603. */
  143604. get output(): NodeMaterialConnectionPoint;
  143605. protected writeOutputs(state: NodeMaterialBuildState): string;
  143606. protected _buildBlock(state: NodeMaterialBuildState): this;
  143607. }
  143608. }
  143609. declare module BABYLON {
  143610. /**
  143611. * Block used to get the screen sizes
  143612. */
  143613. export class ScreenSizeBlock extends NodeMaterialBlock {
  143614. private _varName;
  143615. private _scene;
  143616. /**
  143617. * Creates a new ScreenSizeBlock
  143618. * @param name defines the block name
  143619. */
  143620. constructor(name: string);
  143621. /**
  143622. * Gets the current class name
  143623. * @returns the class name
  143624. */
  143625. getClassName(): string;
  143626. /**
  143627. * Gets the xy component
  143628. */
  143629. get xy(): NodeMaterialConnectionPoint;
  143630. /**
  143631. * Gets the x component
  143632. */
  143633. get x(): NodeMaterialConnectionPoint;
  143634. /**
  143635. * Gets the y component
  143636. */
  143637. get y(): NodeMaterialConnectionPoint;
  143638. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143639. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  143640. protected _buildBlock(state: NodeMaterialBuildState): this;
  143641. }
  143642. }
  143643. declare module BABYLON {
  143644. /**
  143645. * Block used to add support for scene fog
  143646. */
  143647. export class FogBlock extends NodeMaterialBlock {
  143648. private _fogDistanceName;
  143649. private _fogParameters;
  143650. /**
  143651. * Create a new FogBlock
  143652. * @param name defines the block name
  143653. */
  143654. constructor(name: string);
  143655. /**
  143656. * Gets the current class name
  143657. * @returns the class name
  143658. */
  143659. getClassName(): string;
  143660. /**
  143661. * Gets the world position input component
  143662. */
  143663. get worldPosition(): NodeMaterialConnectionPoint;
  143664. /**
  143665. * Gets the view input component
  143666. */
  143667. get view(): NodeMaterialConnectionPoint;
  143668. /**
  143669. * Gets the color input component
  143670. */
  143671. get input(): NodeMaterialConnectionPoint;
  143672. /**
  143673. * Gets the fog color input component
  143674. */
  143675. get fogColor(): NodeMaterialConnectionPoint;
  143676. /**
  143677. * Gets the output component
  143678. */
  143679. get output(): NodeMaterialConnectionPoint;
  143680. autoConfigure(material: NodeMaterial): void;
  143681. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143682. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143683. protected _buildBlock(state: NodeMaterialBuildState): this;
  143684. }
  143685. }
  143686. declare module BABYLON {
  143687. /**
  143688. * Block used to add light in the fragment shader
  143689. */
  143690. export class LightBlock extends NodeMaterialBlock {
  143691. private _lightId;
  143692. /**
  143693. * Gets or sets the light associated with this block
  143694. */
  143695. light: Nullable<Light>;
  143696. /**
  143697. * Create a new LightBlock
  143698. * @param name defines the block name
  143699. */
  143700. constructor(name: string);
  143701. /**
  143702. * Gets the current class name
  143703. * @returns the class name
  143704. */
  143705. getClassName(): string;
  143706. /**
  143707. * Gets the world position input component
  143708. */
  143709. get worldPosition(): NodeMaterialConnectionPoint;
  143710. /**
  143711. * Gets the world normal input component
  143712. */
  143713. get worldNormal(): NodeMaterialConnectionPoint;
  143714. /**
  143715. * Gets the camera (or eye) position component
  143716. */
  143717. get cameraPosition(): NodeMaterialConnectionPoint;
  143718. /**
  143719. * Gets the glossiness component
  143720. */
  143721. get glossiness(): NodeMaterialConnectionPoint;
  143722. /**
  143723. * Gets the glossinness power component
  143724. */
  143725. get glossPower(): NodeMaterialConnectionPoint;
  143726. /**
  143727. * Gets the diffuse color component
  143728. */
  143729. get diffuseColor(): NodeMaterialConnectionPoint;
  143730. /**
  143731. * Gets the specular color component
  143732. */
  143733. get specularColor(): NodeMaterialConnectionPoint;
  143734. /**
  143735. * Gets the diffuse output component
  143736. */
  143737. get diffuseOutput(): NodeMaterialConnectionPoint;
  143738. /**
  143739. * Gets the specular output component
  143740. */
  143741. get specularOutput(): NodeMaterialConnectionPoint;
  143742. /**
  143743. * Gets the shadow output component
  143744. */
  143745. get shadow(): NodeMaterialConnectionPoint;
  143746. autoConfigure(material: NodeMaterial): void;
  143747. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143748. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143749. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143750. private _injectVertexCode;
  143751. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143752. serialize(): any;
  143753. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143754. }
  143755. }
  143756. declare module BABYLON {
  143757. /**
  143758. * Block used to read a reflection texture from a sampler
  143759. */
  143760. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  143761. /**
  143762. * Create a new ReflectionTextureBlock
  143763. * @param name defines the block name
  143764. */
  143765. constructor(name: string);
  143766. /**
  143767. * Gets the current class name
  143768. * @returns the class name
  143769. */
  143770. getClassName(): string;
  143771. /**
  143772. * Gets the world position input component
  143773. */
  143774. get position(): NodeMaterialConnectionPoint;
  143775. /**
  143776. * Gets the world position input component
  143777. */
  143778. get worldPosition(): NodeMaterialConnectionPoint;
  143779. /**
  143780. * Gets the world normal input component
  143781. */
  143782. get worldNormal(): NodeMaterialConnectionPoint;
  143783. /**
  143784. * Gets the world input component
  143785. */
  143786. get world(): NodeMaterialConnectionPoint;
  143787. /**
  143788. * Gets the camera (or eye) position component
  143789. */
  143790. get cameraPosition(): NodeMaterialConnectionPoint;
  143791. /**
  143792. * Gets the view input component
  143793. */
  143794. get view(): NodeMaterialConnectionPoint;
  143795. /**
  143796. * Gets the rgb output component
  143797. */
  143798. get rgb(): NodeMaterialConnectionPoint;
  143799. /**
  143800. * Gets the rgba output component
  143801. */
  143802. get rgba(): NodeMaterialConnectionPoint;
  143803. /**
  143804. * Gets the r output component
  143805. */
  143806. get r(): NodeMaterialConnectionPoint;
  143807. /**
  143808. * Gets the g output component
  143809. */
  143810. get g(): NodeMaterialConnectionPoint;
  143811. /**
  143812. * Gets the b output component
  143813. */
  143814. get b(): NodeMaterialConnectionPoint;
  143815. /**
  143816. * Gets the a output component
  143817. */
  143818. get a(): NodeMaterialConnectionPoint;
  143819. autoConfigure(material: NodeMaterial): void;
  143820. protected _buildBlock(state: NodeMaterialBuildState): this;
  143821. }
  143822. }
  143823. declare module BABYLON {
  143824. /**
  143825. * Block used to add 2 vectors
  143826. */
  143827. export class AddBlock extends NodeMaterialBlock {
  143828. /**
  143829. * Creates a new AddBlock
  143830. * @param name defines the block name
  143831. */
  143832. constructor(name: string);
  143833. /**
  143834. * Gets the current class name
  143835. * @returns the class name
  143836. */
  143837. getClassName(): string;
  143838. /**
  143839. * Gets the left operand input component
  143840. */
  143841. get left(): NodeMaterialConnectionPoint;
  143842. /**
  143843. * Gets the right operand input component
  143844. */
  143845. get right(): NodeMaterialConnectionPoint;
  143846. /**
  143847. * Gets the output component
  143848. */
  143849. get output(): NodeMaterialConnectionPoint;
  143850. protected _buildBlock(state: NodeMaterialBuildState): this;
  143851. }
  143852. }
  143853. declare module BABYLON {
  143854. /**
  143855. * Block used to scale a vector by a float
  143856. */
  143857. export class ScaleBlock extends NodeMaterialBlock {
  143858. /**
  143859. * Creates a new ScaleBlock
  143860. * @param name defines the block name
  143861. */
  143862. constructor(name: string);
  143863. /**
  143864. * Gets the current class name
  143865. * @returns the class name
  143866. */
  143867. getClassName(): string;
  143868. /**
  143869. * Gets the input component
  143870. */
  143871. get input(): NodeMaterialConnectionPoint;
  143872. /**
  143873. * Gets the factor input component
  143874. */
  143875. get factor(): NodeMaterialConnectionPoint;
  143876. /**
  143877. * Gets the output component
  143878. */
  143879. get output(): NodeMaterialConnectionPoint;
  143880. protected _buildBlock(state: NodeMaterialBuildState): this;
  143881. }
  143882. }
  143883. declare module BABYLON {
  143884. /**
  143885. * Block used to clamp a float
  143886. */
  143887. export class ClampBlock extends NodeMaterialBlock {
  143888. /** Gets or sets the minimum range */
  143889. minimum: number;
  143890. /** Gets or sets the maximum range */
  143891. maximum: number;
  143892. /**
  143893. * Creates a new ClampBlock
  143894. * @param name defines the block name
  143895. */
  143896. constructor(name: string);
  143897. /**
  143898. * Gets the current class name
  143899. * @returns the class name
  143900. */
  143901. getClassName(): string;
  143902. /**
  143903. * Gets the value input component
  143904. */
  143905. get value(): NodeMaterialConnectionPoint;
  143906. /**
  143907. * Gets the output component
  143908. */
  143909. get output(): NodeMaterialConnectionPoint;
  143910. protected _buildBlock(state: NodeMaterialBuildState): this;
  143911. protected _dumpPropertiesCode(): string;
  143912. serialize(): any;
  143913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143914. }
  143915. }
  143916. declare module BABYLON {
  143917. /**
  143918. * Block used to apply a cross product between 2 vectors
  143919. */
  143920. export class CrossBlock extends NodeMaterialBlock {
  143921. /**
  143922. * Creates a new CrossBlock
  143923. * @param name defines the block name
  143924. */
  143925. constructor(name: string);
  143926. /**
  143927. * Gets the current class name
  143928. * @returns the class name
  143929. */
  143930. getClassName(): string;
  143931. /**
  143932. * Gets the left operand input component
  143933. */
  143934. get left(): NodeMaterialConnectionPoint;
  143935. /**
  143936. * Gets the right operand input component
  143937. */
  143938. get right(): NodeMaterialConnectionPoint;
  143939. /**
  143940. * Gets the output component
  143941. */
  143942. get output(): NodeMaterialConnectionPoint;
  143943. protected _buildBlock(state: NodeMaterialBuildState): this;
  143944. }
  143945. }
  143946. declare module BABYLON {
  143947. /**
  143948. * Block used to apply a dot product between 2 vectors
  143949. */
  143950. export class DotBlock extends NodeMaterialBlock {
  143951. /**
  143952. * Creates a new DotBlock
  143953. * @param name defines the block name
  143954. */
  143955. constructor(name: string);
  143956. /**
  143957. * Gets the current class name
  143958. * @returns the class name
  143959. */
  143960. getClassName(): string;
  143961. /**
  143962. * Gets the left operand input component
  143963. */
  143964. get left(): NodeMaterialConnectionPoint;
  143965. /**
  143966. * Gets the right operand input component
  143967. */
  143968. get right(): NodeMaterialConnectionPoint;
  143969. /**
  143970. * Gets the output component
  143971. */
  143972. get output(): NodeMaterialConnectionPoint;
  143973. protected _buildBlock(state: NodeMaterialBuildState): this;
  143974. }
  143975. }
  143976. declare module BABYLON {
  143977. /**
  143978. * Block used to normalize a vector
  143979. */
  143980. export class NormalizeBlock extends NodeMaterialBlock {
  143981. /**
  143982. * Creates a new NormalizeBlock
  143983. * @param name defines the block name
  143984. */
  143985. constructor(name: string);
  143986. /**
  143987. * Gets the current class name
  143988. * @returns the class name
  143989. */
  143990. getClassName(): string;
  143991. /**
  143992. * Gets the input component
  143993. */
  143994. get input(): NodeMaterialConnectionPoint;
  143995. /**
  143996. * Gets the output component
  143997. */
  143998. get output(): NodeMaterialConnectionPoint;
  143999. protected _buildBlock(state: NodeMaterialBuildState): this;
  144000. }
  144001. }
  144002. declare module BABYLON {
  144003. /**
  144004. * Block used to create a Color3/4 out of individual inputs (one for each component)
  144005. */
  144006. export class ColorMergerBlock extends NodeMaterialBlock {
  144007. /**
  144008. * Create a new ColorMergerBlock
  144009. * @param name defines the block name
  144010. */
  144011. constructor(name: string);
  144012. /**
  144013. * Gets the current class name
  144014. * @returns the class name
  144015. */
  144016. getClassName(): string;
  144017. /**
  144018. * Gets the rgb component (input)
  144019. */
  144020. get rgbIn(): NodeMaterialConnectionPoint;
  144021. /**
  144022. * Gets the r component (input)
  144023. */
  144024. get r(): NodeMaterialConnectionPoint;
  144025. /**
  144026. * Gets the g component (input)
  144027. */
  144028. get g(): NodeMaterialConnectionPoint;
  144029. /**
  144030. * Gets the b component (input)
  144031. */
  144032. get b(): NodeMaterialConnectionPoint;
  144033. /**
  144034. * Gets the a component (input)
  144035. */
  144036. get a(): NodeMaterialConnectionPoint;
  144037. /**
  144038. * Gets the rgba component (output)
  144039. */
  144040. get rgba(): NodeMaterialConnectionPoint;
  144041. /**
  144042. * Gets the rgb component (output)
  144043. */
  144044. get rgbOut(): NodeMaterialConnectionPoint;
  144045. /**
  144046. * Gets the rgb component (output)
  144047. * @deprecated Please use rgbOut instead.
  144048. */
  144049. get rgb(): NodeMaterialConnectionPoint;
  144050. protected _buildBlock(state: NodeMaterialBuildState): this;
  144051. }
  144052. }
  144053. declare module BABYLON {
  144054. /**
  144055. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  144056. */
  144057. export class VectorSplitterBlock extends NodeMaterialBlock {
  144058. /**
  144059. * Create a new VectorSplitterBlock
  144060. * @param name defines the block name
  144061. */
  144062. constructor(name: string);
  144063. /**
  144064. * Gets the current class name
  144065. * @returns the class name
  144066. */
  144067. getClassName(): string;
  144068. /**
  144069. * Gets the xyzw component (input)
  144070. */
  144071. get xyzw(): NodeMaterialConnectionPoint;
  144072. /**
  144073. * Gets the xyz component (input)
  144074. */
  144075. get xyzIn(): NodeMaterialConnectionPoint;
  144076. /**
  144077. * Gets the xy component (input)
  144078. */
  144079. get xyIn(): NodeMaterialConnectionPoint;
  144080. /**
  144081. * Gets the xyz component (output)
  144082. */
  144083. get xyzOut(): NodeMaterialConnectionPoint;
  144084. /**
  144085. * Gets the xy component (output)
  144086. */
  144087. get xyOut(): NodeMaterialConnectionPoint;
  144088. /**
  144089. * Gets the x component (output)
  144090. */
  144091. get x(): NodeMaterialConnectionPoint;
  144092. /**
  144093. * Gets the y component (output)
  144094. */
  144095. get y(): NodeMaterialConnectionPoint;
  144096. /**
  144097. * Gets the z component (output)
  144098. */
  144099. get z(): NodeMaterialConnectionPoint;
  144100. /**
  144101. * Gets the w component (output)
  144102. */
  144103. get w(): NodeMaterialConnectionPoint;
  144104. protected _inputRename(name: string): string;
  144105. protected _outputRename(name: string): string;
  144106. protected _buildBlock(state: NodeMaterialBuildState): this;
  144107. }
  144108. }
  144109. declare module BABYLON {
  144110. /**
  144111. * Block used to lerp between 2 values
  144112. */
  144113. export class LerpBlock extends NodeMaterialBlock {
  144114. /**
  144115. * Creates a new LerpBlock
  144116. * @param name defines the block name
  144117. */
  144118. constructor(name: string);
  144119. /**
  144120. * Gets the current class name
  144121. * @returns the class name
  144122. */
  144123. getClassName(): string;
  144124. /**
  144125. * Gets the left operand input component
  144126. */
  144127. get left(): NodeMaterialConnectionPoint;
  144128. /**
  144129. * Gets the right operand input component
  144130. */
  144131. get right(): NodeMaterialConnectionPoint;
  144132. /**
  144133. * Gets the gradient operand input component
  144134. */
  144135. get gradient(): NodeMaterialConnectionPoint;
  144136. /**
  144137. * Gets the output component
  144138. */
  144139. get output(): NodeMaterialConnectionPoint;
  144140. protected _buildBlock(state: NodeMaterialBuildState): this;
  144141. }
  144142. }
  144143. declare module BABYLON {
  144144. /**
  144145. * Block used to divide 2 vectors
  144146. */
  144147. export class DivideBlock extends NodeMaterialBlock {
  144148. /**
  144149. * Creates a new DivideBlock
  144150. * @param name defines the block name
  144151. */
  144152. constructor(name: string);
  144153. /**
  144154. * Gets the current class name
  144155. * @returns the class name
  144156. */
  144157. getClassName(): string;
  144158. /**
  144159. * Gets the left operand input component
  144160. */
  144161. get left(): NodeMaterialConnectionPoint;
  144162. /**
  144163. * Gets the right operand input component
  144164. */
  144165. get right(): NodeMaterialConnectionPoint;
  144166. /**
  144167. * Gets the output component
  144168. */
  144169. get output(): NodeMaterialConnectionPoint;
  144170. protected _buildBlock(state: NodeMaterialBuildState): this;
  144171. }
  144172. }
  144173. declare module BABYLON {
  144174. /**
  144175. * Block used to subtract 2 vectors
  144176. */
  144177. export class SubtractBlock extends NodeMaterialBlock {
  144178. /**
  144179. * Creates a new SubtractBlock
  144180. * @param name defines the block name
  144181. */
  144182. constructor(name: string);
  144183. /**
  144184. * Gets the current class name
  144185. * @returns the class name
  144186. */
  144187. getClassName(): string;
  144188. /**
  144189. * Gets the left operand input component
  144190. */
  144191. get left(): NodeMaterialConnectionPoint;
  144192. /**
  144193. * Gets the right operand input component
  144194. */
  144195. get right(): NodeMaterialConnectionPoint;
  144196. /**
  144197. * Gets the output component
  144198. */
  144199. get output(): NodeMaterialConnectionPoint;
  144200. protected _buildBlock(state: NodeMaterialBuildState): this;
  144201. }
  144202. }
  144203. declare module BABYLON {
  144204. /**
  144205. * Block used to step a value
  144206. */
  144207. export class StepBlock extends NodeMaterialBlock {
  144208. /**
  144209. * Creates a new StepBlock
  144210. * @param name defines the block name
  144211. */
  144212. constructor(name: string);
  144213. /**
  144214. * Gets the current class name
  144215. * @returns the class name
  144216. */
  144217. getClassName(): string;
  144218. /**
  144219. * Gets the value operand input component
  144220. */
  144221. get value(): NodeMaterialConnectionPoint;
  144222. /**
  144223. * Gets the edge operand input component
  144224. */
  144225. get edge(): NodeMaterialConnectionPoint;
  144226. /**
  144227. * Gets the output component
  144228. */
  144229. get output(): NodeMaterialConnectionPoint;
  144230. protected _buildBlock(state: NodeMaterialBuildState): this;
  144231. }
  144232. }
  144233. declare module BABYLON {
  144234. /**
  144235. * Block used to get the opposite (1 - x) of a value
  144236. */
  144237. export class OneMinusBlock extends NodeMaterialBlock {
  144238. /**
  144239. * Creates a new OneMinusBlock
  144240. * @param name defines the block name
  144241. */
  144242. constructor(name: string);
  144243. /**
  144244. * Gets the current class name
  144245. * @returns the class name
  144246. */
  144247. getClassName(): string;
  144248. /**
  144249. * Gets the input component
  144250. */
  144251. get input(): NodeMaterialConnectionPoint;
  144252. /**
  144253. * Gets the output component
  144254. */
  144255. get output(): NodeMaterialConnectionPoint;
  144256. protected _buildBlock(state: NodeMaterialBuildState): this;
  144257. }
  144258. }
  144259. declare module BABYLON {
  144260. /**
  144261. * Block used to get the view direction
  144262. */
  144263. export class ViewDirectionBlock extends NodeMaterialBlock {
  144264. /**
  144265. * Creates a new ViewDirectionBlock
  144266. * @param name defines the block name
  144267. */
  144268. constructor(name: string);
  144269. /**
  144270. * Gets the current class name
  144271. * @returns the class name
  144272. */
  144273. getClassName(): string;
  144274. /**
  144275. * Gets the world position component
  144276. */
  144277. get worldPosition(): NodeMaterialConnectionPoint;
  144278. /**
  144279. * Gets the camera position component
  144280. */
  144281. get cameraPosition(): NodeMaterialConnectionPoint;
  144282. /**
  144283. * Gets the output component
  144284. */
  144285. get output(): NodeMaterialConnectionPoint;
  144286. autoConfigure(material: NodeMaterial): void;
  144287. protected _buildBlock(state: NodeMaterialBuildState): this;
  144288. }
  144289. }
  144290. declare module BABYLON {
  144291. /**
  144292. * Block used to compute fresnel value
  144293. */
  144294. export class FresnelBlock extends NodeMaterialBlock {
  144295. /**
  144296. * Create a new FresnelBlock
  144297. * @param name defines the block name
  144298. */
  144299. constructor(name: string);
  144300. /**
  144301. * Gets the current class name
  144302. * @returns the class name
  144303. */
  144304. getClassName(): string;
  144305. /**
  144306. * Gets the world normal input component
  144307. */
  144308. get worldNormal(): NodeMaterialConnectionPoint;
  144309. /**
  144310. * Gets the view direction input component
  144311. */
  144312. get viewDirection(): NodeMaterialConnectionPoint;
  144313. /**
  144314. * Gets the bias input component
  144315. */
  144316. get bias(): NodeMaterialConnectionPoint;
  144317. /**
  144318. * Gets the camera (or eye) position component
  144319. */
  144320. get power(): NodeMaterialConnectionPoint;
  144321. /**
  144322. * Gets the fresnel output component
  144323. */
  144324. get fresnel(): NodeMaterialConnectionPoint;
  144325. autoConfigure(material: NodeMaterial): void;
  144326. protected _buildBlock(state: NodeMaterialBuildState): this;
  144327. }
  144328. }
  144329. declare module BABYLON {
  144330. /**
  144331. * Block used to get the max of 2 values
  144332. */
  144333. export class MaxBlock extends NodeMaterialBlock {
  144334. /**
  144335. * Creates a new MaxBlock
  144336. * @param name defines the block name
  144337. */
  144338. constructor(name: string);
  144339. /**
  144340. * Gets the current class name
  144341. * @returns the class name
  144342. */
  144343. getClassName(): string;
  144344. /**
  144345. * Gets the left operand input component
  144346. */
  144347. get left(): NodeMaterialConnectionPoint;
  144348. /**
  144349. * Gets the right operand input component
  144350. */
  144351. get right(): NodeMaterialConnectionPoint;
  144352. /**
  144353. * Gets the output component
  144354. */
  144355. get output(): NodeMaterialConnectionPoint;
  144356. protected _buildBlock(state: NodeMaterialBuildState): this;
  144357. }
  144358. }
  144359. declare module BABYLON {
  144360. /**
  144361. * Block used to get the min of 2 values
  144362. */
  144363. export class MinBlock extends NodeMaterialBlock {
  144364. /**
  144365. * Creates a new MinBlock
  144366. * @param name defines the block name
  144367. */
  144368. constructor(name: string);
  144369. /**
  144370. * Gets the current class name
  144371. * @returns the class name
  144372. */
  144373. getClassName(): string;
  144374. /**
  144375. * Gets the left operand input component
  144376. */
  144377. get left(): NodeMaterialConnectionPoint;
  144378. /**
  144379. * Gets the right operand input component
  144380. */
  144381. get right(): NodeMaterialConnectionPoint;
  144382. /**
  144383. * Gets the output component
  144384. */
  144385. get output(): NodeMaterialConnectionPoint;
  144386. protected _buildBlock(state: NodeMaterialBuildState): this;
  144387. }
  144388. }
  144389. declare module BABYLON {
  144390. /**
  144391. * Block used to get the distance between 2 values
  144392. */
  144393. export class DistanceBlock extends NodeMaterialBlock {
  144394. /**
  144395. * Creates a new DistanceBlock
  144396. * @param name defines the block name
  144397. */
  144398. constructor(name: string);
  144399. /**
  144400. * Gets the current class name
  144401. * @returns the class name
  144402. */
  144403. getClassName(): string;
  144404. /**
  144405. * Gets the left operand input component
  144406. */
  144407. get left(): NodeMaterialConnectionPoint;
  144408. /**
  144409. * Gets the right operand input component
  144410. */
  144411. get right(): NodeMaterialConnectionPoint;
  144412. /**
  144413. * Gets the output component
  144414. */
  144415. get output(): NodeMaterialConnectionPoint;
  144416. protected _buildBlock(state: NodeMaterialBuildState): this;
  144417. }
  144418. }
  144419. declare module BABYLON {
  144420. /**
  144421. * Block used to get the length of a vector
  144422. */
  144423. export class LengthBlock extends NodeMaterialBlock {
  144424. /**
  144425. * Creates a new LengthBlock
  144426. * @param name defines the block name
  144427. */
  144428. constructor(name: string);
  144429. /**
  144430. * Gets the current class name
  144431. * @returns the class name
  144432. */
  144433. getClassName(): string;
  144434. /**
  144435. * Gets the value input component
  144436. */
  144437. get value(): NodeMaterialConnectionPoint;
  144438. /**
  144439. * Gets the output component
  144440. */
  144441. get output(): NodeMaterialConnectionPoint;
  144442. protected _buildBlock(state: NodeMaterialBuildState): this;
  144443. }
  144444. }
  144445. declare module BABYLON {
  144446. /**
  144447. * Block used to get negative version of a value (i.e. x * -1)
  144448. */
  144449. export class NegateBlock extends NodeMaterialBlock {
  144450. /**
  144451. * Creates a new NegateBlock
  144452. * @param name defines the block name
  144453. */
  144454. constructor(name: string);
  144455. /**
  144456. * Gets the current class name
  144457. * @returns the class name
  144458. */
  144459. getClassName(): string;
  144460. /**
  144461. * Gets the value input component
  144462. */
  144463. get value(): NodeMaterialConnectionPoint;
  144464. /**
  144465. * Gets the output component
  144466. */
  144467. get output(): NodeMaterialConnectionPoint;
  144468. protected _buildBlock(state: NodeMaterialBuildState): this;
  144469. }
  144470. }
  144471. declare module BABYLON {
  144472. /**
  144473. * Block used to get the value of the first parameter raised to the power of the second
  144474. */
  144475. export class PowBlock extends NodeMaterialBlock {
  144476. /**
  144477. * Creates a new PowBlock
  144478. * @param name defines the block name
  144479. */
  144480. constructor(name: string);
  144481. /**
  144482. * Gets the current class name
  144483. * @returns the class name
  144484. */
  144485. getClassName(): string;
  144486. /**
  144487. * Gets the value operand input component
  144488. */
  144489. get value(): NodeMaterialConnectionPoint;
  144490. /**
  144491. * Gets the power operand input component
  144492. */
  144493. get power(): NodeMaterialConnectionPoint;
  144494. /**
  144495. * Gets the output component
  144496. */
  144497. get output(): NodeMaterialConnectionPoint;
  144498. protected _buildBlock(state: NodeMaterialBuildState): this;
  144499. }
  144500. }
  144501. declare module BABYLON {
  144502. /**
  144503. * Block used to get a random number
  144504. */
  144505. export class RandomNumberBlock extends NodeMaterialBlock {
  144506. /**
  144507. * Creates a new RandomNumberBlock
  144508. * @param name defines the block name
  144509. */
  144510. constructor(name: string);
  144511. /**
  144512. * Gets the current class name
  144513. * @returns the class name
  144514. */
  144515. getClassName(): string;
  144516. /**
  144517. * Gets the seed input component
  144518. */
  144519. get seed(): NodeMaterialConnectionPoint;
  144520. /**
  144521. * Gets the output component
  144522. */
  144523. get output(): NodeMaterialConnectionPoint;
  144524. protected _buildBlock(state: NodeMaterialBuildState): this;
  144525. }
  144526. }
  144527. declare module BABYLON {
  144528. /**
  144529. * Block used to compute arc tangent of 2 values
  144530. */
  144531. export class ArcTan2Block extends NodeMaterialBlock {
  144532. /**
  144533. * Creates a new ArcTan2Block
  144534. * @param name defines the block name
  144535. */
  144536. constructor(name: string);
  144537. /**
  144538. * Gets the current class name
  144539. * @returns the class name
  144540. */
  144541. getClassName(): string;
  144542. /**
  144543. * Gets the x operand input component
  144544. */
  144545. get x(): NodeMaterialConnectionPoint;
  144546. /**
  144547. * Gets the y operand input component
  144548. */
  144549. get y(): NodeMaterialConnectionPoint;
  144550. /**
  144551. * Gets the output component
  144552. */
  144553. get output(): NodeMaterialConnectionPoint;
  144554. protected _buildBlock(state: NodeMaterialBuildState): this;
  144555. }
  144556. }
  144557. declare module BABYLON {
  144558. /**
  144559. * Block used to smooth step a value
  144560. */
  144561. export class SmoothStepBlock extends NodeMaterialBlock {
  144562. /**
  144563. * Creates a new SmoothStepBlock
  144564. * @param name defines the block name
  144565. */
  144566. constructor(name: string);
  144567. /**
  144568. * Gets the current class name
  144569. * @returns the class name
  144570. */
  144571. getClassName(): string;
  144572. /**
  144573. * Gets the value operand input component
  144574. */
  144575. get value(): NodeMaterialConnectionPoint;
  144576. /**
  144577. * Gets the first edge operand input component
  144578. */
  144579. get edge0(): NodeMaterialConnectionPoint;
  144580. /**
  144581. * Gets the second edge operand input component
  144582. */
  144583. get edge1(): NodeMaterialConnectionPoint;
  144584. /**
  144585. * Gets the output component
  144586. */
  144587. get output(): NodeMaterialConnectionPoint;
  144588. protected _buildBlock(state: NodeMaterialBuildState): this;
  144589. }
  144590. }
  144591. declare module BABYLON {
  144592. /**
  144593. * Block used to get the reciprocal (1 / x) of a value
  144594. */
  144595. export class ReciprocalBlock extends NodeMaterialBlock {
  144596. /**
  144597. * Creates a new ReciprocalBlock
  144598. * @param name defines the block name
  144599. */
  144600. constructor(name: string);
  144601. /**
  144602. * Gets the current class name
  144603. * @returns the class name
  144604. */
  144605. getClassName(): string;
  144606. /**
  144607. * Gets the input component
  144608. */
  144609. get input(): NodeMaterialConnectionPoint;
  144610. /**
  144611. * Gets the output component
  144612. */
  144613. get output(): NodeMaterialConnectionPoint;
  144614. protected _buildBlock(state: NodeMaterialBuildState): this;
  144615. }
  144616. }
  144617. declare module BABYLON {
  144618. /**
  144619. * Block used to replace a color by another one
  144620. */
  144621. export class ReplaceColorBlock extends NodeMaterialBlock {
  144622. /**
  144623. * Creates a new ReplaceColorBlock
  144624. * @param name defines the block name
  144625. */
  144626. constructor(name: string);
  144627. /**
  144628. * Gets the current class name
  144629. * @returns the class name
  144630. */
  144631. getClassName(): string;
  144632. /**
  144633. * Gets the value input component
  144634. */
  144635. get value(): NodeMaterialConnectionPoint;
  144636. /**
  144637. * Gets the reference input component
  144638. */
  144639. get reference(): NodeMaterialConnectionPoint;
  144640. /**
  144641. * Gets the distance input component
  144642. */
  144643. get distance(): NodeMaterialConnectionPoint;
  144644. /**
  144645. * Gets the replacement input component
  144646. */
  144647. get replacement(): NodeMaterialConnectionPoint;
  144648. /**
  144649. * Gets the output component
  144650. */
  144651. get output(): NodeMaterialConnectionPoint;
  144652. protected _buildBlock(state: NodeMaterialBuildState): this;
  144653. }
  144654. }
  144655. declare module BABYLON {
  144656. /**
  144657. * Block used to posterize a value
  144658. * @see https://en.wikipedia.org/wiki/Posterization
  144659. */
  144660. export class PosterizeBlock extends NodeMaterialBlock {
  144661. /**
  144662. * Creates a new PosterizeBlock
  144663. * @param name defines the block name
  144664. */
  144665. constructor(name: string);
  144666. /**
  144667. * Gets the current class name
  144668. * @returns the class name
  144669. */
  144670. getClassName(): string;
  144671. /**
  144672. * Gets the value input component
  144673. */
  144674. get value(): NodeMaterialConnectionPoint;
  144675. /**
  144676. * Gets the steps input component
  144677. */
  144678. get steps(): NodeMaterialConnectionPoint;
  144679. /**
  144680. * Gets the output component
  144681. */
  144682. get output(): NodeMaterialConnectionPoint;
  144683. protected _buildBlock(state: NodeMaterialBuildState): this;
  144684. }
  144685. }
  144686. declare module BABYLON {
  144687. /**
  144688. * Operations supported by the Wave block
  144689. */
  144690. export enum WaveBlockKind {
  144691. /** SawTooth */
  144692. SawTooth = 0,
  144693. /** Square */
  144694. Square = 1,
  144695. /** Triangle */
  144696. Triangle = 2
  144697. }
  144698. /**
  144699. * Block used to apply wave operation to floats
  144700. */
  144701. export class WaveBlock extends NodeMaterialBlock {
  144702. /**
  144703. * Gets or sets the kibnd of wave to be applied by the block
  144704. */
  144705. kind: WaveBlockKind;
  144706. /**
  144707. * Creates a new WaveBlock
  144708. * @param name defines the block name
  144709. */
  144710. constructor(name: string);
  144711. /**
  144712. * Gets the current class name
  144713. * @returns the class name
  144714. */
  144715. getClassName(): string;
  144716. /**
  144717. * Gets the input component
  144718. */
  144719. get input(): NodeMaterialConnectionPoint;
  144720. /**
  144721. * Gets the output component
  144722. */
  144723. get output(): NodeMaterialConnectionPoint;
  144724. protected _buildBlock(state: NodeMaterialBuildState): this;
  144725. serialize(): any;
  144726. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144727. }
  144728. }
  144729. declare module BABYLON {
  144730. /**
  144731. * Class used to store a color step for the GradientBlock
  144732. */
  144733. export class GradientBlockColorStep {
  144734. private _step;
  144735. /**
  144736. * Gets value indicating which step this color is associated with (between 0 and 1)
  144737. */
  144738. get step(): number;
  144739. /**
  144740. * Sets a value indicating which step this color is associated with (between 0 and 1)
  144741. */
  144742. set step(val: number);
  144743. private _color;
  144744. /**
  144745. * Gets the color associated with this step
  144746. */
  144747. get color(): Color3;
  144748. /**
  144749. * Sets the color associated with this step
  144750. */
  144751. set color(val: Color3);
  144752. /**
  144753. * Creates a new GradientBlockColorStep
  144754. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  144755. * @param color defines the color associated with this step
  144756. */
  144757. constructor(step: number, color: Color3);
  144758. }
  144759. /**
  144760. * Block used to return a color from a gradient based on an input value between 0 and 1
  144761. */
  144762. export class GradientBlock extends NodeMaterialBlock {
  144763. /**
  144764. * Gets or sets the list of color steps
  144765. */
  144766. colorSteps: GradientBlockColorStep[];
  144767. /** Gets an observable raised when the value is changed */
  144768. onValueChangedObservable: Observable<GradientBlock>;
  144769. /** calls observable when the value is changed*/
  144770. colorStepsUpdated(): void;
  144771. /**
  144772. * Creates a new GradientBlock
  144773. * @param name defines the block name
  144774. */
  144775. constructor(name: string);
  144776. /**
  144777. * Gets the current class name
  144778. * @returns the class name
  144779. */
  144780. getClassName(): string;
  144781. /**
  144782. * Gets the gradient input component
  144783. */
  144784. get gradient(): NodeMaterialConnectionPoint;
  144785. /**
  144786. * Gets the output component
  144787. */
  144788. get output(): NodeMaterialConnectionPoint;
  144789. private _writeColorConstant;
  144790. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144791. serialize(): any;
  144792. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144793. protected _dumpPropertiesCode(): string;
  144794. }
  144795. }
  144796. declare module BABYLON {
  144797. /**
  144798. * Block used to normalize lerp between 2 values
  144799. */
  144800. export class NLerpBlock extends NodeMaterialBlock {
  144801. /**
  144802. * Creates a new NLerpBlock
  144803. * @param name defines the block name
  144804. */
  144805. constructor(name: string);
  144806. /**
  144807. * Gets the current class name
  144808. * @returns the class name
  144809. */
  144810. getClassName(): string;
  144811. /**
  144812. * Gets the left operand input component
  144813. */
  144814. get left(): NodeMaterialConnectionPoint;
  144815. /**
  144816. * Gets the right operand input component
  144817. */
  144818. get right(): NodeMaterialConnectionPoint;
  144819. /**
  144820. * Gets the gradient operand input component
  144821. */
  144822. get gradient(): NodeMaterialConnectionPoint;
  144823. /**
  144824. * Gets the output component
  144825. */
  144826. get output(): NodeMaterialConnectionPoint;
  144827. protected _buildBlock(state: NodeMaterialBuildState): this;
  144828. }
  144829. }
  144830. declare module BABYLON {
  144831. /**
  144832. * block used to Generate a Worley Noise 3D Noise Pattern
  144833. */
  144834. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  144835. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144836. manhattanDistance: boolean;
  144837. /**
  144838. * Creates a new WorleyNoise3DBlock
  144839. * @param name defines the block name
  144840. */
  144841. constructor(name: string);
  144842. /**
  144843. * Gets the current class name
  144844. * @returns the class name
  144845. */
  144846. getClassName(): string;
  144847. /**
  144848. * Gets the seed input component
  144849. */
  144850. get seed(): NodeMaterialConnectionPoint;
  144851. /**
  144852. * Gets the jitter input component
  144853. */
  144854. get jitter(): NodeMaterialConnectionPoint;
  144855. /**
  144856. * Gets the output component
  144857. */
  144858. get output(): NodeMaterialConnectionPoint;
  144859. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144860. /**
  144861. * Exposes the properties to the UI?
  144862. */
  144863. protected _dumpPropertiesCode(): string;
  144864. /**
  144865. * Exposes the properties to the Seralize?
  144866. */
  144867. serialize(): any;
  144868. /**
  144869. * Exposes the properties to the deseralize?
  144870. */
  144871. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144872. }
  144873. }
  144874. declare module BABYLON {
  144875. /**
  144876. * block used to Generate a Simplex Perlin 3d Noise Pattern
  144877. */
  144878. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  144879. /**
  144880. * Creates a new SimplexPerlin3DBlock
  144881. * @param name defines the block name
  144882. */
  144883. constructor(name: string);
  144884. /**
  144885. * Gets the current class name
  144886. * @returns the class name
  144887. */
  144888. getClassName(): string;
  144889. /**
  144890. * Gets the seed operand input component
  144891. */
  144892. get seed(): NodeMaterialConnectionPoint;
  144893. /**
  144894. * Gets the output component
  144895. */
  144896. get output(): NodeMaterialConnectionPoint;
  144897. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144898. }
  144899. }
  144900. declare module BABYLON {
  144901. /**
  144902. * Block used to blend normals
  144903. */
  144904. export class NormalBlendBlock extends NodeMaterialBlock {
  144905. /**
  144906. * Creates a new NormalBlendBlock
  144907. * @param name defines the block name
  144908. */
  144909. constructor(name: string);
  144910. /**
  144911. * Gets the current class name
  144912. * @returns the class name
  144913. */
  144914. getClassName(): string;
  144915. /**
  144916. * Gets the first input component
  144917. */
  144918. get normalMap0(): NodeMaterialConnectionPoint;
  144919. /**
  144920. * Gets the second input component
  144921. */
  144922. get normalMap1(): NodeMaterialConnectionPoint;
  144923. /**
  144924. * Gets the output component
  144925. */
  144926. get output(): NodeMaterialConnectionPoint;
  144927. protected _buildBlock(state: NodeMaterialBuildState): this;
  144928. }
  144929. }
  144930. declare module BABYLON {
  144931. /**
  144932. * Block used to rotate a 2d vector by a given angle
  144933. */
  144934. export class Rotate2dBlock extends NodeMaterialBlock {
  144935. /**
  144936. * Creates a new Rotate2dBlock
  144937. * @param name defines the block name
  144938. */
  144939. constructor(name: string);
  144940. /**
  144941. * Gets the current class name
  144942. * @returns the class name
  144943. */
  144944. getClassName(): string;
  144945. /**
  144946. * Gets the input vector
  144947. */
  144948. get input(): NodeMaterialConnectionPoint;
  144949. /**
  144950. * Gets the input angle
  144951. */
  144952. get angle(): NodeMaterialConnectionPoint;
  144953. /**
  144954. * Gets the output component
  144955. */
  144956. get output(): NodeMaterialConnectionPoint;
  144957. autoConfigure(material: NodeMaterial): void;
  144958. protected _buildBlock(state: NodeMaterialBuildState): this;
  144959. }
  144960. }
  144961. declare module BABYLON {
  144962. /**
  144963. * Block used to get the reflected vector from a direction and a normal
  144964. */
  144965. export class ReflectBlock extends NodeMaterialBlock {
  144966. /**
  144967. * Creates a new ReflectBlock
  144968. * @param name defines the block name
  144969. */
  144970. constructor(name: string);
  144971. /**
  144972. * Gets the current class name
  144973. * @returns the class name
  144974. */
  144975. getClassName(): string;
  144976. /**
  144977. * Gets the incident component
  144978. */
  144979. get incident(): NodeMaterialConnectionPoint;
  144980. /**
  144981. * Gets the normal component
  144982. */
  144983. get normal(): NodeMaterialConnectionPoint;
  144984. /**
  144985. * Gets the output component
  144986. */
  144987. get output(): NodeMaterialConnectionPoint;
  144988. protected _buildBlock(state: NodeMaterialBuildState): this;
  144989. }
  144990. }
  144991. declare module BABYLON {
  144992. /**
  144993. * Block used to get the refracted vector from a direction and a normal
  144994. */
  144995. export class RefractBlock extends NodeMaterialBlock {
  144996. /**
  144997. * Creates a new RefractBlock
  144998. * @param name defines the block name
  144999. */
  145000. constructor(name: string);
  145001. /**
  145002. * Gets the current class name
  145003. * @returns the class name
  145004. */
  145005. getClassName(): string;
  145006. /**
  145007. * Gets the incident component
  145008. */
  145009. get incident(): NodeMaterialConnectionPoint;
  145010. /**
  145011. * Gets the normal component
  145012. */
  145013. get normal(): NodeMaterialConnectionPoint;
  145014. /**
  145015. * Gets the index of refraction component
  145016. */
  145017. get ior(): NodeMaterialConnectionPoint;
  145018. /**
  145019. * Gets the output component
  145020. */
  145021. get output(): NodeMaterialConnectionPoint;
  145022. protected _buildBlock(state: NodeMaterialBuildState): this;
  145023. }
  145024. }
  145025. declare module BABYLON {
  145026. /**
  145027. * Block used to desaturate a color
  145028. */
  145029. export class DesaturateBlock extends NodeMaterialBlock {
  145030. /**
  145031. * Creates a new DesaturateBlock
  145032. * @param name defines the block name
  145033. */
  145034. constructor(name: string);
  145035. /**
  145036. * Gets the current class name
  145037. * @returns the class name
  145038. */
  145039. getClassName(): string;
  145040. /**
  145041. * Gets the color operand input component
  145042. */
  145043. get color(): NodeMaterialConnectionPoint;
  145044. /**
  145045. * Gets the level operand input component
  145046. */
  145047. get level(): NodeMaterialConnectionPoint;
  145048. /**
  145049. * Gets the output component
  145050. */
  145051. get output(): NodeMaterialConnectionPoint;
  145052. protected _buildBlock(state: NodeMaterialBuildState): this;
  145053. }
  145054. }
  145055. declare module BABYLON {
  145056. /**
  145057. * Block used to implement the ambient occlusion module of the PBR material
  145058. */
  145059. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  145060. /**
  145061. * Create a new AmbientOcclusionBlock
  145062. * @param name defines the block name
  145063. */
  145064. constructor(name: string);
  145065. /**
  145066. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  145067. */
  145068. useAmbientInGrayScale: boolean;
  145069. /**
  145070. * Initialize the block and prepare the context for build
  145071. * @param state defines the state that will be used for the build
  145072. */
  145073. initialize(state: NodeMaterialBuildState): void;
  145074. /**
  145075. * Gets the current class name
  145076. * @returns the class name
  145077. */
  145078. getClassName(): string;
  145079. /**
  145080. * Gets the texture input component
  145081. */
  145082. get texture(): NodeMaterialConnectionPoint;
  145083. /**
  145084. * Gets the texture intensity component
  145085. */
  145086. get intensity(): NodeMaterialConnectionPoint;
  145087. /**
  145088. * Gets the direct light intensity input component
  145089. */
  145090. get directLightIntensity(): NodeMaterialConnectionPoint;
  145091. /**
  145092. * Gets the ambient occlusion object output component
  145093. */
  145094. get ambientOcc(): NodeMaterialConnectionPoint;
  145095. /**
  145096. * Gets the main code of the block (fragment side)
  145097. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  145098. * @returns the shader code
  145099. */
  145100. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  145101. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145102. protected _buildBlock(state: NodeMaterialBuildState): this;
  145103. protected _dumpPropertiesCode(): string;
  145104. serialize(): any;
  145105. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145106. }
  145107. }
  145108. declare module BABYLON {
  145109. /**
  145110. * Block used to implement the reflection module of the PBR material
  145111. */
  145112. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  145113. /** @hidden */
  145114. _defineLODReflectionAlpha: string;
  145115. /** @hidden */
  145116. _defineLinearSpecularReflection: string;
  145117. private _vEnvironmentIrradianceName;
  145118. /** @hidden */
  145119. _vReflectionMicrosurfaceInfosName: string;
  145120. /** @hidden */
  145121. _vReflectionInfosName: string;
  145122. /** @hidden */
  145123. _vReflectionFilteringInfoName: string;
  145124. private _scene;
  145125. /**
  145126. * The three properties below are set by the main PBR block prior to calling methods of this class.
  145127. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145128. * It's less burden on the user side in the editor part.
  145129. */
  145130. /** @hidden */
  145131. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145132. /** @hidden */
  145133. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145134. /** @hidden */
  145135. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  145136. /**
  145137. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  145138. * diffuse part of the IBL.
  145139. */
  145140. useSphericalHarmonics: boolean;
  145141. /**
  145142. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  145143. */
  145144. forceIrradianceInFragment: boolean;
  145145. /**
  145146. * Create a new ReflectionBlock
  145147. * @param name defines the block name
  145148. */
  145149. constructor(name: string);
  145150. /**
  145151. * Gets the current class name
  145152. * @returns the class name
  145153. */
  145154. getClassName(): string;
  145155. /**
  145156. * Gets the position input component
  145157. */
  145158. get position(): NodeMaterialConnectionPoint;
  145159. /**
  145160. * Gets the world position input component
  145161. */
  145162. get worldPosition(): NodeMaterialConnectionPoint;
  145163. /**
  145164. * Gets the world normal input component
  145165. */
  145166. get worldNormal(): NodeMaterialConnectionPoint;
  145167. /**
  145168. * Gets the world input component
  145169. */
  145170. get world(): NodeMaterialConnectionPoint;
  145171. /**
  145172. * Gets the camera (or eye) position component
  145173. */
  145174. get cameraPosition(): NodeMaterialConnectionPoint;
  145175. /**
  145176. * Gets the view input component
  145177. */
  145178. get view(): NodeMaterialConnectionPoint;
  145179. /**
  145180. * Gets the color input component
  145181. */
  145182. get color(): NodeMaterialConnectionPoint;
  145183. /**
  145184. * Gets the reflection object output component
  145185. */
  145186. get reflection(): NodeMaterialConnectionPoint;
  145187. /**
  145188. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  145189. */
  145190. get hasTexture(): boolean;
  145191. /**
  145192. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  145193. */
  145194. get reflectionColor(): string;
  145195. protected _getTexture(): Nullable<BaseTexture>;
  145196. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145197. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145198. /**
  145199. * Gets the code to inject in the vertex shader
  145200. * @param state current state of the node material building
  145201. * @returns the shader code
  145202. */
  145203. handleVertexSide(state: NodeMaterialBuildState): string;
  145204. /**
  145205. * Gets the main code of the block (fragment side)
  145206. * @param state current state of the node material building
  145207. * @param normalVarName name of the existing variable corresponding to the normal
  145208. * @returns the shader code
  145209. */
  145210. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  145211. protected _buildBlock(state: NodeMaterialBuildState): this;
  145212. protected _dumpPropertiesCode(): string;
  145213. serialize(): any;
  145214. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145215. }
  145216. }
  145217. declare module BABYLON {
  145218. /**
  145219. * Block used to implement the sheen module of the PBR material
  145220. */
  145221. export class SheenBlock extends NodeMaterialBlock {
  145222. /**
  145223. * Create a new SheenBlock
  145224. * @param name defines the block name
  145225. */
  145226. constructor(name: string);
  145227. /**
  145228. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  145229. * It allows the strength of the sheen effect to not depend on the base color of the material,
  145230. * making it easier to setup and tweak the effect
  145231. */
  145232. albedoScaling: boolean;
  145233. /**
  145234. * Defines if the sheen is linked to the sheen color.
  145235. */
  145236. linkSheenWithAlbedo: boolean;
  145237. /**
  145238. * Initialize the block and prepare the context for build
  145239. * @param state defines the state that will be used for the build
  145240. */
  145241. initialize(state: NodeMaterialBuildState): void;
  145242. /**
  145243. * Gets the current class name
  145244. * @returns the class name
  145245. */
  145246. getClassName(): string;
  145247. /**
  145248. * Gets the intensity input component
  145249. */
  145250. get intensity(): NodeMaterialConnectionPoint;
  145251. /**
  145252. * Gets the color input component
  145253. */
  145254. get color(): NodeMaterialConnectionPoint;
  145255. /**
  145256. * Gets the roughness input component
  145257. */
  145258. get roughness(): NodeMaterialConnectionPoint;
  145259. /**
  145260. * Gets the sheen object output component
  145261. */
  145262. get sheen(): NodeMaterialConnectionPoint;
  145263. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145264. /**
  145265. * Gets the main code of the block (fragment side)
  145266. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145267. * @returns the shader code
  145268. */
  145269. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  145270. protected _buildBlock(state: NodeMaterialBuildState): this;
  145271. protected _dumpPropertiesCode(): string;
  145272. serialize(): any;
  145273. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145274. }
  145275. }
  145276. declare module BABYLON {
  145277. /**
  145278. * Block used to implement the reflectivity module of the PBR material
  145279. */
  145280. export class ReflectivityBlock extends NodeMaterialBlock {
  145281. private _metallicReflectanceColor;
  145282. private _metallicF0Factor;
  145283. /** @hidden */
  145284. _vMetallicReflectanceFactorsName: string;
  145285. /**
  145286. * The property below is set by the main PBR block prior to calling methods of this class.
  145287. */
  145288. /** @hidden */
  145289. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  145290. /**
  145291. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  145292. */
  145293. useAmbientOcclusionFromMetallicTextureRed: boolean;
  145294. /**
  145295. * Specifies if the metallic texture contains the metallness information in its blue channel.
  145296. */
  145297. useMetallnessFromMetallicTextureBlue: boolean;
  145298. /**
  145299. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  145300. */
  145301. useRoughnessFromMetallicTextureAlpha: boolean;
  145302. /**
  145303. * Specifies if the metallic texture contains the roughness information in its green channel.
  145304. */
  145305. useRoughnessFromMetallicTextureGreen: boolean;
  145306. /**
  145307. * Create a new ReflectivityBlock
  145308. * @param name defines the block name
  145309. */
  145310. constructor(name: string);
  145311. /**
  145312. * Initialize the block and prepare the context for build
  145313. * @param state defines the state that will be used for the build
  145314. */
  145315. initialize(state: NodeMaterialBuildState): void;
  145316. /**
  145317. * Gets the current class name
  145318. * @returns the class name
  145319. */
  145320. getClassName(): string;
  145321. /**
  145322. * Gets the metallic input component
  145323. */
  145324. get metallic(): NodeMaterialConnectionPoint;
  145325. /**
  145326. * Gets the roughness input component
  145327. */
  145328. get roughness(): NodeMaterialConnectionPoint;
  145329. /**
  145330. * Gets the texture input component
  145331. */
  145332. get texture(): NodeMaterialConnectionPoint;
  145333. /**
  145334. * Gets the reflectivity object output component
  145335. */
  145336. get reflectivity(): NodeMaterialConnectionPoint;
  145337. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145338. /**
  145339. * Gets the main code of the block (fragment side)
  145340. * @param state current state of the node material building
  145341. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  145342. * @returns the shader code
  145343. */
  145344. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  145345. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145346. protected _buildBlock(state: NodeMaterialBuildState): this;
  145347. protected _dumpPropertiesCode(): string;
  145348. serialize(): any;
  145349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145350. }
  145351. }
  145352. declare module BABYLON {
  145353. /**
  145354. * Block used to implement the anisotropy module of the PBR material
  145355. */
  145356. export class AnisotropyBlock extends NodeMaterialBlock {
  145357. /**
  145358. * The two properties below are set by the main PBR block prior to calling methods of this class.
  145359. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145360. * It's less burden on the user side in the editor part.
  145361. */
  145362. /** @hidden */
  145363. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145364. /** @hidden */
  145365. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145366. /**
  145367. * Create a new AnisotropyBlock
  145368. * @param name defines the block name
  145369. */
  145370. constructor(name: string);
  145371. /**
  145372. * Initialize the block and prepare the context for build
  145373. * @param state defines the state that will be used for the build
  145374. */
  145375. initialize(state: NodeMaterialBuildState): void;
  145376. /**
  145377. * Gets the current class name
  145378. * @returns the class name
  145379. */
  145380. getClassName(): string;
  145381. /**
  145382. * Gets the intensity input component
  145383. */
  145384. get intensity(): NodeMaterialConnectionPoint;
  145385. /**
  145386. * Gets the direction input component
  145387. */
  145388. get direction(): NodeMaterialConnectionPoint;
  145389. /**
  145390. * Gets the texture input component
  145391. */
  145392. get texture(): NodeMaterialConnectionPoint;
  145393. /**
  145394. * Gets the uv input component
  145395. */
  145396. get uv(): NodeMaterialConnectionPoint;
  145397. /**
  145398. * Gets the worldTangent input component
  145399. */
  145400. get worldTangent(): NodeMaterialConnectionPoint;
  145401. /**
  145402. * Gets the anisotropy object output component
  145403. */
  145404. get anisotropy(): NodeMaterialConnectionPoint;
  145405. private _generateTBNSpace;
  145406. /**
  145407. * Gets the main code of the block (fragment side)
  145408. * @param state current state of the node material building
  145409. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145410. * @returns the shader code
  145411. */
  145412. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  145413. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145414. protected _buildBlock(state: NodeMaterialBuildState): this;
  145415. }
  145416. }
  145417. declare module BABYLON {
  145418. /**
  145419. * Block used to implement the clear coat module of the PBR material
  145420. */
  145421. export class ClearCoatBlock extends NodeMaterialBlock {
  145422. private _scene;
  145423. /**
  145424. * Create a new ClearCoatBlock
  145425. * @param name defines the block name
  145426. */
  145427. constructor(name: string);
  145428. /**
  145429. * Initialize the block and prepare the context for build
  145430. * @param state defines the state that will be used for the build
  145431. */
  145432. initialize(state: NodeMaterialBuildState): void;
  145433. /**
  145434. * Gets the current class name
  145435. * @returns the class name
  145436. */
  145437. getClassName(): string;
  145438. /**
  145439. * Gets the intensity input component
  145440. */
  145441. get intensity(): NodeMaterialConnectionPoint;
  145442. /**
  145443. * Gets the roughness input component
  145444. */
  145445. get roughness(): NodeMaterialConnectionPoint;
  145446. /**
  145447. * Gets the ior input component
  145448. */
  145449. get ior(): NodeMaterialConnectionPoint;
  145450. /**
  145451. * Gets the texture input component
  145452. */
  145453. get texture(): NodeMaterialConnectionPoint;
  145454. /**
  145455. * Gets the bump texture input component
  145456. */
  145457. get bumpTexture(): NodeMaterialConnectionPoint;
  145458. /**
  145459. * Gets the uv input component
  145460. */
  145461. get uv(): NodeMaterialConnectionPoint;
  145462. /**
  145463. * Gets the tint color input component
  145464. */
  145465. get tintColor(): NodeMaterialConnectionPoint;
  145466. /**
  145467. * Gets the tint "at distance" input component
  145468. */
  145469. get tintAtDistance(): NodeMaterialConnectionPoint;
  145470. /**
  145471. * Gets the tint thickness input component
  145472. */
  145473. get tintThickness(): NodeMaterialConnectionPoint;
  145474. /**
  145475. * Gets the world tangent input component
  145476. */
  145477. get worldTangent(): NodeMaterialConnectionPoint;
  145478. /**
  145479. * Gets the clear coat object output component
  145480. */
  145481. get clearcoat(): NodeMaterialConnectionPoint;
  145482. autoConfigure(material: NodeMaterial): void;
  145483. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145484. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145485. private _generateTBNSpace;
  145486. /**
  145487. * Gets the main code of the block (fragment side)
  145488. * @param state current state of the node material building
  145489. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  145490. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145491. * @param worldPosVarName name of the variable holding the world position
  145492. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145493. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  145494. * @param worldNormalVarName name of the variable holding the world normal
  145495. * @returns the shader code
  145496. */
  145497. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  145498. protected _buildBlock(state: NodeMaterialBuildState): this;
  145499. }
  145500. }
  145501. declare module BABYLON {
  145502. /**
  145503. * Block used to implement the sub surface module of the PBR material
  145504. */
  145505. export class SubSurfaceBlock extends NodeMaterialBlock {
  145506. /**
  145507. * Create a new SubSurfaceBlock
  145508. * @param name defines the block name
  145509. */
  145510. constructor(name: string);
  145511. /**
  145512. * Stores the intensity of the different subsurface effects in the thickness texture.
  145513. * * the green channel is the translucency intensity.
  145514. * * the blue channel is the scattering intensity.
  145515. * * the alpha channel is the refraction intensity.
  145516. */
  145517. useMaskFromThicknessTexture: boolean;
  145518. /**
  145519. * Initialize the block and prepare the context for build
  145520. * @param state defines the state that will be used for the build
  145521. */
  145522. initialize(state: NodeMaterialBuildState): void;
  145523. /**
  145524. * Gets the current class name
  145525. * @returns the class name
  145526. */
  145527. getClassName(): string;
  145528. /**
  145529. * Gets the min thickness input component
  145530. */
  145531. get minThickness(): NodeMaterialConnectionPoint;
  145532. /**
  145533. * Gets the max thickness input component
  145534. */
  145535. get maxThickness(): NodeMaterialConnectionPoint;
  145536. /**
  145537. * Gets the thickness texture component
  145538. */
  145539. get thicknessTexture(): NodeMaterialConnectionPoint;
  145540. /**
  145541. * Gets the tint color input component
  145542. */
  145543. get tintColor(): NodeMaterialConnectionPoint;
  145544. /**
  145545. * Gets the translucency intensity input component
  145546. */
  145547. get translucencyIntensity(): NodeMaterialConnectionPoint;
  145548. /**
  145549. * Gets the translucency diffusion distance input component
  145550. */
  145551. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  145552. /**
  145553. * Gets the refraction object parameters
  145554. */
  145555. get refraction(): NodeMaterialConnectionPoint;
  145556. /**
  145557. * Gets the sub surface object output component
  145558. */
  145559. get subsurface(): NodeMaterialConnectionPoint;
  145560. autoConfigure(material: NodeMaterial): void;
  145561. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145562. /**
  145563. * Gets the main code of the block (fragment side)
  145564. * @param state current state of the node material building
  145565. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  145566. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145567. * @param worldPosVarName name of the variable holding the world position
  145568. * @returns the shader code
  145569. */
  145570. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  145571. protected _buildBlock(state: NodeMaterialBuildState): this;
  145572. }
  145573. }
  145574. declare module BABYLON {
  145575. /**
  145576. * Block used to implement the PBR metallic/roughness model
  145577. */
  145578. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  145579. /**
  145580. * Gets or sets the light associated with this block
  145581. */
  145582. light: Nullable<Light>;
  145583. private _lightId;
  145584. private _scene;
  145585. private _environmentBRDFTexture;
  145586. private _environmentBrdfSamplerName;
  145587. private _vNormalWName;
  145588. private _invertNormalName;
  145589. /**
  145590. * Create a new ReflectionBlock
  145591. * @param name defines the block name
  145592. */
  145593. constructor(name: string);
  145594. /**
  145595. * Intensity of the direct lights e.g. the four lights available in your scene.
  145596. * This impacts both the direct diffuse and specular highlights.
  145597. */
  145598. directIntensity: number;
  145599. /**
  145600. * Intensity of the environment e.g. how much the environment will light the object
  145601. * either through harmonics for rough material or through the refelction for shiny ones.
  145602. */
  145603. environmentIntensity: number;
  145604. /**
  145605. * This is a special control allowing the reduction of the specular highlights coming from the
  145606. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  145607. */
  145608. specularIntensity: number;
  145609. /**
  145610. * Defines the falloff type used in this material.
  145611. * It by default is Physical.
  145612. */
  145613. lightFalloff: number;
  145614. /**
  145615. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  145616. */
  145617. useAlphaFromAlbedoTexture: boolean;
  145618. /**
  145619. * Specifies that alpha test should be used
  145620. */
  145621. useAlphaTest: boolean;
  145622. /**
  145623. * Defines the alpha limits in alpha test mode.
  145624. */
  145625. alphaTestCutoff: number;
  145626. /**
  145627. * Specifies that alpha blending should be used
  145628. */
  145629. useAlphaBlending: boolean;
  145630. /**
  145631. * Defines if the alpha value should be determined via the rgb values.
  145632. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  145633. */
  145634. opacityRGB: boolean;
  145635. /**
  145636. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  145637. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  145638. */
  145639. useRadianceOverAlpha: boolean;
  145640. /**
  145641. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  145642. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  145643. */
  145644. useSpecularOverAlpha: boolean;
  145645. /**
  145646. * Enables specular anti aliasing in the PBR shader.
  145647. * It will both interacts on the Geometry for analytical and IBL lighting.
  145648. * It also prefilter the roughness map based on the bump values.
  145649. */
  145650. enableSpecularAntiAliasing: boolean;
  145651. /**
  145652. * Enables realtime filtering on the texture.
  145653. */
  145654. realTimeFiltering: boolean;
  145655. /**
  145656. * Quality switch for realtime filtering
  145657. */
  145658. realTimeFilteringQuality: number;
  145659. /**
  145660. * Defines if the material uses energy conservation.
  145661. */
  145662. useEnergyConservation: boolean;
  145663. /**
  145664. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  145665. * too much the area relying on ambient texture to define their ambient occlusion.
  145666. */
  145667. useRadianceOcclusion: boolean;
  145668. /**
  145669. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  145670. * makes the reflect vector face the model (under horizon).
  145671. */
  145672. useHorizonOcclusion: boolean;
  145673. /**
  145674. * If set to true, no lighting calculations will be applied.
  145675. */
  145676. unlit: boolean;
  145677. /**
  145678. * Force normal to face away from face.
  145679. */
  145680. forceNormalForward: boolean;
  145681. /**
  145682. * Defines the material debug mode.
  145683. * It helps seeing only some components of the material while troubleshooting.
  145684. */
  145685. debugMode: number;
  145686. /**
  145687. * Specify from where on screen the debug mode should start.
  145688. * The value goes from -1 (full screen) to 1 (not visible)
  145689. * It helps with side by side comparison against the final render
  145690. * This defaults to 0
  145691. */
  145692. debugLimit: number;
  145693. /**
  145694. * As the default viewing range might not be enough (if the ambient is really small for instance)
  145695. * You can use the factor to better multiply the final value.
  145696. */
  145697. debugFactor: number;
  145698. /**
  145699. * Initialize the block and prepare the context for build
  145700. * @param state defines the state that will be used for the build
  145701. */
  145702. initialize(state: NodeMaterialBuildState): void;
  145703. /**
  145704. * Gets the current class name
  145705. * @returns the class name
  145706. */
  145707. getClassName(): string;
  145708. /**
  145709. * Gets the world position input component
  145710. */
  145711. get worldPosition(): NodeMaterialConnectionPoint;
  145712. /**
  145713. * Gets the world normal input component
  145714. */
  145715. get worldNormal(): NodeMaterialConnectionPoint;
  145716. /**
  145717. * Gets the perturbed normal input component
  145718. */
  145719. get perturbedNormal(): NodeMaterialConnectionPoint;
  145720. /**
  145721. * Gets the camera position input component
  145722. */
  145723. get cameraPosition(): NodeMaterialConnectionPoint;
  145724. /**
  145725. * Gets the base color input component
  145726. */
  145727. get baseColor(): NodeMaterialConnectionPoint;
  145728. /**
  145729. * Gets the opacity texture input component
  145730. */
  145731. get opacityTexture(): NodeMaterialConnectionPoint;
  145732. /**
  145733. * Gets the ambient color input component
  145734. */
  145735. get ambientColor(): NodeMaterialConnectionPoint;
  145736. /**
  145737. * Gets the reflectivity object parameters
  145738. */
  145739. get reflectivity(): NodeMaterialConnectionPoint;
  145740. /**
  145741. * Gets the ambient occlusion object parameters
  145742. */
  145743. get ambientOcc(): NodeMaterialConnectionPoint;
  145744. /**
  145745. * Gets the reflection object parameters
  145746. */
  145747. get reflection(): NodeMaterialConnectionPoint;
  145748. /**
  145749. * Gets the sheen object parameters
  145750. */
  145751. get sheen(): NodeMaterialConnectionPoint;
  145752. /**
  145753. * Gets the clear coat object parameters
  145754. */
  145755. get clearcoat(): NodeMaterialConnectionPoint;
  145756. /**
  145757. * Gets the sub surface object parameters
  145758. */
  145759. get subsurface(): NodeMaterialConnectionPoint;
  145760. /**
  145761. * Gets the anisotropy object parameters
  145762. */
  145763. get anisotropy(): NodeMaterialConnectionPoint;
  145764. /**
  145765. * Gets the ambient output component
  145766. */
  145767. get ambient(): NodeMaterialConnectionPoint;
  145768. /**
  145769. * Gets the diffuse output component
  145770. */
  145771. get diffuse(): NodeMaterialConnectionPoint;
  145772. /**
  145773. * Gets the specular output component
  145774. */
  145775. get specular(): NodeMaterialConnectionPoint;
  145776. /**
  145777. * Gets the sheen output component
  145778. */
  145779. get sheenDir(): NodeMaterialConnectionPoint;
  145780. /**
  145781. * Gets the clear coat output component
  145782. */
  145783. get clearcoatDir(): NodeMaterialConnectionPoint;
  145784. /**
  145785. * Gets the indirect diffuse output component
  145786. */
  145787. get diffuseIndirect(): NodeMaterialConnectionPoint;
  145788. /**
  145789. * Gets the indirect specular output component
  145790. */
  145791. get specularIndirect(): NodeMaterialConnectionPoint;
  145792. /**
  145793. * Gets the indirect sheen output component
  145794. */
  145795. get sheenIndirect(): NodeMaterialConnectionPoint;
  145796. /**
  145797. * Gets the indirect clear coat output component
  145798. */
  145799. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  145800. /**
  145801. * Gets the refraction output component
  145802. */
  145803. get refraction(): NodeMaterialConnectionPoint;
  145804. /**
  145805. * Gets the global lighting output component
  145806. */
  145807. get lighting(): NodeMaterialConnectionPoint;
  145808. /**
  145809. * Gets the shadow output component
  145810. */
  145811. get shadow(): NodeMaterialConnectionPoint;
  145812. /**
  145813. * Gets the alpha output component
  145814. */
  145815. get alpha(): NodeMaterialConnectionPoint;
  145816. autoConfigure(material: NodeMaterial): void;
  145817. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145818. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145819. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145820. private _injectVertexCode;
  145821. /**
  145822. * Gets the code corresponding to the albedo/opacity module
  145823. * @returns the shader code
  145824. */
  145825. getAlbedoOpacityCode(): string;
  145826. protected _buildBlock(state: NodeMaterialBuildState): this;
  145827. protected _dumpPropertiesCode(): string;
  145828. serialize(): any;
  145829. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145830. }
  145831. }
  145832. declare module BABYLON {
  145833. /**
  145834. * Block used to compute value of one parameter modulo another
  145835. */
  145836. export class ModBlock extends NodeMaterialBlock {
  145837. /**
  145838. * Creates a new ModBlock
  145839. * @param name defines the block name
  145840. */
  145841. constructor(name: string);
  145842. /**
  145843. * Gets the current class name
  145844. * @returns the class name
  145845. */
  145846. getClassName(): string;
  145847. /**
  145848. * Gets the left operand input component
  145849. */
  145850. get left(): NodeMaterialConnectionPoint;
  145851. /**
  145852. * Gets the right operand input component
  145853. */
  145854. get right(): NodeMaterialConnectionPoint;
  145855. /**
  145856. * Gets the output component
  145857. */
  145858. get output(): NodeMaterialConnectionPoint;
  145859. protected _buildBlock(state: NodeMaterialBuildState): this;
  145860. }
  145861. }
  145862. declare module BABYLON {
  145863. /**
  145864. * Configuration for Draco compression
  145865. */
  145866. export interface IDracoCompressionConfiguration {
  145867. /**
  145868. * Configuration for the decoder.
  145869. */
  145870. decoder: {
  145871. /**
  145872. * The url to the WebAssembly module.
  145873. */
  145874. wasmUrl?: string;
  145875. /**
  145876. * The url to the WebAssembly binary.
  145877. */
  145878. wasmBinaryUrl?: string;
  145879. /**
  145880. * The url to the fallback JavaScript module.
  145881. */
  145882. fallbackUrl?: string;
  145883. };
  145884. }
  145885. /**
  145886. * Draco compression (https://google.github.io/draco/)
  145887. *
  145888. * This class wraps the Draco module.
  145889. *
  145890. * **Encoder**
  145891. *
  145892. * The encoder is not currently implemented.
  145893. *
  145894. * **Decoder**
  145895. *
  145896. * 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.
  145897. *
  145898. * To update the configuration, use the following code:
  145899. * ```javascript
  145900. * DracoCompression.Configuration = {
  145901. * decoder: {
  145902. * wasmUrl: "<url to the WebAssembly library>",
  145903. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  145904. * fallbackUrl: "<url to the fallback JavaScript library>",
  145905. * }
  145906. * };
  145907. * ```
  145908. *
  145909. * 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.
  145910. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  145911. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  145912. *
  145913. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  145914. * ```javascript
  145915. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  145916. * ```
  145917. *
  145918. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  145919. */
  145920. export class DracoCompression implements IDisposable {
  145921. private _workerPoolPromise?;
  145922. private _decoderModulePromise?;
  145923. /**
  145924. * The configuration. Defaults to the following urls:
  145925. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  145926. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  145927. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  145928. */
  145929. static Configuration: IDracoCompressionConfiguration;
  145930. /**
  145931. * Returns true if the decoder configuration is available.
  145932. */
  145933. static get DecoderAvailable(): boolean;
  145934. /**
  145935. * Default number of workers to create when creating the draco compression object.
  145936. */
  145937. static DefaultNumWorkers: number;
  145938. private static GetDefaultNumWorkers;
  145939. private static _Default;
  145940. /**
  145941. * Default instance for the draco compression object.
  145942. */
  145943. static get Default(): DracoCompression;
  145944. /**
  145945. * Constructor
  145946. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  145947. */
  145948. constructor(numWorkers?: number);
  145949. /**
  145950. * Stop all async operations and release resources.
  145951. */
  145952. dispose(): void;
  145953. /**
  145954. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  145955. * @returns a promise that resolves when ready
  145956. */
  145957. whenReadyAsync(): Promise<void>;
  145958. /**
  145959. * Decode Draco compressed mesh data to vertex data.
  145960. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  145961. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  145962. * @returns A promise that resolves with the decoded vertex data
  145963. */
  145964. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  145965. [kind: string]: number;
  145966. }): Promise<VertexData>;
  145967. }
  145968. }
  145969. declare module BABYLON {
  145970. /**
  145971. * Class for building Constructive Solid Geometry
  145972. */
  145973. export class CSG {
  145974. private polygons;
  145975. /**
  145976. * The world matrix
  145977. */
  145978. matrix: Matrix;
  145979. /**
  145980. * Stores the position
  145981. */
  145982. position: Vector3;
  145983. /**
  145984. * Stores the rotation
  145985. */
  145986. rotation: Vector3;
  145987. /**
  145988. * Stores the rotation quaternion
  145989. */
  145990. rotationQuaternion: Nullable<Quaternion>;
  145991. /**
  145992. * Stores the scaling vector
  145993. */
  145994. scaling: Vector3;
  145995. /**
  145996. * Convert the Mesh to CSG
  145997. * @param mesh The Mesh to convert to CSG
  145998. * @returns A new CSG from the Mesh
  145999. */
  146000. static FromMesh(mesh: Mesh): CSG;
  146001. /**
  146002. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  146003. * @param polygons Polygons used to construct a CSG solid
  146004. */
  146005. private static FromPolygons;
  146006. /**
  146007. * Clones, or makes a deep copy, of the CSG
  146008. * @returns A new CSG
  146009. */
  146010. clone(): CSG;
  146011. /**
  146012. * Unions this CSG with another CSG
  146013. * @param csg The CSG to union against this CSG
  146014. * @returns The unioned CSG
  146015. */
  146016. union(csg: CSG): CSG;
  146017. /**
  146018. * Unions this CSG with another CSG in place
  146019. * @param csg The CSG to union against this CSG
  146020. */
  146021. unionInPlace(csg: CSG): void;
  146022. /**
  146023. * Subtracts this CSG with another CSG
  146024. * @param csg The CSG to subtract against this CSG
  146025. * @returns A new CSG
  146026. */
  146027. subtract(csg: CSG): CSG;
  146028. /**
  146029. * Subtracts this CSG with another CSG in place
  146030. * @param csg The CSG to subtact against this CSG
  146031. */
  146032. subtractInPlace(csg: CSG): void;
  146033. /**
  146034. * Intersect this CSG with another CSG
  146035. * @param csg The CSG to intersect against this CSG
  146036. * @returns A new CSG
  146037. */
  146038. intersect(csg: CSG): CSG;
  146039. /**
  146040. * Intersects this CSG with another CSG in place
  146041. * @param csg The CSG to intersect against this CSG
  146042. */
  146043. intersectInPlace(csg: CSG): void;
  146044. /**
  146045. * Return a new CSG solid with solid and empty space switched. This solid is
  146046. * not modified.
  146047. * @returns A new CSG solid with solid and empty space switched
  146048. */
  146049. inverse(): CSG;
  146050. /**
  146051. * Inverses the CSG in place
  146052. */
  146053. inverseInPlace(): void;
  146054. /**
  146055. * This is used to keep meshes transformations so they can be restored
  146056. * when we build back a Babylon Mesh
  146057. * NB : All CSG operations are performed in world coordinates
  146058. * @param csg The CSG to copy the transform attributes from
  146059. * @returns This CSG
  146060. */
  146061. copyTransformAttributes(csg: CSG): CSG;
  146062. /**
  146063. * Build Raw mesh from CSG
  146064. * Coordinates here are in world space
  146065. * @param name The name of the mesh geometry
  146066. * @param scene The Scene
  146067. * @param keepSubMeshes Specifies if the submeshes should be kept
  146068. * @returns A new Mesh
  146069. */
  146070. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146071. /**
  146072. * Build Mesh from CSG taking material and transforms into account
  146073. * @param name The name of the Mesh
  146074. * @param material The material of the Mesh
  146075. * @param scene The Scene
  146076. * @param keepSubMeshes Specifies if submeshes should be kept
  146077. * @returns The new Mesh
  146078. */
  146079. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146080. }
  146081. }
  146082. declare module BABYLON {
  146083. /**
  146084. * Class used to create a trail following a mesh
  146085. */
  146086. export class TrailMesh extends Mesh {
  146087. private _generator;
  146088. private _autoStart;
  146089. private _running;
  146090. private _diameter;
  146091. private _length;
  146092. private _sectionPolygonPointsCount;
  146093. private _sectionVectors;
  146094. private _sectionNormalVectors;
  146095. private _beforeRenderObserver;
  146096. /**
  146097. * @constructor
  146098. * @param name The value used by scene.getMeshByName() to do a lookup.
  146099. * @param generator The mesh or transform node to generate a trail.
  146100. * @param scene The scene to add this mesh to.
  146101. * @param diameter Diameter of trailing mesh. Default is 1.
  146102. * @param length Length of trailing mesh. Default is 60.
  146103. * @param autoStart Automatically start trailing mesh. Default true.
  146104. */
  146105. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  146106. /**
  146107. * "TrailMesh"
  146108. * @returns "TrailMesh"
  146109. */
  146110. getClassName(): string;
  146111. private _createMesh;
  146112. /**
  146113. * Start trailing mesh.
  146114. */
  146115. start(): void;
  146116. /**
  146117. * Stop trailing mesh.
  146118. */
  146119. stop(): void;
  146120. /**
  146121. * Update trailing mesh geometry.
  146122. */
  146123. update(): void;
  146124. /**
  146125. * Returns a new TrailMesh object.
  146126. * @param name is a string, the name given to the new mesh
  146127. * @param newGenerator use new generator object for cloned trail mesh
  146128. * @returns a new mesh
  146129. */
  146130. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  146131. /**
  146132. * Serializes this trail mesh
  146133. * @param serializationObject object to write serialization to
  146134. */
  146135. serialize(serializationObject: any): void;
  146136. /**
  146137. * Parses a serialized trail mesh
  146138. * @param parsedMesh the serialized mesh
  146139. * @param scene the scene to create the trail mesh in
  146140. * @returns the created trail mesh
  146141. */
  146142. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  146143. }
  146144. }
  146145. declare module BABYLON {
  146146. /**
  146147. * Class containing static functions to help procedurally build meshes
  146148. */
  146149. export class TiledBoxBuilder {
  146150. /**
  146151. * Creates a box mesh
  146152. * 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)
  146153. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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 box mesh
  146161. */
  146162. static CreateTiledBox(name: string, options: {
  146163. pattern?: number;
  146164. width?: number;
  146165. height?: number;
  146166. depth?: number;
  146167. tileSize?: number;
  146168. tileWidth?: number;
  146169. tileHeight?: number;
  146170. alignHorizontal?: number;
  146171. alignVertical?: number;
  146172. faceUV?: Vector4[];
  146173. faceColors?: Color4[];
  146174. sideOrientation?: number;
  146175. updatable?: boolean;
  146176. }, scene?: Nullable<Scene>): Mesh;
  146177. }
  146178. }
  146179. declare module BABYLON {
  146180. /**
  146181. * Class containing static functions to help procedurally build meshes
  146182. */
  146183. export class TorusKnotBuilder {
  146184. /**
  146185. * Creates a torus knot mesh
  146186. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146187. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146188. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146189. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146193. * @param name defines the name of the mesh
  146194. * @param options defines the options used to create the mesh
  146195. * @param scene defines the hosting scene
  146196. * @returns the torus knot mesh
  146197. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146198. */
  146199. static CreateTorusKnot(name: string, options: {
  146200. radius?: number;
  146201. tube?: number;
  146202. radialSegments?: number;
  146203. tubularSegments?: number;
  146204. p?: number;
  146205. q?: number;
  146206. updatable?: boolean;
  146207. sideOrientation?: number;
  146208. frontUVs?: Vector4;
  146209. backUVs?: Vector4;
  146210. }, scene: any): Mesh;
  146211. }
  146212. }
  146213. declare module BABYLON {
  146214. /**
  146215. * Polygon
  146216. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  146217. */
  146218. export class Polygon {
  146219. /**
  146220. * Creates a rectangle
  146221. * @param xmin bottom X coord
  146222. * @param ymin bottom Y coord
  146223. * @param xmax top X coord
  146224. * @param ymax top Y coord
  146225. * @returns points that make the resulting rectation
  146226. */
  146227. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  146228. /**
  146229. * Creates a circle
  146230. * @param radius radius of circle
  146231. * @param cx scale in x
  146232. * @param cy scale in y
  146233. * @param numberOfSides number of sides that make up the circle
  146234. * @returns points that make the resulting circle
  146235. */
  146236. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  146237. /**
  146238. * Creates a polygon from input string
  146239. * @param input Input polygon data
  146240. * @returns the parsed points
  146241. */
  146242. static Parse(input: string): Vector2[];
  146243. /**
  146244. * Starts building a polygon from x and y coordinates
  146245. * @param x x coordinate
  146246. * @param y y coordinate
  146247. * @returns the started path2
  146248. */
  146249. static StartingAt(x: number, y: number): Path2;
  146250. }
  146251. /**
  146252. * Builds a polygon
  146253. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  146254. */
  146255. export class PolygonMeshBuilder {
  146256. private _points;
  146257. private _outlinepoints;
  146258. private _holes;
  146259. private _name;
  146260. private _scene;
  146261. private _epoints;
  146262. private _eholes;
  146263. private _addToepoint;
  146264. /**
  146265. * Babylon reference to the earcut plugin.
  146266. */
  146267. bjsEarcut: any;
  146268. /**
  146269. * Creates a PolygonMeshBuilder
  146270. * @param name name of the builder
  146271. * @param contours Path of the polygon
  146272. * @param scene scene to add to when creating the mesh
  146273. * @param earcutInjection can be used to inject your own earcut reference
  146274. */
  146275. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  146276. /**
  146277. * Adds a whole within the polygon
  146278. * @param hole Array of points defining the hole
  146279. * @returns this
  146280. */
  146281. addHole(hole: Vector2[]): PolygonMeshBuilder;
  146282. /**
  146283. * Creates the polygon
  146284. * @param updatable If the mesh should be updatable
  146285. * @param depth The depth of the mesh created
  146286. * @returns the created mesh
  146287. */
  146288. build(updatable?: boolean, depth?: number): Mesh;
  146289. /**
  146290. * Creates the polygon
  146291. * @param depth The depth of the mesh created
  146292. * @returns the created VertexData
  146293. */
  146294. buildVertexData(depth?: number): VertexData;
  146295. /**
  146296. * Adds a side to the polygon
  146297. * @param positions points that make the polygon
  146298. * @param normals normals of the polygon
  146299. * @param uvs uvs of the polygon
  146300. * @param indices indices of the polygon
  146301. * @param bounds bounds of the polygon
  146302. * @param points points of the polygon
  146303. * @param depth depth of the polygon
  146304. * @param flip flip of the polygon
  146305. */
  146306. private addSide;
  146307. }
  146308. }
  146309. declare module BABYLON {
  146310. /**
  146311. * Class containing static functions to help procedurally build meshes
  146312. */
  146313. export class PolygonBuilder {
  146314. /**
  146315. * Creates a polygon mesh
  146316. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146317. * * 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
  146318. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146321. * * Remember you can only change the shape positions, not their number when updating a polygon
  146322. * @param name defines the name of the mesh
  146323. * @param options defines the options used to create the mesh
  146324. * @param scene defines the hosting scene
  146325. * @param earcutInjection can be used to inject your own earcut reference
  146326. * @returns the polygon mesh
  146327. */
  146328. static CreatePolygon(name: string, options: {
  146329. shape: Vector3[];
  146330. holes?: Vector3[][];
  146331. depth?: number;
  146332. faceUV?: Vector4[];
  146333. faceColors?: Color4[];
  146334. updatable?: boolean;
  146335. sideOrientation?: number;
  146336. frontUVs?: Vector4;
  146337. backUVs?: Vector4;
  146338. wrap?: boolean;
  146339. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146340. /**
  146341. * Creates an extruded polygon mesh, with depth in the Y direction.
  146342. * * 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)
  146343. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146344. * @param name defines the name of the mesh
  146345. * @param options defines the options used to create the mesh
  146346. * @param scene defines the hosting scene
  146347. * @param earcutInjection can be used to inject your own earcut reference
  146348. * @returns the polygon mesh
  146349. */
  146350. static ExtrudePolygon(name: string, options: {
  146351. shape: Vector3[];
  146352. holes?: Vector3[][];
  146353. depth?: number;
  146354. faceUV?: Vector4[];
  146355. faceColors?: Color4[];
  146356. updatable?: boolean;
  146357. sideOrientation?: number;
  146358. frontUVs?: Vector4;
  146359. backUVs?: Vector4;
  146360. wrap?: boolean;
  146361. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146362. }
  146363. }
  146364. declare module BABYLON {
  146365. /**
  146366. * Class containing static functions to help procedurally build meshes
  146367. */
  146368. export class LatheBuilder {
  146369. /**
  146370. * Creates lathe mesh.
  146371. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146372. * * 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
  146373. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146374. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146375. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146376. * * 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
  146377. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146378. * * 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
  146379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146380. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146381. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146383. * @param name defines the name of the mesh
  146384. * @param options defines the options used to create the mesh
  146385. * @param scene defines the hosting scene
  146386. * @returns the lathe mesh
  146387. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146388. */
  146389. static CreateLathe(name: string, options: {
  146390. shape: Vector3[];
  146391. radius?: number;
  146392. tessellation?: number;
  146393. clip?: number;
  146394. arc?: number;
  146395. closed?: boolean;
  146396. updatable?: boolean;
  146397. sideOrientation?: number;
  146398. frontUVs?: Vector4;
  146399. backUVs?: Vector4;
  146400. cap?: number;
  146401. invertUV?: boolean;
  146402. }, scene?: Nullable<Scene>): Mesh;
  146403. }
  146404. }
  146405. declare module BABYLON {
  146406. /**
  146407. * Class containing static functions to help procedurally build meshes
  146408. */
  146409. export class TiledPlaneBuilder {
  146410. /**
  146411. * Creates a tiled plane mesh
  146412. * * The parameter `pattern` will, depending on value, do nothing or
  146413. * * * flip (reflect about central vertical) alternate tiles across and up
  146414. * * * flip every tile on alternate rows
  146415. * * * rotate (180 degs) alternate tiles across and up
  146416. * * * rotate every tile on alternate rows
  146417. * * * flip and rotate alternate tiles across and up
  146418. * * * flip and rotate every tile on alternate rows
  146419. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  146420. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  146421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146422. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146423. * * 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)
  146424. * * 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)
  146425. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146426. * @param name defines the name of the mesh
  146427. * @param options defines the options used to create the mesh
  146428. * @param scene defines the hosting scene
  146429. * @returns the box mesh
  146430. */
  146431. static CreateTiledPlane(name: string, options: {
  146432. pattern?: number;
  146433. tileSize?: number;
  146434. tileWidth?: number;
  146435. tileHeight?: number;
  146436. size?: number;
  146437. width?: number;
  146438. height?: number;
  146439. alignHorizontal?: number;
  146440. alignVertical?: number;
  146441. sideOrientation?: number;
  146442. frontUVs?: Vector4;
  146443. backUVs?: Vector4;
  146444. updatable?: boolean;
  146445. }, scene?: Nullable<Scene>): Mesh;
  146446. }
  146447. }
  146448. declare module BABYLON {
  146449. /**
  146450. * Class containing static functions to help procedurally build meshes
  146451. */
  146452. export class TubeBuilder {
  146453. /**
  146454. * Creates a tube mesh.
  146455. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146456. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146457. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146458. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146459. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146460. * * 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)
  146461. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146462. * * 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
  146463. * * 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
  146464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146468. * @param name defines the name of the mesh
  146469. * @param options defines the options used to create the mesh
  146470. * @param scene defines the hosting scene
  146471. * @returns the tube mesh
  146472. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146473. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146474. */
  146475. static CreateTube(name: string, options: {
  146476. path: Vector3[];
  146477. radius?: number;
  146478. tessellation?: number;
  146479. radiusFunction?: {
  146480. (i: number, distance: number): number;
  146481. };
  146482. cap?: number;
  146483. arc?: number;
  146484. updatable?: boolean;
  146485. sideOrientation?: number;
  146486. frontUVs?: Vector4;
  146487. backUVs?: Vector4;
  146488. instance?: Mesh;
  146489. invertUV?: boolean;
  146490. }, scene?: Nullable<Scene>): Mesh;
  146491. }
  146492. }
  146493. declare module BABYLON {
  146494. /**
  146495. * Class containing static functions to help procedurally build meshes
  146496. */
  146497. export class IcoSphereBuilder {
  146498. /**
  146499. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146500. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146501. * * 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`)
  146502. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146503. * * 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
  146504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146507. * @param name defines the name of the mesh
  146508. * @param options defines the options used to create the mesh
  146509. * @param scene defines the hosting scene
  146510. * @returns the icosahedron mesh
  146511. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146512. */
  146513. static CreateIcoSphere(name: string, options: {
  146514. radius?: number;
  146515. radiusX?: number;
  146516. radiusY?: number;
  146517. radiusZ?: number;
  146518. flat?: boolean;
  146519. subdivisions?: number;
  146520. sideOrientation?: number;
  146521. frontUVs?: Vector4;
  146522. backUVs?: Vector4;
  146523. updatable?: boolean;
  146524. }, scene?: Nullable<Scene>): Mesh;
  146525. }
  146526. }
  146527. declare module BABYLON {
  146528. /**
  146529. * Class containing static functions to help procedurally build meshes
  146530. */
  146531. export class DecalBuilder {
  146532. /**
  146533. * Creates a decal mesh.
  146534. * 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
  146535. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146536. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146537. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146538. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146539. * @param name defines the name of the mesh
  146540. * @param sourceMesh defines the mesh where the decal must be applied
  146541. * @param options defines the options used to create the mesh
  146542. * @param scene defines the hosting scene
  146543. * @returns the decal mesh
  146544. * @see https://doc.babylonjs.com/how_to/decals
  146545. */
  146546. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146547. position?: Vector3;
  146548. normal?: Vector3;
  146549. size?: Vector3;
  146550. angle?: number;
  146551. }): Mesh;
  146552. }
  146553. }
  146554. declare module BABYLON {
  146555. /**
  146556. * Class containing static functions to help procedurally build meshes
  146557. */
  146558. export class MeshBuilder {
  146559. /**
  146560. * Creates a box mesh
  146561. * * The parameter `size` sets the size (float) of each box side (default 1)
  146562. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  146563. * * 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)
  146564. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146566. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146569. * @param name defines the name of the mesh
  146570. * @param options defines the options used to create the mesh
  146571. * @param scene defines the hosting scene
  146572. * @returns the box mesh
  146573. */
  146574. static CreateBox(name: string, options: {
  146575. size?: number;
  146576. width?: number;
  146577. height?: number;
  146578. depth?: number;
  146579. faceUV?: Vector4[];
  146580. faceColors?: Color4[];
  146581. sideOrientation?: number;
  146582. frontUVs?: Vector4;
  146583. backUVs?: Vector4;
  146584. wrap?: boolean;
  146585. topBaseAt?: number;
  146586. bottomBaseAt?: number;
  146587. updatable?: boolean;
  146588. }, scene?: Nullable<Scene>): Mesh;
  146589. /**
  146590. * Creates a tiled box mesh
  146591. * * faceTiles sets the pattern, tile size and number of tiles for a face
  146592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146593. * @param name defines the name of the mesh
  146594. * @param options defines the options used to create the mesh
  146595. * @param scene defines the hosting scene
  146596. * @returns the tiled box mesh
  146597. */
  146598. static CreateTiledBox(name: string, options: {
  146599. pattern?: number;
  146600. size?: number;
  146601. width?: number;
  146602. height?: number;
  146603. depth: number;
  146604. tileSize?: number;
  146605. tileWidth?: number;
  146606. tileHeight?: number;
  146607. faceUV?: Vector4[];
  146608. faceColors?: Color4[];
  146609. alignHorizontal?: number;
  146610. alignVertical?: number;
  146611. sideOrientation?: number;
  146612. updatable?: boolean;
  146613. }, scene?: Nullable<Scene>): Mesh;
  146614. /**
  146615. * Creates a sphere mesh
  146616. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  146617. * * 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`)
  146618. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  146619. * * 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
  146620. * * 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)
  146621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146624. * @param name defines the name of the mesh
  146625. * @param options defines the options used to create the mesh
  146626. * @param scene defines the hosting scene
  146627. * @returns the sphere mesh
  146628. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  146629. */
  146630. static CreateSphere(name: string, options: {
  146631. segments?: number;
  146632. diameter?: number;
  146633. diameterX?: number;
  146634. diameterY?: number;
  146635. diameterZ?: number;
  146636. arc?: number;
  146637. slice?: number;
  146638. sideOrientation?: number;
  146639. frontUVs?: Vector4;
  146640. backUVs?: Vector4;
  146641. updatable?: boolean;
  146642. }, scene?: Nullable<Scene>): Mesh;
  146643. /**
  146644. * Creates a plane polygonal mesh. By default, this is a disc
  146645. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  146646. * * 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
  146647. * * 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
  146648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146651. * @param name defines the name of the mesh
  146652. * @param options defines the options used to create the mesh
  146653. * @param scene defines the hosting scene
  146654. * @returns the plane polygonal mesh
  146655. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  146656. */
  146657. static CreateDisc(name: string, options: {
  146658. radius?: number;
  146659. tessellation?: number;
  146660. arc?: number;
  146661. updatable?: boolean;
  146662. sideOrientation?: number;
  146663. frontUVs?: Vector4;
  146664. backUVs?: Vector4;
  146665. }, scene?: Nullable<Scene>): Mesh;
  146666. /**
  146667. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146668. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146669. * * 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`)
  146670. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146671. * * 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
  146672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146675. * @param name defines the name of the mesh
  146676. * @param options defines the options used to create the mesh
  146677. * @param scene defines the hosting scene
  146678. * @returns the icosahedron mesh
  146679. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146680. */
  146681. static CreateIcoSphere(name: string, options: {
  146682. radius?: number;
  146683. radiusX?: number;
  146684. radiusY?: number;
  146685. radiusZ?: number;
  146686. flat?: boolean;
  146687. subdivisions?: number;
  146688. sideOrientation?: number;
  146689. frontUVs?: Vector4;
  146690. backUVs?: Vector4;
  146691. updatable?: boolean;
  146692. }, scene?: Nullable<Scene>): Mesh;
  146693. /**
  146694. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146695. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  146696. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  146697. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  146698. * * 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
  146699. * * 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
  146700. * * 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
  146701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146703. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146704. * * 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
  146705. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  146706. * * 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
  146707. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  146708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146709. * @param name defines the name of the mesh
  146710. * @param options defines the options used to create the mesh
  146711. * @param scene defines the hosting scene
  146712. * @returns the ribbon mesh
  146713. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  146714. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146715. */
  146716. static CreateRibbon(name: string, options: {
  146717. pathArray: Vector3[][];
  146718. closeArray?: boolean;
  146719. closePath?: boolean;
  146720. offset?: number;
  146721. updatable?: boolean;
  146722. sideOrientation?: number;
  146723. frontUVs?: Vector4;
  146724. backUVs?: Vector4;
  146725. instance?: Mesh;
  146726. invertUV?: boolean;
  146727. uvs?: Vector2[];
  146728. colors?: Color4[];
  146729. }, scene?: Nullable<Scene>): Mesh;
  146730. /**
  146731. * Creates a cylinder or a cone mesh
  146732. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  146733. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  146734. * * 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.
  146735. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  146736. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  146737. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  146738. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  146739. * * 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).
  146740. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  146741. * * 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).
  146742. * * 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
  146743. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  146744. * * 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
  146745. * * 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.
  146746. * * If `enclose` is false, a ring surface is one element.
  146747. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  146748. * * 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
  146749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146752. * @param name defines the name of the mesh
  146753. * @param options defines the options used to create the mesh
  146754. * @param scene defines the hosting scene
  146755. * @returns the cylinder mesh
  146756. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  146757. */
  146758. static CreateCylinder(name: string, options: {
  146759. height?: number;
  146760. diameterTop?: number;
  146761. diameterBottom?: number;
  146762. diameter?: number;
  146763. tessellation?: number;
  146764. subdivisions?: number;
  146765. arc?: number;
  146766. faceColors?: Color4[];
  146767. faceUV?: Vector4[];
  146768. updatable?: boolean;
  146769. hasRings?: boolean;
  146770. enclose?: boolean;
  146771. cap?: number;
  146772. sideOrientation?: number;
  146773. frontUVs?: Vector4;
  146774. backUVs?: Vector4;
  146775. }, scene?: Nullable<Scene>): Mesh;
  146776. /**
  146777. * Creates a torus mesh
  146778. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  146779. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  146780. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  146781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146782. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146784. * @param name defines the name of the mesh
  146785. * @param options defines the options used to create the mesh
  146786. * @param scene defines the hosting scene
  146787. * @returns the torus mesh
  146788. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  146789. */
  146790. static CreateTorus(name: string, options: {
  146791. diameter?: number;
  146792. thickness?: number;
  146793. tessellation?: number;
  146794. updatable?: boolean;
  146795. sideOrientation?: number;
  146796. frontUVs?: Vector4;
  146797. backUVs?: Vector4;
  146798. }, scene?: Nullable<Scene>): Mesh;
  146799. /**
  146800. * Creates a torus knot mesh
  146801. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146802. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146803. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146804. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146808. * @param name defines the name of the mesh
  146809. * @param options defines the options used to create the mesh
  146810. * @param scene defines the hosting scene
  146811. * @returns the torus knot mesh
  146812. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146813. */
  146814. static CreateTorusKnot(name: string, options: {
  146815. radius?: number;
  146816. tube?: number;
  146817. radialSegments?: number;
  146818. tubularSegments?: number;
  146819. p?: number;
  146820. q?: number;
  146821. updatable?: boolean;
  146822. sideOrientation?: number;
  146823. frontUVs?: Vector4;
  146824. backUVs?: Vector4;
  146825. }, scene?: Nullable<Scene>): Mesh;
  146826. /**
  146827. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  146828. * * 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
  146829. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  146830. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  146831. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  146832. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  146833. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  146834. * * 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
  146835. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  146836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146837. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  146838. * @param name defines the name of the new line system
  146839. * @param options defines the options used to create the line system
  146840. * @param scene defines the hosting scene
  146841. * @returns a new line system mesh
  146842. */
  146843. static CreateLineSystem(name: string, options: {
  146844. lines: Vector3[][];
  146845. updatable?: boolean;
  146846. instance?: Nullable<LinesMesh>;
  146847. colors?: Nullable<Color4[][]>;
  146848. useVertexAlpha?: boolean;
  146849. }, scene: Nullable<Scene>): LinesMesh;
  146850. /**
  146851. * Creates a line mesh
  146852. * 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
  146853. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146854. * * The parameter `points` is an array successive Vector3
  146855. * * 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
  146856. * * The optional parameter `colors` is an array of successive Color4, one per line point
  146857. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  146858. * * When updating an instance, remember that only point positions can change, not the number of points
  146859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146860. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  146861. * @param name defines the name of the new line system
  146862. * @param options defines the options used to create the line system
  146863. * @param scene defines the hosting scene
  146864. * @returns a new line mesh
  146865. */
  146866. static CreateLines(name: string, options: {
  146867. points: Vector3[];
  146868. updatable?: boolean;
  146869. instance?: Nullable<LinesMesh>;
  146870. colors?: Color4[];
  146871. useVertexAlpha?: boolean;
  146872. }, scene?: Nullable<Scene>): LinesMesh;
  146873. /**
  146874. * Creates a dashed line mesh
  146875. * * 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
  146876. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146877. * * The parameter `points` is an array successive Vector3
  146878. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  146879. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  146880. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  146881. * * 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
  146882. * * When updating an instance, remember that only point positions can change, not the number of points
  146883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146884. * @param name defines the name of the mesh
  146885. * @param options defines the options used to create the mesh
  146886. * @param scene defines the hosting scene
  146887. * @returns the dashed line mesh
  146888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  146889. */
  146890. static CreateDashedLines(name: string, options: {
  146891. points: Vector3[];
  146892. dashSize?: number;
  146893. gapSize?: number;
  146894. dashNb?: number;
  146895. updatable?: boolean;
  146896. instance?: LinesMesh;
  146897. }, scene?: Nullable<Scene>): LinesMesh;
  146898. /**
  146899. * 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.
  146900. * * 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.
  146901. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146902. * * 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.
  146903. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  146904. * * 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
  146905. * * 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
  146906. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  146907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146909. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  146910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146911. * @param name defines the name of the mesh
  146912. * @param options defines the options used to create the mesh
  146913. * @param scene defines the hosting scene
  146914. * @returns the extruded shape mesh
  146915. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146917. */
  146918. static ExtrudeShape(name: string, options: {
  146919. shape: Vector3[];
  146920. path: Vector3[];
  146921. scale?: number;
  146922. rotation?: number;
  146923. cap?: number;
  146924. updatable?: boolean;
  146925. sideOrientation?: number;
  146926. frontUVs?: Vector4;
  146927. backUVs?: Vector4;
  146928. instance?: Mesh;
  146929. invertUV?: boolean;
  146930. }, scene?: Nullable<Scene>): Mesh;
  146931. /**
  146932. * Creates an custom extruded shape mesh.
  146933. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  146934. * * 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.
  146935. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146936. * * 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
  146937. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  146938. * * 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
  146939. * * It must returns a float value that will be the scale value applied to the shape on each path point
  146940. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  146941. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  146942. * * 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
  146943. * * 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
  146944. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  146945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146947. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146949. * @param name defines the name of the mesh
  146950. * @param options defines the options used to create the mesh
  146951. * @param scene defines the hosting scene
  146952. * @returns the custom extruded shape mesh
  146953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  146954. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146956. */
  146957. static ExtrudeShapeCustom(name: string, options: {
  146958. shape: Vector3[];
  146959. path: Vector3[];
  146960. scaleFunction?: any;
  146961. rotationFunction?: any;
  146962. ribbonCloseArray?: boolean;
  146963. ribbonClosePath?: boolean;
  146964. cap?: number;
  146965. updatable?: boolean;
  146966. sideOrientation?: number;
  146967. frontUVs?: Vector4;
  146968. backUVs?: Vector4;
  146969. instance?: Mesh;
  146970. invertUV?: boolean;
  146971. }, scene?: Nullable<Scene>): Mesh;
  146972. /**
  146973. * Creates lathe mesh.
  146974. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146975. * * 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
  146976. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146977. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146978. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146979. * * 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
  146980. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146981. * * 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
  146982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146984. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146986. * @param name defines the name of the mesh
  146987. * @param options defines the options used to create the mesh
  146988. * @param scene defines the hosting scene
  146989. * @returns the lathe mesh
  146990. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146991. */
  146992. static CreateLathe(name: string, options: {
  146993. shape: Vector3[];
  146994. radius?: number;
  146995. tessellation?: number;
  146996. clip?: number;
  146997. arc?: number;
  146998. closed?: boolean;
  146999. updatable?: boolean;
  147000. sideOrientation?: number;
  147001. frontUVs?: Vector4;
  147002. backUVs?: Vector4;
  147003. cap?: number;
  147004. invertUV?: boolean;
  147005. }, scene?: Nullable<Scene>): Mesh;
  147006. /**
  147007. * Creates a tiled plane mesh
  147008. * * You can set a limited pattern arrangement with the tiles
  147009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147012. * @param name defines the name of the mesh
  147013. * @param options defines the options used to create the mesh
  147014. * @param scene defines the hosting scene
  147015. * @returns the plane mesh
  147016. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147017. */
  147018. static CreateTiledPlane(name: string, options: {
  147019. pattern?: number;
  147020. tileSize?: number;
  147021. tileWidth?: number;
  147022. tileHeight?: number;
  147023. size?: number;
  147024. width?: number;
  147025. height?: number;
  147026. alignHorizontal?: number;
  147027. alignVertical?: number;
  147028. sideOrientation?: number;
  147029. frontUVs?: Vector4;
  147030. backUVs?: Vector4;
  147031. updatable?: boolean;
  147032. }, scene?: Nullable<Scene>): Mesh;
  147033. /**
  147034. * Creates a plane mesh
  147035. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  147036. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  147037. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  147038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147039. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147041. * @param name defines the name of the mesh
  147042. * @param options defines the options used to create the mesh
  147043. * @param scene defines the hosting scene
  147044. * @returns the plane mesh
  147045. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147046. */
  147047. static CreatePlane(name: string, options: {
  147048. size?: number;
  147049. width?: number;
  147050. height?: number;
  147051. sideOrientation?: number;
  147052. frontUVs?: Vector4;
  147053. backUVs?: Vector4;
  147054. updatable?: boolean;
  147055. sourcePlane?: Plane;
  147056. }, scene?: Nullable<Scene>): Mesh;
  147057. /**
  147058. * Creates a ground mesh
  147059. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  147060. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  147061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147062. * @param name defines the name of the mesh
  147063. * @param options defines the options used to create the mesh
  147064. * @param scene defines the hosting scene
  147065. * @returns the ground mesh
  147066. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  147067. */
  147068. static CreateGround(name: string, options: {
  147069. width?: number;
  147070. height?: number;
  147071. subdivisions?: number;
  147072. subdivisionsX?: number;
  147073. subdivisionsY?: number;
  147074. updatable?: boolean;
  147075. }, scene?: Nullable<Scene>): Mesh;
  147076. /**
  147077. * Creates a tiled ground mesh
  147078. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  147079. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  147080. * * 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
  147081. * * 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
  147082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147083. * @param name defines the name of the mesh
  147084. * @param options defines the options used to create the mesh
  147085. * @param scene defines the hosting scene
  147086. * @returns the tiled ground mesh
  147087. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  147088. */
  147089. static CreateTiledGround(name: string, options: {
  147090. xmin: number;
  147091. zmin: number;
  147092. xmax: number;
  147093. zmax: number;
  147094. subdivisions?: {
  147095. w: number;
  147096. h: number;
  147097. };
  147098. precision?: {
  147099. w: number;
  147100. h: number;
  147101. };
  147102. updatable?: boolean;
  147103. }, scene?: Nullable<Scene>): Mesh;
  147104. /**
  147105. * Creates a ground mesh from a height map
  147106. * * The parameter `url` sets the URL of the height map image resource.
  147107. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  147108. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  147109. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  147110. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  147111. * * 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.
  147112. * * 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).
  147113. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  147114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147115. * @param name defines the name of the mesh
  147116. * @param url defines the url to the height map
  147117. * @param options defines the options used to create the mesh
  147118. * @param scene defines the hosting scene
  147119. * @returns the ground mesh
  147120. * @see https://doc.babylonjs.com/babylon101/height_map
  147121. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  147122. */
  147123. static CreateGroundFromHeightMap(name: string, url: string, options: {
  147124. width?: number;
  147125. height?: number;
  147126. subdivisions?: number;
  147127. minHeight?: number;
  147128. maxHeight?: number;
  147129. colorFilter?: Color3;
  147130. alphaFilter?: number;
  147131. updatable?: boolean;
  147132. onReady?: (mesh: GroundMesh) => void;
  147133. }, scene?: Nullable<Scene>): GroundMesh;
  147134. /**
  147135. * Creates a polygon mesh
  147136. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147137. * * 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
  147138. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147141. * * Remember you can only change the shape positions, not their number when updating a polygon
  147142. * @param name defines the name of the mesh
  147143. * @param options defines the options used to create the mesh
  147144. * @param scene defines the hosting scene
  147145. * @param earcutInjection can be used to inject your own earcut reference
  147146. * @returns the polygon mesh
  147147. */
  147148. static CreatePolygon(name: string, options: {
  147149. shape: Vector3[];
  147150. holes?: Vector3[][];
  147151. depth?: number;
  147152. faceUV?: Vector4[];
  147153. faceColors?: Color4[];
  147154. updatable?: boolean;
  147155. sideOrientation?: number;
  147156. frontUVs?: Vector4;
  147157. backUVs?: Vector4;
  147158. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147159. /**
  147160. * Creates an extruded polygon mesh, with depth in the Y direction.
  147161. * * 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)
  147162. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147163. * @param name defines the name of the mesh
  147164. * @param options defines the options used to create the mesh
  147165. * @param scene defines the hosting scene
  147166. * @param earcutInjection can be used to inject your own earcut reference
  147167. * @returns the polygon mesh
  147168. */
  147169. static ExtrudePolygon(name: string, options: {
  147170. shape: Vector3[];
  147171. holes?: Vector3[][];
  147172. depth?: number;
  147173. faceUV?: Vector4[];
  147174. faceColors?: Color4[];
  147175. updatable?: boolean;
  147176. sideOrientation?: number;
  147177. frontUVs?: Vector4;
  147178. backUVs?: Vector4;
  147179. wrap?: boolean;
  147180. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147181. /**
  147182. * Creates a tube mesh.
  147183. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147184. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147185. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147186. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147187. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147188. * * 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)
  147189. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147190. * * 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
  147191. * * 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
  147192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147194. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147196. * @param name defines the name of the mesh
  147197. * @param options defines the options used to create the mesh
  147198. * @param scene defines the hosting scene
  147199. * @returns the tube mesh
  147200. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147201. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147202. */
  147203. static CreateTube(name: string, options: {
  147204. path: Vector3[];
  147205. radius?: number;
  147206. tessellation?: number;
  147207. radiusFunction?: {
  147208. (i: number, distance: number): number;
  147209. };
  147210. cap?: number;
  147211. arc?: number;
  147212. updatable?: boolean;
  147213. sideOrientation?: number;
  147214. frontUVs?: Vector4;
  147215. backUVs?: Vector4;
  147216. instance?: Mesh;
  147217. invertUV?: boolean;
  147218. }, scene?: Nullable<Scene>): Mesh;
  147219. /**
  147220. * Creates a polyhedron mesh
  147221. * * 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
  147222. * * The parameter `size` (positive float, default 1) sets the polygon size
  147223. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  147224. * * 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`
  147225. * * 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
  147226. * * 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)`)
  147227. * * 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
  147228. * * 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
  147229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147232. * @param name defines the name of the mesh
  147233. * @param options defines the options used to create the mesh
  147234. * @param scene defines the hosting scene
  147235. * @returns the polyhedron mesh
  147236. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  147237. */
  147238. static CreatePolyhedron(name: string, options: {
  147239. type?: number;
  147240. size?: number;
  147241. sizeX?: number;
  147242. sizeY?: number;
  147243. sizeZ?: number;
  147244. custom?: any;
  147245. faceUV?: Vector4[];
  147246. faceColors?: Color4[];
  147247. flat?: boolean;
  147248. updatable?: boolean;
  147249. sideOrientation?: number;
  147250. frontUVs?: Vector4;
  147251. backUVs?: Vector4;
  147252. }, scene?: Nullable<Scene>): Mesh;
  147253. /**
  147254. * Creates a decal mesh.
  147255. * 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
  147256. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147257. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147258. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147259. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147260. * @param name defines the name of the mesh
  147261. * @param sourceMesh defines the mesh where the decal must be applied
  147262. * @param options defines the options used to create the mesh
  147263. * @param scene defines the hosting scene
  147264. * @returns the decal mesh
  147265. * @see https://doc.babylonjs.com/how_to/decals
  147266. */
  147267. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147268. position?: Vector3;
  147269. normal?: Vector3;
  147270. size?: Vector3;
  147271. angle?: number;
  147272. }): Mesh;
  147273. /**
  147274. * Creates a Capsule Mesh
  147275. * @param name defines the name of the mesh.
  147276. * @param options the constructors options used to shape the mesh.
  147277. * @param scene defines the scene the mesh is scoped to.
  147278. * @returns the capsule mesh
  147279. * @see https://doc.babylonjs.com/how_to/capsule_shape
  147280. */
  147281. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  147282. }
  147283. }
  147284. declare module BABYLON {
  147285. /**
  147286. * A simplifier interface for future simplification implementations
  147287. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147288. */
  147289. export interface ISimplifier {
  147290. /**
  147291. * Simplification of a given mesh according to the given settings.
  147292. * Since this requires computation, it is assumed that the function runs async.
  147293. * @param settings The settings of the simplification, including quality and distance
  147294. * @param successCallback A callback that will be called after the mesh was simplified.
  147295. * @param errorCallback in case of an error, this callback will be called. optional.
  147296. */
  147297. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  147298. }
  147299. /**
  147300. * Expected simplification settings.
  147301. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  147302. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147303. */
  147304. export interface ISimplificationSettings {
  147305. /**
  147306. * Gets or sets the expected quality
  147307. */
  147308. quality: number;
  147309. /**
  147310. * Gets or sets the distance when this optimized version should be used
  147311. */
  147312. distance: number;
  147313. /**
  147314. * Gets an already optimized mesh
  147315. */
  147316. optimizeMesh?: boolean;
  147317. }
  147318. /**
  147319. * Class used to specify simplification options
  147320. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147321. */
  147322. export class SimplificationSettings implements ISimplificationSettings {
  147323. /** expected quality */
  147324. quality: number;
  147325. /** distance when this optimized version should be used */
  147326. distance: number;
  147327. /** already optimized mesh */
  147328. optimizeMesh?: boolean | undefined;
  147329. /**
  147330. * Creates a SimplificationSettings
  147331. * @param quality expected quality
  147332. * @param distance distance when this optimized version should be used
  147333. * @param optimizeMesh already optimized mesh
  147334. */
  147335. constructor(
  147336. /** expected quality */
  147337. quality: number,
  147338. /** distance when this optimized version should be used */
  147339. distance: number,
  147340. /** already optimized mesh */
  147341. optimizeMesh?: boolean | undefined);
  147342. }
  147343. /**
  147344. * Interface used to define a simplification task
  147345. */
  147346. export interface ISimplificationTask {
  147347. /**
  147348. * Array of settings
  147349. */
  147350. settings: Array<ISimplificationSettings>;
  147351. /**
  147352. * Simplification type
  147353. */
  147354. simplificationType: SimplificationType;
  147355. /**
  147356. * Mesh to simplify
  147357. */
  147358. mesh: Mesh;
  147359. /**
  147360. * Callback called on success
  147361. */
  147362. successCallback?: () => void;
  147363. /**
  147364. * Defines if parallel processing can be used
  147365. */
  147366. parallelProcessing: boolean;
  147367. }
  147368. /**
  147369. * Queue used to order the simplification tasks
  147370. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147371. */
  147372. export class SimplificationQueue {
  147373. private _simplificationArray;
  147374. /**
  147375. * Gets a boolean indicating that the process is still running
  147376. */
  147377. running: boolean;
  147378. /**
  147379. * Creates a new queue
  147380. */
  147381. constructor();
  147382. /**
  147383. * Adds a new simplification task
  147384. * @param task defines a task to add
  147385. */
  147386. addTask(task: ISimplificationTask): void;
  147387. /**
  147388. * Execute next task
  147389. */
  147390. executeNext(): void;
  147391. /**
  147392. * Execute a simplification task
  147393. * @param task defines the task to run
  147394. */
  147395. runSimplification(task: ISimplificationTask): void;
  147396. private getSimplifier;
  147397. }
  147398. /**
  147399. * The implemented types of simplification
  147400. * At the moment only Quadratic Error Decimation is implemented
  147401. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147402. */
  147403. export enum SimplificationType {
  147404. /** Quadratic error decimation */
  147405. QUADRATIC = 0
  147406. }
  147407. /**
  147408. * An implementation of the Quadratic Error simplification algorithm.
  147409. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  147410. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  147411. * @author RaananW
  147412. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147413. */
  147414. export class QuadraticErrorSimplification implements ISimplifier {
  147415. private _mesh;
  147416. private triangles;
  147417. private vertices;
  147418. private references;
  147419. private _reconstructedMesh;
  147420. /** Gets or sets the number pf sync interations */
  147421. syncIterations: number;
  147422. /** Gets or sets the aggressiveness of the simplifier */
  147423. aggressiveness: number;
  147424. /** Gets or sets the number of allowed iterations for decimation */
  147425. decimationIterations: number;
  147426. /** Gets or sets the espilon to use for bounding box computation */
  147427. boundingBoxEpsilon: number;
  147428. /**
  147429. * Creates a new QuadraticErrorSimplification
  147430. * @param _mesh defines the target mesh
  147431. */
  147432. constructor(_mesh: Mesh);
  147433. /**
  147434. * Simplification of a given mesh according to the given settings.
  147435. * Since this requires computation, it is assumed that the function runs async.
  147436. * @param settings The settings of the simplification, including quality and distance
  147437. * @param successCallback A callback that will be called after the mesh was simplified.
  147438. */
  147439. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  147440. private runDecimation;
  147441. private initWithMesh;
  147442. private init;
  147443. private reconstructMesh;
  147444. private initDecimatedMesh;
  147445. private isFlipped;
  147446. private updateTriangles;
  147447. private identifyBorder;
  147448. private updateMesh;
  147449. private vertexError;
  147450. private calculateError;
  147451. }
  147452. }
  147453. declare module BABYLON {
  147454. interface Scene {
  147455. /** @hidden (Backing field) */
  147456. _simplificationQueue: SimplificationQueue;
  147457. /**
  147458. * Gets or sets the simplification queue attached to the scene
  147459. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147460. */
  147461. simplificationQueue: SimplificationQueue;
  147462. }
  147463. interface Mesh {
  147464. /**
  147465. * Simplify the mesh according to the given array of settings.
  147466. * Function will return immediately and will simplify async
  147467. * @param settings a collection of simplification settings
  147468. * @param parallelProcessing should all levels calculate parallel or one after the other
  147469. * @param simplificationType the type of simplification to run
  147470. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  147471. * @returns the current mesh
  147472. */
  147473. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  147474. }
  147475. /**
  147476. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  147477. * created in a scene
  147478. */
  147479. export class SimplicationQueueSceneComponent implements ISceneComponent {
  147480. /**
  147481. * The component name helpfull to identify the component in the list of scene components.
  147482. */
  147483. readonly name: string;
  147484. /**
  147485. * The scene the component belongs to.
  147486. */
  147487. scene: Scene;
  147488. /**
  147489. * Creates a new instance of the component for the given scene
  147490. * @param scene Defines the scene to register the component in
  147491. */
  147492. constructor(scene: Scene);
  147493. /**
  147494. * Registers the component in a given scene
  147495. */
  147496. register(): void;
  147497. /**
  147498. * Rebuilds the elements related to this component in case of
  147499. * context lost for instance.
  147500. */
  147501. rebuild(): void;
  147502. /**
  147503. * Disposes the component and the associated ressources
  147504. */
  147505. dispose(): void;
  147506. private _beforeCameraUpdate;
  147507. }
  147508. }
  147509. declare module BABYLON {
  147510. interface Mesh {
  147511. /**
  147512. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  147513. */
  147514. thinInstanceEnablePicking: boolean;
  147515. /**
  147516. * Creates a new thin instance
  147517. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  147518. * @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
  147519. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  147520. */
  147521. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  147522. /**
  147523. * Adds the transformation (matrix) of the current mesh as a thin instance
  147524. * @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
  147525. * @returns the thin instance index number
  147526. */
  147527. thinInstanceAddSelf(refresh: boolean): number;
  147528. /**
  147529. * Registers a custom attribute to be used with thin instances
  147530. * @param kind name of the attribute
  147531. * @param stride size in floats of the attribute
  147532. */
  147533. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  147534. /**
  147535. * Sets the matrix of a thin instance
  147536. * @param index index of the thin instance
  147537. * @param matrix matrix to set
  147538. * @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
  147539. */
  147540. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  147541. /**
  147542. * Sets the value of a custom attribute for a thin instance
  147543. * @param kind name of the attribute
  147544. * @param index index of the thin instance
  147545. * @param value value to set
  147546. * @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
  147547. */
  147548. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  147549. /**
  147550. * 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.
  147551. */
  147552. thinInstanceCount: number;
  147553. /**
  147554. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  147555. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  147556. * @param buffer buffer to set
  147557. * @param stride size in floats of each value of the buffer
  147558. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  147559. */
  147560. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  147561. /**
  147562. * Gets the list of world matrices
  147563. * @return an array containing all the world matrices from the thin instances
  147564. */
  147565. thinInstanceGetWorldMatrices(): Matrix[];
  147566. /**
  147567. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  147568. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147569. */
  147570. thinInstanceBufferUpdated(kind: string): void;
  147571. /**
  147572. * Applies a partial update to a buffer directly on the GPU
  147573. * 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
  147574. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147575. * @param data the data to set in the GPU buffer
  147576. * @param offset the offset in the GPU buffer where to update the data
  147577. */
  147578. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  147579. /**
  147580. * Refreshes the bounding info, taking into account all the thin instances defined
  147581. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  147582. */
  147583. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  147584. /** @hidden */
  147585. _thinInstanceInitializeUserStorage(): void;
  147586. /** @hidden */
  147587. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  147588. /** @hidden */
  147589. _userThinInstanceBuffersStorage: {
  147590. data: {
  147591. [key: string]: Float32Array;
  147592. };
  147593. sizes: {
  147594. [key: string]: number;
  147595. };
  147596. vertexBuffers: {
  147597. [key: string]: Nullable<VertexBuffer>;
  147598. };
  147599. strides: {
  147600. [key: string]: number;
  147601. };
  147602. };
  147603. }
  147604. }
  147605. declare module BABYLON {
  147606. /**
  147607. * Navigation plugin interface to add navigation constrained by a navigation mesh
  147608. */
  147609. export interface INavigationEnginePlugin {
  147610. /**
  147611. * plugin name
  147612. */
  147613. name: string;
  147614. /**
  147615. * Creates a navigation mesh
  147616. * @param meshes array of all the geometry used to compute the navigatio mesh
  147617. * @param parameters bunch of parameters used to filter geometry
  147618. */
  147619. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147620. /**
  147621. * Create a navigation mesh debug mesh
  147622. * @param scene is where the mesh will be added
  147623. * @returns debug display mesh
  147624. */
  147625. createDebugNavMesh(scene: Scene): Mesh;
  147626. /**
  147627. * Get a navigation mesh constrained position, closest to the parameter position
  147628. * @param position world position
  147629. * @returns the closest point to position constrained by the navigation mesh
  147630. */
  147631. getClosestPoint(position: Vector3): Vector3;
  147632. /**
  147633. * Get a navigation mesh constrained position, closest to the parameter position
  147634. * @param position world position
  147635. * @param result output the closest point to position constrained by the navigation mesh
  147636. */
  147637. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147638. /**
  147639. * Get a navigation mesh constrained position, within a particular radius
  147640. * @param position world position
  147641. * @param maxRadius the maximum distance to the constrained world position
  147642. * @returns the closest point to position constrained by the navigation mesh
  147643. */
  147644. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147645. /**
  147646. * Get a navigation mesh constrained position, within a particular radius
  147647. * @param position world position
  147648. * @param maxRadius the maximum distance to the constrained world position
  147649. * @param result output the closest point to position constrained by the navigation mesh
  147650. */
  147651. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147652. /**
  147653. * Compute the final position from a segment made of destination-position
  147654. * @param position world position
  147655. * @param destination world position
  147656. * @returns the resulting point along the navmesh
  147657. */
  147658. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147659. /**
  147660. * Compute the final position from a segment made of destination-position
  147661. * @param position world position
  147662. * @param destination world position
  147663. * @param result output the resulting point along the navmesh
  147664. */
  147665. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147666. /**
  147667. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147668. * @param start world position
  147669. * @param end world position
  147670. * @returns array containing world position composing the path
  147671. */
  147672. computePath(start: Vector3, end: Vector3): Vector3[];
  147673. /**
  147674. * If this plugin is supported
  147675. * @returns true if plugin is supported
  147676. */
  147677. isSupported(): boolean;
  147678. /**
  147679. * Create a new Crowd so you can add agents
  147680. * @param maxAgents the maximum agent count in the crowd
  147681. * @param maxAgentRadius the maximum radius an agent can have
  147682. * @param scene to attach the crowd to
  147683. * @returns the crowd you can add agents to
  147684. */
  147685. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147686. /**
  147687. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147688. * The queries will try to find a solution within those bounds
  147689. * default is (1,1,1)
  147690. * @param extent x,y,z value that define the extent around the queries point of reference
  147691. */
  147692. setDefaultQueryExtent(extent: Vector3): void;
  147693. /**
  147694. * Get the Bounding box extent specified by setDefaultQueryExtent
  147695. * @returns the box extent values
  147696. */
  147697. getDefaultQueryExtent(): Vector3;
  147698. /**
  147699. * build the navmesh from a previously saved state using getNavmeshData
  147700. * @param data the Uint8Array returned by getNavmeshData
  147701. */
  147702. buildFromNavmeshData(data: Uint8Array): void;
  147703. /**
  147704. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147705. * @returns data the Uint8Array that can be saved and reused
  147706. */
  147707. getNavmeshData(): Uint8Array;
  147708. /**
  147709. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147710. * @param result output the box extent values
  147711. */
  147712. getDefaultQueryExtentToRef(result: Vector3): void;
  147713. /**
  147714. * Release all resources
  147715. */
  147716. dispose(): void;
  147717. }
  147718. /**
  147719. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  147720. */
  147721. export interface ICrowd {
  147722. /**
  147723. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147724. * You can attach anything to that node. The node position is updated in the scene update tick.
  147725. * @param pos world position that will be constrained by the navigation mesh
  147726. * @param parameters agent parameters
  147727. * @param transform hooked to the agent that will be update by the scene
  147728. * @returns agent index
  147729. */
  147730. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147731. /**
  147732. * Returns the agent position in world space
  147733. * @param index agent index returned by addAgent
  147734. * @returns world space position
  147735. */
  147736. getAgentPosition(index: number): Vector3;
  147737. /**
  147738. * Gets the agent position result in world space
  147739. * @param index agent index returned by addAgent
  147740. * @param result output world space position
  147741. */
  147742. getAgentPositionToRef(index: number, result: Vector3): void;
  147743. /**
  147744. * Gets the agent velocity in world space
  147745. * @param index agent index returned by addAgent
  147746. * @returns world space velocity
  147747. */
  147748. getAgentVelocity(index: number): Vector3;
  147749. /**
  147750. * Gets the agent velocity result in world space
  147751. * @param index agent index returned by addAgent
  147752. * @param result output world space velocity
  147753. */
  147754. getAgentVelocityToRef(index: number, result: Vector3): void;
  147755. /**
  147756. * remove a particular agent previously created
  147757. * @param index agent index returned by addAgent
  147758. */
  147759. removeAgent(index: number): void;
  147760. /**
  147761. * get the list of all agents attached to this crowd
  147762. * @returns list of agent indices
  147763. */
  147764. getAgents(): number[];
  147765. /**
  147766. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147767. * @param deltaTime in seconds
  147768. */
  147769. update(deltaTime: number): void;
  147770. /**
  147771. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147772. * @param index agent index returned by addAgent
  147773. * @param destination targeted world position
  147774. */
  147775. agentGoto(index: number, destination: Vector3): void;
  147776. /**
  147777. * Teleport the agent to a new position
  147778. * @param index agent index returned by addAgent
  147779. * @param destination targeted world position
  147780. */
  147781. agentTeleport(index: number, destination: Vector3): void;
  147782. /**
  147783. * Update agent parameters
  147784. * @param index agent index returned by addAgent
  147785. * @param parameters agent parameters
  147786. */
  147787. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147788. /**
  147789. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147790. * The queries will try to find a solution within those bounds
  147791. * default is (1,1,1)
  147792. * @param extent x,y,z value that define the extent around the queries point of reference
  147793. */
  147794. setDefaultQueryExtent(extent: Vector3): void;
  147795. /**
  147796. * Get the Bounding box extent specified by setDefaultQueryExtent
  147797. * @returns the box extent values
  147798. */
  147799. getDefaultQueryExtent(): Vector3;
  147800. /**
  147801. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147802. * @param result output the box extent values
  147803. */
  147804. getDefaultQueryExtentToRef(result: Vector3): void;
  147805. /**
  147806. * Release all resources
  147807. */
  147808. dispose(): void;
  147809. }
  147810. /**
  147811. * Configures an agent
  147812. */
  147813. export interface IAgentParameters {
  147814. /**
  147815. * Agent radius. [Limit: >= 0]
  147816. */
  147817. radius: number;
  147818. /**
  147819. * Agent height. [Limit: > 0]
  147820. */
  147821. height: number;
  147822. /**
  147823. * Maximum allowed acceleration. [Limit: >= 0]
  147824. */
  147825. maxAcceleration: number;
  147826. /**
  147827. * Maximum allowed speed. [Limit: >= 0]
  147828. */
  147829. maxSpeed: number;
  147830. /**
  147831. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  147832. */
  147833. collisionQueryRange: number;
  147834. /**
  147835. * The path visibility optimization range. [Limit: > 0]
  147836. */
  147837. pathOptimizationRange: number;
  147838. /**
  147839. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  147840. */
  147841. separationWeight: number;
  147842. }
  147843. /**
  147844. * Configures the navigation mesh creation
  147845. */
  147846. export interface INavMeshParameters {
  147847. /**
  147848. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  147849. */
  147850. cs: number;
  147851. /**
  147852. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  147853. */
  147854. ch: number;
  147855. /**
  147856. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  147857. */
  147858. walkableSlopeAngle: number;
  147859. /**
  147860. * Minimum floor to 'ceiling' height that will still allow the floor area to
  147861. * be considered walkable. [Limit: >= 3] [Units: vx]
  147862. */
  147863. walkableHeight: number;
  147864. /**
  147865. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  147866. */
  147867. walkableClimb: number;
  147868. /**
  147869. * The distance to erode/shrink the walkable area of the heightfield away from
  147870. * obstructions. [Limit: >=0] [Units: vx]
  147871. */
  147872. walkableRadius: number;
  147873. /**
  147874. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  147875. */
  147876. maxEdgeLen: number;
  147877. /**
  147878. * The maximum distance a simplfied contour's border edges should deviate
  147879. * the original raw contour. [Limit: >=0] [Units: vx]
  147880. */
  147881. maxSimplificationError: number;
  147882. /**
  147883. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  147884. */
  147885. minRegionArea: number;
  147886. /**
  147887. * Any regions with a span count smaller than this value will, if possible,
  147888. * be merged with larger regions. [Limit: >=0] [Units: vx]
  147889. */
  147890. mergeRegionArea: number;
  147891. /**
  147892. * The maximum number of vertices allowed for polygons generated during the
  147893. * contour to polygon conversion process. [Limit: >= 3]
  147894. */
  147895. maxVertsPerPoly: number;
  147896. /**
  147897. * Sets the sampling distance to use when generating the detail mesh.
  147898. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  147899. */
  147900. detailSampleDist: number;
  147901. /**
  147902. * The maximum distance the detail mesh surface should deviate from heightfield
  147903. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  147904. */
  147905. detailSampleMaxError: number;
  147906. }
  147907. }
  147908. declare module BABYLON {
  147909. /**
  147910. * RecastJS navigation plugin
  147911. */
  147912. export class RecastJSPlugin implements INavigationEnginePlugin {
  147913. /**
  147914. * Reference to the Recast library
  147915. */
  147916. bjsRECAST: any;
  147917. /**
  147918. * plugin name
  147919. */
  147920. name: string;
  147921. /**
  147922. * the first navmesh created. We might extend this to support multiple navmeshes
  147923. */
  147924. navMesh: any;
  147925. /**
  147926. * Initializes the recastJS plugin
  147927. * @param recastInjection can be used to inject your own recast reference
  147928. */
  147929. constructor(recastInjection?: any);
  147930. /**
  147931. * Creates a navigation mesh
  147932. * @param meshes array of all the geometry used to compute the navigatio mesh
  147933. * @param parameters bunch of parameters used to filter geometry
  147934. */
  147935. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147936. /**
  147937. * Create a navigation mesh debug mesh
  147938. * @param scene is where the mesh will be added
  147939. * @returns debug display mesh
  147940. */
  147941. createDebugNavMesh(scene: Scene): Mesh;
  147942. /**
  147943. * Get a navigation mesh constrained position, closest to the parameter position
  147944. * @param position world position
  147945. * @returns the closest point to position constrained by the navigation mesh
  147946. */
  147947. getClosestPoint(position: Vector3): Vector3;
  147948. /**
  147949. * Get a navigation mesh constrained position, closest to the parameter position
  147950. * @param position world position
  147951. * @param result output the closest point to position constrained by the navigation mesh
  147952. */
  147953. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147954. /**
  147955. * Get a navigation mesh constrained position, within a particular radius
  147956. * @param position world position
  147957. * @param maxRadius the maximum distance to the constrained world position
  147958. * @returns the closest point to position constrained by the navigation mesh
  147959. */
  147960. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147961. /**
  147962. * Get a navigation mesh constrained position, within a particular radius
  147963. * @param position world position
  147964. * @param maxRadius the maximum distance to the constrained world position
  147965. * @param result output the closest point to position constrained by the navigation mesh
  147966. */
  147967. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147968. /**
  147969. * Compute the final position from a segment made of destination-position
  147970. * @param position world position
  147971. * @param destination world position
  147972. * @returns the resulting point along the navmesh
  147973. */
  147974. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147975. /**
  147976. * Compute the final position from a segment made of destination-position
  147977. * @param position world position
  147978. * @param destination world position
  147979. * @param result output the resulting point along the navmesh
  147980. */
  147981. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147982. /**
  147983. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147984. * @param start world position
  147985. * @param end world position
  147986. * @returns array containing world position composing the path
  147987. */
  147988. computePath(start: Vector3, end: Vector3): Vector3[];
  147989. /**
  147990. * Create a new Crowd so you can add agents
  147991. * @param maxAgents the maximum agent count in the crowd
  147992. * @param maxAgentRadius the maximum radius an agent can have
  147993. * @param scene to attach the crowd to
  147994. * @returns the crowd you can add agents to
  147995. */
  147996. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147997. /**
  147998. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147999. * The queries will try to find a solution within those bounds
  148000. * default is (1,1,1)
  148001. * @param extent x,y,z value that define the extent around the queries point of reference
  148002. */
  148003. setDefaultQueryExtent(extent: Vector3): void;
  148004. /**
  148005. * Get the Bounding box extent specified by setDefaultQueryExtent
  148006. * @returns the box extent values
  148007. */
  148008. getDefaultQueryExtent(): Vector3;
  148009. /**
  148010. * build the navmesh from a previously saved state using getNavmeshData
  148011. * @param data the Uint8Array returned by getNavmeshData
  148012. */
  148013. buildFromNavmeshData(data: Uint8Array): void;
  148014. /**
  148015. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148016. * @returns data the Uint8Array that can be saved and reused
  148017. */
  148018. getNavmeshData(): Uint8Array;
  148019. /**
  148020. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148021. * @param result output the box extent values
  148022. */
  148023. getDefaultQueryExtentToRef(result: Vector3): void;
  148024. /**
  148025. * Disposes
  148026. */
  148027. dispose(): void;
  148028. /**
  148029. * If this plugin is supported
  148030. * @returns true if plugin is supported
  148031. */
  148032. isSupported(): boolean;
  148033. }
  148034. /**
  148035. * Recast detour crowd implementation
  148036. */
  148037. export class RecastJSCrowd implements ICrowd {
  148038. /**
  148039. * Recast/detour plugin
  148040. */
  148041. bjsRECASTPlugin: RecastJSPlugin;
  148042. /**
  148043. * Link to the detour crowd
  148044. */
  148045. recastCrowd: any;
  148046. /**
  148047. * One transform per agent
  148048. */
  148049. transforms: TransformNode[];
  148050. /**
  148051. * All agents created
  148052. */
  148053. agents: number[];
  148054. /**
  148055. * Link to the scene is kept to unregister the crowd from the scene
  148056. */
  148057. private _scene;
  148058. /**
  148059. * Observer for crowd updates
  148060. */
  148061. private _onBeforeAnimationsObserver;
  148062. /**
  148063. * Constructor
  148064. * @param plugin recastJS plugin
  148065. * @param maxAgents the maximum agent count in the crowd
  148066. * @param maxAgentRadius the maximum radius an agent can have
  148067. * @param scene to attach the crowd to
  148068. * @returns the crowd you can add agents to
  148069. */
  148070. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  148071. /**
  148072. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148073. * You can attach anything to that node. The node position is updated in the scene update tick.
  148074. * @param pos world position that will be constrained by the navigation mesh
  148075. * @param parameters agent parameters
  148076. * @param transform hooked to the agent that will be update by the scene
  148077. * @returns agent index
  148078. */
  148079. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148080. /**
  148081. * Returns the agent position in world space
  148082. * @param index agent index returned by addAgent
  148083. * @returns world space position
  148084. */
  148085. getAgentPosition(index: number): Vector3;
  148086. /**
  148087. * Returns the agent position result in world space
  148088. * @param index agent index returned by addAgent
  148089. * @param result output world space position
  148090. */
  148091. getAgentPositionToRef(index: number, result: Vector3): void;
  148092. /**
  148093. * Returns the agent velocity in world space
  148094. * @param index agent index returned by addAgent
  148095. * @returns world space velocity
  148096. */
  148097. getAgentVelocity(index: number): Vector3;
  148098. /**
  148099. * Returns the agent velocity result in world space
  148100. * @param index agent index returned by addAgent
  148101. * @param result output world space velocity
  148102. */
  148103. getAgentVelocityToRef(index: number, result: Vector3): void;
  148104. /**
  148105. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148106. * @param index agent index returned by addAgent
  148107. * @param destination targeted world position
  148108. */
  148109. agentGoto(index: number, destination: Vector3): void;
  148110. /**
  148111. * Teleport the agent to a new position
  148112. * @param index agent index returned by addAgent
  148113. * @param destination targeted world position
  148114. */
  148115. agentTeleport(index: number, destination: Vector3): void;
  148116. /**
  148117. * Update agent parameters
  148118. * @param index agent index returned by addAgent
  148119. * @param parameters agent parameters
  148120. */
  148121. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148122. /**
  148123. * remove a particular agent previously created
  148124. * @param index agent index returned by addAgent
  148125. */
  148126. removeAgent(index: number): void;
  148127. /**
  148128. * get the list of all agents attached to this crowd
  148129. * @returns list of agent indices
  148130. */
  148131. getAgents(): number[];
  148132. /**
  148133. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148134. * @param deltaTime in seconds
  148135. */
  148136. update(deltaTime: number): void;
  148137. /**
  148138. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148139. * The queries will try to find a solution within those bounds
  148140. * default is (1,1,1)
  148141. * @param extent x,y,z value that define the extent around the queries point of reference
  148142. */
  148143. setDefaultQueryExtent(extent: Vector3): void;
  148144. /**
  148145. * Get the Bounding box extent specified by setDefaultQueryExtent
  148146. * @returns the box extent values
  148147. */
  148148. getDefaultQueryExtent(): Vector3;
  148149. /**
  148150. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148151. * @param result output the box extent values
  148152. */
  148153. getDefaultQueryExtentToRef(result: Vector3): void;
  148154. /**
  148155. * Release all resources
  148156. */
  148157. dispose(): void;
  148158. }
  148159. }
  148160. declare module BABYLON {
  148161. /**
  148162. * Class used to enable access to IndexedDB
  148163. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  148164. */
  148165. export class Database implements IOfflineProvider {
  148166. private _callbackManifestChecked;
  148167. private _currentSceneUrl;
  148168. private _db;
  148169. private _enableSceneOffline;
  148170. private _enableTexturesOffline;
  148171. private _manifestVersionFound;
  148172. private _mustUpdateRessources;
  148173. private _hasReachedQuota;
  148174. private _isSupported;
  148175. private _idbFactory;
  148176. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  148177. private static IsUASupportingBlobStorage;
  148178. /**
  148179. * Gets a boolean indicating if Database storate is enabled (off by default)
  148180. */
  148181. static IDBStorageEnabled: boolean;
  148182. /**
  148183. * Gets a boolean indicating if scene must be saved in the database
  148184. */
  148185. get enableSceneOffline(): boolean;
  148186. /**
  148187. * Gets a boolean indicating if textures must be saved in the database
  148188. */
  148189. get enableTexturesOffline(): boolean;
  148190. /**
  148191. * Creates a new Database
  148192. * @param urlToScene defines the url to load the scene
  148193. * @param callbackManifestChecked defines the callback to use when manifest is checked
  148194. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  148195. */
  148196. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  148197. private static _ParseURL;
  148198. private static _ReturnFullUrlLocation;
  148199. private _checkManifestFile;
  148200. /**
  148201. * Open the database and make it available
  148202. * @param successCallback defines the callback to call on success
  148203. * @param errorCallback defines the callback to call on error
  148204. */
  148205. open(successCallback: () => void, errorCallback: () => void): void;
  148206. /**
  148207. * Loads an image from the database
  148208. * @param url defines the url to load from
  148209. * @param image defines the target DOM image
  148210. */
  148211. loadImage(url: string, image: HTMLImageElement): void;
  148212. private _loadImageFromDBAsync;
  148213. private _saveImageIntoDBAsync;
  148214. private _checkVersionFromDB;
  148215. private _loadVersionFromDBAsync;
  148216. private _saveVersionIntoDBAsync;
  148217. /**
  148218. * Loads a file from database
  148219. * @param url defines the URL to load from
  148220. * @param sceneLoaded defines a callback to call on success
  148221. * @param progressCallBack defines a callback to call when progress changed
  148222. * @param errorCallback defines a callback to call on error
  148223. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  148224. */
  148225. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  148226. private _loadFileAsync;
  148227. private _saveFileAsync;
  148228. /**
  148229. * Validates if xhr data is correct
  148230. * @param xhr defines the request to validate
  148231. * @param dataType defines the expected data type
  148232. * @returns true if data is correct
  148233. */
  148234. private static _ValidateXHRData;
  148235. }
  148236. }
  148237. declare module BABYLON {
  148238. /** @hidden */
  148239. export var gpuUpdateParticlesPixelShader: {
  148240. name: string;
  148241. shader: string;
  148242. };
  148243. }
  148244. declare module BABYLON {
  148245. /** @hidden */
  148246. export var gpuUpdateParticlesVertexShader: {
  148247. name: string;
  148248. shader: string;
  148249. };
  148250. }
  148251. declare module BABYLON {
  148252. /** @hidden */
  148253. export var clipPlaneFragmentDeclaration2: {
  148254. name: string;
  148255. shader: string;
  148256. };
  148257. }
  148258. declare module BABYLON {
  148259. /** @hidden */
  148260. export var gpuRenderParticlesPixelShader: {
  148261. name: string;
  148262. shader: string;
  148263. };
  148264. }
  148265. declare module BABYLON {
  148266. /** @hidden */
  148267. export var clipPlaneVertexDeclaration2: {
  148268. name: string;
  148269. shader: string;
  148270. };
  148271. }
  148272. declare module BABYLON {
  148273. /** @hidden */
  148274. export var gpuRenderParticlesVertexShader: {
  148275. name: string;
  148276. shader: string;
  148277. };
  148278. }
  148279. declare module BABYLON {
  148280. /**
  148281. * This represents a GPU particle system in Babylon
  148282. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  148283. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  148284. */
  148285. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  148286. /**
  148287. * The layer mask we are rendering the particles through.
  148288. */
  148289. layerMask: number;
  148290. private _capacity;
  148291. private _activeCount;
  148292. private _currentActiveCount;
  148293. private _accumulatedCount;
  148294. private _renderEffect;
  148295. private _updateEffect;
  148296. private _buffer0;
  148297. private _buffer1;
  148298. private _spriteBuffer;
  148299. private _updateVAO;
  148300. private _renderVAO;
  148301. private _targetIndex;
  148302. private _sourceBuffer;
  148303. private _targetBuffer;
  148304. private _currentRenderId;
  148305. private _started;
  148306. private _stopped;
  148307. private _timeDelta;
  148308. private _randomTexture;
  148309. private _randomTexture2;
  148310. private _attributesStrideSize;
  148311. private _updateEffectOptions;
  148312. private _randomTextureSize;
  148313. private _actualFrame;
  148314. private _customEffect;
  148315. private readonly _rawTextureWidth;
  148316. /**
  148317. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  148318. */
  148319. static get IsSupported(): boolean;
  148320. /**
  148321. * An event triggered when the system is disposed.
  148322. */
  148323. onDisposeObservable: Observable<IParticleSystem>;
  148324. /**
  148325. * Gets the maximum number of particles active at the same time.
  148326. * @returns The max number of active particles.
  148327. */
  148328. getCapacity(): number;
  148329. /**
  148330. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  148331. * to override the particles.
  148332. */
  148333. forceDepthWrite: boolean;
  148334. /**
  148335. * Gets or set the number of active particles
  148336. */
  148337. get activeParticleCount(): number;
  148338. set activeParticleCount(value: number);
  148339. private _preWarmDone;
  148340. /**
  148341. * Specifies if the particles are updated in emitter local space or world space.
  148342. */
  148343. isLocal: boolean;
  148344. /** Gets or sets a matrix to use to compute projection */
  148345. defaultProjectionMatrix: Matrix;
  148346. /**
  148347. * Is this system ready to be used/rendered
  148348. * @return true if the system is ready
  148349. */
  148350. isReady(): boolean;
  148351. /**
  148352. * Gets if the system has been started. (Note: this will still be true after stop is called)
  148353. * @returns True if it has been started, otherwise false.
  148354. */
  148355. isStarted(): boolean;
  148356. /**
  148357. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  148358. * @returns True if it has been stopped, otherwise false.
  148359. */
  148360. isStopped(): boolean;
  148361. /**
  148362. * Gets a boolean indicating that the system is stopping
  148363. * @returns true if the system is currently stopping
  148364. */
  148365. isStopping(): boolean;
  148366. /**
  148367. * Gets the number of particles active at the same time.
  148368. * @returns The number of active particles.
  148369. */
  148370. getActiveCount(): number;
  148371. /**
  148372. * Starts the particle system and begins to emit
  148373. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  148374. */
  148375. start(delay?: number): void;
  148376. /**
  148377. * Stops the particle system.
  148378. */
  148379. stop(): void;
  148380. /**
  148381. * Remove all active particles
  148382. */
  148383. reset(): void;
  148384. /**
  148385. * Returns the string "GPUParticleSystem"
  148386. * @returns a string containing the class name
  148387. */
  148388. getClassName(): string;
  148389. /**
  148390. * Gets the custom effect used to render the particles
  148391. * @param blendMode Blend mode for which the effect should be retrieved
  148392. * @returns The effect
  148393. */
  148394. getCustomEffect(blendMode?: number): Nullable<Effect>;
  148395. /**
  148396. * Sets the custom effect used to render the particles
  148397. * @param effect The effect to set
  148398. * @param blendMode Blend mode for which the effect should be set
  148399. */
  148400. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  148401. /** @hidden */
  148402. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  148403. /**
  148404. * Observable that will be called just before the particles are drawn
  148405. */
  148406. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  148407. /**
  148408. * Gets the name of the particle vertex shader
  148409. */
  148410. get vertexShaderName(): string;
  148411. private _colorGradientsTexture;
  148412. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  148413. /**
  148414. * Adds a new color gradient
  148415. * @param gradient defines the gradient to use (between 0 and 1)
  148416. * @param color1 defines the color to affect to the specified gradient
  148417. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  148418. * @returns the current particle system
  148419. */
  148420. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  148421. private _refreshColorGradient;
  148422. /** Force the system to rebuild all gradients that need to be resync */
  148423. forceRefreshGradients(): void;
  148424. /**
  148425. * Remove a specific color gradient
  148426. * @param gradient defines the gradient to remove
  148427. * @returns the current particle system
  148428. */
  148429. removeColorGradient(gradient: number): GPUParticleSystem;
  148430. private _angularSpeedGradientsTexture;
  148431. private _sizeGradientsTexture;
  148432. private _velocityGradientsTexture;
  148433. private _limitVelocityGradientsTexture;
  148434. private _dragGradientsTexture;
  148435. private _addFactorGradient;
  148436. /**
  148437. * Adds a new size gradient
  148438. * @param gradient defines the gradient to use (between 0 and 1)
  148439. * @param factor defines the size factor to affect to the specified gradient
  148440. * @returns the current particle system
  148441. */
  148442. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  148443. /**
  148444. * Remove a specific size gradient
  148445. * @param gradient defines the gradient to remove
  148446. * @returns the current particle system
  148447. */
  148448. removeSizeGradient(gradient: number): GPUParticleSystem;
  148449. private _refreshFactorGradient;
  148450. /**
  148451. * Adds a new angular speed gradient
  148452. * @param gradient defines the gradient to use (between 0 and 1)
  148453. * @param factor defines the angular speed to affect to the specified gradient
  148454. * @returns the current particle system
  148455. */
  148456. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  148457. /**
  148458. * Remove a specific angular speed gradient
  148459. * @param gradient defines the gradient to remove
  148460. * @returns the current particle system
  148461. */
  148462. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  148463. /**
  148464. * Adds a new velocity gradient
  148465. * @param gradient defines the gradient to use (between 0 and 1)
  148466. * @param factor defines the velocity to affect to the specified gradient
  148467. * @returns the current particle system
  148468. */
  148469. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148470. /**
  148471. * Remove a specific velocity gradient
  148472. * @param gradient defines the gradient to remove
  148473. * @returns the current particle system
  148474. */
  148475. removeVelocityGradient(gradient: number): GPUParticleSystem;
  148476. /**
  148477. * Adds a new limit velocity gradient
  148478. * @param gradient defines the gradient to use (between 0 and 1)
  148479. * @param factor defines the limit velocity value to affect to the specified gradient
  148480. * @returns the current particle system
  148481. */
  148482. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148483. /**
  148484. * Remove a specific limit velocity gradient
  148485. * @param gradient defines the gradient to remove
  148486. * @returns the current particle system
  148487. */
  148488. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  148489. /**
  148490. * Adds a new drag gradient
  148491. * @param gradient defines the gradient to use (between 0 and 1)
  148492. * @param factor defines the drag value to affect to the specified gradient
  148493. * @returns the current particle system
  148494. */
  148495. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  148496. /**
  148497. * Remove a specific drag gradient
  148498. * @param gradient defines the gradient to remove
  148499. * @returns the current particle system
  148500. */
  148501. removeDragGradient(gradient: number): GPUParticleSystem;
  148502. /**
  148503. * Not supported by GPUParticleSystem
  148504. * @param gradient defines the gradient to use (between 0 and 1)
  148505. * @param factor defines the emit rate value to affect to the specified gradient
  148506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148507. * @returns the current particle system
  148508. */
  148509. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148510. /**
  148511. * Not supported by GPUParticleSystem
  148512. * @param gradient defines the gradient to remove
  148513. * @returns the current particle system
  148514. */
  148515. removeEmitRateGradient(gradient: number): IParticleSystem;
  148516. /**
  148517. * Not supported by GPUParticleSystem
  148518. * @param gradient defines the gradient to use (between 0 and 1)
  148519. * @param factor defines the start size value to affect to the specified gradient
  148520. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148521. * @returns the current particle system
  148522. */
  148523. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148524. /**
  148525. * Not supported by GPUParticleSystem
  148526. * @param gradient defines the gradient to remove
  148527. * @returns the current particle system
  148528. */
  148529. removeStartSizeGradient(gradient: number): IParticleSystem;
  148530. /**
  148531. * Not supported by GPUParticleSystem
  148532. * @param gradient defines the gradient to use (between 0 and 1)
  148533. * @param min defines the color remap minimal range
  148534. * @param max defines the color remap maximal range
  148535. * @returns the current particle system
  148536. */
  148537. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148538. /**
  148539. * Not supported by GPUParticleSystem
  148540. * @param gradient defines the gradient to remove
  148541. * @returns the current particle system
  148542. */
  148543. removeColorRemapGradient(): IParticleSystem;
  148544. /**
  148545. * Not supported by GPUParticleSystem
  148546. * @param gradient defines the gradient to use (between 0 and 1)
  148547. * @param min defines the alpha remap minimal range
  148548. * @param max defines the alpha remap maximal range
  148549. * @returns the current particle system
  148550. */
  148551. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148552. /**
  148553. * Not supported by GPUParticleSystem
  148554. * @param gradient defines the gradient to remove
  148555. * @returns the current particle system
  148556. */
  148557. removeAlphaRemapGradient(): IParticleSystem;
  148558. /**
  148559. * Not supported by GPUParticleSystem
  148560. * @param gradient defines the gradient to use (between 0 and 1)
  148561. * @param color defines the color to affect to the specified gradient
  148562. * @returns the current particle system
  148563. */
  148564. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  148565. /**
  148566. * Not supported by GPUParticleSystem
  148567. * @param gradient defines the gradient to remove
  148568. * @returns the current particle system
  148569. */
  148570. removeRampGradient(): IParticleSystem;
  148571. /**
  148572. * Not supported by GPUParticleSystem
  148573. * @returns the list of ramp gradients
  148574. */
  148575. getRampGradients(): Nullable<Array<Color3Gradient>>;
  148576. /**
  148577. * Not supported by GPUParticleSystem
  148578. * Gets or sets a boolean indicating that ramp gradients must be used
  148579. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  148580. */
  148581. get useRampGradients(): boolean;
  148582. set useRampGradients(value: boolean);
  148583. /**
  148584. * Not supported by GPUParticleSystem
  148585. * @param gradient defines the gradient to use (between 0 and 1)
  148586. * @param factor defines the life time factor to affect to the specified gradient
  148587. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148588. * @returns the current particle system
  148589. */
  148590. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148591. /**
  148592. * Not supported by GPUParticleSystem
  148593. * @param gradient defines the gradient to remove
  148594. * @returns the current particle system
  148595. */
  148596. removeLifeTimeGradient(gradient: number): IParticleSystem;
  148597. /**
  148598. * Instantiates a GPU particle system.
  148599. * 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.
  148600. * @param name The name of the particle system
  148601. * @param options The options used to create the system
  148602. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  148603. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  148604. * @param customEffect a custom effect used to change the way particles are rendered by default
  148605. */
  148606. constructor(name: string, options: Partial<{
  148607. capacity: number;
  148608. randomTextureSize: number;
  148609. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  148610. protected _reset(): void;
  148611. private _createUpdateVAO;
  148612. private _createRenderVAO;
  148613. private _initialize;
  148614. /** @hidden */
  148615. _recreateUpdateEffect(): void;
  148616. private _getEffect;
  148617. /**
  148618. * Fill the defines array according to the current settings of the particle system
  148619. * @param defines Array to be updated
  148620. * @param blendMode blend mode to take into account when updating the array
  148621. */
  148622. fillDefines(defines: Array<string>, blendMode?: number): void;
  148623. /**
  148624. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  148625. * @param uniforms Uniforms array to fill
  148626. * @param attributes Attributes array to fill
  148627. * @param samplers Samplers array to fill
  148628. */
  148629. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  148630. /** @hidden */
  148631. _recreateRenderEffect(): Effect;
  148632. /**
  148633. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  148634. * @param preWarm defines if we are in the pre-warmimg phase
  148635. */
  148636. animate(preWarm?: boolean): void;
  148637. private _createFactorGradientTexture;
  148638. private _createSizeGradientTexture;
  148639. private _createAngularSpeedGradientTexture;
  148640. private _createVelocityGradientTexture;
  148641. private _createLimitVelocityGradientTexture;
  148642. private _createDragGradientTexture;
  148643. private _createColorGradientTexture;
  148644. /**
  148645. * Renders the particle system in its current state
  148646. * @param preWarm defines if the system should only update the particles but not render them
  148647. * @returns the current number of particles
  148648. */
  148649. render(preWarm?: boolean): number;
  148650. /**
  148651. * Rebuilds the particle system
  148652. */
  148653. rebuild(): void;
  148654. private _releaseBuffers;
  148655. private _releaseVAOs;
  148656. /**
  148657. * Disposes the particle system and free the associated resources
  148658. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  148659. */
  148660. dispose(disposeTexture?: boolean): void;
  148661. /**
  148662. * Clones the particle system.
  148663. * @param name The name of the cloned object
  148664. * @param newEmitter The new emitter to use
  148665. * @returns the cloned particle system
  148666. */
  148667. clone(name: string, newEmitter: any): GPUParticleSystem;
  148668. /**
  148669. * Serializes the particle system to a JSON object
  148670. * @param serializeTexture defines if the texture must be serialized as well
  148671. * @returns the JSON object
  148672. */
  148673. serialize(serializeTexture?: boolean): any;
  148674. /**
  148675. * Parses a JSON object to create a GPU particle system.
  148676. * @param parsedParticleSystem The JSON object to parse
  148677. * @param sceneOrEngine The scene or the engine to create the particle system in
  148678. * @param rootUrl The root url to use to load external dependencies like texture
  148679. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  148680. * @returns the parsed GPU particle system
  148681. */
  148682. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  148683. }
  148684. }
  148685. declare module BABYLON {
  148686. /**
  148687. * Represents a set of particle systems working together to create a specific effect
  148688. */
  148689. export class ParticleSystemSet implements IDisposable {
  148690. /**
  148691. * Gets or sets base Assets URL
  148692. */
  148693. static BaseAssetsUrl: string;
  148694. private _emitterCreationOptions;
  148695. private _emitterNode;
  148696. /**
  148697. * Gets the particle system list
  148698. */
  148699. systems: IParticleSystem[];
  148700. /**
  148701. * Gets the emitter node used with this set
  148702. */
  148703. get emitterNode(): Nullable<TransformNode>;
  148704. /**
  148705. * Creates a new emitter mesh as a sphere
  148706. * @param options defines the options used to create the sphere
  148707. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  148708. * @param scene defines the hosting scene
  148709. */
  148710. setEmitterAsSphere(options: {
  148711. diameter: number;
  148712. segments: number;
  148713. color: Color3;
  148714. }, renderingGroupId: number, scene: Scene): void;
  148715. /**
  148716. * Starts all particle systems of the set
  148717. * @param emitter defines an optional mesh to use as emitter for the particle systems
  148718. */
  148719. start(emitter?: AbstractMesh): void;
  148720. /**
  148721. * Release all associated resources
  148722. */
  148723. dispose(): void;
  148724. /**
  148725. * Serialize the set into a JSON compatible object
  148726. * @param serializeTexture defines if the texture must be serialized as well
  148727. * @returns a JSON compatible representation of the set
  148728. */
  148729. serialize(serializeTexture?: boolean): any;
  148730. /**
  148731. * Parse a new ParticleSystemSet from a serialized source
  148732. * @param data defines a JSON compatible representation of the set
  148733. * @param scene defines the hosting scene
  148734. * @param gpu defines if we want GPU particles or CPU particles
  148735. * @returns a new ParticleSystemSet
  148736. */
  148737. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  148738. }
  148739. }
  148740. declare module BABYLON {
  148741. /**
  148742. * This class is made for on one-liner static method to help creating particle system set.
  148743. */
  148744. export class ParticleHelper {
  148745. /**
  148746. * Gets or sets base Assets URL
  148747. */
  148748. static BaseAssetsUrl: string;
  148749. /** Define the Url to load snippets */
  148750. static SnippetUrl: string;
  148751. /**
  148752. * Create a default particle system that you can tweak
  148753. * @param emitter defines the emitter to use
  148754. * @param capacity defines the system capacity (default is 500 particles)
  148755. * @param scene defines the hosting scene
  148756. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  148757. * @returns the new Particle system
  148758. */
  148759. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  148760. /**
  148761. * This is the main static method (one-liner) of this helper to create different particle systems
  148762. * @param type This string represents the type to the particle system to create
  148763. * @param scene The scene where the particle system should live
  148764. * @param gpu If the system will use gpu
  148765. * @returns the ParticleSystemSet created
  148766. */
  148767. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  148768. /**
  148769. * Static function used to export a particle system to a ParticleSystemSet variable.
  148770. * Please note that the emitter shape is not exported
  148771. * @param systems defines the particle systems to export
  148772. * @returns the created particle system set
  148773. */
  148774. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  148775. /**
  148776. * Creates a particle system from a snippet saved in a remote file
  148777. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  148778. * @param url defines the url to load from
  148779. * @param scene defines the hosting scene
  148780. * @param gpu If the system will use gpu
  148781. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148782. * @returns a promise that will resolve to the new particle system
  148783. */
  148784. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148785. /**
  148786. * Creates a particle system from a snippet saved by the particle system editor
  148787. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  148788. * @param scene defines the hosting scene
  148789. * @param gpu If the system will use gpu
  148790. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148791. * @returns a promise that will resolve to the new particle system
  148792. */
  148793. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148794. }
  148795. }
  148796. declare module BABYLON {
  148797. interface Engine {
  148798. /**
  148799. * Create an effect to use with particle systems.
  148800. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  148801. * the particle system for which you want to create a custom effect in the last parameter
  148802. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  148803. * @param uniformsNames defines a list of attribute names
  148804. * @param samplers defines an array of string used to represent textures
  148805. * @param defines defines the string containing the defines to use to compile the shaders
  148806. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  148807. * @param onCompiled defines a function to call when the effect creation is successful
  148808. * @param onError defines a function to call when the effect creation has failed
  148809. * @param particleSystem the particle system you want to create the effect for
  148810. * @returns the new Effect
  148811. */
  148812. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  148813. }
  148814. interface Mesh {
  148815. /**
  148816. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  148817. * @returns an array of IParticleSystem
  148818. */
  148819. getEmittedParticleSystems(): IParticleSystem[];
  148820. /**
  148821. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  148822. * @returns an array of IParticleSystem
  148823. */
  148824. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  148825. }
  148826. }
  148827. declare module BABYLON {
  148828. /** Defines the 4 color options */
  148829. export enum PointColor {
  148830. /** color value */
  148831. Color = 2,
  148832. /** uv value */
  148833. UV = 1,
  148834. /** random value */
  148835. Random = 0,
  148836. /** stated value */
  148837. Stated = 3
  148838. }
  148839. /**
  148840. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  148841. * 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.
  148842. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  148843. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  148844. *
  148845. * Full documentation here : TO BE ENTERED
  148846. */
  148847. export class PointsCloudSystem implements IDisposable {
  148848. /**
  148849. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  148850. * Example : var p = SPS.particles[i];
  148851. */
  148852. particles: CloudPoint[];
  148853. /**
  148854. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  148855. */
  148856. nbParticles: number;
  148857. /**
  148858. * This a counter for your own usage. It's not set by any SPS functions.
  148859. */
  148860. counter: number;
  148861. /**
  148862. * The PCS name. This name is also given to the underlying mesh.
  148863. */
  148864. name: string;
  148865. /**
  148866. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  148867. */
  148868. mesh: Mesh;
  148869. /**
  148870. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  148871. * Please read :
  148872. */
  148873. vars: any;
  148874. /**
  148875. * @hidden
  148876. */
  148877. _size: number;
  148878. private _scene;
  148879. private _promises;
  148880. private _positions;
  148881. private _indices;
  148882. private _normals;
  148883. private _colors;
  148884. private _uvs;
  148885. private _indices32;
  148886. private _positions32;
  148887. private _colors32;
  148888. private _uvs32;
  148889. private _updatable;
  148890. private _isVisibilityBoxLocked;
  148891. private _alwaysVisible;
  148892. private _groups;
  148893. private _groupCounter;
  148894. private _computeParticleColor;
  148895. private _computeParticleTexture;
  148896. private _computeParticleRotation;
  148897. private _computeBoundingBox;
  148898. private _isReady;
  148899. /**
  148900. * Creates a PCS (Points Cloud System) object
  148901. * @param name (String) is the PCS name, this will be the underlying mesh name
  148902. * @param pointSize (number) is the size for each point
  148903. * @param scene (Scene) is the scene in which the PCS is added
  148904. * @param options defines the options of the PCS e.g.
  148905. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  148906. */
  148907. constructor(name: string, pointSize: number, scene: Scene, options?: {
  148908. updatable?: boolean;
  148909. });
  148910. /**
  148911. * Builds the PCS underlying mesh. Returns a standard Mesh.
  148912. * If no points were added to the PCS, the returned mesh is just a single point.
  148913. * @returns a promise for the created mesh
  148914. */
  148915. buildMeshAsync(): Promise<Mesh>;
  148916. /**
  148917. * @hidden
  148918. */
  148919. private _buildMesh;
  148920. private _addParticle;
  148921. private _randomUnitVector;
  148922. private _getColorIndicesForCoord;
  148923. private _setPointsColorOrUV;
  148924. private _colorFromTexture;
  148925. private _calculateDensity;
  148926. /**
  148927. * Adds points to the PCS in random positions within a unit sphere
  148928. * @param nb (positive integer) the number of particles to be created from this model
  148929. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  148930. * @returns the number of groups in the system
  148931. */
  148932. addPoints(nb: number, pointFunction?: any): number;
  148933. /**
  148934. * Adds points to the PCS from the surface of the model shape
  148935. * @param mesh is any Mesh object that will be used as a surface model for the points
  148936. * @param nb (positive integer) the number of particles to be created from this model
  148937. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148938. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148939. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148940. * @returns the number of groups in the system
  148941. */
  148942. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148943. /**
  148944. * Adds points to the PCS inside the model shape
  148945. * @param mesh is any Mesh object that will be used as a surface model for the points
  148946. * @param nb (positive integer) the number of particles to be created from this model
  148947. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148948. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148949. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148950. * @returns the number of groups in the system
  148951. */
  148952. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148953. /**
  148954. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  148955. * This method calls `updateParticle()` for each particle of the SPS.
  148956. * For an animated SPS, it is usually called within the render loop.
  148957. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  148958. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  148959. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  148960. * @returns the PCS.
  148961. */
  148962. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  148963. /**
  148964. * Disposes the PCS.
  148965. */
  148966. dispose(): void;
  148967. /**
  148968. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  148969. * doc :
  148970. * @returns the PCS.
  148971. */
  148972. refreshVisibleSize(): PointsCloudSystem;
  148973. /**
  148974. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  148975. * @param size the size (float) of the visibility box
  148976. * note : this doesn't lock the PCS mesh bounding box.
  148977. * doc :
  148978. */
  148979. setVisibilityBox(size: number): void;
  148980. /**
  148981. * Gets whether the PCS is always visible or not
  148982. * doc :
  148983. */
  148984. get isAlwaysVisible(): boolean;
  148985. /**
  148986. * Sets the PCS as always visible or not
  148987. * doc :
  148988. */
  148989. set isAlwaysVisible(val: boolean);
  148990. /**
  148991. * Tells to `setParticles()` to compute the particle rotations or not
  148992. * Default value : false. The PCS is faster when it's set to false
  148993. * Note : particle rotations are only applied to parent particles
  148994. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  148995. */
  148996. set computeParticleRotation(val: boolean);
  148997. /**
  148998. * Tells to `setParticles()` to compute the particle colors or not.
  148999. * Default value : true. The PCS is faster when it's set to false.
  149000. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149001. */
  149002. set computeParticleColor(val: boolean);
  149003. set computeParticleTexture(val: boolean);
  149004. /**
  149005. * Gets if `setParticles()` computes the particle colors or not.
  149006. * Default value : false. The PCS is faster when it's set to false.
  149007. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149008. */
  149009. get computeParticleColor(): boolean;
  149010. /**
  149011. * Gets if `setParticles()` computes the particle textures or not.
  149012. * Default value : false. The PCS is faster when it's set to false.
  149013. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  149014. */
  149015. get computeParticleTexture(): boolean;
  149016. /**
  149017. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  149018. */
  149019. set computeBoundingBox(val: boolean);
  149020. /**
  149021. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  149022. */
  149023. get computeBoundingBox(): boolean;
  149024. /**
  149025. * This function does nothing. It may be overwritten to set all the particle first values.
  149026. * The PCS doesn't call this function, you may have to call it by your own.
  149027. * doc :
  149028. */
  149029. initParticles(): void;
  149030. /**
  149031. * This function does nothing. It may be overwritten to recycle a particle
  149032. * The PCS doesn't call this function, you can to call it
  149033. * doc :
  149034. * @param particle The particle to recycle
  149035. * @returns the recycled particle
  149036. */
  149037. recycleParticle(particle: CloudPoint): CloudPoint;
  149038. /**
  149039. * Updates a particle : this function should be overwritten by the user.
  149040. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  149041. * doc :
  149042. * @example : just set a particle position or velocity and recycle conditions
  149043. * @param particle The particle to update
  149044. * @returns the updated particle
  149045. */
  149046. updateParticle(particle: CloudPoint): CloudPoint;
  149047. /**
  149048. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  149049. * This does nothing and may be overwritten by the user.
  149050. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149051. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149052. * @param update the boolean update value actually passed to setParticles()
  149053. */
  149054. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149055. /**
  149056. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  149057. * This will be passed three parameters.
  149058. * This does nothing and may be overwritten by the user.
  149059. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149060. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149061. * @param update the boolean update value actually passed to setParticles()
  149062. */
  149063. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149064. }
  149065. }
  149066. declare module BABYLON {
  149067. /**
  149068. * Represents one particle of a points cloud system.
  149069. */
  149070. export class CloudPoint {
  149071. /**
  149072. * particle global index
  149073. */
  149074. idx: number;
  149075. /**
  149076. * The color of the particle
  149077. */
  149078. color: Nullable<Color4>;
  149079. /**
  149080. * The world space position of the particle.
  149081. */
  149082. position: Vector3;
  149083. /**
  149084. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  149085. */
  149086. rotation: Vector3;
  149087. /**
  149088. * The world space rotation quaternion of the particle.
  149089. */
  149090. rotationQuaternion: Nullable<Quaternion>;
  149091. /**
  149092. * The uv of the particle.
  149093. */
  149094. uv: Nullable<Vector2>;
  149095. /**
  149096. * The current speed of the particle.
  149097. */
  149098. velocity: Vector3;
  149099. /**
  149100. * The pivot point in the particle local space.
  149101. */
  149102. pivot: Vector3;
  149103. /**
  149104. * Must the particle be translated from its pivot point in its local space ?
  149105. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  149106. * Default : false
  149107. */
  149108. translateFromPivot: boolean;
  149109. /**
  149110. * Index of this particle in the global "positions" array (Internal use)
  149111. * @hidden
  149112. */
  149113. _pos: number;
  149114. /**
  149115. * @hidden Index of this particle in the global "indices" array (Internal use)
  149116. */
  149117. _ind: number;
  149118. /**
  149119. * Group this particle belongs to
  149120. */
  149121. _group: PointsGroup;
  149122. /**
  149123. * Group id of this particle
  149124. */
  149125. groupId: number;
  149126. /**
  149127. * Index of the particle in its group id (Internal use)
  149128. */
  149129. idxInGroup: number;
  149130. /**
  149131. * @hidden Particle BoundingInfo object (Internal use)
  149132. */
  149133. _boundingInfo: BoundingInfo;
  149134. /**
  149135. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  149136. */
  149137. _pcs: PointsCloudSystem;
  149138. /**
  149139. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  149140. */
  149141. _stillInvisible: boolean;
  149142. /**
  149143. * @hidden Last computed particle rotation matrix
  149144. */
  149145. _rotationMatrix: number[];
  149146. /**
  149147. * Parent particle Id, if any.
  149148. * Default null.
  149149. */
  149150. parentId: Nullable<number>;
  149151. /**
  149152. * @hidden Internal global position in the PCS.
  149153. */
  149154. _globalPosition: Vector3;
  149155. /**
  149156. * Creates a Point Cloud object.
  149157. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  149158. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  149159. * @param group (PointsGroup) is the group the particle belongs to
  149160. * @param groupId (integer) is the group identifier in the PCS.
  149161. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  149162. * @param pcs defines the PCS it is associated to
  149163. */
  149164. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  149165. /**
  149166. * get point size
  149167. */
  149168. get size(): Vector3;
  149169. /**
  149170. * Set point size
  149171. */
  149172. set size(scale: Vector3);
  149173. /**
  149174. * Legacy support, changed quaternion to rotationQuaternion
  149175. */
  149176. get quaternion(): Nullable<Quaternion>;
  149177. /**
  149178. * Legacy support, changed quaternion to rotationQuaternion
  149179. */
  149180. set quaternion(q: Nullable<Quaternion>);
  149181. /**
  149182. * Returns a boolean. True if the particle intersects a mesh, else false
  149183. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  149184. * @param target is the object (point or mesh) what the intersection is computed against
  149185. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  149186. * @returns true if it intersects
  149187. */
  149188. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  149189. /**
  149190. * get the rotation matrix of the particle
  149191. * @hidden
  149192. */
  149193. getRotationMatrix(m: Matrix): void;
  149194. }
  149195. /**
  149196. * Represents a group of points in a points cloud system
  149197. * * PCS internal tool, don't use it manually.
  149198. */
  149199. export class PointsGroup {
  149200. /**
  149201. * The group id
  149202. * @hidden
  149203. */
  149204. groupID: number;
  149205. /**
  149206. * image data for group (internal use)
  149207. * @hidden
  149208. */
  149209. _groupImageData: Nullable<ArrayBufferView>;
  149210. /**
  149211. * Image Width (internal use)
  149212. * @hidden
  149213. */
  149214. _groupImgWidth: number;
  149215. /**
  149216. * Image Height (internal use)
  149217. * @hidden
  149218. */
  149219. _groupImgHeight: number;
  149220. /**
  149221. * Custom position function (internal use)
  149222. * @hidden
  149223. */
  149224. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  149225. /**
  149226. * density per facet for surface points
  149227. * @hidden
  149228. */
  149229. _groupDensity: number[];
  149230. /**
  149231. * Only when points are colored by texture carries pointer to texture list array
  149232. * @hidden
  149233. */
  149234. _textureNb: number;
  149235. /**
  149236. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  149237. * PCS internal tool, don't use it manually.
  149238. * @hidden
  149239. */
  149240. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  149241. }
  149242. }
  149243. declare module BABYLON {
  149244. interface Scene {
  149245. /** @hidden (Backing field) */
  149246. _physicsEngine: Nullable<IPhysicsEngine>;
  149247. /** @hidden */
  149248. _physicsTimeAccumulator: number;
  149249. /**
  149250. * Gets the current physics engine
  149251. * @returns a IPhysicsEngine or null if none attached
  149252. */
  149253. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  149254. /**
  149255. * Enables physics to the current scene
  149256. * @param gravity defines the scene's gravity for the physics engine
  149257. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  149258. * @return a boolean indicating if the physics engine was initialized
  149259. */
  149260. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  149261. /**
  149262. * Disables and disposes the physics engine associated with the scene
  149263. */
  149264. disablePhysicsEngine(): void;
  149265. /**
  149266. * Gets a boolean indicating if there is an active physics engine
  149267. * @returns a boolean indicating if there is an active physics engine
  149268. */
  149269. isPhysicsEnabled(): boolean;
  149270. /**
  149271. * Deletes a physics compound impostor
  149272. * @param compound defines the compound to delete
  149273. */
  149274. deleteCompoundImpostor(compound: any): void;
  149275. /**
  149276. * An event triggered when physic simulation is about to be run
  149277. */
  149278. onBeforePhysicsObservable: Observable<Scene>;
  149279. /**
  149280. * An event triggered when physic simulation has been done
  149281. */
  149282. onAfterPhysicsObservable: Observable<Scene>;
  149283. }
  149284. interface AbstractMesh {
  149285. /** @hidden */
  149286. _physicsImpostor: Nullable<PhysicsImpostor>;
  149287. /**
  149288. * Gets or sets impostor used for physic simulation
  149289. * @see https://doc.babylonjs.com/features/physics_engine
  149290. */
  149291. physicsImpostor: Nullable<PhysicsImpostor>;
  149292. /**
  149293. * Gets the current physics impostor
  149294. * @see https://doc.babylonjs.com/features/physics_engine
  149295. * @returns a physics impostor or null
  149296. */
  149297. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  149298. /** Apply a physic impulse to the mesh
  149299. * @param force defines the force to apply
  149300. * @param contactPoint defines where to apply the force
  149301. * @returns the current mesh
  149302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  149303. */
  149304. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  149305. /**
  149306. * Creates a physic joint between two meshes
  149307. * @param otherMesh defines the other mesh to use
  149308. * @param pivot1 defines the pivot to use on this mesh
  149309. * @param pivot2 defines the pivot to use on the other mesh
  149310. * @param options defines additional options (can be plugin dependent)
  149311. * @returns the current mesh
  149312. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  149313. */
  149314. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  149315. /** @hidden */
  149316. _disposePhysicsObserver: Nullable<Observer<Node>>;
  149317. }
  149318. /**
  149319. * Defines the physics engine scene component responsible to manage a physics engine
  149320. */
  149321. export class PhysicsEngineSceneComponent implements ISceneComponent {
  149322. /**
  149323. * The component name helpful to identify the component in the list of scene components.
  149324. */
  149325. readonly name: string;
  149326. /**
  149327. * The scene the component belongs to.
  149328. */
  149329. scene: Scene;
  149330. /**
  149331. * Creates a new instance of the component for the given scene
  149332. * @param scene Defines the scene to register the component in
  149333. */
  149334. constructor(scene: Scene);
  149335. /**
  149336. * Registers the component in a given scene
  149337. */
  149338. register(): void;
  149339. /**
  149340. * Rebuilds the elements related to this component in case of
  149341. * context lost for instance.
  149342. */
  149343. rebuild(): void;
  149344. /**
  149345. * Disposes the component and the associated ressources
  149346. */
  149347. dispose(): void;
  149348. }
  149349. }
  149350. declare module BABYLON {
  149351. /**
  149352. * A helper for physics simulations
  149353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149354. */
  149355. export class PhysicsHelper {
  149356. private _scene;
  149357. private _physicsEngine;
  149358. /**
  149359. * Initializes the Physics helper
  149360. * @param scene Babylon.js scene
  149361. */
  149362. constructor(scene: Scene);
  149363. /**
  149364. * Applies a radial explosion impulse
  149365. * @param origin the origin of the explosion
  149366. * @param radiusOrEventOptions the radius or the options of radial explosion
  149367. * @param strength the explosion strength
  149368. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149369. * @returns A physics radial explosion event, or null
  149370. */
  149371. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149372. /**
  149373. * Applies a radial explosion force
  149374. * @param origin the origin of the explosion
  149375. * @param radiusOrEventOptions the radius or the options of radial explosion
  149376. * @param strength the explosion strength
  149377. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149378. * @returns A physics radial explosion event, or null
  149379. */
  149380. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149381. /**
  149382. * Creates a gravitational field
  149383. * @param origin the origin of the explosion
  149384. * @param radiusOrEventOptions the radius or the options of radial explosion
  149385. * @param strength the explosion strength
  149386. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149387. * @returns A physics gravitational field event, or null
  149388. */
  149389. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  149390. /**
  149391. * Creates a physics updraft event
  149392. * @param origin the origin of the updraft
  149393. * @param radiusOrEventOptions the radius or the options of the updraft
  149394. * @param strength the strength of the updraft
  149395. * @param height the height of the updraft
  149396. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  149397. * @returns A physics updraft event, or null
  149398. */
  149399. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  149400. /**
  149401. * Creates a physics vortex event
  149402. * @param origin the of the vortex
  149403. * @param radiusOrEventOptions the radius or the options of the vortex
  149404. * @param strength the strength of the vortex
  149405. * @param height the height of the vortex
  149406. * @returns a Physics vortex event, or null
  149407. * A physics vortex event or null
  149408. */
  149409. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  149410. }
  149411. /**
  149412. * Represents a physics radial explosion event
  149413. */
  149414. class PhysicsRadialExplosionEvent {
  149415. private _scene;
  149416. private _options;
  149417. private _sphere;
  149418. private _dataFetched;
  149419. /**
  149420. * Initializes a radial explosioin event
  149421. * @param _scene BabylonJS scene
  149422. * @param _options The options for the vortex event
  149423. */
  149424. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  149425. /**
  149426. * Returns the data related to the radial explosion event (sphere).
  149427. * @returns The radial explosion event data
  149428. */
  149429. getData(): PhysicsRadialExplosionEventData;
  149430. /**
  149431. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  149432. * @param impostor A physics imposter
  149433. * @param origin the origin of the explosion
  149434. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  149435. */
  149436. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  149437. /**
  149438. * Triggers affecterd impostors callbacks
  149439. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  149440. */
  149441. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  149442. /**
  149443. * Disposes the sphere.
  149444. * @param force Specifies if the sphere should be disposed by force
  149445. */
  149446. dispose(force?: boolean): void;
  149447. /*** Helpers ***/
  149448. private _prepareSphere;
  149449. private _intersectsWithSphere;
  149450. }
  149451. /**
  149452. * Represents a gravitational field event
  149453. */
  149454. class PhysicsGravitationalFieldEvent {
  149455. private _physicsHelper;
  149456. private _scene;
  149457. private _origin;
  149458. private _options;
  149459. private _tickCallback;
  149460. private _sphere;
  149461. private _dataFetched;
  149462. /**
  149463. * Initializes the physics gravitational field event
  149464. * @param _physicsHelper A physics helper
  149465. * @param _scene BabylonJS scene
  149466. * @param _origin The origin position of the gravitational field event
  149467. * @param _options The options for the vortex event
  149468. */
  149469. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  149470. /**
  149471. * Returns the data related to the gravitational field event (sphere).
  149472. * @returns A gravitational field event
  149473. */
  149474. getData(): PhysicsGravitationalFieldEventData;
  149475. /**
  149476. * Enables the gravitational field.
  149477. */
  149478. enable(): void;
  149479. /**
  149480. * Disables the gravitational field.
  149481. */
  149482. disable(): void;
  149483. /**
  149484. * Disposes the sphere.
  149485. * @param force The force to dispose from the gravitational field event
  149486. */
  149487. dispose(force?: boolean): void;
  149488. private _tick;
  149489. }
  149490. /**
  149491. * Represents a physics updraft event
  149492. */
  149493. class PhysicsUpdraftEvent {
  149494. private _scene;
  149495. private _origin;
  149496. private _options;
  149497. private _physicsEngine;
  149498. private _originTop;
  149499. private _originDirection;
  149500. private _tickCallback;
  149501. private _cylinder;
  149502. private _cylinderPosition;
  149503. private _dataFetched;
  149504. /**
  149505. * Initializes the physics updraft event
  149506. * @param _scene BabylonJS scene
  149507. * @param _origin The origin position of the updraft
  149508. * @param _options The options for the updraft event
  149509. */
  149510. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  149511. /**
  149512. * Returns the data related to the updraft event (cylinder).
  149513. * @returns A physics updraft event
  149514. */
  149515. getData(): PhysicsUpdraftEventData;
  149516. /**
  149517. * Enables the updraft.
  149518. */
  149519. enable(): void;
  149520. /**
  149521. * Disables the updraft.
  149522. */
  149523. disable(): void;
  149524. /**
  149525. * Disposes the cylinder.
  149526. * @param force Specifies if the updraft should be disposed by force
  149527. */
  149528. dispose(force?: boolean): void;
  149529. private getImpostorHitData;
  149530. private _tick;
  149531. /*** Helpers ***/
  149532. private _prepareCylinder;
  149533. private _intersectsWithCylinder;
  149534. }
  149535. /**
  149536. * Represents a physics vortex event
  149537. */
  149538. class PhysicsVortexEvent {
  149539. private _scene;
  149540. private _origin;
  149541. private _options;
  149542. private _physicsEngine;
  149543. private _originTop;
  149544. private _tickCallback;
  149545. private _cylinder;
  149546. private _cylinderPosition;
  149547. private _dataFetched;
  149548. /**
  149549. * Initializes the physics vortex event
  149550. * @param _scene The BabylonJS scene
  149551. * @param _origin The origin position of the vortex
  149552. * @param _options The options for the vortex event
  149553. */
  149554. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  149555. /**
  149556. * Returns the data related to the vortex event (cylinder).
  149557. * @returns The physics vortex event data
  149558. */
  149559. getData(): PhysicsVortexEventData;
  149560. /**
  149561. * Enables the vortex.
  149562. */
  149563. enable(): void;
  149564. /**
  149565. * Disables the cortex.
  149566. */
  149567. disable(): void;
  149568. /**
  149569. * Disposes the sphere.
  149570. * @param force
  149571. */
  149572. dispose(force?: boolean): void;
  149573. private getImpostorHitData;
  149574. private _tick;
  149575. /*** Helpers ***/
  149576. private _prepareCylinder;
  149577. private _intersectsWithCylinder;
  149578. }
  149579. /**
  149580. * Options fot the radial explosion event
  149581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149582. */
  149583. export class PhysicsRadialExplosionEventOptions {
  149584. /**
  149585. * The radius of the sphere for the radial explosion.
  149586. */
  149587. radius: number;
  149588. /**
  149589. * The strenth of the explosion.
  149590. */
  149591. strength: number;
  149592. /**
  149593. * The strenght of the force in correspondence to the distance of the affected object
  149594. */
  149595. falloff: PhysicsRadialImpulseFalloff;
  149596. /**
  149597. * Sphere options for the radial explosion.
  149598. */
  149599. sphere: {
  149600. segments: number;
  149601. diameter: number;
  149602. };
  149603. /**
  149604. * Sphere options for the radial explosion.
  149605. */
  149606. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  149607. }
  149608. /**
  149609. * Options fot the updraft event
  149610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149611. */
  149612. export class PhysicsUpdraftEventOptions {
  149613. /**
  149614. * The radius of the cylinder for the vortex
  149615. */
  149616. radius: number;
  149617. /**
  149618. * The strenth of the updraft.
  149619. */
  149620. strength: number;
  149621. /**
  149622. * The height of the cylinder for the updraft.
  149623. */
  149624. height: number;
  149625. /**
  149626. * The mode for the the updraft.
  149627. */
  149628. updraftMode: PhysicsUpdraftMode;
  149629. }
  149630. /**
  149631. * Options fot the vortex event
  149632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149633. */
  149634. export class PhysicsVortexEventOptions {
  149635. /**
  149636. * The radius of the cylinder for the vortex
  149637. */
  149638. radius: number;
  149639. /**
  149640. * The strenth of the vortex.
  149641. */
  149642. strength: number;
  149643. /**
  149644. * The height of the cylinder for the vortex.
  149645. */
  149646. height: number;
  149647. /**
  149648. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  149649. */
  149650. centripetalForceThreshold: number;
  149651. /**
  149652. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  149653. */
  149654. centripetalForceMultiplier: number;
  149655. /**
  149656. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  149657. */
  149658. centrifugalForceMultiplier: number;
  149659. /**
  149660. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  149661. */
  149662. updraftForceMultiplier: number;
  149663. }
  149664. /**
  149665. * The strenght of the force in correspondence to the distance of the affected object
  149666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149667. */
  149668. export enum PhysicsRadialImpulseFalloff {
  149669. /** Defines that impulse is constant in strength across it's whole radius */
  149670. Constant = 0,
  149671. /** Defines that impulse gets weaker if it's further from the origin */
  149672. Linear = 1
  149673. }
  149674. /**
  149675. * The strength of the force in correspondence to the distance of the affected object
  149676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149677. */
  149678. export enum PhysicsUpdraftMode {
  149679. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  149680. Center = 0,
  149681. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  149682. Perpendicular = 1
  149683. }
  149684. /**
  149685. * Interface for a physics hit data
  149686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149687. */
  149688. export interface PhysicsHitData {
  149689. /**
  149690. * The force applied at the contact point
  149691. */
  149692. force: Vector3;
  149693. /**
  149694. * The contact point
  149695. */
  149696. contactPoint: Vector3;
  149697. /**
  149698. * The distance from the origin to the contact point
  149699. */
  149700. distanceFromOrigin: number;
  149701. }
  149702. /**
  149703. * Interface for radial explosion event data
  149704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149705. */
  149706. export interface PhysicsRadialExplosionEventData {
  149707. /**
  149708. * A sphere used for the radial explosion event
  149709. */
  149710. sphere: Mesh;
  149711. }
  149712. /**
  149713. * Interface for gravitational field event data
  149714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149715. */
  149716. export interface PhysicsGravitationalFieldEventData {
  149717. /**
  149718. * A sphere mesh used for the gravitational field event
  149719. */
  149720. sphere: Mesh;
  149721. }
  149722. /**
  149723. * Interface for updraft event data
  149724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149725. */
  149726. export interface PhysicsUpdraftEventData {
  149727. /**
  149728. * A cylinder used for the updraft event
  149729. */
  149730. cylinder: Mesh;
  149731. }
  149732. /**
  149733. * Interface for vortex event data
  149734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149735. */
  149736. export interface PhysicsVortexEventData {
  149737. /**
  149738. * A cylinder used for the vortex event
  149739. */
  149740. cylinder: Mesh;
  149741. }
  149742. /**
  149743. * Interface for an affected physics impostor
  149744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149745. */
  149746. export interface PhysicsAffectedImpostorWithData {
  149747. /**
  149748. * The impostor affected by the effect
  149749. */
  149750. impostor: PhysicsImpostor;
  149751. /**
  149752. * The data about the hit/horce from the explosion
  149753. */
  149754. hitData: PhysicsHitData;
  149755. }
  149756. }
  149757. declare module BABYLON {
  149758. /** @hidden */
  149759. export var blackAndWhitePixelShader: {
  149760. name: string;
  149761. shader: string;
  149762. };
  149763. }
  149764. declare module BABYLON {
  149765. /**
  149766. * Post process used to render in black and white
  149767. */
  149768. export class BlackAndWhitePostProcess extends PostProcess {
  149769. /**
  149770. * Linear about to convert he result to black and white (default: 1)
  149771. */
  149772. degree: number;
  149773. /**
  149774. * Gets a string identifying the name of the class
  149775. * @returns "BlackAndWhitePostProcess" string
  149776. */
  149777. getClassName(): string;
  149778. /**
  149779. * Creates a black and white post process
  149780. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  149781. * @param name The name of the effect.
  149782. * @param options The required width/height ratio to downsize to before computing the render pass.
  149783. * @param camera The camera to apply the render pass to.
  149784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149785. * @param engine The engine which the post process will be applied. (default: current engine)
  149786. * @param reusable If the post process can be reused on the same frame. (default: false)
  149787. */
  149788. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149789. /** @hidden */
  149790. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  149791. }
  149792. }
  149793. declare module BABYLON {
  149794. /**
  149795. * This represents a set of one or more post processes in Babylon.
  149796. * A post process can be used to apply a shader to a texture after it is rendered.
  149797. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149798. */
  149799. export class PostProcessRenderEffect {
  149800. private _postProcesses;
  149801. private _getPostProcesses;
  149802. private _singleInstance;
  149803. private _cameras;
  149804. private _indicesForCamera;
  149805. /**
  149806. * Name of the effect
  149807. * @hidden
  149808. */
  149809. _name: string;
  149810. /**
  149811. * Instantiates a post process render effect.
  149812. * A post process can be used to apply a shader to a texture after it is rendered.
  149813. * @param engine The engine the effect is tied to
  149814. * @param name The name of the effect
  149815. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  149816. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  149817. */
  149818. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  149819. /**
  149820. * Checks if all the post processes in the effect are supported.
  149821. */
  149822. get isSupported(): boolean;
  149823. /**
  149824. * Updates the current state of the effect
  149825. * @hidden
  149826. */
  149827. _update(): void;
  149828. /**
  149829. * Attaches the effect on cameras
  149830. * @param cameras The camera to attach to.
  149831. * @hidden
  149832. */
  149833. _attachCameras(cameras: Camera): void;
  149834. /**
  149835. * Attaches the effect on cameras
  149836. * @param cameras The camera to attach to.
  149837. * @hidden
  149838. */
  149839. _attachCameras(cameras: Camera[]): void;
  149840. /**
  149841. * Detaches the effect on cameras
  149842. * @param cameras The camera to detatch from.
  149843. * @hidden
  149844. */
  149845. _detachCameras(cameras: Camera): void;
  149846. /**
  149847. * Detatches the effect on cameras
  149848. * @param cameras The camera to detatch from.
  149849. * @hidden
  149850. */
  149851. _detachCameras(cameras: Camera[]): void;
  149852. /**
  149853. * Enables the effect on given cameras
  149854. * @param cameras The camera to enable.
  149855. * @hidden
  149856. */
  149857. _enable(cameras: Camera): void;
  149858. /**
  149859. * Enables the effect on given cameras
  149860. * @param cameras The camera to enable.
  149861. * @hidden
  149862. */
  149863. _enable(cameras: Nullable<Camera[]>): void;
  149864. /**
  149865. * Disables the effect on the given cameras
  149866. * @param cameras The camera to disable.
  149867. * @hidden
  149868. */
  149869. _disable(cameras: Camera): void;
  149870. /**
  149871. * Disables the effect on the given cameras
  149872. * @param cameras The camera to disable.
  149873. * @hidden
  149874. */
  149875. _disable(cameras: Nullable<Camera[]>): void;
  149876. /**
  149877. * Gets a list of the post processes contained in the effect.
  149878. * @param camera The camera to get the post processes on.
  149879. * @returns The list of the post processes in the effect.
  149880. */
  149881. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  149882. }
  149883. }
  149884. declare module BABYLON {
  149885. /** @hidden */
  149886. export var extractHighlightsPixelShader: {
  149887. name: string;
  149888. shader: string;
  149889. };
  149890. }
  149891. declare module BABYLON {
  149892. /**
  149893. * 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.
  149894. */
  149895. export class ExtractHighlightsPostProcess extends PostProcess {
  149896. /**
  149897. * The luminance threshold, pixels below this value will be set to black.
  149898. */
  149899. threshold: number;
  149900. /** @hidden */
  149901. _exposure: number;
  149902. /**
  149903. * Post process which has the input texture to be used when performing highlight extraction
  149904. * @hidden
  149905. */
  149906. _inputPostProcess: Nullable<PostProcess>;
  149907. /**
  149908. * Gets a string identifying the name of the class
  149909. * @returns "ExtractHighlightsPostProcess" string
  149910. */
  149911. getClassName(): string;
  149912. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149913. }
  149914. }
  149915. declare module BABYLON {
  149916. /** @hidden */
  149917. export var bloomMergePixelShader: {
  149918. name: string;
  149919. shader: string;
  149920. };
  149921. }
  149922. declare module BABYLON {
  149923. /**
  149924. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149925. */
  149926. export class BloomMergePostProcess extends PostProcess {
  149927. /** Weight of the bloom to be added to the original input. */
  149928. weight: number;
  149929. /**
  149930. * Gets a string identifying the name of the class
  149931. * @returns "BloomMergePostProcess" string
  149932. */
  149933. getClassName(): string;
  149934. /**
  149935. * Creates a new instance of @see BloomMergePostProcess
  149936. * @param name The name of the effect.
  149937. * @param originalFromInput Post process which's input will be used for the merge.
  149938. * @param blurred Blurred highlights post process which's output will be used.
  149939. * @param weight Weight of the bloom to be added to the original input.
  149940. * @param options The required width/height ratio to downsize to before computing the render pass.
  149941. * @param camera The camera to apply the render pass to.
  149942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149943. * @param engine The engine which the post process will be applied. (default: current engine)
  149944. * @param reusable If the post process can be reused on the same frame. (default: false)
  149945. * @param textureType Type of textures used when performing the post process. (default: 0)
  149946. * @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)
  149947. */
  149948. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  149949. /** Weight of the bloom to be added to the original input. */
  149950. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149951. }
  149952. }
  149953. declare module BABYLON {
  149954. /**
  149955. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  149956. */
  149957. export class BloomEffect extends PostProcessRenderEffect {
  149958. private bloomScale;
  149959. /**
  149960. * @hidden Internal
  149961. */
  149962. _effects: Array<PostProcess>;
  149963. /**
  149964. * @hidden Internal
  149965. */
  149966. _downscale: ExtractHighlightsPostProcess;
  149967. private _blurX;
  149968. private _blurY;
  149969. private _merge;
  149970. /**
  149971. * The luminance threshold to find bright areas of the image to bloom.
  149972. */
  149973. get threshold(): number;
  149974. set threshold(value: number);
  149975. /**
  149976. * The strength of the bloom.
  149977. */
  149978. get weight(): number;
  149979. set weight(value: number);
  149980. /**
  149981. * Specifies the size of the bloom blur kernel, relative to the final output size
  149982. */
  149983. get kernel(): number;
  149984. set kernel(value: number);
  149985. /**
  149986. * Creates a new instance of @see BloomEffect
  149987. * @param scene The scene the effect belongs to.
  149988. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  149989. * @param bloomKernel The size of the kernel to be used when applying the blur.
  149990. * @param bloomWeight The the strength of bloom.
  149991. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149992. * @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)
  149993. */
  149994. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  149995. /**
  149996. * Disposes each of the internal effects for a given camera.
  149997. * @param camera The camera to dispose the effect on.
  149998. */
  149999. disposeEffects(camera: Camera): void;
  150000. /**
  150001. * @hidden Internal
  150002. */
  150003. _updateEffects(): void;
  150004. /**
  150005. * Internal
  150006. * @returns if all the contained post processes are ready.
  150007. * @hidden
  150008. */
  150009. _isReady(): boolean;
  150010. }
  150011. }
  150012. declare module BABYLON {
  150013. /** @hidden */
  150014. export var chromaticAberrationPixelShader: {
  150015. name: string;
  150016. shader: string;
  150017. };
  150018. }
  150019. declare module BABYLON {
  150020. /**
  150021. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  150022. */
  150023. export class ChromaticAberrationPostProcess extends PostProcess {
  150024. /**
  150025. * The amount of seperation of rgb channels (default: 30)
  150026. */
  150027. aberrationAmount: number;
  150028. /**
  150029. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  150030. */
  150031. radialIntensity: number;
  150032. /**
  150033. * 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))
  150034. */
  150035. direction: Vector2;
  150036. /**
  150037. * 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))
  150038. */
  150039. centerPosition: Vector2;
  150040. /** The width of the screen to apply the effect on */
  150041. screenWidth: number;
  150042. /** The height of the screen to apply the effect on */
  150043. screenHeight: number;
  150044. /**
  150045. * Gets a string identifying the name of the class
  150046. * @returns "ChromaticAberrationPostProcess" string
  150047. */
  150048. getClassName(): string;
  150049. /**
  150050. * Creates a new instance ChromaticAberrationPostProcess
  150051. * @param name The name of the effect.
  150052. * @param screenWidth The width of the screen to apply the effect on.
  150053. * @param screenHeight The height of the screen to apply the effect on.
  150054. * @param options The required width/height ratio to downsize to before computing the render pass.
  150055. * @param camera The camera to apply the render pass to.
  150056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150057. * @param engine The engine which the post process will be applied. (default: current engine)
  150058. * @param reusable If the post process can be reused on the same frame. (default: false)
  150059. * @param textureType Type of textures used when performing the post process. (default: 0)
  150060. * @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)
  150061. */
  150062. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150063. /** @hidden */
  150064. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  150065. }
  150066. }
  150067. declare module BABYLON {
  150068. /** @hidden */
  150069. export var circleOfConfusionPixelShader: {
  150070. name: string;
  150071. shader: string;
  150072. };
  150073. }
  150074. declare module BABYLON {
  150075. /**
  150076. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  150077. */
  150078. export class CircleOfConfusionPostProcess extends PostProcess {
  150079. /**
  150080. * 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.
  150081. */
  150082. lensSize: number;
  150083. /**
  150084. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150085. */
  150086. fStop: number;
  150087. /**
  150088. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150089. */
  150090. focusDistance: number;
  150091. /**
  150092. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  150093. */
  150094. focalLength: number;
  150095. /**
  150096. * Gets a string identifying the name of the class
  150097. * @returns "CircleOfConfusionPostProcess" string
  150098. */
  150099. getClassName(): string;
  150100. private _depthTexture;
  150101. /**
  150102. * Creates a new instance CircleOfConfusionPostProcess
  150103. * @param name The name of the effect.
  150104. * @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.
  150105. * @param options The required width/height ratio to downsize to before computing the render pass.
  150106. * @param camera The camera to apply the render pass to.
  150107. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150108. * @param engine The engine which the post process will be applied. (default: current engine)
  150109. * @param reusable If the post process can be reused on the same frame. (default: false)
  150110. * @param textureType Type of textures used when performing the post process. (default: 0)
  150111. * @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)
  150112. */
  150113. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150114. /**
  150115. * 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.
  150116. */
  150117. set depthTexture(value: RenderTargetTexture);
  150118. }
  150119. }
  150120. declare module BABYLON {
  150121. /** @hidden */
  150122. export var colorCorrectionPixelShader: {
  150123. name: string;
  150124. shader: string;
  150125. };
  150126. }
  150127. declare module BABYLON {
  150128. /**
  150129. *
  150130. * This post-process allows the modification of rendered colors by using
  150131. * a 'look-up table' (LUT). This effect is also called Color Grading.
  150132. *
  150133. * The object needs to be provided an url to a texture containing the color
  150134. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  150135. * Use an image editing software to tweak the LUT to match your needs.
  150136. *
  150137. * For an example of a color LUT, see here:
  150138. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  150139. * For explanations on color grading, see here:
  150140. * @see http://udn.epicgames.com/Three/ColorGrading.html
  150141. *
  150142. */
  150143. export class ColorCorrectionPostProcess extends PostProcess {
  150144. private _colorTableTexture;
  150145. /**
  150146. * Gets the color table url used to create the LUT texture
  150147. */
  150148. colorTableUrl: string;
  150149. /**
  150150. * Gets a string identifying the name of the class
  150151. * @returns "ColorCorrectionPostProcess" string
  150152. */
  150153. getClassName(): string;
  150154. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150155. /** @hidden */
  150156. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  150157. }
  150158. }
  150159. declare module BABYLON {
  150160. /** @hidden */
  150161. export var convolutionPixelShader: {
  150162. name: string;
  150163. shader: string;
  150164. };
  150165. }
  150166. declare module BABYLON {
  150167. /**
  150168. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  150169. * input texture to perform effects such as edge detection or sharpening
  150170. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150171. */
  150172. export class ConvolutionPostProcess extends PostProcess {
  150173. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  150174. kernel: number[];
  150175. /**
  150176. * Gets a string identifying the name of the class
  150177. * @returns "ConvolutionPostProcess" string
  150178. */
  150179. getClassName(): string;
  150180. /**
  150181. * Creates a new instance ConvolutionPostProcess
  150182. * @param name The name of the effect.
  150183. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  150184. * @param options The required width/height ratio to downsize to before computing the render pass.
  150185. * @param camera The camera to apply the render pass to.
  150186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150187. * @param engine The engine which the post process will be applied. (default: current engine)
  150188. * @param reusable If the post process can be reused on the same frame. (default: false)
  150189. * @param textureType Type of textures used when performing the post process. (default: 0)
  150190. */
  150191. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150192. /** @hidden */
  150193. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  150194. /**
  150195. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150196. */
  150197. static EdgeDetect0Kernel: number[];
  150198. /**
  150199. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150200. */
  150201. static EdgeDetect1Kernel: number[];
  150202. /**
  150203. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150204. */
  150205. static EdgeDetect2Kernel: number[];
  150206. /**
  150207. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150208. */
  150209. static SharpenKernel: number[];
  150210. /**
  150211. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150212. */
  150213. static EmbossKernel: number[];
  150214. /**
  150215. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150216. */
  150217. static GaussianKernel: number[];
  150218. }
  150219. }
  150220. declare module BABYLON {
  150221. /**
  150222. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  150223. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  150224. * based on samples that have a large difference in distance than the center pixel.
  150225. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  150226. */
  150227. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  150228. /**
  150229. * The direction the blur should be applied
  150230. */
  150231. direction: Vector2;
  150232. /**
  150233. * Gets a string identifying the name of the class
  150234. * @returns "DepthOfFieldBlurPostProcess" string
  150235. */
  150236. getClassName(): string;
  150237. /**
  150238. * Creates a new instance CircleOfConfusionPostProcess
  150239. * @param name The name of the effect.
  150240. * @param scene The scene the effect belongs to.
  150241. * @param direction The direction the blur should be applied.
  150242. * @param kernel The size of the kernel used to blur.
  150243. * @param options The required width/height ratio to downsize to before computing the render pass.
  150244. * @param camera The camera to apply the render pass to.
  150245. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  150246. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  150247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150248. * @param engine The engine which the post process will be applied. (default: current engine)
  150249. * @param reusable If the post process can be reused on the same frame. (default: false)
  150250. * @param textureType Type of textures used when performing the post process. (default: 0)
  150251. * @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)
  150252. */
  150253. 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);
  150254. }
  150255. }
  150256. declare module BABYLON {
  150257. /** @hidden */
  150258. export var depthOfFieldMergePixelShader: {
  150259. name: string;
  150260. shader: string;
  150261. };
  150262. }
  150263. declare module BABYLON {
  150264. /**
  150265. * Options to be set when merging outputs from the default pipeline.
  150266. */
  150267. export class DepthOfFieldMergePostProcessOptions {
  150268. /**
  150269. * The original image to merge on top of
  150270. */
  150271. originalFromInput: PostProcess;
  150272. /**
  150273. * Parameters to perform the merge of the depth of field effect
  150274. */
  150275. depthOfField?: {
  150276. circleOfConfusion: PostProcess;
  150277. blurSteps: Array<PostProcess>;
  150278. };
  150279. /**
  150280. * Parameters to perform the merge of bloom effect
  150281. */
  150282. bloom?: {
  150283. blurred: PostProcess;
  150284. weight: number;
  150285. };
  150286. }
  150287. /**
  150288. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150289. */
  150290. export class DepthOfFieldMergePostProcess extends PostProcess {
  150291. private blurSteps;
  150292. /**
  150293. * Gets a string identifying the name of the class
  150294. * @returns "DepthOfFieldMergePostProcess" string
  150295. */
  150296. getClassName(): string;
  150297. /**
  150298. * Creates a new instance of DepthOfFieldMergePostProcess
  150299. * @param name The name of the effect.
  150300. * @param originalFromInput Post process which's input will be used for the merge.
  150301. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  150302. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  150303. * @param options The required width/height ratio to downsize to before computing the render pass.
  150304. * @param camera The camera to apply the render pass to.
  150305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150306. * @param engine The engine which the post process will be applied. (default: current engine)
  150307. * @param reusable If the post process can be reused on the same frame. (default: false)
  150308. * @param textureType Type of textures used when performing the post process. (default: 0)
  150309. * @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)
  150310. */
  150311. 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);
  150312. /**
  150313. * Updates the effect with the current post process compile time values and recompiles the shader.
  150314. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  150315. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  150316. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  150317. * @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
  150318. * @param onCompiled Called when the shader has been compiled.
  150319. * @param onError Called if there is an error when compiling a shader.
  150320. */
  150321. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  150322. }
  150323. }
  150324. declare module BABYLON {
  150325. /**
  150326. * Specifies the level of max blur that should be applied when using the depth of field effect
  150327. */
  150328. export enum DepthOfFieldEffectBlurLevel {
  150329. /**
  150330. * Subtle blur
  150331. */
  150332. Low = 0,
  150333. /**
  150334. * Medium blur
  150335. */
  150336. Medium = 1,
  150337. /**
  150338. * Large blur
  150339. */
  150340. High = 2
  150341. }
  150342. /**
  150343. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  150344. */
  150345. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  150346. private _circleOfConfusion;
  150347. /**
  150348. * @hidden Internal, blurs from high to low
  150349. */
  150350. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  150351. private _depthOfFieldBlurY;
  150352. private _dofMerge;
  150353. /**
  150354. * @hidden Internal post processes in depth of field effect
  150355. */
  150356. _effects: Array<PostProcess>;
  150357. /**
  150358. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  150359. */
  150360. set focalLength(value: number);
  150361. get focalLength(): number;
  150362. /**
  150363. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150364. */
  150365. set fStop(value: number);
  150366. get fStop(): number;
  150367. /**
  150368. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150369. */
  150370. set focusDistance(value: number);
  150371. get focusDistance(): number;
  150372. /**
  150373. * 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.
  150374. */
  150375. set lensSize(value: number);
  150376. get lensSize(): number;
  150377. /**
  150378. * Creates a new instance DepthOfFieldEffect
  150379. * @param scene The scene the effect belongs to.
  150380. * @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.
  150381. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150382. * @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)
  150383. */
  150384. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  150385. /**
  150386. * Get the current class name of the current effet
  150387. * @returns "DepthOfFieldEffect"
  150388. */
  150389. getClassName(): string;
  150390. /**
  150391. * 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.
  150392. */
  150393. set depthTexture(value: RenderTargetTexture);
  150394. /**
  150395. * Disposes each of the internal effects for a given camera.
  150396. * @param camera The camera to dispose the effect on.
  150397. */
  150398. disposeEffects(camera: Camera): void;
  150399. /**
  150400. * @hidden Internal
  150401. */
  150402. _updateEffects(): void;
  150403. /**
  150404. * Internal
  150405. * @returns if all the contained post processes are ready.
  150406. * @hidden
  150407. */
  150408. _isReady(): boolean;
  150409. }
  150410. }
  150411. declare module BABYLON {
  150412. /** @hidden */
  150413. export var displayPassPixelShader: {
  150414. name: string;
  150415. shader: string;
  150416. };
  150417. }
  150418. declare module BABYLON {
  150419. /**
  150420. * DisplayPassPostProcess which produces an output the same as it's input
  150421. */
  150422. export class DisplayPassPostProcess extends PostProcess {
  150423. /**
  150424. * Gets a string identifying the name of the class
  150425. * @returns "DisplayPassPostProcess" string
  150426. */
  150427. getClassName(): string;
  150428. /**
  150429. * Creates the DisplayPassPostProcess
  150430. * @param name The name of the effect.
  150431. * @param options The required width/height ratio to downsize to before computing the render pass.
  150432. * @param camera The camera to apply the render pass to.
  150433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150434. * @param engine The engine which the post process will be applied. (default: current engine)
  150435. * @param reusable If the post process can be reused on the same frame. (default: false)
  150436. */
  150437. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150438. /** @hidden */
  150439. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  150440. }
  150441. }
  150442. declare module BABYLON {
  150443. /** @hidden */
  150444. export var filterPixelShader: {
  150445. name: string;
  150446. shader: string;
  150447. };
  150448. }
  150449. declare module BABYLON {
  150450. /**
  150451. * Applies a kernel filter to the image
  150452. */
  150453. export class FilterPostProcess extends PostProcess {
  150454. /** The matrix to be applied to the image */
  150455. kernelMatrix: Matrix;
  150456. /**
  150457. * Gets a string identifying the name of the class
  150458. * @returns "FilterPostProcess" string
  150459. */
  150460. getClassName(): string;
  150461. /**
  150462. *
  150463. * @param name The name of the effect.
  150464. * @param kernelMatrix The matrix to be applied to the image
  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. */
  150471. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150472. /** @hidden */
  150473. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  150474. }
  150475. }
  150476. declare module BABYLON {
  150477. /** @hidden */
  150478. export var fxaaPixelShader: {
  150479. name: string;
  150480. shader: string;
  150481. };
  150482. }
  150483. declare module BABYLON {
  150484. /** @hidden */
  150485. export var fxaaVertexShader: {
  150486. name: string;
  150487. shader: string;
  150488. };
  150489. }
  150490. declare module BABYLON {
  150491. /**
  150492. * Fxaa post process
  150493. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  150494. */
  150495. export class FxaaPostProcess extends PostProcess {
  150496. /**
  150497. * Gets a string identifying the name of the class
  150498. * @returns "FxaaPostProcess" string
  150499. */
  150500. getClassName(): string;
  150501. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150502. private _getDefines;
  150503. /** @hidden */
  150504. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  150505. }
  150506. }
  150507. declare module BABYLON {
  150508. /** @hidden */
  150509. export var grainPixelShader: {
  150510. name: string;
  150511. shader: string;
  150512. };
  150513. }
  150514. declare module BABYLON {
  150515. /**
  150516. * The GrainPostProcess adds noise to the image at mid luminance levels
  150517. */
  150518. export class GrainPostProcess extends PostProcess {
  150519. /**
  150520. * The intensity of the grain added (default: 30)
  150521. */
  150522. intensity: number;
  150523. /**
  150524. * If the grain should be randomized on every frame
  150525. */
  150526. animated: boolean;
  150527. /**
  150528. * Gets a string identifying the name of the class
  150529. * @returns "GrainPostProcess" string
  150530. */
  150531. getClassName(): string;
  150532. /**
  150533. * Creates a new instance of @see GrainPostProcess
  150534. * @param name The name of the effect.
  150535. * @param options The required width/height ratio to downsize to before computing the render pass.
  150536. * @param camera The camera to apply the render pass to.
  150537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150538. * @param engine The engine which the post process will be applied. (default: current engine)
  150539. * @param reusable If the post process can be reused on the same frame. (default: false)
  150540. * @param textureType Type of textures used when performing the post process. (default: 0)
  150541. * @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)
  150542. */
  150543. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150544. /** @hidden */
  150545. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  150546. }
  150547. }
  150548. declare module BABYLON {
  150549. /** @hidden */
  150550. export var highlightsPixelShader: {
  150551. name: string;
  150552. shader: string;
  150553. };
  150554. }
  150555. declare module BABYLON {
  150556. /**
  150557. * Extracts highlights from the image
  150558. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150559. */
  150560. export class HighlightsPostProcess extends PostProcess {
  150561. /**
  150562. * Gets a string identifying the name of the class
  150563. * @returns "HighlightsPostProcess" string
  150564. */
  150565. getClassName(): string;
  150566. /**
  150567. * Extracts highlights from the image
  150568. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150569. * @param name The name of the effect.
  150570. * @param options The required width/height ratio to downsize to before computing the render pass.
  150571. * @param camera The camera to apply the render pass to.
  150572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150573. * @param engine The engine which the post process will be applied. (default: current engine)
  150574. * @param reusable If the post process can be reused on the same frame. (default: false)
  150575. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  150576. */
  150577. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150578. }
  150579. }
  150580. declare module BABYLON {
  150581. /** @hidden */
  150582. export var mrtFragmentDeclaration: {
  150583. name: string;
  150584. shader: string;
  150585. };
  150586. }
  150587. declare module BABYLON {
  150588. /** @hidden */
  150589. export var geometryPixelShader: {
  150590. name: string;
  150591. shader: string;
  150592. };
  150593. }
  150594. declare module BABYLON {
  150595. /** @hidden */
  150596. export var geometryVertexShader: {
  150597. name: string;
  150598. shader: string;
  150599. };
  150600. }
  150601. declare module BABYLON {
  150602. /** @hidden */
  150603. interface ISavedTransformationMatrix {
  150604. world: Matrix;
  150605. viewProjection: Matrix;
  150606. }
  150607. /**
  150608. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  150609. */
  150610. export class GeometryBufferRenderer {
  150611. /**
  150612. * Constant used to retrieve the position texture index in the G-Buffer textures array
  150613. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  150614. */
  150615. static readonly POSITION_TEXTURE_TYPE: number;
  150616. /**
  150617. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  150618. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  150619. */
  150620. static readonly VELOCITY_TEXTURE_TYPE: number;
  150621. /**
  150622. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  150623. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  150624. */
  150625. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  150626. /**
  150627. * Dictionary used to store the previous transformation matrices of each rendered mesh
  150628. * in order to compute objects velocities when enableVelocity is set to "true"
  150629. * @hidden
  150630. */
  150631. _previousTransformationMatrices: {
  150632. [index: number]: ISavedTransformationMatrix;
  150633. };
  150634. /**
  150635. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  150636. * in order to compute objects velocities when enableVelocity is set to "true"
  150637. * @hidden
  150638. */
  150639. _previousBonesTransformationMatrices: {
  150640. [index: number]: Float32Array;
  150641. };
  150642. /**
  150643. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  150644. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  150645. */
  150646. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  150647. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  150648. renderTransparentMeshes: boolean;
  150649. private _scene;
  150650. private _resizeObserver;
  150651. private _multiRenderTarget;
  150652. private _ratio;
  150653. private _enablePosition;
  150654. private _enableVelocity;
  150655. private _enableReflectivity;
  150656. private _positionIndex;
  150657. private _velocityIndex;
  150658. private _reflectivityIndex;
  150659. protected _effect: Effect;
  150660. protected _cachedDefines: string;
  150661. /**
  150662. * Set the render list (meshes to be rendered) used in the G buffer.
  150663. */
  150664. set renderList(meshes: Mesh[]);
  150665. /**
  150666. * Gets wether or not G buffer are supported by the running hardware.
  150667. * This requires draw buffer supports
  150668. */
  150669. get isSupported(): boolean;
  150670. /**
  150671. * Returns the index of the given texture type in the G-Buffer textures array
  150672. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  150673. * @returns the index of the given texture type in the G-Buffer textures array
  150674. */
  150675. getTextureIndex(textureType: number): number;
  150676. /**
  150677. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  150678. */
  150679. get enablePosition(): boolean;
  150680. /**
  150681. * Sets whether or not objects positions are enabled for the G buffer.
  150682. */
  150683. set enablePosition(enable: boolean);
  150684. /**
  150685. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  150686. */
  150687. get enableVelocity(): boolean;
  150688. /**
  150689. * Sets wether or not objects velocities are enabled for the G buffer.
  150690. */
  150691. set enableVelocity(enable: boolean);
  150692. /**
  150693. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  150694. */
  150695. get enableReflectivity(): boolean;
  150696. /**
  150697. * Sets wether or not objects roughness are enabled for the G buffer.
  150698. */
  150699. set enableReflectivity(enable: boolean);
  150700. /**
  150701. * Gets the scene associated with the buffer.
  150702. */
  150703. get scene(): Scene;
  150704. /**
  150705. * Gets the ratio used by the buffer during its creation.
  150706. * How big is the buffer related to the main canvas.
  150707. */
  150708. get ratio(): number;
  150709. /** @hidden */
  150710. static _SceneComponentInitialization: (scene: Scene) => void;
  150711. /**
  150712. * Creates a new G Buffer for the scene
  150713. * @param scene The scene the buffer belongs to
  150714. * @param ratio How big is the buffer related to the main canvas.
  150715. */
  150716. constructor(scene: Scene, ratio?: number);
  150717. /**
  150718. * Checks wether everything is ready to render a submesh to the G buffer.
  150719. * @param subMesh the submesh to check readiness for
  150720. * @param useInstances is the mesh drawn using instance or not
  150721. * @returns true if ready otherwise false
  150722. */
  150723. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150724. /**
  150725. * Gets the current underlying G Buffer.
  150726. * @returns the buffer
  150727. */
  150728. getGBuffer(): MultiRenderTarget;
  150729. /**
  150730. * Gets the number of samples used to render the buffer (anti aliasing).
  150731. */
  150732. get samples(): number;
  150733. /**
  150734. * Sets the number of samples used to render the buffer (anti aliasing).
  150735. */
  150736. set samples(value: number);
  150737. /**
  150738. * Disposes the renderer and frees up associated resources.
  150739. */
  150740. dispose(): void;
  150741. protected _createRenderTargets(): void;
  150742. private _copyBonesTransformationMatrices;
  150743. }
  150744. }
  150745. declare module BABYLON {
  150746. /**
  150747. * Contains all parameters needed for the prepass to perform
  150748. * motion blur
  150749. */
  150750. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  150751. /**
  150752. * Is motion blur enabled
  150753. */
  150754. enabled: boolean;
  150755. /**
  150756. * Name of the configuration
  150757. */
  150758. name: string;
  150759. /**
  150760. * Textures that should be present in the MRT for this effect to work
  150761. */
  150762. readonly texturesRequired: number[];
  150763. }
  150764. }
  150765. declare module BABYLON {
  150766. interface Scene {
  150767. /** @hidden (Backing field) */
  150768. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150769. /**
  150770. * Gets or Sets the current geometry buffer associated to the scene.
  150771. */
  150772. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150773. /**
  150774. * Enables a GeometryBufferRender and associates it with the scene
  150775. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  150776. * @returns the GeometryBufferRenderer
  150777. */
  150778. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  150779. /**
  150780. * Disables the GeometryBufferRender associated with the scene
  150781. */
  150782. disableGeometryBufferRenderer(): void;
  150783. }
  150784. /**
  150785. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150786. * in several rendering techniques.
  150787. */
  150788. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  150789. /**
  150790. * The component name helpful to identify the component in the list of scene components.
  150791. */
  150792. readonly name: string;
  150793. /**
  150794. * The scene the component belongs to.
  150795. */
  150796. scene: Scene;
  150797. /**
  150798. * Creates a new instance of the component for the given scene
  150799. * @param scene Defines the scene to register the component in
  150800. */
  150801. constructor(scene: Scene);
  150802. /**
  150803. * Registers the component in a given scene
  150804. */
  150805. register(): void;
  150806. /**
  150807. * Rebuilds the elements related to this component in case of
  150808. * context lost for instance.
  150809. */
  150810. rebuild(): void;
  150811. /**
  150812. * Disposes the component and the associated ressources
  150813. */
  150814. dispose(): void;
  150815. private _gatherRenderTargets;
  150816. }
  150817. }
  150818. declare module BABYLON {
  150819. /** @hidden */
  150820. export var motionBlurPixelShader: {
  150821. name: string;
  150822. shader: string;
  150823. };
  150824. }
  150825. declare module BABYLON {
  150826. /**
  150827. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  150828. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  150829. * As an example, all you have to do is to create the post-process:
  150830. * var mb = new BABYLON.MotionBlurPostProcess(
  150831. * 'mb', // The name of the effect.
  150832. * scene, // The scene containing the objects to blur according to their velocity.
  150833. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  150834. * camera // The camera to apply the render pass to.
  150835. * );
  150836. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  150837. */
  150838. export class MotionBlurPostProcess extends PostProcess {
  150839. /**
  150840. * Defines how much the image is blurred by the movement. Default value is equal to 1
  150841. */
  150842. motionStrength: number;
  150843. /**
  150844. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  150845. */
  150846. get motionBlurSamples(): number;
  150847. /**
  150848. * Sets the number of iterations to be used for motion blur quality
  150849. */
  150850. set motionBlurSamples(samples: number);
  150851. private _motionBlurSamples;
  150852. private _forceGeometryBuffer;
  150853. private _geometryBufferRenderer;
  150854. private _prePassRenderer;
  150855. /**
  150856. * Gets a string identifying the name of the class
  150857. * @returns "MotionBlurPostProcess" string
  150858. */
  150859. getClassName(): string;
  150860. /**
  150861. * Creates a new instance MotionBlurPostProcess
  150862. * @param name The name of the effect.
  150863. * @param scene The scene containing the objects to blur according to their velocity.
  150864. * @param options The required width/height ratio to downsize to before computing the render pass.
  150865. * @param camera The camera to apply the render pass to.
  150866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150867. * @param engine The engine which the post process will be applied. (default: current engine)
  150868. * @param reusable If the post process can be reused on the same frame. (default: false)
  150869. * @param textureType Type of textures used when performing the post process. (default: 0)
  150870. * @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)
  150871. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  150872. */
  150873. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  150874. /**
  150875. * Excludes the given skinned mesh from computing bones velocities.
  150876. * 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.
  150877. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  150878. */
  150879. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150880. /**
  150881. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  150882. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  150883. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  150884. */
  150885. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150886. /**
  150887. * Disposes the post process.
  150888. * @param camera The camera to dispose the post process on.
  150889. */
  150890. dispose(camera?: Camera): void;
  150891. /** @hidden */
  150892. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  150893. }
  150894. }
  150895. declare module BABYLON {
  150896. /** @hidden */
  150897. export var refractionPixelShader: {
  150898. name: string;
  150899. shader: string;
  150900. };
  150901. }
  150902. declare module BABYLON {
  150903. /**
  150904. * Post process which applies a refractin texture
  150905. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150906. */
  150907. export class RefractionPostProcess extends PostProcess {
  150908. private _refTexture;
  150909. private _ownRefractionTexture;
  150910. /** the base color of the refraction (used to taint the rendering) */
  150911. color: Color3;
  150912. /** simulated refraction depth */
  150913. depth: number;
  150914. /** the coefficient of the base color (0 to remove base color tainting) */
  150915. colorLevel: number;
  150916. /** Gets the url used to load the refraction texture */
  150917. refractionTextureUrl: string;
  150918. /**
  150919. * Gets or sets the refraction texture
  150920. * Please note that you are responsible for disposing the texture if you set it manually
  150921. */
  150922. get refractionTexture(): Texture;
  150923. set refractionTexture(value: Texture);
  150924. /**
  150925. * Gets a string identifying the name of the class
  150926. * @returns "RefractionPostProcess" string
  150927. */
  150928. getClassName(): string;
  150929. /**
  150930. * Initializes the RefractionPostProcess
  150931. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150932. * @param name The name of the effect.
  150933. * @param refractionTextureUrl Url of the refraction texture to use
  150934. * @param color the base color of the refraction (used to taint the rendering)
  150935. * @param depth simulated refraction depth
  150936. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  150937. * @param camera The camera to apply the render pass to.
  150938. * @param options The required width/height ratio to downsize to before computing the render pass.
  150939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150940. * @param engine The engine which the post process will be applied. (default: current engine)
  150941. * @param reusable If the post process can be reused on the same frame. (default: false)
  150942. */
  150943. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150944. /**
  150945. * Disposes of the post process
  150946. * @param camera Camera to dispose post process on
  150947. */
  150948. dispose(camera: Camera): void;
  150949. /** @hidden */
  150950. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  150951. }
  150952. }
  150953. declare module BABYLON {
  150954. /** @hidden */
  150955. export var sharpenPixelShader: {
  150956. name: string;
  150957. shader: string;
  150958. };
  150959. }
  150960. declare module BABYLON {
  150961. /**
  150962. * The SharpenPostProcess applies a sharpen kernel to every pixel
  150963. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150964. */
  150965. export class SharpenPostProcess extends PostProcess {
  150966. /**
  150967. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  150968. */
  150969. colorAmount: number;
  150970. /**
  150971. * How much sharpness should be applied (default: 0.3)
  150972. */
  150973. edgeAmount: number;
  150974. /**
  150975. * Gets a string identifying the name of the class
  150976. * @returns "SharpenPostProcess" string
  150977. */
  150978. getClassName(): string;
  150979. /**
  150980. * Creates a new instance ConvolutionPostProcess
  150981. * @param name The name of the effect.
  150982. * @param options The required width/height ratio to downsize to before computing the render pass.
  150983. * @param camera The camera to apply the render pass to.
  150984. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150985. * @param engine The engine which the post process will be applied. (default: current engine)
  150986. * @param reusable If the post process can be reused on the same frame. (default: false)
  150987. * @param textureType Type of textures used when performing the post process. (default: 0)
  150988. * @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)
  150989. */
  150990. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150991. /** @hidden */
  150992. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  150993. }
  150994. }
  150995. declare module BABYLON {
  150996. /**
  150997. * PostProcessRenderPipeline
  150998. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150999. */
  151000. export class PostProcessRenderPipeline {
  151001. private engine;
  151002. private _renderEffects;
  151003. private _renderEffectsForIsolatedPass;
  151004. /**
  151005. * List of inspectable custom properties (used by the Inspector)
  151006. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  151007. */
  151008. inspectableCustomProperties: IInspectable[];
  151009. /**
  151010. * @hidden
  151011. */
  151012. protected _cameras: Camera[];
  151013. /** @hidden */
  151014. _name: string;
  151015. /**
  151016. * Gets pipeline name
  151017. */
  151018. get name(): string;
  151019. /** Gets the list of attached cameras */
  151020. get cameras(): Camera[];
  151021. /**
  151022. * Initializes a PostProcessRenderPipeline
  151023. * @param engine engine to add the pipeline to
  151024. * @param name name of the pipeline
  151025. */
  151026. constructor(engine: Engine, name: string);
  151027. /**
  151028. * Gets the class name
  151029. * @returns "PostProcessRenderPipeline"
  151030. */
  151031. getClassName(): string;
  151032. /**
  151033. * If all the render effects in the pipeline are supported
  151034. */
  151035. get isSupported(): boolean;
  151036. /**
  151037. * Adds an effect to the pipeline
  151038. * @param renderEffect the effect to add
  151039. */
  151040. addEffect(renderEffect: PostProcessRenderEffect): void;
  151041. /** @hidden */
  151042. _rebuild(): void;
  151043. /** @hidden */
  151044. _enableEffect(renderEffectName: string, cameras: Camera): void;
  151045. /** @hidden */
  151046. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  151047. /** @hidden */
  151048. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151049. /** @hidden */
  151050. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151051. /** @hidden */
  151052. _attachCameras(cameras: Camera, unique: boolean): void;
  151053. /** @hidden */
  151054. _attachCameras(cameras: Camera[], unique: boolean): void;
  151055. /** @hidden */
  151056. _detachCameras(cameras: Camera): void;
  151057. /** @hidden */
  151058. _detachCameras(cameras: Nullable<Camera[]>): void;
  151059. /** @hidden */
  151060. _update(): void;
  151061. /** @hidden */
  151062. _reset(): void;
  151063. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  151064. /**
  151065. * Sets the required values to the prepass renderer.
  151066. * @param prePassRenderer defines the prepass renderer to setup.
  151067. * @returns true if the pre pass is needed.
  151068. */
  151069. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151070. /**
  151071. * Disposes of the pipeline
  151072. */
  151073. dispose(): void;
  151074. }
  151075. }
  151076. declare module BABYLON {
  151077. /**
  151078. * PostProcessRenderPipelineManager class
  151079. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151080. */
  151081. export class PostProcessRenderPipelineManager {
  151082. private _renderPipelines;
  151083. /**
  151084. * Initializes a PostProcessRenderPipelineManager
  151085. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151086. */
  151087. constructor();
  151088. /**
  151089. * Gets the list of supported render pipelines
  151090. */
  151091. get supportedPipelines(): PostProcessRenderPipeline[];
  151092. /**
  151093. * Adds a pipeline to the manager
  151094. * @param renderPipeline The pipeline to add
  151095. */
  151096. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  151097. /**
  151098. * Attaches a camera to the pipeline
  151099. * @param renderPipelineName The name of the pipeline to attach to
  151100. * @param cameras the camera to attach
  151101. * @param unique if the camera can be attached multiple times to the pipeline
  151102. */
  151103. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  151104. /**
  151105. * Detaches a camera from the pipeline
  151106. * @param renderPipelineName The name of the pipeline to detach from
  151107. * @param cameras the camera to detach
  151108. */
  151109. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  151110. /**
  151111. * Enables an effect by name on a pipeline
  151112. * @param renderPipelineName the name of the pipeline to enable the effect in
  151113. * @param renderEffectName the name of the effect to enable
  151114. * @param cameras the cameras that the effect should be enabled on
  151115. */
  151116. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151117. /**
  151118. * Disables an effect by name on a pipeline
  151119. * @param renderPipelineName the name of the pipeline to disable the effect in
  151120. * @param renderEffectName the name of the effect to disable
  151121. * @param cameras the cameras that the effect should be disabled on
  151122. */
  151123. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151124. /**
  151125. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  151126. */
  151127. update(): void;
  151128. /** @hidden */
  151129. _rebuild(): void;
  151130. /**
  151131. * Disposes of the manager and pipelines
  151132. */
  151133. dispose(): void;
  151134. }
  151135. }
  151136. declare module BABYLON {
  151137. interface Scene {
  151138. /** @hidden (Backing field) */
  151139. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151140. /**
  151141. * Gets the postprocess render pipeline manager
  151142. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151143. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151144. */
  151145. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151146. }
  151147. /**
  151148. * Defines the Render Pipeline scene component responsible to rendering pipelines
  151149. */
  151150. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  151151. /**
  151152. * The component name helpfull to identify the component in the list of scene components.
  151153. */
  151154. readonly name: string;
  151155. /**
  151156. * The scene the component belongs to.
  151157. */
  151158. scene: Scene;
  151159. /**
  151160. * Creates a new instance of the component for the given scene
  151161. * @param scene Defines the scene to register the component in
  151162. */
  151163. constructor(scene: Scene);
  151164. /**
  151165. * Registers the component in a given scene
  151166. */
  151167. register(): void;
  151168. /**
  151169. * Rebuilds the elements related to this component in case of
  151170. * context lost for instance.
  151171. */
  151172. rebuild(): void;
  151173. /**
  151174. * Disposes the component and the associated ressources
  151175. */
  151176. dispose(): void;
  151177. private _gatherRenderTargets;
  151178. }
  151179. }
  151180. declare module BABYLON {
  151181. /**
  151182. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  151183. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151184. */
  151185. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151186. private _scene;
  151187. private _camerasToBeAttached;
  151188. /**
  151189. * ID of the sharpen post process,
  151190. */
  151191. private readonly SharpenPostProcessId;
  151192. /**
  151193. * @ignore
  151194. * ID of the image processing post process;
  151195. */
  151196. readonly ImageProcessingPostProcessId: string;
  151197. /**
  151198. * @ignore
  151199. * ID of the Fast Approximate Anti-Aliasing post process;
  151200. */
  151201. readonly FxaaPostProcessId: string;
  151202. /**
  151203. * ID of the chromatic aberration post process,
  151204. */
  151205. private readonly ChromaticAberrationPostProcessId;
  151206. /**
  151207. * ID of the grain post process
  151208. */
  151209. private readonly GrainPostProcessId;
  151210. /**
  151211. * Sharpen post process which will apply a sharpen convolution to enhance edges
  151212. */
  151213. sharpen: SharpenPostProcess;
  151214. private _sharpenEffect;
  151215. private bloom;
  151216. /**
  151217. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  151218. */
  151219. depthOfField: DepthOfFieldEffect;
  151220. /**
  151221. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151222. */
  151223. fxaa: FxaaPostProcess;
  151224. /**
  151225. * Image post processing pass used to perform operations such as tone mapping or color grading.
  151226. */
  151227. imageProcessing: ImageProcessingPostProcess;
  151228. /**
  151229. * Chromatic aberration post process which will shift rgb colors in the image
  151230. */
  151231. chromaticAberration: ChromaticAberrationPostProcess;
  151232. private _chromaticAberrationEffect;
  151233. /**
  151234. * Grain post process which add noise to the image
  151235. */
  151236. grain: GrainPostProcess;
  151237. private _grainEffect;
  151238. /**
  151239. * Glow post process which adds a glow to emissive areas of the image
  151240. */
  151241. private _glowLayer;
  151242. /**
  151243. * Animations which can be used to tweak settings over a period of time
  151244. */
  151245. animations: Animation[];
  151246. private _imageProcessingConfigurationObserver;
  151247. private _sharpenEnabled;
  151248. private _bloomEnabled;
  151249. private _depthOfFieldEnabled;
  151250. private _depthOfFieldBlurLevel;
  151251. private _fxaaEnabled;
  151252. private _imageProcessingEnabled;
  151253. private _defaultPipelineTextureType;
  151254. private _bloomScale;
  151255. private _chromaticAberrationEnabled;
  151256. private _grainEnabled;
  151257. private _buildAllowed;
  151258. /**
  151259. * Gets active scene
  151260. */
  151261. get scene(): Scene;
  151262. /**
  151263. * Enable or disable the sharpen process from the pipeline
  151264. */
  151265. set sharpenEnabled(enabled: boolean);
  151266. get sharpenEnabled(): boolean;
  151267. private _resizeObserver;
  151268. private _hardwareScaleLevel;
  151269. private _bloomKernel;
  151270. /**
  151271. * Specifies the size of the bloom blur kernel, relative to the final output size
  151272. */
  151273. get bloomKernel(): number;
  151274. set bloomKernel(value: number);
  151275. /**
  151276. * Specifies the weight of the bloom in the final rendering
  151277. */
  151278. private _bloomWeight;
  151279. /**
  151280. * Specifies the luma threshold for the area that will be blurred by the bloom
  151281. */
  151282. private _bloomThreshold;
  151283. private _hdr;
  151284. /**
  151285. * The strength of the bloom.
  151286. */
  151287. set bloomWeight(value: number);
  151288. get bloomWeight(): number;
  151289. /**
  151290. * The strength of the bloom.
  151291. */
  151292. set bloomThreshold(value: number);
  151293. get bloomThreshold(): number;
  151294. /**
  151295. * The scale of the bloom, lower value will provide better performance.
  151296. */
  151297. set bloomScale(value: number);
  151298. get bloomScale(): number;
  151299. /**
  151300. * Enable or disable the bloom from the pipeline
  151301. */
  151302. set bloomEnabled(enabled: boolean);
  151303. get bloomEnabled(): boolean;
  151304. private _rebuildBloom;
  151305. /**
  151306. * If the depth of field is enabled.
  151307. */
  151308. get depthOfFieldEnabled(): boolean;
  151309. set depthOfFieldEnabled(enabled: boolean);
  151310. /**
  151311. * Blur level of the depth of field effect. (Higher blur will effect performance)
  151312. */
  151313. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  151314. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  151315. /**
  151316. * If the anti aliasing is enabled.
  151317. */
  151318. set fxaaEnabled(enabled: boolean);
  151319. get fxaaEnabled(): boolean;
  151320. private _samples;
  151321. /**
  151322. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151323. */
  151324. set samples(sampleCount: number);
  151325. get samples(): number;
  151326. /**
  151327. * If image processing is enabled.
  151328. */
  151329. set imageProcessingEnabled(enabled: boolean);
  151330. get imageProcessingEnabled(): boolean;
  151331. /**
  151332. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  151333. */
  151334. set glowLayerEnabled(enabled: boolean);
  151335. get glowLayerEnabled(): boolean;
  151336. /**
  151337. * Gets the glow layer (or null if not defined)
  151338. */
  151339. get glowLayer(): Nullable<GlowLayer>;
  151340. /**
  151341. * Enable or disable the chromaticAberration process from the pipeline
  151342. */
  151343. set chromaticAberrationEnabled(enabled: boolean);
  151344. get chromaticAberrationEnabled(): boolean;
  151345. /**
  151346. * Enable or disable the grain process from the pipeline
  151347. */
  151348. set grainEnabled(enabled: boolean);
  151349. get grainEnabled(): boolean;
  151350. /**
  151351. * @constructor
  151352. * @param name - The rendering pipeline name (default: "")
  151353. * @param hdr - If high dynamic range textures should be used (default: true)
  151354. * @param scene - The scene linked to this pipeline (default: the last created scene)
  151355. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  151356. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  151357. */
  151358. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  151359. /**
  151360. * Get the class name
  151361. * @returns "DefaultRenderingPipeline"
  151362. */
  151363. getClassName(): string;
  151364. /**
  151365. * Force the compilation of the entire pipeline.
  151366. */
  151367. prepare(): void;
  151368. private _hasCleared;
  151369. private _prevPostProcess;
  151370. private _prevPrevPostProcess;
  151371. private _setAutoClearAndTextureSharing;
  151372. private _depthOfFieldSceneObserver;
  151373. private _buildPipeline;
  151374. private _disposePostProcesses;
  151375. /**
  151376. * Adds a camera to the pipeline
  151377. * @param camera the camera to be added
  151378. */
  151379. addCamera(camera: Camera): void;
  151380. /**
  151381. * Removes a camera from the pipeline
  151382. * @param camera the camera to remove
  151383. */
  151384. removeCamera(camera: Camera): void;
  151385. /**
  151386. * Dispose of the pipeline and stop all post processes
  151387. */
  151388. dispose(): void;
  151389. /**
  151390. * Serialize the rendering pipeline (Used when exporting)
  151391. * @returns the serialized object
  151392. */
  151393. serialize(): any;
  151394. /**
  151395. * Parse the serialized pipeline
  151396. * @param source Source pipeline.
  151397. * @param scene The scene to load the pipeline to.
  151398. * @param rootUrl The URL of the serialized pipeline.
  151399. * @returns An instantiated pipeline from the serialized object.
  151400. */
  151401. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  151402. }
  151403. }
  151404. declare module BABYLON {
  151405. /** @hidden */
  151406. export var lensHighlightsPixelShader: {
  151407. name: string;
  151408. shader: string;
  151409. };
  151410. }
  151411. declare module BABYLON {
  151412. /** @hidden */
  151413. export var depthOfFieldPixelShader: {
  151414. name: string;
  151415. shader: string;
  151416. };
  151417. }
  151418. declare module BABYLON {
  151419. /**
  151420. * BABYLON.JS Chromatic Aberration GLSL Shader
  151421. * Author: Olivier Guyot
  151422. * Separates very slightly R, G and B colors on the edges of the screen
  151423. * Inspired by Francois Tarlier & Martins Upitis
  151424. */
  151425. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  151426. /**
  151427. * @ignore
  151428. * The chromatic aberration PostProcess id in the pipeline
  151429. */
  151430. LensChromaticAberrationEffect: string;
  151431. /**
  151432. * @ignore
  151433. * The highlights enhancing PostProcess id in the pipeline
  151434. */
  151435. HighlightsEnhancingEffect: string;
  151436. /**
  151437. * @ignore
  151438. * The depth-of-field PostProcess id in the pipeline
  151439. */
  151440. LensDepthOfFieldEffect: string;
  151441. private _scene;
  151442. private _depthTexture;
  151443. private _grainTexture;
  151444. private _chromaticAberrationPostProcess;
  151445. private _highlightsPostProcess;
  151446. private _depthOfFieldPostProcess;
  151447. private _edgeBlur;
  151448. private _grainAmount;
  151449. private _chromaticAberration;
  151450. private _distortion;
  151451. private _highlightsGain;
  151452. private _highlightsThreshold;
  151453. private _dofDistance;
  151454. private _dofAperture;
  151455. private _dofDarken;
  151456. private _dofPentagon;
  151457. private _blurNoise;
  151458. /**
  151459. * @constructor
  151460. *
  151461. * Effect parameters are as follow:
  151462. * {
  151463. * chromatic_aberration: number; // from 0 to x (1 for realism)
  151464. * edge_blur: number; // from 0 to x (1 for realism)
  151465. * distortion: number; // from 0 to x (1 for realism)
  151466. * grain_amount: number; // from 0 to 1
  151467. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  151468. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  151469. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  151470. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  151471. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  151472. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  151473. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  151474. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  151475. * }
  151476. * Note: if an effect parameter is unset, effect is disabled
  151477. *
  151478. * @param name The rendering pipeline name
  151479. * @param parameters - An object containing all parameters (see above)
  151480. * @param scene The scene linked to this pipeline
  151481. * @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)
  151482. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151483. */
  151484. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  151485. /**
  151486. * Get the class name
  151487. * @returns "LensRenderingPipeline"
  151488. */
  151489. getClassName(): string;
  151490. /**
  151491. * Gets associated scene
  151492. */
  151493. get scene(): Scene;
  151494. /**
  151495. * Gets or sets the edge blur
  151496. */
  151497. get edgeBlur(): number;
  151498. set edgeBlur(value: number);
  151499. /**
  151500. * Gets or sets the grain amount
  151501. */
  151502. get grainAmount(): number;
  151503. set grainAmount(value: number);
  151504. /**
  151505. * Gets or sets the chromatic aberration amount
  151506. */
  151507. get chromaticAberration(): number;
  151508. set chromaticAberration(value: number);
  151509. /**
  151510. * Gets or sets the depth of field aperture
  151511. */
  151512. get dofAperture(): number;
  151513. set dofAperture(value: number);
  151514. /**
  151515. * Gets or sets the edge distortion
  151516. */
  151517. get edgeDistortion(): number;
  151518. set edgeDistortion(value: number);
  151519. /**
  151520. * Gets or sets the depth of field distortion
  151521. */
  151522. get dofDistortion(): number;
  151523. set dofDistortion(value: number);
  151524. /**
  151525. * Gets or sets the darken out of focus amount
  151526. */
  151527. get darkenOutOfFocus(): number;
  151528. set darkenOutOfFocus(value: number);
  151529. /**
  151530. * Gets or sets a boolean indicating if blur noise is enabled
  151531. */
  151532. get blurNoise(): boolean;
  151533. set blurNoise(value: boolean);
  151534. /**
  151535. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151536. */
  151537. get pentagonBokeh(): boolean;
  151538. set pentagonBokeh(value: boolean);
  151539. /**
  151540. * Gets or sets the highlight grain amount
  151541. */
  151542. get highlightsGain(): number;
  151543. set highlightsGain(value: number);
  151544. /**
  151545. * Gets or sets the highlight threshold
  151546. */
  151547. get highlightsThreshold(): number;
  151548. set highlightsThreshold(value: number);
  151549. /**
  151550. * Sets the amount of blur at the edges
  151551. * @param amount blur amount
  151552. */
  151553. setEdgeBlur(amount: number): void;
  151554. /**
  151555. * Sets edge blur to 0
  151556. */
  151557. disableEdgeBlur(): void;
  151558. /**
  151559. * Sets the amout of grain
  151560. * @param amount Amount of grain
  151561. */
  151562. setGrainAmount(amount: number): void;
  151563. /**
  151564. * Set grain amount to 0
  151565. */
  151566. disableGrain(): void;
  151567. /**
  151568. * Sets the chromatic aberration amount
  151569. * @param amount amount of chromatic aberration
  151570. */
  151571. setChromaticAberration(amount: number): void;
  151572. /**
  151573. * Sets chromatic aberration amount to 0
  151574. */
  151575. disableChromaticAberration(): void;
  151576. /**
  151577. * Sets the EdgeDistortion amount
  151578. * @param amount amount of EdgeDistortion
  151579. */
  151580. setEdgeDistortion(amount: number): void;
  151581. /**
  151582. * Sets edge distortion to 0
  151583. */
  151584. disableEdgeDistortion(): void;
  151585. /**
  151586. * Sets the FocusDistance amount
  151587. * @param amount amount of FocusDistance
  151588. */
  151589. setFocusDistance(amount: number): void;
  151590. /**
  151591. * Disables depth of field
  151592. */
  151593. disableDepthOfField(): void;
  151594. /**
  151595. * Sets the Aperture amount
  151596. * @param amount amount of Aperture
  151597. */
  151598. setAperture(amount: number): void;
  151599. /**
  151600. * Sets the DarkenOutOfFocus amount
  151601. * @param amount amount of DarkenOutOfFocus
  151602. */
  151603. setDarkenOutOfFocus(amount: number): void;
  151604. private _pentagonBokehIsEnabled;
  151605. /**
  151606. * Creates a pentagon bokeh effect
  151607. */
  151608. enablePentagonBokeh(): void;
  151609. /**
  151610. * Disables the pentagon bokeh effect
  151611. */
  151612. disablePentagonBokeh(): void;
  151613. /**
  151614. * Enables noise blur
  151615. */
  151616. enableNoiseBlur(): void;
  151617. /**
  151618. * Disables noise blur
  151619. */
  151620. disableNoiseBlur(): void;
  151621. /**
  151622. * Sets the HighlightsGain amount
  151623. * @param amount amount of HighlightsGain
  151624. */
  151625. setHighlightsGain(amount: number): void;
  151626. /**
  151627. * Sets the HighlightsThreshold amount
  151628. * @param amount amount of HighlightsThreshold
  151629. */
  151630. setHighlightsThreshold(amount: number): void;
  151631. /**
  151632. * Disables highlights
  151633. */
  151634. disableHighlights(): void;
  151635. /**
  151636. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  151637. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  151638. */
  151639. dispose(disableDepthRender?: boolean): void;
  151640. private _createChromaticAberrationPostProcess;
  151641. private _createHighlightsPostProcess;
  151642. private _createDepthOfFieldPostProcess;
  151643. private _createGrainTexture;
  151644. }
  151645. }
  151646. declare module BABYLON {
  151647. /**
  151648. * Contains all parameters needed for the prepass to perform
  151649. * screen space subsurface scattering
  151650. */
  151651. export class SSAO2Configuration implements PrePassEffectConfiguration {
  151652. /**
  151653. * Is subsurface enabled
  151654. */
  151655. enabled: boolean;
  151656. /**
  151657. * Name of the configuration
  151658. */
  151659. name: string;
  151660. /**
  151661. * Textures that should be present in the MRT for this effect to work
  151662. */
  151663. readonly texturesRequired: number[];
  151664. }
  151665. }
  151666. declare module BABYLON {
  151667. /** @hidden */
  151668. export var ssao2PixelShader: {
  151669. name: string;
  151670. shader: string;
  151671. };
  151672. }
  151673. declare module BABYLON {
  151674. /** @hidden */
  151675. export var ssaoCombinePixelShader: {
  151676. name: string;
  151677. shader: string;
  151678. };
  151679. }
  151680. declare module BABYLON {
  151681. /**
  151682. * Render pipeline to produce ssao effect
  151683. */
  151684. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  151685. /**
  151686. * @ignore
  151687. * The PassPostProcess id in the pipeline that contains the original scene color
  151688. */
  151689. SSAOOriginalSceneColorEffect: string;
  151690. /**
  151691. * @ignore
  151692. * The SSAO PostProcess id in the pipeline
  151693. */
  151694. SSAORenderEffect: string;
  151695. /**
  151696. * @ignore
  151697. * The horizontal blur PostProcess id in the pipeline
  151698. */
  151699. SSAOBlurHRenderEffect: string;
  151700. /**
  151701. * @ignore
  151702. * The vertical blur PostProcess id in the pipeline
  151703. */
  151704. SSAOBlurVRenderEffect: string;
  151705. /**
  151706. * @ignore
  151707. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151708. */
  151709. SSAOCombineRenderEffect: string;
  151710. /**
  151711. * The output strength of the SSAO post-process. Default value is 1.0.
  151712. */
  151713. totalStrength: number;
  151714. /**
  151715. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  151716. */
  151717. maxZ: number;
  151718. /**
  151719. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  151720. */
  151721. minZAspect: number;
  151722. private _samples;
  151723. /**
  151724. * Number of samples used for the SSAO calculations. Default value is 8
  151725. */
  151726. set samples(n: number);
  151727. get samples(): number;
  151728. private _textureSamples;
  151729. /**
  151730. * Number of samples to use for antialiasing
  151731. */
  151732. set textureSamples(n: number);
  151733. get textureSamples(): number;
  151734. /**
  151735. * Force rendering the geometry through geometry buffer
  151736. */
  151737. private _forceGeometryBuffer;
  151738. /**
  151739. * Ratio object used for SSAO ratio and blur ratio
  151740. */
  151741. private _ratio;
  151742. /**
  151743. * Dynamically generated sphere sampler.
  151744. */
  151745. private _sampleSphere;
  151746. /**
  151747. * Blur filter offsets
  151748. */
  151749. private _samplerOffsets;
  151750. private _expensiveBlur;
  151751. /**
  151752. * If bilateral blur should be used
  151753. */
  151754. set expensiveBlur(b: boolean);
  151755. get expensiveBlur(): boolean;
  151756. /**
  151757. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  151758. */
  151759. radius: number;
  151760. /**
  151761. * The base color of the SSAO post-process
  151762. * The final result is "base + ssao" between [0, 1]
  151763. */
  151764. base: number;
  151765. /**
  151766. * Support test.
  151767. */
  151768. static get IsSupported(): boolean;
  151769. private _scene;
  151770. private _randomTexture;
  151771. private _originalColorPostProcess;
  151772. private _ssaoPostProcess;
  151773. private _blurHPostProcess;
  151774. private _blurVPostProcess;
  151775. private _ssaoCombinePostProcess;
  151776. private _prePassRenderer;
  151777. /**
  151778. * Gets active scene
  151779. */
  151780. get scene(): Scene;
  151781. /**
  151782. * @constructor
  151783. * @param name The rendering pipeline name
  151784. * @param scene The scene linked to this pipeline
  151785. * @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 }
  151786. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151787. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  151788. */
  151789. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  151790. /**
  151791. * Get the class name
  151792. * @returns "SSAO2RenderingPipeline"
  151793. */
  151794. getClassName(): string;
  151795. /**
  151796. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151797. */
  151798. dispose(disableGeometryBufferRenderer?: boolean): void;
  151799. private _createBlurPostProcess;
  151800. /** @hidden */
  151801. _rebuild(): void;
  151802. private _bits;
  151803. private _radicalInverse_VdC;
  151804. private _hammersley;
  151805. private _hemisphereSample_uniform;
  151806. private _generateHemisphere;
  151807. private _getDefinesForSSAO;
  151808. private _createSSAOPostProcess;
  151809. private _createSSAOCombinePostProcess;
  151810. private _createRandomTexture;
  151811. /**
  151812. * Serialize the rendering pipeline (Used when exporting)
  151813. * @returns the serialized object
  151814. */
  151815. serialize(): any;
  151816. /**
  151817. * Parse the serialized pipeline
  151818. * @param source Source pipeline.
  151819. * @param scene The scene to load the pipeline to.
  151820. * @param rootUrl The URL of the serialized pipeline.
  151821. * @returns An instantiated pipeline from the serialized object.
  151822. */
  151823. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  151824. }
  151825. }
  151826. declare module BABYLON {
  151827. /** @hidden */
  151828. export var ssaoPixelShader: {
  151829. name: string;
  151830. shader: string;
  151831. };
  151832. }
  151833. declare module BABYLON {
  151834. /**
  151835. * Render pipeline to produce ssao effect
  151836. */
  151837. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  151838. /**
  151839. * @ignore
  151840. * The PassPostProcess id in the pipeline that contains the original scene color
  151841. */
  151842. SSAOOriginalSceneColorEffect: string;
  151843. /**
  151844. * @ignore
  151845. * The SSAO PostProcess id in the pipeline
  151846. */
  151847. SSAORenderEffect: string;
  151848. /**
  151849. * @ignore
  151850. * The horizontal blur PostProcess id in the pipeline
  151851. */
  151852. SSAOBlurHRenderEffect: string;
  151853. /**
  151854. * @ignore
  151855. * The vertical blur PostProcess id in the pipeline
  151856. */
  151857. SSAOBlurVRenderEffect: string;
  151858. /**
  151859. * @ignore
  151860. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151861. */
  151862. SSAOCombineRenderEffect: string;
  151863. /**
  151864. * The output strength of the SSAO post-process. Default value is 1.0.
  151865. */
  151866. totalStrength: number;
  151867. /**
  151868. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  151869. */
  151870. radius: number;
  151871. /**
  151872. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  151873. * Must not be equal to fallOff and superior to fallOff.
  151874. * Default value is 0.0075
  151875. */
  151876. area: number;
  151877. /**
  151878. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  151879. * Must not be equal to area and inferior to area.
  151880. * Default value is 0.000001
  151881. */
  151882. fallOff: number;
  151883. /**
  151884. * The base color of the SSAO post-process
  151885. * The final result is "base + ssao" between [0, 1]
  151886. */
  151887. base: number;
  151888. private _scene;
  151889. private _depthTexture;
  151890. private _randomTexture;
  151891. private _originalColorPostProcess;
  151892. private _ssaoPostProcess;
  151893. private _blurHPostProcess;
  151894. private _blurVPostProcess;
  151895. private _ssaoCombinePostProcess;
  151896. private _firstUpdate;
  151897. /**
  151898. * Gets active scene
  151899. */
  151900. get scene(): Scene;
  151901. /**
  151902. * @constructor
  151903. * @param name - The rendering pipeline name
  151904. * @param scene - The scene linked to this pipeline
  151905. * @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 }
  151906. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  151907. */
  151908. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  151909. /**
  151910. * Get the class name
  151911. * @returns "SSAORenderingPipeline"
  151912. */
  151913. getClassName(): string;
  151914. /**
  151915. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151916. */
  151917. dispose(disableDepthRender?: boolean): void;
  151918. private _createBlurPostProcess;
  151919. /** @hidden */
  151920. _rebuild(): void;
  151921. private _createSSAOPostProcess;
  151922. private _createSSAOCombinePostProcess;
  151923. private _createRandomTexture;
  151924. }
  151925. }
  151926. declare module BABYLON {
  151927. /**
  151928. * Contains all parameters needed for the prepass to perform
  151929. * screen space reflections
  151930. */
  151931. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  151932. /**
  151933. * Is ssr enabled
  151934. */
  151935. enabled: boolean;
  151936. /**
  151937. * Name of the configuration
  151938. */
  151939. name: string;
  151940. /**
  151941. * Textures that should be present in the MRT for this effect to work
  151942. */
  151943. readonly texturesRequired: number[];
  151944. }
  151945. }
  151946. declare module BABYLON {
  151947. /** @hidden */
  151948. export var screenSpaceReflectionPixelShader: {
  151949. name: string;
  151950. shader: string;
  151951. };
  151952. }
  151953. declare module BABYLON {
  151954. /**
  151955. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  151956. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  151957. */
  151958. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  151959. /**
  151960. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  151961. */
  151962. threshold: number;
  151963. /**
  151964. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  151965. */
  151966. strength: number;
  151967. /**
  151968. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  151969. */
  151970. reflectionSpecularFalloffExponent: number;
  151971. /**
  151972. * 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]
  151973. */
  151974. step: number;
  151975. /**
  151976. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  151977. */
  151978. roughnessFactor: number;
  151979. private _forceGeometryBuffer;
  151980. private _geometryBufferRenderer;
  151981. private _prePassRenderer;
  151982. private _enableSmoothReflections;
  151983. private _reflectionSamples;
  151984. private _smoothSteps;
  151985. /**
  151986. * Gets a string identifying the name of the class
  151987. * @returns "ScreenSpaceReflectionPostProcess" string
  151988. */
  151989. getClassName(): string;
  151990. /**
  151991. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  151992. * @param name The name of the effect.
  151993. * @param scene The scene containing the objects to calculate reflections.
  151994. * @param options The required width/height ratio to downsize to before computing the render pass.
  151995. * @param camera The camera to apply the render pass to.
  151996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151997. * @param engine The engine which the post process will be applied. (default: current engine)
  151998. * @param reusable If the post process can be reused on the same frame. (default: false)
  151999. * @param textureType Type of textures used when performing the post process. (default: 0)
  152000. * @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)
  152001. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152002. */
  152003. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152004. /**
  152005. * Gets wether or not smoothing reflections is enabled.
  152006. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152007. */
  152008. get enableSmoothReflections(): boolean;
  152009. /**
  152010. * Sets wether or not smoothing reflections is enabled.
  152011. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152012. */
  152013. set enableSmoothReflections(enabled: boolean);
  152014. /**
  152015. * Gets the number of samples taken while computing reflections. More samples count is high,
  152016. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152017. */
  152018. get reflectionSamples(): number;
  152019. /**
  152020. * Sets the number of samples taken while computing reflections. More samples count is high,
  152021. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152022. */
  152023. set reflectionSamples(samples: number);
  152024. /**
  152025. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  152026. * more the post-process will require GPU power and can generate a drop in FPS.
  152027. * Default value (5.0) work pretty well in all cases but can be adjusted.
  152028. */
  152029. get smoothSteps(): number;
  152030. set smoothSteps(steps: number);
  152031. private _updateEffectDefines;
  152032. /** @hidden */
  152033. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  152034. }
  152035. }
  152036. declare module BABYLON {
  152037. /** @hidden */
  152038. export var standardPixelShader: {
  152039. name: string;
  152040. shader: string;
  152041. };
  152042. }
  152043. declare module BABYLON {
  152044. /**
  152045. * Standard rendering pipeline
  152046. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152047. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  152048. */
  152049. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152050. /**
  152051. * Public members
  152052. */
  152053. /**
  152054. * Post-process which contains the original scene color before the pipeline applies all the effects
  152055. */
  152056. originalPostProcess: Nullable<PostProcess>;
  152057. /**
  152058. * Post-process used to down scale an image x4
  152059. */
  152060. downSampleX4PostProcess: Nullable<PostProcess>;
  152061. /**
  152062. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  152063. */
  152064. brightPassPostProcess: Nullable<PostProcess>;
  152065. /**
  152066. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  152067. */
  152068. blurHPostProcesses: PostProcess[];
  152069. /**
  152070. * Post-process array storing all the vertical blur post-processes used by the pipeline
  152071. */
  152072. blurVPostProcesses: PostProcess[];
  152073. /**
  152074. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  152075. */
  152076. textureAdderPostProcess: Nullable<PostProcess>;
  152077. /**
  152078. * Post-process used to create volumetric lighting effect
  152079. */
  152080. volumetricLightPostProcess: Nullable<PostProcess>;
  152081. /**
  152082. * Post-process used to smooth the previous volumetric light post-process on the X axis
  152083. */
  152084. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  152085. /**
  152086. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  152087. */
  152088. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  152089. /**
  152090. * Post-process used to merge the volumetric light effect and the real scene color
  152091. */
  152092. volumetricLightMergePostProces: Nullable<PostProcess>;
  152093. /**
  152094. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  152095. */
  152096. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  152097. /**
  152098. * Base post-process used to calculate the average luminance of the final image for HDR
  152099. */
  152100. luminancePostProcess: Nullable<PostProcess>;
  152101. /**
  152102. * Post-processes used to create down sample post-processes in order to get
  152103. * the average luminance of the final image for HDR
  152104. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  152105. */
  152106. luminanceDownSamplePostProcesses: PostProcess[];
  152107. /**
  152108. * Post-process used to create a HDR effect (light adaptation)
  152109. */
  152110. hdrPostProcess: Nullable<PostProcess>;
  152111. /**
  152112. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  152113. */
  152114. textureAdderFinalPostProcess: Nullable<PostProcess>;
  152115. /**
  152116. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  152117. */
  152118. lensFlareFinalPostProcess: Nullable<PostProcess>;
  152119. /**
  152120. * Post-process used to merge the final HDR post-process and the real scene color
  152121. */
  152122. hdrFinalPostProcess: Nullable<PostProcess>;
  152123. /**
  152124. * Post-process used to create a lens flare effect
  152125. */
  152126. lensFlarePostProcess: Nullable<PostProcess>;
  152127. /**
  152128. * Post-process that merges the result of the lens flare post-process and the real scene color
  152129. */
  152130. lensFlareComposePostProcess: Nullable<PostProcess>;
  152131. /**
  152132. * Post-process used to create a motion blur effect
  152133. */
  152134. motionBlurPostProcess: Nullable<PostProcess>;
  152135. /**
  152136. * Post-process used to create a depth of field effect
  152137. */
  152138. depthOfFieldPostProcess: Nullable<PostProcess>;
  152139. /**
  152140. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152141. */
  152142. fxaaPostProcess: Nullable<FxaaPostProcess>;
  152143. /**
  152144. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  152145. */
  152146. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  152147. /**
  152148. * Represents the brightness threshold in order to configure the illuminated surfaces
  152149. */
  152150. brightThreshold: number;
  152151. /**
  152152. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  152153. */
  152154. blurWidth: number;
  152155. /**
  152156. * Sets if the blur for highlighted surfaces must be only horizontal
  152157. */
  152158. horizontalBlur: boolean;
  152159. /**
  152160. * Gets the overall exposure used by the pipeline
  152161. */
  152162. get exposure(): number;
  152163. /**
  152164. * Sets the overall exposure used by the pipeline
  152165. */
  152166. set exposure(value: number);
  152167. /**
  152168. * Texture used typically to simulate "dirty" on camera lens
  152169. */
  152170. lensTexture: Nullable<Texture>;
  152171. /**
  152172. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  152173. */
  152174. volumetricLightCoefficient: number;
  152175. /**
  152176. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  152177. */
  152178. volumetricLightPower: number;
  152179. /**
  152180. * Used the set the blur intensity to smooth the volumetric lights
  152181. */
  152182. volumetricLightBlurScale: number;
  152183. /**
  152184. * Light (spot or directional) used to generate the volumetric lights rays
  152185. * The source light must have a shadow generate so the pipeline can get its
  152186. * depth map
  152187. */
  152188. sourceLight: Nullable<SpotLight | DirectionalLight>;
  152189. /**
  152190. * For eye adaptation, represents the minimum luminance the eye can see
  152191. */
  152192. hdrMinimumLuminance: number;
  152193. /**
  152194. * For eye adaptation, represents the decrease luminance speed
  152195. */
  152196. hdrDecreaseRate: number;
  152197. /**
  152198. * For eye adaptation, represents the increase luminance speed
  152199. */
  152200. hdrIncreaseRate: number;
  152201. /**
  152202. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152203. */
  152204. get hdrAutoExposure(): boolean;
  152205. /**
  152206. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152207. */
  152208. set hdrAutoExposure(value: boolean);
  152209. /**
  152210. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  152211. */
  152212. lensColorTexture: Nullable<Texture>;
  152213. /**
  152214. * The overall strengh for the lens flare effect
  152215. */
  152216. lensFlareStrength: number;
  152217. /**
  152218. * Dispersion coefficient for lens flare ghosts
  152219. */
  152220. lensFlareGhostDispersal: number;
  152221. /**
  152222. * Main lens flare halo width
  152223. */
  152224. lensFlareHaloWidth: number;
  152225. /**
  152226. * Based on the lens distortion effect, defines how much the lens flare result
  152227. * is distorted
  152228. */
  152229. lensFlareDistortionStrength: number;
  152230. /**
  152231. * Configures the blur intensity used for for lens flare (halo)
  152232. */
  152233. lensFlareBlurWidth: number;
  152234. /**
  152235. * Lens star texture must be used to simulate rays on the flares and is available
  152236. * in the documentation
  152237. */
  152238. lensStarTexture: Nullable<Texture>;
  152239. /**
  152240. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  152241. * flare effect by taking account of the dirt texture
  152242. */
  152243. lensFlareDirtTexture: Nullable<Texture>;
  152244. /**
  152245. * Represents the focal length for the depth of field effect
  152246. */
  152247. depthOfFieldDistance: number;
  152248. /**
  152249. * Represents the blur intensity for the blurred part of the depth of field effect
  152250. */
  152251. depthOfFieldBlurWidth: number;
  152252. /**
  152253. * Gets how much the image is blurred by the movement while using the motion blur post-process
  152254. */
  152255. get motionStrength(): number;
  152256. /**
  152257. * Sets how much the image is blurred by the movement while using the motion blur post-process
  152258. */
  152259. set motionStrength(strength: number);
  152260. /**
  152261. * Gets wether or not the motion blur post-process is object based or screen based.
  152262. */
  152263. get objectBasedMotionBlur(): boolean;
  152264. /**
  152265. * Sets wether or not the motion blur post-process should be object based or screen based
  152266. */
  152267. set objectBasedMotionBlur(value: boolean);
  152268. /**
  152269. * List of animations for the pipeline (IAnimatable implementation)
  152270. */
  152271. animations: Animation[];
  152272. /**
  152273. * Private members
  152274. */
  152275. private _scene;
  152276. private _currentDepthOfFieldSource;
  152277. private _basePostProcess;
  152278. private _fixedExposure;
  152279. private _currentExposure;
  152280. private _hdrAutoExposure;
  152281. private _hdrCurrentLuminance;
  152282. private _motionStrength;
  152283. private _isObjectBasedMotionBlur;
  152284. private _floatTextureType;
  152285. private _camerasToBeAttached;
  152286. private _ratio;
  152287. private _bloomEnabled;
  152288. private _depthOfFieldEnabled;
  152289. private _vlsEnabled;
  152290. private _lensFlareEnabled;
  152291. private _hdrEnabled;
  152292. private _motionBlurEnabled;
  152293. private _fxaaEnabled;
  152294. private _screenSpaceReflectionsEnabled;
  152295. private _motionBlurSamples;
  152296. private _volumetricLightStepsCount;
  152297. private _samples;
  152298. /**
  152299. * @ignore
  152300. * Specifies if the bloom pipeline is enabled
  152301. */
  152302. get BloomEnabled(): boolean;
  152303. set BloomEnabled(enabled: boolean);
  152304. /**
  152305. * @ignore
  152306. * Specifies if the depth of field pipeline is enabed
  152307. */
  152308. get DepthOfFieldEnabled(): boolean;
  152309. set DepthOfFieldEnabled(enabled: boolean);
  152310. /**
  152311. * @ignore
  152312. * Specifies if the lens flare pipeline is enabed
  152313. */
  152314. get LensFlareEnabled(): boolean;
  152315. set LensFlareEnabled(enabled: boolean);
  152316. /**
  152317. * @ignore
  152318. * Specifies if the HDR pipeline is enabled
  152319. */
  152320. get HDREnabled(): boolean;
  152321. set HDREnabled(enabled: boolean);
  152322. /**
  152323. * @ignore
  152324. * Specifies if the volumetric lights scattering effect is enabled
  152325. */
  152326. get VLSEnabled(): boolean;
  152327. set VLSEnabled(enabled: boolean);
  152328. /**
  152329. * @ignore
  152330. * Specifies if the motion blur effect is enabled
  152331. */
  152332. get MotionBlurEnabled(): boolean;
  152333. set MotionBlurEnabled(enabled: boolean);
  152334. /**
  152335. * Specifies if anti-aliasing is enabled
  152336. */
  152337. get fxaaEnabled(): boolean;
  152338. set fxaaEnabled(enabled: boolean);
  152339. /**
  152340. * Specifies if screen space reflections are enabled.
  152341. */
  152342. get screenSpaceReflectionsEnabled(): boolean;
  152343. set screenSpaceReflectionsEnabled(enabled: boolean);
  152344. /**
  152345. * Specifies the number of steps used to calculate the volumetric lights
  152346. * Typically in interval [50, 200]
  152347. */
  152348. get volumetricLightStepsCount(): number;
  152349. set volumetricLightStepsCount(count: number);
  152350. /**
  152351. * Specifies the number of samples used for the motion blur effect
  152352. * Typically in interval [16, 64]
  152353. */
  152354. get motionBlurSamples(): number;
  152355. set motionBlurSamples(samples: number);
  152356. /**
  152357. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152358. */
  152359. get samples(): number;
  152360. set samples(sampleCount: number);
  152361. /**
  152362. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152363. * @constructor
  152364. * @param name The rendering pipeline name
  152365. * @param scene The scene linked to this pipeline
  152366. * @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)
  152367. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  152368. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152369. */
  152370. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  152371. private _buildPipeline;
  152372. private _createDownSampleX4PostProcess;
  152373. private _createBrightPassPostProcess;
  152374. private _createBlurPostProcesses;
  152375. private _createTextureAdderPostProcess;
  152376. private _createVolumetricLightPostProcess;
  152377. private _createLuminancePostProcesses;
  152378. private _createHdrPostProcess;
  152379. private _createLensFlarePostProcess;
  152380. private _createDepthOfFieldPostProcess;
  152381. private _createMotionBlurPostProcess;
  152382. private _getDepthTexture;
  152383. private _disposePostProcesses;
  152384. /**
  152385. * Dispose of the pipeline and stop all post processes
  152386. */
  152387. dispose(): void;
  152388. /**
  152389. * Serialize the rendering pipeline (Used when exporting)
  152390. * @returns the serialized object
  152391. */
  152392. serialize(): any;
  152393. /**
  152394. * Parse the serialized pipeline
  152395. * @param source Source pipeline.
  152396. * @param scene The scene to load the pipeline to.
  152397. * @param rootUrl The URL of the serialized pipeline.
  152398. * @returns An instantiated pipeline from the serialized object.
  152399. */
  152400. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  152401. /**
  152402. * Luminance steps
  152403. */
  152404. static LuminanceSteps: number;
  152405. }
  152406. }
  152407. declare module BABYLON {
  152408. /** @hidden */
  152409. export var stereoscopicInterlacePixelShader: {
  152410. name: string;
  152411. shader: string;
  152412. };
  152413. }
  152414. declare module BABYLON {
  152415. /**
  152416. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  152417. */
  152418. export class StereoscopicInterlacePostProcessI extends PostProcess {
  152419. private _stepSize;
  152420. private _passedProcess;
  152421. /**
  152422. * Gets a string identifying the name of the class
  152423. * @returns "StereoscopicInterlacePostProcessI" string
  152424. */
  152425. getClassName(): string;
  152426. /**
  152427. * Initializes a StereoscopicInterlacePostProcessI
  152428. * @param name The name of the effect.
  152429. * @param rigCameras The rig cameras to be appled to the post process
  152430. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  152431. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  152432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152433. * @param engine The engine which the post process will be applied. (default: current engine)
  152434. * @param reusable If the post process can be reused on the same frame. (default: false)
  152435. */
  152436. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152437. }
  152438. /**
  152439. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152440. */
  152441. export class StereoscopicInterlacePostProcess extends PostProcess {
  152442. private _stepSize;
  152443. private _passedProcess;
  152444. /**
  152445. * Gets a string identifying the name of the class
  152446. * @returns "StereoscopicInterlacePostProcess" string
  152447. */
  152448. getClassName(): string;
  152449. /**
  152450. * Initializes a StereoscopicInterlacePostProcess
  152451. * @param name The name of the effect.
  152452. * @param rigCameras The rig cameras to be appled to the post process
  152453. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152455. * @param engine The engine which the post process will be applied. (default: current engine)
  152456. * @param reusable If the post process can be reused on the same frame. (default: false)
  152457. */
  152458. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152459. }
  152460. }
  152461. declare module BABYLON {
  152462. /** @hidden */
  152463. export var tonemapPixelShader: {
  152464. name: string;
  152465. shader: string;
  152466. };
  152467. }
  152468. declare module BABYLON {
  152469. /** Defines operator used for tonemapping */
  152470. export enum TonemappingOperator {
  152471. /** Hable */
  152472. Hable = 0,
  152473. /** Reinhard */
  152474. Reinhard = 1,
  152475. /** HejiDawson */
  152476. HejiDawson = 2,
  152477. /** Photographic */
  152478. Photographic = 3
  152479. }
  152480. /**
  152481. * Defines a post process to apply tone mapping
  152482. */
  152483. export class TonemapPostProcess extends PostProcess {
  152484. private _operator;
  152485. /** Defines the required exposure adjustement */
  152486. exposureAdjustment: number;
  152487. /**
  152488. * Gets a string identifying the name of the class
  152489. * @returns "TonemapPostProcess" string
  152490. */
  152491. getClassName(): string;
  152492. /**
  152493. * Creates a new TonemapPostProcess
  152494. * @param name defines the name of the postprocess
  152495. * @param _operator defines the operator to use
  152496. * @param exposureAdjustment defines the required exposure adjustement
  152497. * @param camera defines the camera to use (can be null)
  152498. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  152499. * @param engine defines the hosting engine (can be ignore if camera is set)
  152500. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152501. */
  152502. constructor(name: string, _operator: TonemappingOperator,
  152503. /** Defines the required exposure adjustement */
  152504. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  152505. }
  152506. }
  152507. declare module BABYLON {
  152508. /** @hidden */
  152509. export var volumetricLightScatteringPixelShader: {
  152510. name: string;
  152511. shader: string;
  152512. };
  152513. }
  152514. declare module BABYLON {
  152515. /** @hidden */
  152516. export var volumetricLightScatteringPassVertexShader: {
  152517. name: string;
  152518. shader: string;
  152519. };
  152520. }
  152521. declare module BABYLON {
  152522. /** @hidden */
  152523. export var volumetricLightScatteringPassPixelShader: {
  152524. name: string;
  152525. shader: string;
  152526. };
  152527. }
  152528. declare module BABYLON {
  152529. /**
  152530. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152531. */
  152532. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152533. private _volumetricLightScatteringPass;
  152534. private _volumetricLightScatteringRTT;
  152535. private _viewPort;
  152536. private _screenCoordinates;
  152537. private _cachedDefines;
  152538. /**
  152539. * If not undefined, the mesh position is computed from the attached node position
  152540. */
  152541. attachedNode: {
  152542. position: Vector3;
  152543. };
  152544. /**
  152545. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152546. */
  152547. customMeshPosition: Vector3;
  152548. /**
  152549. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152550. */
  152551. useCustomMeshPosition: boolean;
  152552. /**
  152553. * If the post-process should inverse the light scattering direction
  152554. */
  152555. invert: boolean;
  152556. /**
  152557. * The internal mesh used by the post-process
  152558. */
  152559. mesh: Mesh;
  152560. /**
  152561. * @hidden
  152562. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152563. */
  152564. get useDiffuseColor(): boolean;
  152565. set useDiffuseColor(useDiffuseColor: boolean);
  152566. /**
  152567. * Array containing the excluded meshes not rendered in the internal pass
  152568. */
  152569. excludedMeshes: AbstractMesh[];
  152570. /**
  152571. * Controls the overall intensity of the post-process
  152572. */
  152573. exposure: number;
  152574. /**
  152575. * Dissipates each sample's contribution in range [0, 1]
  152576. */
  152577. decay: number;
  152578. /**
  152579. * Controls the overall intensity of each sample
  152580. */
  152581. weight: number;
  152582. /**
  152583. * Controls the density of each sample
  152584. */
  152585. density: number;
  152586. /**
  152587. * @constructor
  152588. * @param name The post-process name
  152589. * @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)
  152590. * @param camera The camera that the post-process will be attached to
  152591. * @param mesh The mesh used to create the light scattering
  152592. * @param samples The post-process quality, default 100
  152593. * @param samplingModeThe post-process filtering mode
  152594. * @param engine The babylon engine
  152595. * @param reusable If the post-process is reusable
  152596. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152597. */
  152598. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152599. /**
  152600. * Returns the string "VolumetricLightScatteringPostProcess"
  152601. * @returns "VolumetricLightScatteringPostProcess"
  152602. */
  152603. getClassName(): string;
  152604. private _isReady;
  152605. /**
  152606. * Sets the new light position for light scattering effect
  152607. * @param position The new custom light position
  152608. */
  152609. setCustomMeshPosition(position: Vector3): void;
  152610. /**
  152611. * Returns the light position for light scattering effect
  152612. * @return Vector3 The custom light position
  152613. */
  152614. getCustomMeshPosition(): Vector3;
  152615. /**
  152616. * Disposes the internal assets and detaches the post-process from the camera
  152617. */
  152618. dispose(camera: Camera): void;
  152619. /**
  152620. * Returns the render target texture used by the post-process
  152621. * @return the render target texture used by the post-process
  152622. */
  152623. getPass(): RenderTargetTexture;
  152624. private _meshExcluded;
  152625. private _createPass;
  152626. private _updateMeshScreenCoordinates;
  152627. /**
  152628. * Creates a default mesh for the Volumeric Light Scattering post-process
  152629. * @param name The mesh name
  152630. * @param scene The scene where to create the mesh
  152631. * @return the default mesh
  152632. */
  152633. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  152634. }
  152635. }
  152636. declare module BABYLON {
  152637. /** @hidden */
  152638. export var screenSpaceCurvaturePixelShader: {
  152639. name: string;
  152640. shader: string;
  152641. };
  152642. }
  152643. declare module BABYLON {
  152644. /**
  152645. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  152646. */
  152647. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  152648. /**
  152649. * Defines how much ridge the curvature effect displays.
  152650. */
  152651. ridge: number;
  152652. /**
  152653. * Defines how much valley the curvature effect displays.
  152654. */
  152655. valley: number;
  152656. private _geometryBufferRenderer;
  152657. /**
  152658. * Gets a string identifying the name of the class
  152659. * @returns "ScreenSpaceCurvaturePostProcess" string
  152660. */
  152661. getClassName(): string;
  152662. /**
  152663. * Creates a new instance ScreenSpaceCurvaturePostProcess
  152664. * @param name The name of the effect.
  152665. * @param scene The scene containing the objects to blur according to their velocity.
  152666. * @param options The required width/height ratio to downsize to before computing the render pass.
  152667. * @param camera The camera to apply the render pass to.
  152668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152669. * @param engine The engine which the post process will be applied. (default: current engine)
  152670. * @param reusable If the post process can be reused on the same frame. (default: false)
  152671. * @param textureType Type of textures used when performing the post process. (default: 0)
  152672. * @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)
  152673. */
  152674. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152675. /**
  152676. * Support test.
  152677. */
  152678. static get IsSupported(): boolean;
  152679. /** @hidden */
  152680. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  152681. }
  152682. }
  152683. declare module BABYLON {
  152684. interface Scene {
  152685. /** @hidden (Backing field) */
  152686. _boundingBoxRenderer: BoundingBoxRenderer;
  152687. /** @hidden (Backing field) */
  152688. _forceShowBoundingBoxes: boolean;
  152689. /**
  152690. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  152691. */
  152692. forceShowBoundingBoxes: boolean;
  152693. /**
  152694. * Gets the bounding box renderer associated with the scene
  152695. * @returns a BoundingBoxRenderer
  152696. */
  152697. getBoundingBoxRenderer(): BoundingBoxRenderer;
  152698. }
  152699. interface AbstractMesh {
  152700. /** @hidden (Backing field) */
  152701. _showBoundingBox: boolean;
  152702. /**
  152703. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  152704. */
  152705. showBoundingBox: boolean;
  152706. }
  152707. /**
  152708. * Component responsible of rendering the bounding box of the meshes in a scene.
  152709. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  152710. */
  152711. export class BoundingBoxRenderer implements ISceneComponent {
  152712. /**
  152713. * The component name helpfull to identify the component in the list of scene components.
  152714. */
  152715. readonly name: string;
  152716. /**
  152717. * The scene the component belongs to.
  152718. */
  152719. scene: Scene;
  152720. /**
  152721. * Color of the bounding box lines placed in front of an object
  152722. */
  152723. frontColor: Color3;
  152724. /**
  152725. * Color of the bounding box lines placed behind an object
  152726. */
  152727. backColor: Color3;
  152728. /**
  152729. * Defines if the renderer should show the back lines or not
  152730. */
  152731. showBackLines: boolean;
  152732. /**
  152733. * Observable raised before rendering a bounding box
  152734. */
  152735. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  152736. /**
  152737. * Observable raised after rendering a bounding box
  152738. */
  152739. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  152740. /**
  152741. * @hidden
  152742. */
  152743. renderList: SmartArray<BoundingBox>;
  152744. private _colorShader;
  152745. private _vertexBuffers;
  152746. private _indexBuffer;
  152747. private _fillIndexBuffer;
  152748. private _fillIndexData;
  152749. /**
  152750. * Instantiates a new bounding box renderer in a scene.
  152751. * @param scene the scene the renderer renders in
  152752. */
  152753. constructor(scene: Scene);
  152754. /**
  152755. * Registers the component in a given scene
  152756. */
  152757. register(): void;
  152758. private _evaluateSubMesh;
  152759. private _activeMesh;
  152760. private _prepareRessources;
  152761. private _createIndexBuffer;
  152762. /**
  152763. * Rebuilds the elements related to this component in case of
  152764. * context lost for instance.
  152765. */
  152766. rebuild(): void;
  152767. /**
  152768. * @hidden
  152769. */
  152770. reset(): void;
  152771. /**
  152772. * Render the bounding boxes of a specific rendering group
  152773. * @param renderingGroupId defines the rendering group to render
  152774. */
  152775. render(renderingGroupId: number): void;
  152776. /**
  152777. * In case of occlusion queries, we can render the occlusion bounding box through this method
  152778. * @param mesh Define the mesh to render the occlusion bounding box for
  152779. */
  152780. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  152781. /**
  152782. * Dispose and release the resources attached to this renderer.
  152783. */
  152784. dispose(): void;
  152785. }
  152786. }
  152787. declare module BABYLON {
  152788. interface Scene {
  152789. /** @hidden (Backing field) */
  152790. _depthRenderer: {
  152791. [id: string]: DepthRenderer;
  152792. };
  152793. /**
  152794. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  152795. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  152796. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  152797. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  152798. * @returns the created depth renderer
  152799. */
  152800. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  152801. /**
  152802. * Disables a depth renderer for a given camera
  152803. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  152804. */
  152805. disableDepthRenderer(camera?: Nullable<Camera>): void;
  152806. }
  152807. /**
  152808. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  152809. * in several rendering techniques.
  152810. */
  152811. export class DepthRendererSceneComponent implements ISceneComponent {
  152812. /**
  152813. * The component name helpfull to identify the component in the list of scene components.
  152814. */
  152815. readonly name: string;
  152816. /**
  152817. * The scene the component belongs to.
  152818. */
  152819. scene: Scene;
  152820. /**
  152821. * Creates a new instance of the component for the given scene
  152822. * @param scene Defines the scene to register the component in
  152823. */
  152824. constructor(scene: Scene);
  152825. /**
  152826. * Registers the component in a given scene
  152827. */
  152828. register(): void;
  152829. /**
  152830. * Rebuilds the elements related to this component in case of
  152831. * context lost for instance.
  152832. */
  152833. rebuild(): void;
  152834. /**
  152835. * Disposes the component and the associated ressources
  152836. */
  152837. dispose(): void;
  152838. private _gatherRenderTargets;
  152839. private _gatherActiveCameraRenderTargets;
  152840. }
  152841. }
  152842. declare module BABYLON {
  152843. interface AbstractScene {
  152844. /** @hidden (Backing field) */
  152845. _prePassRenderer: Nullable<PrePassRenderer>;
  152846. /**
  152847. * Gets or Sets the current prepass renderer associated to the scene.
  152848. */
  152849. prePassRenderer: Nullable<PrePassRenderer>;
  152850. /**
  152851. * Enables the prepass and associates it with the scene
  152852. * @returns the PrePassRenderer
  152853. */
  152854. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  152855. /**
  152856. * Disables the prepass associated with the scene
  152857. */
  152858. disablePrePassRenderer(): void;
  152859. }
  152860. /**
  152861. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152862. * in several rendering techniques.
  152863. */
  152864. export class PrePassRendererSceneComponent implements ISceneComponent {
  152865. /**
  152866. * The component name helpful to identify the component in the list of scene components.
  152867. */
  152868. readonly name: string;
  152869. /**
  152870. * The scene the component belongs to.
  152871. */
  152872. scene: Scene;
  152873. /**
  152874. * Creates a new instance of the component for the given scene
  152875. * @param scene Defines the scene to register the component in
  152876. */
  152877. constructor(scene: Scene);
  152878. /**
  152879. * Registers the component in a given scene
  152880. */
  152881. register(): void;
  152882. private _beforeCameraDraw;
  152883. private _afterCameraDraw;
  152884. private _beforeClearStage;
  152885. /**
  152886. * Rebuilds the elements related to this component in case of
  152887. * context lost for instance.
  152888. */
  152889. rebuild(): void;
  152890. /**
  152891. * Disposes the component and the associated ressources
  152892. */
  152893. dispose(): void;
  152894. }
  152895. }
  152896. declare module BABYLON {
  152897. /** @hidden */
  152898. export var fibonacci: {
  152899. name: string;
  152900. shader: string;
  152901. };
  152902. }
  152903. declare module BABYLON {
  152904. /** @hidden */
  152905. export var diffusionProfile: {
  152906. name: string;
  152907. shader: string;
  152908. };
  152909. }
  152910. declare module BABYLON {
  152911. /** @hidden */
  152912. export var subSurfaceScatteringPixelShader: {
  152913. name: string;
  152914. shader: string;
  152915. };
  152916. }
  152917. declare module BABYLON {
  152918. /**
  152919. * Sub surface scattering post process
  152920. */
  152921. export class SubSurfaceScatteringPostProcess extends PostProcess {
  152922. /**
  152923. * Gets a string identifying the name of the class
  152924. * @returns "SubSurfaceScatteringPostProcess" string
  152925. */
  152926. getClassName(): string;
  152927. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152928. }
  152929. }
  152930. declare module BABYLON {
  152931. /**
  152932. * Contains all parameters needed for the prepass to perform
  152933. * screen space subsurface scattering
  152934. */
  152935. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  152936. /** @hidden */
  152937. static _SceneComponentInitialization: (scene: Scene) => void;
  152938. private _ssDiffusionS;
  152939. private _ssFilterRadii;
  152940. private _ssDiffusionD;
  152941. /**
  152942. * Post process to attach for screen space subsurface scattering
  152943. */
  152944. postProcess: SubSurfaceScatteringPostProcess;
  152945. /**
  152946. * Diffusion profile color for subsurface scattering
  152947. */
  152948. get ssDiffusionS(): number[];
  152949. /**
  152950. * Diffusion profile max color channel value for subsurface scattering
  152951. */
  152952. get ssDiffusionD(): number[];
  152953. /**
  152954. * Diffusion profile filter radius for subsurface scattering
  152955. */
  152956. get ssFilterRadii(): number[];
  152957. /**
  152958. * Is subsurface enabled
  152959. */
  152960. enabled: boolean;
  152961. /**
  152962. * Name of the configuration
  152963. */
  152964. name: string;
  152965. /**
  152966. * Diffusion profile colors for subsurface scattering
  152967. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  152968. * See ...
  152969. * Note that you can only store up to 5 of them
  152970. */
  152971. ssDiffusionProfileColors: Color3[];
  152972. /**
  152973. * Defines the ratio real world => scene units.
  152974. * Used for subsurface scattering
  152975. */
  152976. metersPerUnit: number;
  152977. /**
  152978. * Textures that should be present in the MRT for this effect to work
  152979. */
  152980. readonly texturesRequired: number[];
  152981. private _scene;
  152982. /**
  152983. * Builds a subsurface configuration object
  152984. * @param scene The scene
  152985. */
  152986. constructor(scene: Scene);
  152987. /**
  152988. * Adds a new diffusion profile.
  152989. * Useful for more realistic subsurface scattering on diverse materials.
  152990. * @param color The color of the diffusion profile. Should be the average color of the material.
  152991. * @return The index of the diffusion profile for the material subsurface configuration
  152992. */
  152993. addDiffusionProfile(color: Color3): number;
  152994. /**
  152995. * Creates the sss post process
  152996. * @return The created post process
  152997. */
  152998. createPostProcess(): SubSurfaceScatteringPostProcess;
  152999. /**
  153000. * Deletes all diffusion profiles.
  153001. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  153002. */
  153003. clearAllDiffusionProfiles(): void;
  153004. /**
  153005. * Disposes this object
  153006. */
  153007. dispose(): void;
  153008. /**
  153009. * @hidden
  153010. * https://zero-radiance.github.io/post/sampling-diffusion/
  153011. *
  153012. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  153013. * ------------------------------------------------------------------------------------
  153014. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  153015. * PDF[r, phi, s] = r * R[r, phi, s]
  153016. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  153017. * ------------------------------------------------------------------------------------
  153018. * We importance sample the color channel with the widest scattering distance.
  153019. */
  153020. getDiffusionProfileParameters(color: Color3): number;
  153021. /**
  153022. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  153023. * 'u' is the random number (the value of the CDF): [0, 1).
  153024. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  153025. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  153026. */
  153027. private _sampleBurleyDiffusionProfile;
  153028. }
  153029. }
  153030. declare module BABYLON {
  153031. interface AbstractScene {
  153032. /** @hidden (Backing field) */
  153033. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153034. /**
  153035. * Gets or Sets the current prepass renderer associated to the scene.
  153036. */
  153037. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153038. /**
  153039. * Enables the subsurface effect for prepass
  153040. * @returns the SubSurfaceConfiguration
  153041. */
  153042. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  153043. /**
  153044. * Disables the subsurface effect for prepass
  153045. */
  153046. disableSubSurfaceForPrePass(): void;
  153047. }
  153048. /**
  153049. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153050. * in several rendering techniques.
  153051. */
  153052. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  153053. /**
  153054. * The component name helpful to identify the component in the list of scene components.
  153055. */
  153056. readonly name: string;
  153057. /**
  153058. * The scene the component belongs to.
  153059. */
  153060. scene: Scene;
  153061. /**
  153062. * Creates a new instance of the component for the given scene
  153063. * @param scene Defines the scene to register the component in
  153064. */
  153065. constructor(scene: Scene);
  153066. /**
  153067. * Registers the component in a given scene
  153068. */
  153069. register(): void;
  153070. /**
  153071. * Serializes the component data to the specified json object
  153072. * @param serializationObject The object to serialize to
  153073. */
  153074. serialize(serializationObject: any): void;
  153075. /**
  153076. * Adds all the elements from the container to the scene
  153077. * @param container the container holding the elements
  153078. */
  153079. addFromContainer(container: AbstractScene): void;
  153080. /**
  153081. * Removes all the elements in the container from the scene
  153082. * @param container contains the elements to remove
  153083. * @param dispose if the removed element should be disposed (default: false)
  153084. */
  153085. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  153086. /**
  153087. * Rebuilds the elements related to this component in case of
  153088. * context lost for instance.
  153089. */
  153090. rebuild(): void;
  153091. /**
  153092. * Disposes the component and the associated ressources
  153093. */
  153094. dispose(): void;
  153095. }
  153096. }
  153097. declare module BABYLON {
  153098. /** @hidden */
  153099. export var outlinePixelShader: {
  153100. name: string;
  153101. shader: string;
  153102. };
  153103. }
  153104. declare module BABYLON {
  153105. /** @hidden */
  153106. export var outlineVertexShader: {
  153107. name: string;
  153108. shader: string;
  153109. };
  153110. }
  153111. declare module BABYLON {
  153112. interface Scene {
  153113. /** @hidden */
  153114. _outlineRenderer: OutlineRenderer;
  153115. /**
  153116. * Gets the outline renderer associated with the scene
  153117. * @returns a OutlineRenderer
  153118. */
  153119. getOutlineRenderer(): OutlineRenderer;
  153120. }
  153121. interface AbstractMesh {
  153122. /** @hidden (Backing field) */
  153123. _renderOutline: boolean;
  153124. /**
  153125. * Gets or sets a boolean indicating if the outline must be rendered as well
  153126. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  153127. */
  153128. renderOutline: boolean;
  153129. /** @hidden (Backing field) */
  153130. _renderOverlay: boolean;
  153131. /**
  153132. * Gets or sets a boolean indicating if the overlay must be rendered as well
  153133. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  153134. */
  153135. renderOverlay: boolean;
  153136. }
  153137. /**
  153138. * This class is responsible to draw bothe outline/overlay of meshes.
  153139. * It should not be used directly but through the available method on mesh.
  153140. */
  153141. export class OutlineRenderer implements ISceneComponent {
  153142. /**
  153143. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  153144. */
  153145. private static _StencilReference;
  153146. /**
  153147. * The name of the component. Each component must have a unique name.
  153148. */
  153149. name: string;
  153150. /**
  153151. * The scene the component belongs to.
  153152. */
  153153. scene: Scene;
  153154. /**
  153155. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  153156. */
  153157. zOffset: number;
  153158. private _engine;
  153159. private _effect;
  153160. private _cachedDefines;
  153161. private _savedDepthWrite;
  153162. /**
  153163. * Instantiates a new outline renderer. (There could be only one per scene).
  153164. * @param scene Defines the scene it belongs to
  153165. */
  153166. constructor(scene: Scene);
  153167. /**
  153168. * Register the component to one instance of a scene.
  153169. */
  153170. register(): void;
  153171. /**
  153172. * Rebuilds the elements related to this component in case of
  153173. * context lost for instance.
  153174. */
  153175. rebuild(): void;
  153176. /**
  153177. * Disposes the component and the associated ressources.
  153178. */
  153179. dispose(): void;
  153180. /**
  153181. * Renders the outline in the canvas.
  153182. * @param subMesh Defines the sumesh to render
  153183. * @param batch Defines the batch of meshes in case of instances
  153184. * @param useOverlay Defines if the rendering is for the overlay or the outline
  153185. */
  153186. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  153187. /**
  153188. * Returns whether or not the outline renderer is ready for a given submesh.
  153189. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  153190. * @param subMesh Defines the submesh to check readyness for
  153191. * @param useInstances Defines wheter wee are trying to render instances or not
  153192. * @returns true if ready otherwise false
  153193. */
  153194. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  153195. private _beforeRenderingMesh;
  153196. private _afterRenderingMesh;
  153197. }
  153198. }
  153199. declare module BABYLON {
  153200. /**
  153201. * Defines the basic options interface of a Sprite Frame Source Size.
  153202. */
  153203. export interface ISpriteJSONSpriteSourceSize {
  153204. /**
  153205. * number of the original width of the Frame
  153206. */
  153207. w: number;
  153208. /**
  153209. * number of the original height of the Frame
  153210. */
  153211. h: number;
  153212. }
  153213. /**
  153214. * Defines the basic options interface of a Sprite Frame Data.
  153215. */
  153216. export interface ISpriteJSONSpriteFrameData {
  153217. /**
  153218. * number of the x offset of the Frame
  153219. */
  153220. x: number;
  153221. /**
  153222. * number of the y offset of the Frame
  153223. */
  153224. y: number;
  153225. /**
  153226. * number of the width of the Frame
  153227. */
  153228. w: number;
  153229. /**
  153230. * number of the height of the Frame
  153231. */
  153232. h: number;
  153233. }
  153234. /**
  153235. * Defines the basic options interface of a JSON Sprite.
  153236. */
  153237. export interface ISpriteJSONSprite {
  153238. /**
  153239. * string name of the Frame
  153240. */
  153241. filename: string;
  153242. /**
  153243. * ISpriteJSONSpriteFrame basic object of the frame data
  153244. */
  153245. frame: ISpriteJSONSpriteFrameData;
  153246. /**
  153247. * boolean to flag is the frame was rotated.
  153248. */
  153249. rotated: boolean;
  153250. /**
  153251. * boolean to flag is the frame was trimmed.
  153252. */
  153253. trimmed: boolean;
  153254. /**
  153255. * ISpriteJSONSpriteFrame basic object of the source data
  153256. */
  153257. spriteSourceSize: ISpriteJSONSpriteFrameData;
  153258. /**
  153259. * ISpriteJSONSpriteFrame basic object of the source data
  153260. */
  153261. sourceSize: ISpriteJSONSpriteSourceSize;
  153262. }
  153263. /**
  153264. * Defines the basic options interface of a JSON atlas.
  153265. */
  153266. export interface ISpriteJSONAtlas {
  153267. /**
  153268. * Array of objects that contain the frame data.
  153269. */
  153270. frames: Array<ISpriteJSONSprite>;
  153271. /**
  153272. * object basic object containing the sprite meta data.
  153273. */
  153274. meta?: object;
  153275. }
  153276. }
  153277. declare module BABYLON {
  153278. /** @hidden */
  153279. export var spriteMapPixelShader: {
  153280. name: string;
  153281. shader: string;
  153282. };
  153283. }
  153284. declare module BABYLON {
  153285. /** @hidden */
  153286. export var spriteMapVertexShader: {
  153287. name: string;
  153288. shader: string;
  153289. };
  153290. }
  153291. declare module BABYLON {
  153292. /**
  153293. * Defines the basic options interface of a SpriteMap
  153294. */
  153295. export interface ISpriteMapOptions {
  153296. /**
  153297. * Vector2 of the number of cells in the grid.
  153298. */
  153299. stageSize?: Vector2;
  153300. /**
  153301. * Vector2 of the size of the output plane in World Units.
  153302. */
  153303. outputSize?: Vector2;
  153304. /**
  153305. * Vector3 of the position of the output plane in World Units.
  153306. */
  153307. outputPosition?: Vector3;
  153308. /**
  153309. * Vector3 of the rotation of the output plane.
  153310. */
  153311. outputRotation?: Vector3;
  153312. /**
  153313. * number of layers that the system will reserve in resources.
  153314. */
  153315. layerCount?: number;
  153316. /**
  153317. * number of max animation frames a single cell will reserve in resources.
  153318. */
  153319. maxAnimationFrames?: number;
  153320. /**
  153321. * number cell index of the base tile when the system compiles.
  153322. */
  153323. baseTile?: number;
  153324. /**
  153325. * boolean flip the sprite after its been repositioned by the framing data.
  153326. */
  153327. flipU?: boolean;
  153328. /**
  153329. * Vector3 scalar of the global RGB values of the SpriteMap.
  153330. */
  153331. colorMultiply?: Vector3;
  153332. }
  153333. /**
  153334. * Defines the IDisposable interface in order to be cleanable from resources.
  153335. */
  153336. export interface ISpriteMap extends IDisposable {
  153337. /**
  153338. * String name of the SpriteMap.
  153339. */
  153340. name: string;
  153341. /**
  153342. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  153343. */
  153344. atlasJSON: ISpriteJSONAtlas;
  153345. /**
  153346. * Texture of the SpriteMap.
  153347. */
  153348. spriteSheet: Texture;
  153349. /**
  153350. * The parameters to initialize the SpriteMap with.
  153351. */
  153352. options: ISpriteMapOptions;
  153353. }
  153354. /**
  153355. * Class used to manage a grid restricted sprite deployment on an Output plane.
  153356. */
  153357. export class SpriteMap implements ISpriteMap {
  153358. /** The Name of the spriteMap */
  153359. name: string;
  153360. /** The JSON file with the frame and meta data */
  153361. atlasJSON: ISpriteJSONAtlas;
  153362. /** The systems Sprite Sheet Texture */
  153363. spriteSheet: Texture;
  153364. /** Arguments passed with the Constructor */
  153365. options: ISpriteMapOptions;
  153366. /** Public Sprite Storage array, parsed from atlasJSON */
  153367. sprites: Array<ISpriteJSONSprite>;
  153368. /** Returns the Number of Sprites in the System */
  153369. get spriteCount(): number;
  153370. /** Returns the Position of Output Plane*/
  153371. get position(): Vector3;
  153372. /** Returns the Position of Output Plane*/
  153373. set position(v: Vector3);
  153374. /** Returns the Rotation of Output Plane*/
  153375. get rotation(): Vector3;
  153376. /** Returns the Rotation of Output Plane*/
  153377. set rotation(v: Vector3);
  153378. /** Sets the AnimationMap*/
  153379. get animationMap(): RawTexture;
  153380. /** Sets the AnimationMap*/
  153381. set animationMap(v: RawTexture);
  153382. /** Scene that the SpriteMap was created in */
  153383. private _scene;
  153384. /** Texture Buffer of Float32 that holds tile frame data*/
  153385. private _frameMap;
  153386. /** Texture Buffers of Float32 that holds tileMap data*/
  153387. private _tileMaps;
  153388. /** Texture Buffer of Float32 that holds Animation Data*/
  153389. private _animationMap;
  153390. /** Custom ShaderMaterial Central to the System*/
  153391. private _material;
  153392. /** Custom ShaderMaterial Central to the System*/
  153393. private _output;
  153394. /** Systems Time Ticker*/
  153395. private _time;
  153396. /**
  153397. * Creates a new SpriteMap
  153398. * @param name defines the SpriteMaps Name
  153399. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  153400. * @param spriteSheet is the Texture that the Sprites are on.
  153401. * @param options a basic deployment configuration
  153402. * @param scene The Scene that the map is deployed on
  153403. */
  153404. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  153405. /**
  153406. * Returns tileID location
  153407. * @returns Vector2 the cell position ID
  153408. */
  153409. getTileID(): Vector2;
  153410. /**
  153411. * Gets the UV location of the mouse over the SpriteMap.
  153412. * @returns Vector2 the UV position of the mouse interaction
  153413. */
  153414. getMousePosition(): Vector2;
  153415. /**
  153416. * Creates the "frame" texture Buffer
  153417. * -------------------------------------
  153418. * Structure of frames
  153419. * "filename": "Falling-Water-2.png",
  153420. * "frame": {"x":69,"y":103,"w":24,"h":32},
  153421. * "rotated": true,
  153422. * "trimmed": true,
  153423. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  153424. * "sourceSize": {"w":32,"h":32}
  153425. * @returns RawTexture of the frameMap
  153426. */
  153427. private _createFrameBuffer;
  153428. /**
  153429. * Creates the tileMap texture Buffer
  153430. * @param buffer normally and array of numbers, or a false to generate from scratch
  153431. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  153432. * @returns RawTexture of the tileMap
  153433. */
  153434. private _createTileBuffer;
  153435. /**
  153436. * Modifies the data of the tileMaps
  153437. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  153438. * @param pos is the iVector2 Coordinates of the Tile
  153439. * @param tile The SpriteIndex of the new Tile
  153440. */
  153441. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153442. /**
  153443. * Creates the animationMap texture Buffer
  153444. * @param buffer normally and array of numbers, or a false to generate from scratch
  153445. * @returns RawTexture of the animationMap
  153446. */
  153447. private _createTileAnimationBuffer;
  153448. /**
  153449. * Modifies the data of the animationMap
  153450. * @param cellID is the Index of the Sprite
  153451. * @param _frame is the target Animation frame
  153452. * @param toCell is the Target Index of the next frame of the animation
  153453. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153454. * @param speed is a global scalar of the time variable on the map.
  153455. */
  153456. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153457. /**
  153458. * Exports the .tilemaps file
  153459. */
  153460. saveTileMaps(): void;
  153461. /**
  153462. * Imports the .tilemaps file
  153463. * @param url of the .tilemaps file
  153464. */
  153465. loadTileMaps(url: string): void;
  153466. /**
  153467. * Release associated resources
  153468. */
  153469. dispose(): void;
  153470. }
  153471. }
  153472. declare module BABYLON {
  153473. /**
  153474. * Class used to manage multiple sprites of different sizes on the same spritesheet
  153475. * @see https://doc.babylonjs.com/babylon101/sprites
  153476. */
  153477. export class SpritePackedManager extends SpriteManager {
  153478. /** defines the packed manager's name */
  153479. name: string;
  153480. /**
  153481. * Creates a new sprite manager from a packed sprite sheet
  153482. * @param name defines the manager's name
  153483. * @param imgUrl defines the sprite sheet url
  153484. * @param capacity defines the maximum allowed number of sprites
  153485. * @param scene defines the hosting scene
  153486. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  153487. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  153488. * @param samplingMode defines the smapling mode to use with spritesheet
  153489. * @param fromPacked set to true; do not alter
  153490. */
  153491. constructor(
  153492. /** defines the packed manager's name */
  153493. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  153494. }
  153495. }
  153496. declare module BABYLON {
  153497. /**
  153498. * Defines the list of states available for a task inside a AssetsManager
  153499. */
  153500. export enum AssetTaskState {
  153501. /**
  153502. * Initialization
  153503. */
  153504. INIT = 0,
  153505. /**
  153506. * Running
  153507. */
  153508. RUNNING = 1,
  153509. /**
  153510. * Done
  153511. */
  153512. DONE = 2,
  153513. /**
  153514. * Error
  153515. */
  153516. ERROR = 3
  153517. }
  153518. /**
  153519. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  153520. */
  153521. export abstract class AbstractAssetTask {
  153522. /**
  153523. * Task name
  153524. */ name: string;
  153525. /**
  153526. * Callback called when the task is successful
  153527. */
  153528. onSuccess: (task: any) => void;
  153529. /**
  153530. * Callback called when the task is not successful
  153531. */
  153532. onError: (task: any, message?: string, exception?: any) => void;
  153533. /**
  153534. * Creates a new AssetsManager
  153535. * @param name defines the name of the task
  153536. */
  153537. constructor(
  153538. /**
  153539. * Task name
  153540. */ name: string);
  153541. private _isCompleted;
  153542. private _taskState;
  153543. private _errorObject;
  153544. /**
  153545. * Get if the task is completed
  153546. */
  153547. get isCompleted(): boolean;
  153548. /**
  153549. * Gets the current state of the task
  153550. */
  153551. get taskState(): AssetTaskState;
  153552. /**
  153553. * Gets the current error object (if task is in error)
  153554. */
  153555. get errorObject(): {
  153556. message?: string;
  153557. exception?: any;
  153558. };
  153559. /**
  153560. * Internal only
  153561. * @hidden
  153562. */
  153563. _setErrorObject(message?: string, exception?: any): void;
  153564. /**
  153565. * Execute the current task
  153566. * @param scene defines the scene where you want your assets to be loaded
  153567. * @param onSuccess is a callback called when the task is successfully executed
  153568. * @param onError is a callback called if an error occurs
  153569. */
  153570. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153571. /**
  153572. * Execute the current task
  153573. * @param scene defines the scene where you want your assets to be loaded
  153574. * @param onSuccess is a callback called when the task is successfully executed
  153575. * @param onError is a callback called if an error occurs
  153576. */
  153577. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153578. /**
  153579. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153580. * This can be used with failed tasks that have the reason for failure fixed.
  153581. */
  153582. reset(): void;
  153583. private onErrorCallback;
  153584. private onDoneCallback;
  153585. }
  153586. /**
  153587. * Define the interface used by progress events raised during assets loading
  153588. */
  153589. export interface IAssetsProgressEvent {
  153590. /**
  153591. * Defines the number of remaining tasks to process
  153592. */
  153593. remainingCount: number;
  153594. /**
  153595. * Defines the total number of tasks
  153596. */
  153597. totalCount: number;
  153598. /**
  153599. * Defines the task that was just processed
  153600. */
  153601. task: AbstractAssetTask;
  153602. }
  153603. /**
  153604. * Class used to share progress information about assets loading
  153605. */
  153606. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153607. /**
  153608. * Defines the number of remaining tasks to process
  153609. */
  153610. remainingCount: number;
  153611. /**
  153612. * Defines the total number of tasks
  153613. */
  153614. totalCount: number;
  153615. /**
  153616. * Defines the task that was just processed
  153617. */
  153618. task: AbstractAssetTask;
  153619. /**
  153620. * Creates a AssetsProgressEvent
  153621. * @param remainingCount defines the number of remaining tasks to process
  153622. * @param totalCount defines the total number of tasks
  153623. * @param task defines the task that was just processed
  153624. */
  153625. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  153626. }
  153627. /**
  153628. * Define a task used by AssetsManager to load assets into a container
  153629. */
  153630. export class ContainerAssetTask extends AbstractAssetTask {
  153631. /**
  153632. * Defines the name of the task
  153633. */
  153634. name: string;
  153635. /**
  153636. * Defines the list of mesh's names you want to load
  153637. */
  153638. meshesNames: any;
  153639. /**
  153640. * Defines the root url to use as a base to load your meshes and associated resources
  153641. */
  153642. rootUrl: string;
  153643. /**
  153644. * Defines the filename or File of the scene to load from
  153645. */
  153646. sceneFilename: string | File;
  153647. /**
  153648. * Get the loaded asset container
  153649. */
  153650. loadedContainer: AssetContainer;
  153651. /**
  153652. * Gets the list of loaded meshes
  153653. */
  153654. loadedMeshes: Array<AbstractMesh>;
  153655. /**
  153656. * Gets the list of loaded particle systems
  153657. */
  153658. loadedParticleSystems: Array<IParticleSystem>;
  153659. /**
  153660. * Gets the list of loaded skeletons
  153661. */
  153662. loadedSkeletons: Array<Skeleton>;
  153663. /**
  153664. * Gets the list of loaded animation groups
  153665. */
  153666. loadedAnimationGroups: Array<AnimationGroup>;
  153667. /**
  153668. * Callback called when the task is successful
  153669. */
  153670. onSuccess: (task: ContainerAssetTask) => void;
  153671. /**
  153672. * Callback called when the task is successful
  153673. */
  153674. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  153675. /**
  153676. * Creates a new ContainerAssetTask
  153677. * @param name defines the name of the task
  153678. * @param meshesNames defines the list of mesh's names you want to load
  153679. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153680. * @param sceneFilename defines the filename or File of the scene to load from
  153681. */
  153682. constructor(
  153683. /**
  153684. * Defines the name of the task
  153685. */
  153686. name: string,
  153687. /**
  153688. * Defines the list of mesh's names you want to load
  153689. */
  153690. meshesNames: any,
  153691. /**
  153692. * Defines the root url to use as a base to load your meshes and associated resources
  153693. */
  153694. rootUrl: string,
  153695. /**
  153696. * Defines the filename or File of the scene to load from
  153697. */
  153698. sceneFilename: string | File);
  153699. /**
  153700. * Execute the current task
  153701. * @param scene defines the scene where you want your assets to be loaded
  153702. * @param onSuccess is a callback called when the task is successfully executed
  153703. * @param onError is a callback called if an error occurs
  153704. */
  153705. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153706. }
  153707. /**
  153708. * Define a task used by AssetsManager to load meshes
  153709. */
  153710. export class MeshAssetTask extends AbstractAssetTask {
  153711. /**
  153712. * Defines the name of the task
  153713. */
  153714. name: string;
  153715. /**
  153716. * Defines the list of mesh's names you want to load
  153717. */
  153718. meshesNames: any;
  153719. /**
  153720. * Defines the root url to use as a base to load your meshes and associated resources
  153721. */
  153722. rootUrl: string;
  153723. /**
  153724. * Defines the filename or File of the scene to load from
  153725. */
  153726. sceneFilename: string | File;
  153727. /**
  153728. * Gets the list of loaded meshes
  153729. */
  153730. loadedMeshes: Array<AbstractMesh>;
  153731. /**
  153732. * Gets the list of loaded particle systems
  153733. */
  153734. loadedParticleSystems: Array<IParticleSystem>;
  153735. /**
  153736. * Gets the list of loaded skeletons
  153737. */
  153738. loadedSkeletons: Array<Skeleton>;
  153739. /**
  153740. * Gets the list of loaded animation groups
  153741. */
  153742. loadedAnimationGroups: Array<AnimationGroup>;
  153743. /**
  153744. * Callback called when the task is successful
  153745. */
  153746. onSuccess: (task: MeshAssetTask) => void;
  153747. /**
  153748. * Callback called when the task is successful
  153749. */
  153750. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  153751. /**
  153752. * Creates a new MeshAssetTask
  153753. * @param name defines the name of the task
  153754. * @param meshesNames defines the list of mesh's names you want to load
  153755. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153756. * @param sceneFilename defines the filename or File of the scene to load from
  153757. */
  153758. constructor(
  153759. /**
  153760. * Defines the name of the task
  153761. */
  153762. name: string,
  153763. /**
  153764. * Defines the list of mesh's names you want to load
  153765. */
  153766. meshesNames: any,
  153767. /**
  153768. * Defines the root url to use as a base to load your meshes and associated resources
  153769. */
  153770. rootUrl: string,
  153771. /**
  153772. * Defines the filename or File of the scene to load from
  153773. */
  153774. sceneFilename: string | File);
  153775. /**
  153776. * Execute the current task
  153777. * @param scene defines the scene where you want your assets to be loaded
  153778. * @param onSuccess is a callback called when the task is successfully executed
  153779. * @param onError is a callback called if an error occurs
  153780. */
  153781. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153782. }
  153783. /**
  153784. * Define a task used by AssetsManager to load text content
  153785. */
  153786. export class TextFileAssetTask extends AbstractAssetTask {
  153787. /**
  153788. * Defines the name of the task
  153789. */
  153790. name: string;
  153791. /**
  153792. * Defines the location of the file to load
  153793. */
  153794. url: string;
  153795. /**
  153796. * Gets the loaded text string
  153797. */
  153798. text: string;
  153799. /**
  153800. * Callback called when the task is successful
  153801. */
  153802. onSuccess: (task: TextFileAssetTask) => void;
  153803. /**
  153804. * Callback called when the task is successful
  153805. */
  153806. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  153807. /**
  153808. * Creates a new TextFileAssetTask object
  153809. * @param name defines the name of the task
  153810. * @param url defines the location of the file to load
  153811. */
  153812. constructor(
  153813. /**
  153814. * Defines the name of the task
  153815. */
  153816. name: string,
  153817. /**
  153818. * Defines the location of the file to load
  153819. */
  153820. url: string);
  153821. /**
  153822. * Execute the current task
  153823. * @param scene defines the scene where you want your assets to be loaded
  153824. * @param onSuccess is a callback called when the task is successfully executed
  153825. * @param onError is a callback called if an error occurs
  153826. */
  153827. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153828. }
  153829. /**
  153830. * Define a task used by AssetsManager to load binary data
  153831. */
  153832. export class BinaryFileAssetTask extends AbstractAssetTask {
  153833. /**
  153834. * Defines the name of the task
  153835. */
  153836. name: string;
  153837. /**
  153838. * Defines the location of the file to load
  153839. */
  153840. url: string;
  153841. /**
  153842. * Gets the lodaded data (as an array buffer)
  153843. */
  153844. data: ArrayBuffer;
  153845. /**
  153846. * Callback called when the task is successful
  153847. */
  153848. onSuccess: (task: BinaryFileAssetTask) => void;
  153849. /**
  153850. * Callback called when the task is successful
  153851. */
  153852. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  153853. /**
  153854. * Creates a new BinaryFileAssetTask object
  153855. * @param name defines the name of the new task
  153856. * @param url defines the location of the file to load
  153857. */
  153858. constructor(
  153859. /**
  153860. * Defines the name of the task
  153861. */
  153862. name: string,
  153863. /**
  153864. * Defines the location of the file to load
  153865. */
  153866. url: string);
  153867. /**
  153868. * Execute the current task
  153869. * @param scene defines the scene where you want your assets to be loaded
  153870. * @param onSuccess is a callback called when the task is successfully executed
  153871. * @param onError is a callback called if an error occurs
  153872. */
  153873. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153874. }
  153875. /**
  153876. * Define a task used by AssetsManager to load images
  153877. */
  153878. export class ImageAssetTask extends AbstractAssetTask {
  153879. /**
  153880. * Defines the name of the task
  153881. */
  153882. name: string;
  153883. /**
  153884. * Defines the location of the image to load
  153885. */
  153886. url: string;
  153887. /**
  153888. * Gets the loaded images
  153889. */
  153890. image: HTMLImageElement;
  153891. /**
  153892. * Callback called when the task is successful
  153893. */
  153894. onSuccess: (task: ImageAssetTask) => void;
  153895. /**
  153896. * Callback called when the task is successful
  153897. */
  153898. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  153899. /**
  153900. * Creates a new ImageAssetTask
  153901. * @param name defines the name of the task
  153902. * @param url defines the location of the image to load
  153903. */
  153904. constructor(
  153905. /**
  153906. * Defines the name of the task
  153907. */
  153908. name: string,
  153909. /**
  153910. * Defines the location of the image to load
  153911. */
  153912. url: string);
  153913. /**
  153914. * Execute the current task
  153915. * @param scene defines the scene where you want your assets to be loaded
  153916. * @param onSuccess is a callback called when the task is successfully executed
  153917. * @param onError is a callback called if an error occurs
  153918. */
  153919. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153920. }
  153921. /**
  153922. * Defines the interface used by texture loading tasks
  153923. */
  153924. export interface ITextureAssetTask<TEX extends BaseTexture> {
  153925. /**
  153926. * Gets the loaded texture
  153927. */
  153928. texture: TEX;
  153929. }
  153930. /**
  153931. * Define a task used by AssetsManager to load 2D textures
  153932. */
  153933. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  153934. /**
  153935. * Defines the name of the task
  153936. */
  153937. name: string;
  153938. /**
  153939. * Defines the location of the file to load
  153940. */
  153941. url: string;
  153942. /**
  153943. * Defines if mipmap should not be generated (default is false)
  153944. */
  153945. noMipmap?: boolean | undefined;
  153946. /**
  153947. * Defines if texture must be inverted on Y axis (default is true)
  153948. */
  153949. invertY: boolean;
  153950. /**
  153951. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153952. */
  153953. samplingMode: number;
  153954. /**
  153955. * Gets the loaded texture
  153956. */
  153957. texture: Texture;
  153958. /**
  153959. * Callback called when the task is successful
  153960. */
  153961. onSuccess: (task: TextureAssetTask) => void;
  153962. /**
  153963. * Callback called when the task is successful
  153964. */
  153965. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  153966. /**
  153967. * Creates a new TextureAssetTask object
  153968. * @param name defines the name of the task
  153969. * @param url defines the location of the file to load
  153970. * @param noMipmap defines if mipmap should not be generated (default is false)
  153971. * @param invertY defines if texture must be inverted on Y axis (default is true)
  153972. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153973. */
  153974. constructor(
  153975. /**
  153976. * Defines the name of the task
  153977. */
  153978. name: string,
  153979. /**
  153980. * Defines the location of the file to load
  153981. */
  153982. url: string,
  153983. /**
  153984. * Defines if mipmap should not be generated (default is false)
  153985. */
  153986. noMipmap?: boolean | undefined,
  153987. /**
  153988. * Defines if texture must be inverted on Y axis (default is true)
  153989. */
  153990. invertY?: boolean,
  153991. /**
  153992. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153993. */
  153994. samplingMode?: number);
  153995. /**
  153996. * Execute the current task
  153997. * @param scene defines the scene where you want your assets to be loaded
  153998. * @param onSuccess is a callback called when the task is successfully executed
  153999. * @param onError is a callback called if an error occurs
  154000. */
  154001. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154002. }
  154003. /**
  154004. * Define a task used by AssetsManager to load cube textures
  154005. */
  154006. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  154007. /**
  154008. * Defines the name of the task
  154009. */
  154010. name: string;
  154011. /**
  154012. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154013. */
  154014. url: string;
  154015. /**
  154016. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154017. */
  154018. extensions?: string[] | undefined;
  154019. /**
  154020. * Defines if mipmaps should not be generated (default is false)
  154021. */
  154022. noMipmap?: boolean | undefined;
  154023. /**
  154024. * Defines the explicit list of files (undefined by default)
  154025. */
  154026. files?: string[] | undefined;
  154027. /**
  154028. * Gets the loaded texture
  154029. */
  154030. texture: CubeTexture;
  154031. /**
  154032. * Callback called when the task is successful
  154033. */
  154034. onSuccess: (task: CubeTextureAssetTask) => void;
  154035. /**
  154036. * Callback called when the task is successful
  154037. */
  154038. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  154039. /**
  154040. * Creates a new CubeTextureAssetTask
  154041. * @param name defines the name of the task
  154042. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154043. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154044. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154045. * @param files defines the explicit list of files (undefined by default)
  154046. */
  154047. constructor(
  154048. /**
  154049. * Defines the name of the task
  154050. */
  154051. name: string,
  154052. /**
  154053. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154054. */
  154055. url: string,
  154056. /**
  154057. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154058. */
  154059. extensions?: string[] | undefined,
  154060. /**
  154061. * Defines if mipmaps should not be generated (default is false)
  154062. */
  154063. noMipmap?: boolean | undefined,
  154064. /**
  154065. * Defines the explicit list of files (undefined by default)
  154066. */
  154067. files?: string[] | undefined);
  154068. /**
  154069. * Execute the current task
  154070. * @param scene defines the scene where you want your assets to be loaded
  154071. * @param onSuccess is a callback called when the task is successfully executed
  154072. * @param onError is a callback called if an error occurs
  154073. */
  154074. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154075. }
  154076. /**
  154077. * Define a task used by AssetsManager to load HDR cube textures
  154078. */
  154079. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  154080. /**
  154081. * Defines the name of the task
  154082. */
  154083. name: string;
  154084. /**
  154085. * Defines the location of the file to load
  154086. */
  154087. url: string;
  154088. /**
  154089. * Defines the desired size (the more it increases the longer the generation will be)
  154090. */
  154091. size: number;
  154092. /**
  154093. * Defines if mipmaps should not be generated (default is false)
  154094. */
  154095. noMipmap: boolean;
  154096. /**
  154097. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154098. */
  154099. generateHarmonics: boolean;
  154100. /**
  154101. * 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)
  154102. */
  154103. gammaSpace: boolean;
  154104. /**
  154105. * Internal Use Only
  154106. */
  154107. reserved: boolean;
  154108. /**
  154109. * Gets the loaded texture
  154110. */
  154111. texture: HDRCubeTexture;
  154112. /**
  154113. * Callback called when the task is successful
  154114. */
  154115. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  154116. /**
  154117. * Callback called when the task is successful
  154118. */
  154119. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  154120. /**
  154121. * Creates a new HDRCubeTextureAssetTask object
  154122. * @param name defines the name of the task
  154123. * @param url defines the location of the file to load
  154124. * @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.
  154125. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154126. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154127. * @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)
  154128. * @param reserved Internal use only
  154129. */
  154130. constructor(
  154131. /**
  154132. * Defines the name of the task
  154133. */
  154134. name: string,
  154135. /**
  154136. * Defines the location of the file to load
  154137. */
  154138. url: string,
  154139. /**
  154140. * Defines the desired size (the more it increases the longer the generation will be)
  154141. */
  154142. size: number,
  154143. /**
  154144. * Defines if mipmaps should not be generated (default is false)
  154145. */
  154146. noMipmap?: boolean,
  154147. /**
  154148. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154149. */
  154150. generateHarmonics?: boolean,
  154151. /**
  154152. * 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)
  154153. */
  154154. gammaSpace?: boolean,
  154155. /**
  154156. * Internal Use Only
  154157. */
  154158. reserved?: boolean);
  154159. /**
  154160. * Execute the current task
  154161. * @param scene defines the scene where you want your assets to be loaded
  154162. * @param onSuccess is a callback called when the task is successfully executed
  154163. * @param onError is a callback called if an error occurs
  154164. */
  154165. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154166. }
  154167. /**
  154168. * Define a task used by AssetsManager to load Equirectangular cube textures
  154169. */
  154170. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  154171. /**
  154172. * Defines the name of the task
  154173. */
  154174. name: string;
  154175. /**
  154176. * Defines the location of the file to load
  154177. */
  154178. url: string;
  154179. /**
  154180. * Defines the desired size (the more it increases the longer the generation will be)
  154181. */
  154182. size: number;
  154183. /**
  154184. * Defines if mipmaps should not be generated (default is false)
  154185. */
  154186. noMipmap: boolean;
  154187. /**
  154188. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154189. * but the standard material would require them in Gamma space) (default is true)
  154190. */
  154191. gammaSpace: boolean;
  154192. /**
  154193. * Gets the loaded texture
  154194. */
  154195. texture: EquiRectangularCubeTexture;
  154196. /**
  154197. * Callback called when the task is successful
  154198. */
  154199. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  154200. /**
  154201. * Callback called when the task is successful
  154202. */
  154203. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  154204. /**
  154205. * Creates a new EquiRectangularCubeTextureAssetTask object
  154206. * @param name defines the name of the task
  154207. * @param url defines the location of the file to load
  154208. * @param size defines the desired size (the more it increases the longer the generation will be)
  154209. * If the size is omitted this implies you are using a preprocessed cubemap.
  154210. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154211. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  154212. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  154213. * (default is true)
  154214. */
  154215. constructor(
  154216. /**
  154217. * Defines the name of the task
  154218. */
  154219. name: string,
  154220. /**
  154221. * Defines the location of the file to load
  154222. */
  154223. url: string,
  154224. /**
  154225. * Defines the desired size (the more it increases the longer the generation will be)
  154226. */
  154227. size: number,
  154228. /**
  154229. * Defines if mipmaps should not be generated (default is false)
  154230. */
  154231. noMipmap?: boolean,
  154232. /**
  154233. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154234. * but the standard material would require them in Gamma space) (default is true)
  154235. */
  154236. gammaSpace?: boolean);
  154237. /**
  154238. * Execute the current task
  154239. * @param scene defines the scene where you want your assets to be loaded
  154240. * @param onSuccess is a callback called when the task is successfully executed
  154241. * @param onError is a callback called if an error occurs
  154242. */
  154243. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154244. }
  154245. /**
  154246. * This class can be used to easily import assets into a scene
  154247. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  154248. */
  154249. export class AssetsManager {
  154250. private _scene;
  154251. private _isLoading;
  154252. protected _tasks: AbstractAssetTask[];
  154253. protected _waitingTasksCount: number;
  154254. protected _totalTasksCount: number;
  154255. /**
  154256. * Callback called when all tasks are processed
  154257. */
  154258. onFinish: (tasks: AbstractAssetTask[]) => void;
  154259. /**
  154260. * Callback called when a task is successful
  154261. */
  154262. onTaskSuccess: (task: AbstractAssetTask) => void;
  154263. /**
  154264. * Callback called when a task had an error
  154265. */
  154266. onTaskError: (task: AbstractAssetTask) => void;
  154267. /**
  154268. * Callback called when a task is done (whatever the result is)
  154269. */
  154270. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  154271. /**
  154272. * Observable called when all tasks are processed
  154273. */
  154274. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  154275. /**
  154276. * Observable called when a task had an error
  154277. */
  154278. onTaskErrorObservable: Observable<AbstractAssetTask>;
  154279. /**
  154280. * Observable called when all tasks were executed
  154281. */
  154282. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  154283. /**
  154284. * Observable called when a task is done (whatever the result is)
  154285. */
  154286. onProgressObservable: Observable<IAssetsProgressEvent>;
  154287. /**
  154288. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  154289. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  154290. */
  154291. useDefaultLoadingScreen: boolean;
  154292. /**
  154293. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  154294. * when all assets have been downloaded.
  154295. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  154296. */
  154297. autoHideLoadingUI: boolean;
  154298. /**
  154299. * Creates a new AssetsManager
  154300. * @param scene defines the scene to work on
  154301. */
  154302. constructor(scene: Scene);
  154303. /**
  154304. * Add a ContainerAssetTask to the list of active tasks
  154305. * @param taskName defines the name of the new task
  154306. * @param meshesNames defines the name of meshes to load
  154307. * @param rootUrl defines the root url to use to locate files
  154308. * @param sceneFilename defines the filename of the scene file
  154309. * @returns a new ContainerAssetTask object
  154310. */
  154311. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  154312. /**
  154313. * Add a MeshAssetTask to the list of active tasks
  154314. * @param taskName defines the name of the new task
  154315. * @param meshesNames defines the name of meshes to load
  154316. * @param rootUrl defines the root url to use to locate files
  154317. * @param sceneFilename defines the filename of the scene file
  154318. * @returns a new MeshAssetTask object
  154319. */
  154320. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  154321. /**
  154322. * Add a TextFileAssetTask to the list of active tasks
  154323. * @param taskName defines the name of the new task
  154324. * @param url defines the url of the file to load
  154325. * @returns a new TextFileAssetTask object
  154326. */
  154327. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  154328. /**
  154329. * Add a BinaryFileAssetTask to the list of active tasks
  154330. * @param taskName defines the name of the new task
  154331. * @param url defines the url of the file to load
  154332. * @returns a new BinaryFileAssetTask object
  154333. */
  154334. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  154335. /**
  154336. * Add a ImageAssetTask to the list of active tasks
  154337. * @param taskName defines the name of the new task
  154338. * @param url defines the url of the file to load
  154339. * @returns a new ImageAssetTask object
  154340. */
  154341. addImageTask(taskName: string, url: string): ImageAssetTask;
  154342. /**
  154343. * Add a TextureAssetTask to the list of active tasks
  154344. * @param taskName defines the name of the new task
  154345. * @param url defines the url of the file to load
  154346. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154347. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  154348. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  154349. * @returns a new TextureAssetTask object
  154350. */
  154351. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  154352. /**
  154353. * Add a CubeTextureAssetTask to the list of active tasks
  154354. * @param taskName defines the name of the new task
  154355. * @param url defines the url of the file to load
  154356. * @param extensions defines the extension to use to load the cube map (can be null)
  154357. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154358. * @param files defines the list of files to load (can be null)
  154359. * @returns a new CubeTextureAssetTask object
  154360. */
  154361. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  154362. /**
  154363. *
  154364. * Add a HDRCubeTextureAssetTask to the list of active tasks
  154365. * @param taskName defines the name of the new task
  154366. * @param url defines the url of the file to load
  154367. * @param size defines the size you want for the cubemap (can be null)
  154368. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154369. * @param generateHarmonics defines if you want to automatically generate (true by default)
  154370. * @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)
  154371. * @param reserved Internal use only
  154372. * @returns a new HDRCubeTextureAssetTask object
  154373. */
  154374. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  154375. /**
  154376. *
  154377. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  154378. * @param taskName defines the name of the new task
  154379. * @param url defines the url of the file to load
  154380. * @param size defines the size you want for the cubemap (can be null)
  154381. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154382. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  154383. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  154384. * @returns a new EquiRectangularCubeTextureAssetTask object
  154385. */
  154386. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  154387. /**
  154388. * Remove a task from the assets manager.
  154389. * @param task the task to remove
  154390. */
  154391. removeTask(task: AbstractAssetTask): void;
  154392. private _decreaseWaitingTasksCount;
  154393. private _runTask;
  154394. /**
  154395. * Reset the AssetsManager and remove all tasks
  154396. * @return the current instance of the AssetsManager
  154397. */
  154398. reset(): AssetsManager;
  154399. /**
  154400. * Start the loading process
  154401. * @return the current instance of the AssetsManager
  154402. */
  154403. load(): AssetsManager;
  154404. /**
  154405. * Start the loading process as an async operation
  154406. * @return a promise returning the list of failed tasks
  154407. */
  154408. loadAsync(): Promise<void>;
  154409. }
  154410. }
  154411. declare module BABYLON {
  154412. /**
  154413. * Wrapper class for promise with external resolve and reject.
  154414. */
  154415. export class Deferred<T> {
  154416. /**
  154417. * The promise associated with this deferred object.
  154418. */
  154419. readonly promise: Promise<T>;
  154420. private _resolve;
  154421. private _reject;
  154422. /**
  154423. * The resolve method of the promise associated with this deferred object.
  154424. */
  154425. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  154426. /**
  154427. * The reject method of the promise associated with this deferred object.
  154428. */
  154429. get reject(): (reason?: any) => void;
  154430. /**
  154431. * Constructor for this deferred object.
  154432. */
  154433. constructor();
  154434. }
  154435. }
  154436. declare module BABYLON {
  154437. /**
  154438. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154439. */
  154440. export class MeshExploder {
  154441. private _centerMesh;
  154442. private _meshes;
  154443. private _meshesOrigins;
  154444. private _toCenterVectors;
  154445. private _scaledDirection;
  154446. private _newPosition;
  154447. private _centerPosition;
  154448. /**
  154449. * Explodes meshes from a center mesh.
  154450. * @param meshes The meshes to explode.
  154451. * @param centerMesh The mesh to be center of explosion.
  154452. */
  154453. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154454. private _setCenterMesh;
  154455. /**
  154456. * Get class name
  154457. * @returns "MeshExploder"
  154458. */
  154459. getClassName(): string;
  154460. /**
  154461. * "Exploded meshes"
  154462. * @returns Array of meshes with the centerMesh at index 0.
  154463. */
  154464. getMeshes(): Array<Mesh>;
  154465. /**
  154466. * Explodes meshes giving a specific direction
  154467. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  154468. */
  154469. explode(direction?: number): void;
  154470. }
  154471. }
  154472. declare module BABYLON {
  154473. /**
  154474. * Class used to help managing file picking and drag'n'drop
  154475. */
  154476. export class FilesInput {
  154477. /**
  154478. * List of files ready to be loaded
  154479. */
  154480. static get FilesToLoad(): {
  154481. [key: string]: File;
  154482. };
  154483. /**
  154484. * Callback called when a file is processed
  154485. */
  154486. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  154487. private _engine;
  154488. private _currentScene;
  154489. private _sceneLoadedCallback;
  154490. private _progressCallback;
  154491. private _additionalRenderLoopLogicCallback;
  154492. private _textureLoadingCallback;
  154493. private _startingProcessingFilesCallback;
  154494. private _onReloadCallback;
  154495. private _errorCallback;
  154496. private _elementToMonitor;
  154497. private _sceneFileToLoad;
  154498. private _filesToLoad;
  154499. /**
  154500. * Creates a new FilesInput
  154501. * @param engine defines the rendering engine
  154502. * @param scene defines the hosting scene
  154503. * @param sceneLoadedCallback callback called when scene is loaded
  154504. * @param progressCallback callback called to track progress
  154505. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  154506. * @param textureLoadingCallback callback called when a texture is loading
  154507. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  154508. * @param onReloadCallback callback called when a reload is requested
  154509. * @param errorCallback callback call if an error occurs
  154510. */
  154511. 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>);
  154512. private _dragEnterHandler;
  154513. private _dragOverHandler;
  154514. private _dropHandler;
  154515. /**
  154516. * Calls this function to listen to drag'n'drop events on a specific DOM element
  154517. * @param elementToMonitor defines the DOM element to track
  154518. */
  154519. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  154520. /** Gets the current list of files to load */
  154521. get filesToLoad(): File[];
  154522. /**
  154523. * Release all associated resources
  154524. */
  154525. dispose(): void;
  154526. private renderFunction;
  154527. private drag;
  154528. private drop;
  154529. private _traverseFolder;
  154530. private _processFiles;
  154531. /**
  154532. * Load files from a drop event
  154533. * @param event defines the drop event to use as source
  154534. */
  154535. loadFiles(event: any): void;
  154536. private _processReload;
  154537. /**
  154538. * Reload the current scene from the loaded files
  154539. */
  154540. reload(): void;
  154541. }
  154542. }
  154543. declare module BABYLON {
  154544. /**
  154545. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154546. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154547. */
  154548. export class SceneOptimization {
  154549. /**
  154550. * Defines the priority of this optimization (0 by default which means first in the list)
  154551. */
  154552. priority: number;
  154553. /**
  154554. * Gets a string describing the action executed by the current optimization
  154555. * @returns description string
  154556. */
  154557. getDescription(): string;
  154558. /**
  154559. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154560. * @param scene defines the current scene where to apply this optimization
  154561. * @param optimizer defines the current optimizer
  154562. * @returns true if everything that can be done was applied
  154563. */
  154564. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154565. /**
  154566. * Creates the SceneOptimization object
  154567. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154568. * @param desc defines the description associated with the optimization
  154569. */
  154570. constructor(
  154571. /**
  154572. * Defines the priority of this optimization (0 by default which means first in the list)
  154573. */
  154574. priority?: number);
  154575. }
  154576. /**
  154577. * Defines an optimization used to reduce the size of render target textures
  154578. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154579. */
  154580. export class TextureOptimization extends SceneOptimization {
  154581. /**
  154582. * Defines the priority of this optimization (0 by default which means first in the list)
  154583. */
  154584. priority: number;
  154585. /**
  154586. * 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
  154587. */
  154588. maximumSize: number;
  154589. /**
  154590. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154591. */
  154592. step: number;
  154593. /**
  154594. * Gets a string describing the action executed by the current optimization
  154595. * @returns description string
  154596. */
  154597. getDescription(): string;
  154598. /**
  154599. * Creates the TextureOptimization object
  154600. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154601. * @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
  154602. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154603. */
  154604. constructor(
  154605. /**
  154606. * Defines the priority of this optimization (0 by default which means first in the list)
  154607. */
  154608. priority?: number,
  154609. /**
  154610. * 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
  154611. */
  154612. maximumSize?: number,
  154613. /**
  154614. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154615. */
  154616. step?: number);
  154617. /**
  154618. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154619. * @param scene defines the current scene where to apply this optimization
  154620. * @param optimizer defines the current optimizer
  154621. * @returns true if everything that can be done was applied
  154622. */
  154623. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154624. }
  154625. /**
  154626. * Defines an optimization used to increase or decrease the rendering resolution
  154627. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154628. */
  154629. export class HardwareScalingOptimization extends SceneOptimization {
  154630. /**
  154631. * Defines the priority of this optimization (0 by default which means first in the list)
  154632. */
  154633. priority: number;
  154634. /**
  154635. * Defines the maximum scale to use (2 by default)
  154636. */
  154637. maximumScale: number;
  154638. /**
  154639. * Defines the step to use between two passes (0.5 by default)
  154640. */
  154641. step: number;
  154642. private _currentScale;
  154643. private _directionOffset;
  154644. /**
  154645. * Gets a string describing the action executed by the current optimization
  154646. * @return description string
  154647. */
  154648. getDescription(): string;
  154649. /**
  154650. * Creates the HardwareScalingOptimization object
  154651. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154652. * @param maximumScale defines the maximum scale to use (2 by default)
  154653. * @param step defines the step to use between two passes (0.5 by default)
  154654. */
  154655. constructor(
  154656. /**
  154657. * Defines the priority of this optimization (0 by default which means first in the list)
  154658. */
  154659. priority?: number,
  154660. /**
  154661. * Defines the maximum scale to use (2 by default)
  154662. */
  154663. maximumScale?: number,
  154664. /**
  154665. * Defines the step to use between two passes (0.5 by default)
  154666. */
  154667. step?: number);
  154668. /**
  154669. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154670. * @param scene defines the current scene where to apply this optimization
  154671. * @param optimizer defines the current optimizer
  154672. * @returns true if everything that can be done was applied
  154673. */
  154674. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154675. }
  154676. /**
  154677. * Defines an optimization used to remove shadows
  154678. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154679. */
  154680. export class ShadowsOptimization extends SceneOptimization {
  154681. /**
  154682. * Gets a string describing the action executed by the current optimization
  154683. * @return description string
  154684. */
  154685. getDescription(): string;
  154686. /**
  154687. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154688. * @param scene defines the current scene where to apply this optimization
  154689. * @param optimizer defines the current optimizer
  154690. * @returns true if everything that can be done was applied
  154691. */
  154692. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154693. }
  154694. /**
  154695. * Defines an optimization used to turn post-processes off
  154696. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154697. */
  154698. export class PostProcessesOptimization extends SceneOptimization {
  154699. /**
  154700. * Gets a string describing the action executed by the current optimization
  154701. * @return description string
  154702. */
  154703. getDescription(): string;
  154704. /**
  154705. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154706. * @param scene defines the current scene where to apply this optimization
  154707. * @param optimizer defines the current optimizer
  154708. * @returns true if everything that can be done was applied
  154709. */
  154710. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154711. }
  154712. /**
  154713. * Defines an optimization used to turn lens flares off
  154714. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154715. */
  154716. export class LensFlaresOptimization extends SceneOptimization {
  154717. /**
  154718. * Gets a string describing the action executed by the current optimization
  154719. * @return description string
  154720. */
  154721. getDescription(): string;
  154722. /**
  154723. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154724. * @param scene defines the current scene where to apply this optimization
  154725. * @param optimizer defines the current optimizer
  154726. * @returns true if everything that can be done was applied
  154727. */
  154728. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154729. }
  154730. /**
  154731. * Defines an optimization based on user defined callback.
  154732. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154733. */
  154734. export class CustomOptimization extends SceneOptimization {
  154735. /**
  154736. * Callback called to apply the custom optimization.
  154737. */
  154738. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  154739. /**
  154740. * Callback called to get custom description
  154741. */
  154742. onGetDescription: () => string;
  154743. /**
  154744. * Gets a string describing the action executed by the current optimization
  154745. * @returns description string
  154746. */
  154747. getDescription(): string;
  154748. /**
  154749. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154750. * @param scene defines the current scene where to apply this optimization
  154751. * @param optimizer defines the current optimizer
  154752. * @returns true if everything that can be done was applied
  154753. */
  154754. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154755. }
  154756. /**
  154757. * Defines an optimization used to turn particles off
  154758. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154759. */
  154760. export class ParticlesOptimization extends SceneOptimization {
  154761. /**
  154762. * Gets a string describing the action executed by the current optimization
  154763. * @return description string
  154764. */
  154765. getDescription(): string;
  154766. /**
  154767. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154768. * @param scene defines the current scene where to apply this optimization
  154769. * @param optimizer defines the current optimizer
  154770. * @returns true if everything that can be done was applied
  154771. */
  154772. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154773. }
  154774. /**
  154775. * Defines an optimization used to turn render targets off
  154776. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154777. */
  154778. export class RenderTargetsOptimization extends SceneOptimization {
  154779. /**
  154780. * Gets a string describing the action executed by the current optimization
  154781. * @return description string
  154782. */
  154783. getDescription(): string;
  154784. /**
  154785. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154786. * @param scene defines the current scene where to apply this optimization
  154787. * @param optimizer defines the current optimizer
  154788. * @returns true if everything that can be done was applied
  154789. */
  154790. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154791. }
  154792. /**
  154793. * Defines an optimization used to merge meshes with compatible materials
  154794. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154795. */
  154796. export class MergeMeshesOptimization extends SceneOptimization {
  154797. private static _UpdateSelectionTree;
  154798. /**
  154799. * Gets or sets a boolean which defines if optimization octree has to be updated
  154800. */
  154801. static get UpdateSelectionTree(): boolean;
  154802. /**
  154803. * Gets or sets a boolean which defines if optimization octree has to be updated
  154804. */
  154805. static set UpdateSelectionTree(value: boolean);
  154806. /**
  154807. * Gets a string describing the action executed by the current optimization
  154808. * @return description string
  154809. */
  154810. getDescription(): string;
  154811. private _canBeMerged;
  154812. /**
  154813. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154814. * @param scene defines the current scene where to apply this optimization
  154815. * @param optimizer defines the current optimizer
  154816. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  154817. * @returns true if everything that can be done was applied
  154818. */
  154819. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  154820. }
  154821. /**
  154822. * Defines a list of options used by SceneOptimizer
  154823. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154824. */
  154825. export class SceneOptimizerOptions {
  154826. /**
  154827. * Defines the target frame rate to reach (60 by default)
  154828. */
  154829. targetFrameRate: number;
  154830. /**
  154831. * Defines the interval between two checkes (2000ms by default)
  154832. */
  154833. trackerDuration: number;
  154834. /**
  154835. * Gets the list of optimizations to apply
  154836. */
  154837. optimizations: SceneOptimization[];
  154838. /**
  154839. * Creates a new list of options used by SceneOptimizer
  154840. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  154841. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  154842. */
  154843. constructor(
  154844. /**
  154845. * Defines the target frame rate to reach (60 by default)
  154846. */
  154847. targetFrameRate?: number,
  154848. /**
  154849. * Defines the interval between two checkes (2000ms by default)
  154850. */
  154851. trackerDuration?: number);
  154852. /**
  154853. * Add a new optimization
  154854. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  154855. * @returns the current SceneOptimizerOptions
  154856. */
  154857. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  154858. /**
  154859. * Add a new custom optimization
  154860. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  154861. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  154862. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154863. * @returns the current SceneOptimizerOptions
  154864. */
  154865. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  154866. /**
  154867. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  154868. * @param targetFrameRate defines the target frame rate (60 by default)
  154869. * @returns a SceneOptimizerOptions object
  154870. */
  154871. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154872. /**
  154873. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  154874. * @param targetFrameRate defines the target frame rate (60 by default)
  154875. * @returns a SceneOptimizerOptions object
  154876. */
  154877. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154878. /**
  154879. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  154880. * @param targetFrameRate defines the target frame rate (60 by default)
  154881. * @returns a SceneOptimizerOptions object
  154882. */
  154883. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154884. }
  154885. /**
  154886. * Class used to run optimizations in order to reach a target frame rate
  154887. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154888. */
  154889. export class SceneOptimizer implements IDisposable {
  154890. private _isRunning;
  154891. private _options;
  154892. private _scene;
  154893. private _currentPriorityLevel;
  154894. private _targetFrameRate;
  154895. private _trackerDuration;
  154896. private _currentFrameRate;
  154897. private _sceneDisposeObserver;
  154898. private _improvementMode;
  154899. /**
  154900. * Defines an observable called when the optimizer reaches the target frame rate
  154901. */
  154902. onSuccessObservable: Observable<SceneOptimizer>;
  154903. /**
  154904. * Defines an observable called when the optimizer enables an optimization
  154905. */
  154906. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  154907. /**
  154908. * Defines an observable called when the optimizer is not able to reach the target frame rate
  154909. */
  154910. onFailureObservable: Observable<SceneOptimizer>;
  154911. /**
  154912. * Gets a boolean indicating if the optimizer is in improvement mode
  154913. */
  154914. get isInImprovementMode(): boolean;
  154915. /**
  154916. * Gets the current priority level (0 at start)
  154917. */
  154918. get currentPriorityLevel(): number;
  154919. /**
  154920. * Gets the current frame rate checked by the SceneOptimizer
  154921. */
  154922. get currentFrameRate(): number;
  154923. /**
  154924. * Gets or sets the current target frame rate (60 by default)
  154925. */
  154926. get targetFrameRate(): number;
  154927. /**
  154928. * Gets or sets the current target frame rate (60 by default)
  154929. */
  154930. set targetFrameRate(value: number);
  154931. /**
  154932. * Gets or sets the current interval between two checks (every 2000ms by default)
  154933. */
  154934. get trackerDuration(): number;
  154935. /**
  154936. * Gets or sets the current interval between two checks (every 2000ms by default)
  154937. */
  154938. set trackerDuration(value: number);
  154939. /**
  154940. * Gets the list of active optimizations
  154941. */
  154942. get optimizations(): SceneOptimization[];
  154943. /**
  154944. * Creates a new SceneOptimizer
  154945. * @param scene defines the scene to work on
  154946. * @param options defines the options to use with the SceneOptimizer
  154947. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  154948. * @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)
  154949. */
  154950. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  154951. /**
  154952. * Stops the current optimizer
  154953. */
  154954. stop(): void;
  154955. /**
  154956. * Reset the optimizer to initial step (current priority level = 0)
  154957. */
  154958. reset(): void;
  154959. /**
  154960. * Start the optimizer. By default it will try to reach a specific framerate
  154961. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  154962. */
  154963. start(): void;
  154964. private _checkCurrentState;
  154965. /**
  154966. * Release all resources
  154967. */
  154968. dispose(): void;
  154969. /**
  154970. * Helper function to create a SceneOptimizer with one single line of code
  154971. * @param scene defines the scene to work on
  154972. * @param options defines the options to use with the SceneOptimizer
  154973. * @param onSuccess defines a callback to call on success
  154974. * @param onFailure defines a callback to call on failure
  154975. * @returns the new SceneOptimizer object
  154976. */
  154977. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  154978. }
  154979. }
  154980. declare module BABYLON {
  154981. /**
  154982. * Class used to serialize a scene into a string
  154983. */
  154984. export class SceneSerializer {
  154985. /**
  154986. * Clear cache used by a previous serialization
  154987. */
  154988. static ClearCache(): void;
  154989. /**
  154990. * Serialize a scene into a JSON compatible object
  154991. * @param scene defines the scene to serialize
  154992. * @returns a JSON compatible object
  154993. */
  154994. static Serialize(scene: Scene): any;
  154995. /**
  154996. * Serialize a mesh into a JSON compatible object
  154997. * @param toSerialize defines the mesh to serialize
  154998. * @param withParents defines if parents must be serialized as well
  154999. * @param withChildren defines if children must be serialized as well
  155000. * @returns a JSON compatible object
  155001. */
  155002. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  155003. }
  155004. }
  155005. declare module BABYLON {
  155006. /**
  155007. * Class used to host texture specific utilities
  155008. */
  155009. export class TextureTools {
  155010. /**
  155011. * Uses the GPU to create a copy texture rescaled at a given size
  155012. * @param texture Texture to copy from
  155013. * @param width defines the desired width
  155014. * @param height defines the desired height
  155015. * @param useBilinearMode defines if bilinear mode has to be used
  155016. * @return the generated texture
  155017. */
  155018. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  155019. }
  155020. }
  155021. declare module BABYLON {
  155022. /**
  155023. * This represents the different options available for the video capture.
  155024. */
  155025. export interface VideoRecorderOptions {
  155026. /** Defines the mime type of the video. */
  155027. mimeType: string;
  155028. /** Defines the FPS the video should be recorded at. */
  155029. fps: number;
  155030. /** Defines the chunk size for the recording data. */
  155031. recordChunckSize: number;
  155032. /** The audio tracks to attach to the recording. */
  155033. audioTracks?: MediaStreamTrack[];
  155034. }
  155035. /**
  155036. * This can help with recording videos from BabylonJS.
  155037. * This is based on the available WebRTC functionalities of the browser.
  155038. *
  155039. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  155040. */
  155041. export class VideoRecorder {
  155042. private static readonly _defaultOptions;
  155043. /**
  155044. * Returns whether or not the VideoRecorder is available in your browser.
  155045. * @param engine Defines the Babylon Engine.
  155046. * @returns true if supported otherwise false.
  155047. */
  155048. static IsSupported(engine: Engine): boolean;
  155049. private readonly _options;
  155050. private _canvas;
  155051. private _mediaRecorder;
  155052. private _recordedChunks;
  155053. private _fileName;
  155054. private _resolve;
  155055. private _reject;
  155056. /**
  155057. * True when a recording is already in progress.
  155058. */
  155059. get isRecording(): boolean;
  155060. /**
  155061. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  155062. * @param engine Defines the BabylonJS Engine you wish to record.
  155063. * @param options Defines options that can be used to customize the capture.
  155064. */
  155065. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  155066. /**
  155067. * Stops the current recording before the default capture timeout passed in the startRecording function.
  155068. */
  155069. stopRecording(): void;
  155070. /**
  155071. * Starts recording the canvas for a max duration specified in parameters.
  155072. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  155073. * If null no automatic download will start and you can rely on the promise to get the data back.
  155074. * @param maxDuration Defines the maximum recording time in seconds.
  155075. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  155076. * @return A promise callback at the end of the recording with the video data in Blob.
  155077. */
  155078. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  155079. /**
  155080. * Releases internal resources used during the recording.
  155081. */
  155082. dispose(): void;
  155083. private _handleDataAvailable;
  155084. private _handleError;
  155085. private _handleStop;
  155086. }
  155087. }
  155088. declare module BABYLON {
  155089. /**
  155090. * Class containing a set of static utilities functions for screenshots
  155091. */
  155092. export class ScreenshotTools {
  155093. /**
  155094. * Captures a screenshot of the current rendering
  155095. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155096. * @param engine defines the rendering engine
  155097. * @param camera defines the source camera
  155098. * @param size This parameter can be set to a single number or to an object with the
  155099. * following (optional) properties: precision, width, height. If a single number is passed,
  155100. * it will be used for both width and height. If an object is passed, the screenshot size
  155101. * will be derived from the parameters. The precision property is a multiplier allowing
  155102. * rendering at a higher or lower resolution
  155103. * @param successCallback defines the callback receives a single parameter which contains the
  155104. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155105. * src parameter of an <img> to display it
  155106. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155107. * Check your browser for supported MIME types
  155108. */
  155109. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  155110. /**
  155111. * Captures a screenshot of the current rendering
  155112. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155113. * @param engine defines the rendering engine
  155114. * @param camera defines the source camera
  155115. * @param size This parameter can be set to a single number or to an object with the
  155116. * following (optional) properties: precision, width, height. If a single number is passed,
  155117. * it will be used for both width and height. If an object is passed, the screenshot size
  155118. * will be derived from the parameters. The precision property is a multiplier allowing
  155119. * rendering at a higher or lower resolution
  155120. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155121. * Check your browser for supported MIME types
  155122. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155123. * to the src parameter of an <img> to display it
  155124. */
  155125. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  155126. /**
  155127. * Generates an image screenshot from the specified camera.
  155128. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155129. * @param engine The engine to use for rendering
  155130. * @param camera The camera to use for rendering
  155131. * @param size This parameter can be set to a single number or to an object with the
  155132. * following (optional) properties: precision, width, height. If a single number is passed,
  155133. * it will be used for both width and height. If an object is passed, the screenshot size
  155134. * will be derived from the parameters. The precision property is a multiplier allowing
  155135. * rendering at a higher or lower resolution
  155136. * @param successCallback The callback receives a single parameter which contains the
  155137. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155138. * src parameter of an <img> to display it
  155139. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155140. * Check your browser for supported MIME types
  155141. * @param samples Texture samples (default: 1)
  155142. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155143. * @param fileName A name for for the downloaded file.
  155144. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155145. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  155146. */
  155147. 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;
  155148. /**
  155149. * Generates an image screenshot from the specified camera.
  155150. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155151. * @param engine The engine to use for rendering
  155152. * @param camera The camera to use for rendering
  155153. * @param size This parameter can be set to a single number or to an object with the
  155154. * following (optional) properties: precision, width, height. If a single number is passed,
  155155. * it will be used for both width and height. If an object is passed, the screenshot size
  155156. * will be derived from the parameters. The precision property is a multiplier allowing
  155157. * rendering at a higher or lower resolution
  155158. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155159. * Check your browser for supported MIME types
  155160. * @param samples Texture samples (default: 1)
  155161. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155162. * @param fileName A name for for the downloaded file.
  155163. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155164. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155165. * to the src parameter of an <img> to display it
  155166. */
  155167. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  155168. /**
  155169. * Gets height and width for screenshot size
  155170. * @private
  155171. */
  155172. private static _getScreenshotSize;
  155173. }
  155174. }
  155175. declare module BABYLON {
  155176. /**
  155177. * Interface for a data buffer
  155178. */
  155179. export interface IDataBuffer {
  155180. /**
  155181. * Reads bytes from the data buffer.
  155182. * @param byteOffset The byte offset to read
  155183. * @param byteLength The byte length to read
  155184. * @returns A promise that resolves when the bytes are read
  155185. */
  155186. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  155187. /**
  155188. * The byte length of the buffer.
  155189. */
  155190. readonly byteLength: number;
  155191. }
  155192. /**
  155193. * Utility class for reading from a data buffer
  155194. */
  155195. export class DataReader {
  155196. /**
  155197. * The data buffer associated with this data reader.
  155198. */
  155199. readonly buffer: IDataBuffer;
  155200. /**
  155201. * The current byte offset from the beginning of the data buffer.
  155202. */
  155203. byteOffset: number;
  155204. private _dataView;
  155205. private _dataByteOffset;
  155206. /**
  155207. * Constructor
  155208. * @param buffer The buffer to read
  155209. */
  155210. constructor(buffer: IDataBuffer);
  155211. /**
  155212. * Loads the given byte length.
  155213. * @param byteLength The byte length to load
  155214. * @returns A promise that resolves when the load is complete
  155215. */
  155216. loadAsync(byteLength: number): Promise<void>;
  155217. /**
  155218. * Read a unsigned 32-bit integer from the currently loaded data range.
  155219. * @returns The 32-bit integer read
  155220. */
  155221. readUint32(): number;
  155222. /**
  155223. * Read a byte array from the currently loaded data range.
  155224. * @param byteLength The byte length to read
  155225. * @returns The byte array read
  155226. */
  155227. readUint8Array(byteLength: number): Uint8Array;
  155228. /**
  155229. * Read a string from the currently loaded data range.
  155230. * @param byteLength The byte length to read
  155231. * @returns The string read
  155232. */
  155233. readString(byteLength: number): string;
  155234. /**
  155235. * Skips the given byte length the currently loaded data range.
  155236. * @param byteLength The byte length to skip
  155237. */
  155238. skipBytes(byteLength: number): void;
  155239. }
  155240. }
  155241. declare module BABYLON {
  155242. /**
  155243. * Class for storing data to local storage if available or in-memory storage otherwise
  155244. */
  155245. export class DataStorage {
  155246. private static _Storage;
  155247. private static _GetStorage;
  155248. /**
  155249. * Reads a string from the data storage
  155250. * @param key The key to read
  155251. * @param defaultValue The value if the key doesn't exist
  155252. * @returns The string value
  155253. */
  155254. static ReadString(key: string, defaultValue: string): string;
  155255. /**
  155256. * Writes a string to the data storage
  155257. * @param key The key to write
  155258. * @param value The value to write
  155259. */
  155260. static WriteString(key: string, value: string): void;
  155261. /**
  155262. * Reads a boolean from the data storage
  155263. * @param key The key to read
  155264. * @param defaultValue The value if the key doesn't exist
  155265. * @returns The boolean value
  155266. */
  155267. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  155268. /**
  155269. * Writes a boolean to the data storage
  155270. * @param key The key to write
  155271. * @param value The value to write
  155272. */
  155273. static WriteBoolean(key: string, value: boolean): void;
  155274. /**
  155275. * Reads a number from the data storage
  155276. * @param key The key to read
  155277. * @param defaultValue The value if the key doesn't exist
  155278. * @returns The number value
  155279. */
  155280. static ReadNumber(key: string, defaultValue: number): number;
  155281. /**
  155282. * Writes a number to the data storage
  155283. * @param key The key to write
  155284. * @param value The value to write
  155285. */
  155286. static WriteNumber(key: string, value: number): void;
  155287. }
  155288. }
  155289. declare module BABYLON {
  155290. /**
  155291. * Class used to record delta files between 2 scene states
  155292. */
  155293. export class SceneRecorder {
  155294. private _trackedScene;
  155295. private _savedJSON;
  155296. /**
  155297. * Track a given scene. This means the current scene state will be considered the original state
  155298. * @param scene defines the scene to track
  155299. */
  155300. track(scene: Scene): void;
  155301. /**
  155302. * Get the delta between current state and original state
  155303. * @returns a string containing the delta
  155304. */
  155305. getDelta(): any;
  155306. private _compareArray;
  155307. private _compareObjects;
  155308. private _compareCollections;
  155309. private static GetShadowGeneratorById;
  155310. /**
  155311. * Apply a given delta to a given scene
  155312. * @param deltaJSON defines the JSON containing the delta
  155313. * @param scene defines the scene to apply the delta to
  155314. */
  155315. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  155316. private static _ApplyPropertiesToEntity;
  155317. private static _ApplyDeltaForEntity;
  155318. }
  155319. }
  155320. declare module BABYLON {
  155321. /**
  155322. * A 3D trajectory consisting of an order list of vectors describing a
  155323. * path of motion through 3D space.
  155324. */
  155325. export class Trajectory {
  155326. private _points;
  155327. private readonly _segmentLength;
  155328. /**
  155329. * Serialize to JSON.
  155330. * @returns serialized JSON string
  155331. */
  155332. serialize(): string;
  155333. /**
  155334. * Deserialize from JSON.
  155335. * @param json serialized JSON string
  155336. * @returns deserialized Trajectory
  155337. */
  155338. static Deserialize(json: string): Trajectory;
  155339. /**
  155340. * Create a new empty Trajectory.
  155341. * @param segmentLength radius of discretization for Trajectory points
  155342. */
  155343. constructor(segmentLength?: number);
  155344. /**
  155345. * Get the length of the Trajectory.
  155346. * @returns length of the Trajectory
  155347. */
  155348. getLength(): number;
  155349. /**
  155350. * Append a new point to the Trajectory.
  155351. * NOTE: This implementation has many allocations.
  155352. * @param point point to append to the Trajectory
  155353. */
  155354. add(point: DeepImmutable<Vector3>): void;
  155355. /**
  155356. * Create a new Trajectory with a segment length chosen to make it
  155357. * probable that the new Trajectory will have a specified number of
  155358. * segments. This operation is imprecise.
  155359. * @param targetResolution number of segments desired
  155360. * @returns new Trajectory with approximately the requested number of segments
  155361. */
  155362. resampleAtTargetResolution(targetResolution: number): Trajectory;
  155363. /**
  155364. * Convert Trajectory segments into tokenized representation. This
  155365. * representation is an array of numbers where each nth number is the
  155366. * index of the token which is most similar to the nth segment of the
  155367. * Trajectory.
  155368. * @param tokens list of vectors which serve as discrete tokens
  155369. * @returns list of indices of most similar token per segment
  155370. */
  155371. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  155372. private static _forwardDir;
  155373. private static _inverseFromVec;
  155374. private static _upDir;
  155375. private static _fromToVec;
  155376. private static _lookMatrix;
  155377. /**
  155378. * Transform the rotation (i.e., direction) of a segment to isolate
  155379. * the relative transformation represented by the segment. This operation
  155380. * may or may not succeed due to singularities in the equations that define
  155381. * motion relativity in this context.
  155382. * @param priorVec the origin of the prior segment
  155383. * @param fromVec the origin of the current segment
  155384. * @param toVec the destination of the current segment
  155385. * @param result reference to output variable
  155386. * @returns whether or not transformation was successful
  155387. */
  155388. private static _transformSegmentDirToRef;
  155389. private static _bestMatch;
  155390. private static _score;
  155391. private static _bestScore;
  155392. /**
  155393. * Determine which token vector is most similar to the
  155394. * segment vector.
  155395. * @param segment segment vector
  155396. * @param tokens token vector list
  155397. * @returns index of the most similar token to the segment
  155398. */
  155399. private static _tokenizeSegment;
  155400. }
  155401. /**
  155402. * Class representing a set of known, named trajectories to which Trajectories can be
  155403. * added and using which Trajectories can be recognized.
  155404. */
  155405. export class TrajectoryClassifier {
  155406. private _maximumAllowableMatchCost;
  155407. private _vector3Alphabet;
  155408. private _levenshteinAlphabet;
  155409. private _nameToDescribedTrajectory;
  155410. /**
  155411. * Serialize to JSON.
  155412. * @returns JSON serialization
  155413. */
  155414. serialize(): string;
  155415. /**
  155416. * Deserialize from JSON.
  155417. * @param json JSON serialization
  155418. * @returns deserialized TrajectorySet
  155419. */
  155420. static Deserialize(json: string): TrajectoryClassifier;
  155421. /**
  155422. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  155423. * VERY naive, need to be generating these things from known
  155424. * sets. Better version later, probably eliminating this one.
  155425. * @returns auto-generated TrajectorySet
  155426. */
  155427. static Generate(): TrajectoryClassifier;
  155428. private constructor();
  155429. /**
  155430. * Add a new Trajectory to the set with a given name.
  155431. * @param trajectory new Trajectory to be added
  155432. * @param classification name to which to add the Trajectory
  155433. */
  155434. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  155435. /**
  155436. * Remove a known named trajectory and all Trajectories associated with it.
  155437. * @param classification name to remove
  155438. * @returns whether anything was removed
  155439. */
  155440. deleteClassification(classification: string): boolean;
  155441. /**
  155442. * Attempt to recognize a Trajectory from among all the classifications
  155443. * already known to the classifier.
  155444. * @param trajectory Trajectory to be recognized
  155445. * @returns classification of Trajectory if recognized, null otherwise
  155446. */
  155447. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155448. }
  155449. }
  155450. declare module BABYLON {
  155451. /**
  155452. * An interface for all Hit test features
  155453. */
  155454. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155455. /**
  155456. * Triggered when new babylon (transformed) hit test results are available
  155457. */
  155458. onHitTestResultObservable: Observable<T[]>;
  155459. }
  155460. /**
  155461. * Options used for hit testing
  155462. */
  155463. export interface IWebXRLegacyHitTestOptions {
  155464. /**
  155465. * Only test when user interacted with the scene. Default - hit test every frame
  155466. */
  155467. testOnPointerDownOnly?: boolean;
  155468. /**
  155469. * The node to use to transform the local results to world coordinates
  155470. */
  155471. worldParentNode?: TransformNode;
  155472. }
  155473. /**
  155474. * Interface defining the babylon result of raycasting/hit-test
  155475. */
  155476. export interface IWebXRLegacyHitResult {
  155477. /**
  155478. * Transformation matrix that can be applied to a node that will put it in the hit point location
  155479. */
  155480. transformationMatrix: Matrix;
  155481. /**
  155482. * The native hit test result
  155483. */
  155484. xrHitResult: XRHitResult | XRHitTestResult;
  155485. }
  155486. /**
  155487. * The currently-working hit-test module.
  155488. * Hit test (or Ray-casting) is used to interact with the real world.
  155489. * For further information read here - https://github.com/immersive-web/hit-test
  155490. */
  155491. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  155492. /**
  155493. * options to use when constructing this feature
  155494. */
  155495. readonly options: IWebXRLegacyHitTestOptions;
  155496. private _direction;
  155497. private _mat;
  155498. private _onSelectEnabled;
  155499. private _origin;
  155500. /**
  155501. * The module's name
  155502. */
  155503. static readonly Name: string;
  155504. /**
  155505. * The (Babylon) version of this module.
  155506. * This is an integer representing the implementation version.
  155507. * This number does not correspond to the WebXR specs version
  155508. */
  155509. static readonly Version: number;
  155510. /**
  155511. * Populated with the last native XR Hit Results
  155512. */
  155513. lastNativeXRHitResults: XRHitResult[];
  155514. /**
  155515. * Triggered when new babylon (transformed) hit test results are available
  155516. */
  155517. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  155518. /**
  155519. * Creates a new instance of the (legacy version) hit test feature
  155520. * @param _xrSessionManager an instance of WebXRSessionManager
  155521. * @param options options to use when constructing this feature
  155522. */
  155523. constructor(_xrSessionManager: WebXRSessionManager,
  155524. /**
  155525. * options to use when constructing this feature
  155526. */
  155527. options?: IWebXRLegacyHitTestOptions);
  155528. /**
  155529. * execute a hit test with an XR Ray
  155530. *
  155531. * @param xrSession a native xrSession that will execute this hit test
  155532. * @param xrRay the ray (position and direction) to use for ray-casting
  155533. * @param referenceSpace native XR reference space to use for the hit-test
  155534. * @param filter filter function that will filter the results
  155535. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155536. */
  155537. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155538. /**
  155539. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155540. * @param event the (select) event to use to select with
  155541. * @param referenceSpace the reference space to use for this hit test
  155542. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155543. */
  155544. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155545. /**
  155546. * attach this feature
  155547. * Will usually be called by the features manager
  155548. *
  155549. * @returns true if successful.
  155550. */
  155551. attach(): boolean;
  155552. /**
  155553. * detach this feature.
  155554. * Will usually be called by the features manager
  155555. *
  155556. * @returns true if successful.
  155557. */
  155558. detach(): boolean;
  155559. /**
  155560. * Dispose this feature and all of the resources attached
  155561. */
  155562. dispose(): void;
  155563. protected _onXRFrame(frame: XRFrame): void;
  155564. private _onHitTestResults;
  155565. private _onSelect;
  155566. }
  155567. }
  155568. declare module BABYLON {
  155569. /**
  155570. * Options used for hit testing (version 2)
  155571. */
  155572. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155573. /**
  155574. * Do not create a permanent hit test. Will usually be used when only
  155575. * transient inputs are needed.
  155576. */
  155577. disablePermanentHitTest?: boolean;
  155578. /**
  155579. * Enable transient (for example touch-based) hit test inspections
  155580. */
  155581. enableTransientHitTest?: boolean;
  155582. /**
  155583. * Offset ray for the permanent hit test
  155584. */
  155585. offsetRay?: Vector3;
  155586. /**
  155587. * Offset ray for the transient hit test
  155588. */
  155589. transientOffsetRay?: Vector3;
  155590. /**
  155591. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155592. */
  155593. useReferenceSpace?: boolean;
  155594. /**
  155595. * Override the default entity type(s) of the hit-test result
  155596. */
  155597. entityTypes?: XRHitTestTrackableType[];
  155598. }
  155599. /**
  155600. * Interface defining the babylon result of hit-test
  155601. */
  155602. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155603. /**
  155604. * The input source that generated this hit test (if transient)
  155605. */
  155606. inputSource?: XRInputSource;
  155607. /**
  155608. * Is this a transient hit test
  155609. */
  155610. isTransient?: boolean;
  155611. /**
  155612. * Position of the hit test result
  155613. */
  155614. position: Vector3;
  155615. /**
  155616. * Rotation of the hit test result
  155617. */
  155618. rotationQuaternion: Quaternion;
  155619. /**
  155620. * The native hit test result
  155621. */
  155622. xrHitResult: XRHitTestResult;
  155623. }
  155624. /**
  155625. * The currently-working hit-test module.
  155626. * Hit test (or Ray-casting) is used to interact with the real world.
  155627. * For further information read here - https://github.com/immersive-web/hit-test
  155628. *
  155629. * Tested on chrome (mobile) 80.
  155630. */
  155631. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  155632. /**
  155633. * options to use when constructing this feature
  155634. */
  155635. readonly options: IWebXRHitTestOptions;
  155636. private _tmpMat;
  155637. private _tmpPos;
  155638. private _tmpQuat;
  155639. private _transientXrHitTestSource;
  155640. private _xrHitTestSource;
  155641. private initHitTestSource;
  155642. /**
  155643. * The module's name
  155644. */
  155645. static readonly Name: string;
  155646. /**
  155647. * The (Babylon) version of this module.
  155648. * This is an integer representing the implementation version.
  155649. * This number does not correspond to the WebXR specs version
  155650. */
  155651. static readonly Version: number;
  155652. /**
  155653. * When set to true, each hit test will have its own position/rotation objects
  155654. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  155655. * the developers will clone them or copy them as they see fit.
  155656. */
  155657. autoCloneTransformation: boolean;
  155658. /**
  155659. * Triggered when new babylon (transformed) hit test results are available
  155660. * Note - this will be called when results come back from the device. It can be an empty array!!
  155661. */
  155662. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  155663. /**
  155664. * Use this to temporarily pause hit test checks.
  155665. */
  155666. paused: boolean;
  155667. /**
  155668. * Creates a new instance of the hit test feature
  155669. * @param _xrSessionManager an instance of WebXRSessionManager
  155670. * @param options options to use when constructing this feature
  155671. */
  155672. constructor(_xrSessionManager: WebXRSessionManager,
  155673. /**
  155674. * options to use when constructing this feature
  155675. */
  155676. options?: IWebXRHitTestOptions);
  155677. /**
  155678. * attach this feature
  155679. * Will usually be called by the features manager
  155680. *
  155681. * @returns true if successful.
  155682. */
  155683. attach(): boolean;
  155684. /**
  155685. * detach this feature.
  155686. * Will usually be called by the features manager
  155687. *
  155688. * @returns true if successful.
  155689. */
  155690. detach(): boolean;
  155691. /**
  155692. * Dispose this feature and all of the resources attached
  155693. */
  155694. dispose(): void;
  155695. protected _onXRFrame(frame: XRFrame): void;
  155696. private _processWebXRHitTestResult;
  155697. }
  155698. }
  155699. declare module BABYLON {
  155700. /**
  155701. * Configuration options of the anchor system
  155702. */
  155703. export interface IWebXRAnchorSystemOptions {
  155704. /**
  155705. * a node that will be used to convert local to world coordinates
  155706. */
  155707. worldParentNode?: TransformNode;
  155708. /**
  155709. * If set to true a reference of the created anchors will be kept until the next session starts
  155710. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  155711. */
  155712. doNotRemoveAnchorsOnSessionEnded?: boolean;
  155713. }
  155714. /**
  155715. * A babylon container for an XR Anchor
  155716. */
  155717. export interface IWebXRAnchor {
  155718. /**
  155719. * A babylon-assigned ID for this anchor
  155720. */
  155721. id: number;
  155722. /**
  155723. * Transformation matrix to apply to an object attached to this anchor
  155724. */
  155725. transformationMatrix: Matrix;
  155726. /**
  155727. * The native anchor object
  155728. */
  155729. xrAnchor: XRAnchor;
  155730. /**
  155731. * if defined, this object will be constantly updated by the anchor's position and rotation
  155732. */
  155733. attachedNode?: TransformNode;
  155734. }
  155735. /**
  155736. * An implementation of the anchor system for WebXR.
  155737. * For further information see https://github.com/immersive-web/anchors/
  155738. */
  155739. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  155740. private _options;
  155741. private _lastFrameDetected;
  155742. private _trackedAnchors;
  155743. private _referenceSpaceForFrameAnchors;
  155744. private _futureAnchors;
  155745. /**
  155746. * The module's name
  155747. */
  155748. static readonly Name: string;
  155749. /**
  155750. * The (Babylon) version of this module.
  155751. * This is an integer representing the implementation version.
  155752. * This number does not correspond to the WebXR specs version
  155753. */
  155754. static readonly Version: number;
  155755. /**
  155756. * Observers registered here will be executed when a new anchor was added to the session
  155757. */
  155758. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  155759. /**
  155760. * Observers registered here will be executed when an anchor was removed from the session
  155761. */
  155762. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  155763. /**
  155764. * Observers registered here will be executed when an existing anchor updates
  155765. * This can execute N times every frame
  155766. */
  155767. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  155768. /**
  155769. * Set the reference space to use for anchor creation, when not using a hit test.
  155770. * Will default to the session's reference space if not defined
  155771. */
  155772. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  155773. /**
  155774. * constructs a new anchor system
  155775. * @param _xrSessionManager an instance of WebXRSessionManager
  155776. * @param _options configuration object for this feature
  155777. */
  155778. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  155779. private _tmpVector;
  155780. private _tmpQuaternion;
  155781. private _populateTmpTransformation;
  155782. /**
  155783. * Create a new anchor point using a hit test result at a specific point in the scene
  155784. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155785. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155786. *
  155787. * @param hitTestResult The hit test result to use for this anchor creation
  155788. * @param position an optional position offset for this anchor
  155789. * @param rotationQuaternion an optional rotation offset for this anchor
  155790. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155791. */
  155792. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  155793. /**
  155794. * Add a new anchor at a specific position and rotation
  155795. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  155796. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  155797. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155798. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155799. *
  155800. * @param position the position in which to add an anchor
  155801. * @param rotationQuaternion an optional rotation for the anchor transformation
  155802. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  155803. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155804. */
  155805. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  155806. /**
  155807. * detach this feature.
  155808. * Will usually be called by the features manager
  155809. *
  155810. * @returns true if successful.
  155811. */
  155812. detach(): boolean;
  155813. /**
  155814. * Dispose this feature and all of the resources attached
  155815. */
  155816. dispose(): void;
  155817. protected _onXRFrame(frame: XRFrame): void;
  155818. /**
  155819. * avoiding using Array.find for global support.
  155820. * @param xrAnchor the plane to find in the array
  155821. */
  155822. private _findIndexInAnchorArray;
  155823. private _updateAnchorWithXRFrame;
  155824. private _createAnchorAtTransformation;
  155825. }
  155826. }
  155827. declare module BABYLON {
  155828. /**
  155829. * Options used in the plane detector module
  155830. */
  155831. export interface IWebXRPlaneDetectorOptions {
  155832. /**
  155833. * The node to use to transform the local results to world coordinates
  155834. */
  155835. worldParentNode?: TransformNode;
  155836. /**
  155837. * If set to true a reference of the created planes will be kept until the next session starts
  155838. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  155839. */
  155840. doNotRemovePlanesOnSessionEnded?: boolean;
  155841. }
  155842. /**
  155843. * A babylon interface for a WebXR plane.
  155844. * A Plane is actually a polygon, built from N points in space
  155845. *
  155846. * Supported in chrome 79, not supported in canary 81 ATM
  155847. */
  155848. export interface IWebXRPlane {
  155849. /**
  155850. * a babylon-assigned ID for this polygon
  155851. */
  155852. id: number;
  155853. /**
  155854. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  155855. */
  155856. polygonDefinition: Array<Vector3>;
  155857. /**
  155858. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  155859. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  155860. */
  155861. transformationMatrix: Matrix;
  155862. /**
  155863. * the native xr-plane object
  155864. */
  155865. xrPlane: XRPlane;
  155866. }
  155867. /**
  155868. * The plane detector is used to detect planes in the real world when in AR
  155869. * For more information see https://github.com/immersive-web/real-world-geometry/
  155870. */
  155871. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  155872. private _options;
  155873. private _detectedPlanes;
  155874. private _enabled;
  155875. private _lastFrameDetected;
  155876. /**
  155877. * The module's name
  155878. */
  155879. static readonly Name: string;
  155880. /**
  155881. * The (Babylon) version of this module.
  155882. * This is an integer representing the implementation version.
  155883. * This number does not correspond to the WebXR specs version
  155884. */
  155885. static readonly Version: number;
  155886. /**
  155887. * Observers registered here will be executed when a new plane was added to the session
  155888. */
  155889. onPlaneAddedObservable: Observable<IWebXRPlane>;
  155890. /**
  155891. * Observers registered here will be executed when a plane is no longer detected in the session
  155892. */
  155893. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  155894. /**
  155895. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  155896. * This can execute N times every frame
  155897. */
  155898. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  155899. /**
  155900. * construct a new Plane Detector
  155901. * @param _xrSessionManager an instance of xr Session manager
  155902. * @param _options configuration to use when constructing this feature
  155903. */
  155904. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  155905. /**
  155906. * detach this feature.
  155907. * Will usually be called by the features manager
  155908. *
  155909. * @returns true if successful.
  155910. */
  155911. detach(): boolean;
  155912. /**
  155913. * Dispose this feature and all of the resources attached
  155914. */
  155915. dispose(): void;
  155916. protected _onXRFrame(frame: XRFrame): void;
  155917. private _init;
  155918. private _updatePlaneWithXRPlane;
  155919. /**
  155920. * avoiding using Array.find for global support.
  155921. * @param xrPlane the plane to find in the array
  155922. */
  155923. private findIndexInPlaneArray;
  155924. }
  155925. }
  155926. declare module BABYLON {
  155927. /**
  155928. * Options interface for the background remover plugin
  155929. */
  155930. export interface IWebXRBackgroundRemoverOptions {
  155931. /**
  155932. * Further background meshes to disable when entering AR
  155933. */
  155934. backgroundMeshes?: AbstractMesh[];
  155935. /**
  155936. * flags to configure the removal of the environment helper.
  155937. * If not set, the entire background will be removed. If set, flags should be set as well.
  155938. */
  155939. environmentHelperRemovalFlags?: {
  155940. /**
  155941. * Should the skybox be removed (default false)
  155942. */
  155943. skyBox?: boolean;
  155944. /**
  155945. * Should the ground be removed (default false)
  155946. */
  155947. ground?: boolean;
  155948. };
  155949. /**
  155950. * don't disable the environment helper
  155951. */
  155952. ignoreEnvironmentHelper?: boolean;
  155953. }
  155954. /**
  155955. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  155956. */
  155957. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  155958. /**
  155959. * read-only options to be used in this module
  155960. */
  155961. readonly options: IWebXRBackgroundRemoverOptions;
  155962. /**
  155963. * The module's name
  155964. */
  155965. static readonly Name: string;
  155966. /**
  155967. * The (Babylon) version of this module.
  155968. * This is an integer representing the implementation version.
  155969. * This number does not correspond to the WebXR specs version
  155970. */
  155971. static readonly Version: number;
  155972. /**
  155973. * registered observers will be triggered when the background state changes
  155974. */
  155975. onBackgroundStateChangedObservable: Observable<boolean>;
  155976. /**
  155977. * constructs a new background remover module
  155978. * @param _xrSessionManager the session manager for this module
  155979. * @param options read-only options to be used in this module
  155980. */
  155981. constructor(_xrSessionManager: WebXRSessionManager,
  155982. /**
  155983. * read-only options to be used in this module
  155984. */
  155985. options?: IWebXRBackgroundRemoverOptions);
  155986. /**
  155987. * attach this feature
  155988. * Will usually be called by the features manager
  155989. *
  155990. * @returns true if successful.
  155991. */
  155992. attach(): boolean;
  155993. /**
  155994. * detach this feature.
  155995. * Will usually be called by the features manager
  155996. *
  155997. * @returns true if successful.
  155998. */
  155999. detach(): boolean;
  156000. /**
  156001. * Dispose this feature and all of the resources attached
  156002. */
  156003. dispose(): void;
  156004. protected _onXRFrame(_xrFrame: XRFrame): void;
  156005. private _setBackgroundState;
  156006. }
  156007. }
  156008. declare module BABYLON {
  156009. /**
  156010. * Options for the controller physics feature
  156011. */
  156012. export class IWebXRControllerPhysicsOptions {
  156013. /**
  156014. * Should the headset get its own impostor
  156015. */
  156016. enableHeadsetImpostor?: boolean;
  156017. /**
  156018. * Optional parameters for the headset impostor
  156019. */
  156020. headsetImpostorParams?: {
  156021. /**
  156022. * The type of impostor to create. Default is sphere
  156023. */
  156024. impostorType: number;
  156025. /**
  156026. * the size of the impostor. Defaults to 10cm
  156027. */
  156028. impostorSize?: number | {
  156029. width: number;
  156030. height: number;
  156031. depth: number;
  156032. };
  156033. /**
  156034. * Friction definitions
  156035. */
  156036. friction?: number;
  156037. /**
  156038. * Restitution
  156039. */
  156040. restitution?: number;
  156041. };
  156042. /**
  156043. * The physics properties of the future impostors
  156044. */
  156045. physicsProperties?: {
  156046. /**
  156047. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  156048. * Note that this requires a physics engine that supports mesh impostors!
  156049. */
  156050. useControllerMesh?: boolean;
  156051. /**
  156052. * The type of impostor to create. Default is sphere
  156053. */
  156054. impostorType?: number;
  156055. /**
  156056. * the size of the impostor. Defaults to 10cm
  156057. */
  156058. impostorSize?: number | {
  156059. width: number;
  156060. height: number;
  156061. depth: number;
  156062. };
  156063. /**
  156064. * Friction definitions
  156065. */
  156066. friction?: number;
  156067. /**
  156068. * Restitution
  156069. */
  156070. restitution?: number;
  156071. };
  156072. /**
  156073. * the xr input to use with this pointer selection
  156074. */
  156075. xrInput: WebXRInput;
  156076. }
  156077. /**
  156078. * Add physics impostor to your webxr controllers,
  156079. * including naive calculation of their linear and angular velocity
  156080. */
  156081. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  156082. private readonly _options;
  156083. private _attachController;
  156084. private _controllers;
  156085. private _debugMode;
  156086. private _delta;
  156087. private _headsetImpostor?;
  156088. private _headsetMesh?;
  156089. private _lastTimestamp;
  156090. private _tmpQuaternion;
  156091. private _tmpVector;
  156092. /**
  156093. * The module's name
  156094. */
  156095. static readonly Name: string;
  156096. /**
  156097. * The (Babylon) version of this module.
  156098. * This is an integer representing the implementation version.
  156099. * This number does not correspond to the webxr specs version
  156100. */
  156101. static readonly Version: number;
  156102. /**
  156103. * Construct a new Controller Physics Feature
  156104. * @param _xrSessionManager the corresponding xr session manager
  156105. * @param _options options to create this feature with
  156106. */
  156107. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  156108. /**
  156109. * @hidden
  156110. * enable debugging - will show console outputs and the impostor mesh
  156111. */
  156112. _enablePhysicsDebug(): void;
  156113. /**
  156114. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  156115. * @param xrController the controller to add
  156116. */
  156117. addController(xrController: WebXRInputSource): void;
  156118. /**
  156119. * attach this feature
  156120. * Will usually be called by the features manager
  156121. *
  156122. * @returns true if successful.
  156123. */
  156124. attach(): boolean;
  156125. /**
  156126. * detach this feature.
  156127. * Will usually be called by the features manager
  156128. *
  156129. * @returns true if successful.
  156130. */
  156131. detach(): boolean;
  156132. /**
  156133. * Get the headset impostor, if enabled
  156134. * @returns the impostor
  156135. */
  156136. getHeadsetImpostor(): PhysicsImpostor | undefined;
  156137. /**
  156138. * Get the physics impostor of a specific controller.
  156139. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  156140. * @param controller the controller or the controller id of which to get the impostor
  156141. * @returns the impostor or null
  156142. */
  156143. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  156144. /**
  156145. * Update the physics properties provided in the constructor
  156146. * @param newProperties the new properties object
  156147. */
  156148. setPhysicsProperties(newProperties: {
  156149. impostorType?: number;
  156150. impostorSize?: number | {
  156151. width: number;
  156152. height: number;
  156153. depth: number;
  156154. };
  156155. friction?: number;
  156156. restitution?: number;
  156157. }): void;
  156158. protected _onXRFrame(_xrFrame: any): void;
  156159. private _detachController;
  156160. }
  156161. }
  156162. declare module BABYLON {
  156163. /**
  156164. * A babylon interface for a "WebXR" feature point.
  156165. * Represents the position and confidence value of a given feature point.
  156166. */
  156167. export interface IWebXRFeaturePoint {
  156168. /**
  156169. * Represents the position of the feature point in world space.
  156170. */
  156171. position: Vector3;
  156172. /**
  156173. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  156174. */
  156175. confidenceValue: number;
  156176. }
  156177. /**
  156178. * The feature point system is used to detect feature points from real world geometry.
  156179. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  156180. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  156181. */
  156182. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  156183. private _enabled;
  156184. private _featurePointCloud;
  156185. /**
  156186. * The module's name
  156187. */
  156188. static readonly Name: string;
  156189. /**
  156190. * The (Babylon) version of this module.
  156191. * This is an integer representing the implementation version.
  156192. * This number does not correspond to the WebXR specs version
  156193. */
  156194. static readonly Version: number;
  156195. /**
  156196. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  156197. * Will notify the observers about which feature points have been added.
  156198. */
  156199. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  156200. /**
  156201. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  156202. * Will notify the observers about which feature points have been updated.
  156203. */
  156204. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  156205. /**
  156206. * The current feature point cloud maintained across frames.
  156207. */
  156208. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  156209. /**
  156210. * construct the feature point system
  156211. * @param _xrSessionManager an instance of xr Session manager
  156212. */
  156213. constructor(_xrSessionManager: WebXRSessionManager);
  156214. /**
  156215. * Detach this feature.
  156216. * Will usually be called by the features manager
  156217. *
  156218. * @returns true if successful.
  156219. */
  156220. detach(): boolean;
  156221. /**
  156222. * Dispose this feature and all of the resources attached
  156223. */
  156224. dispose(): void;
  156225. /**
  156226. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  156227. */
  156228. protected _onXRFrame(frame: XRFrame): void;
  156229. /**
  156230. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  156231. */
  156232. private _init;
  156233. }
  156234. }
  156235. declare module BABYLON {
  156236. /**
  156237. * Configuration interface for the hand tracking feature
  156238. */
  156239. export interface IWebXRHandTrackingOptions {
  156240. /**
  156241. * The xrInput that will be used as source for new hands
  156242. */
  156243. xrInput: WebXRInput;
  156244. /**
  156245. * Configuration object for the joint meshes
  156246. */
  156247. jointMeshes?: {
  156248. /**
  156249. * Should the meshes created be invisible (defaults to false)
  156250. */
  156251. invisible?: boolean;
  156252. /**
  156253. * A source mesh to be used to create instances. Defaults to a sphere.
  156254. * This mesh will be the source for all other (25) meshes.
  156255. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  156256. */
  156257. sourceMesh?: Mesh;
  156258. /**
  156259. * This function will be called after a mesh was created for a specific joint.
  156260. * Using this function you can either manipulate the instance or return a new mesh.
  156261. * When returning a new mesh the instance created before will be disposed
  156262. */
  156263. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  156264. /**
  156265. * Should the source mesh stay visible. Defaults to false
  156266. */
  156267. keepOriginalVisible?: boolean;
  156268. /**
  156269. * Scale factor for all instances (defaults to 2)
  156270. */
  156271. scaleFactor?: number;
  156272. /**
  156273. * Should each instance have its own physics impostor
  156274. */
  156275. enablePhysics?: boolean;
  156276. /**
  156277. * If enabled, override default physics properties
  156278. */
  156279. physicsProps?: {
  156280. friction?: number;
  156281. restitution?: number;
  156282. impostorType?: number;
  156283. };
  156284. /**
  156285. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  156286. */
  156287. handMesh?: AbstractMesh;
  156288. };
  156289. }
  156290. /**
  156291. * Parts of the hands divided to writs and finger names
  156292. */
  156293. export const enum HandPart {
  156294. /**
  156295. * HandPart - Wrist
  156296. */
  156297. WRIST = "wrist",
  156298. /**
  156299. * HandPart - The THumb
  156300. */
  156301. THUMB = "thumb",
  156302. /**
  156303. * HandPart - Index finger
  156304. */
  156305. INDEX = "index",
  156306. /**
  156307. * HandPart - Middle finger
  156308. */
  156309. MIDDLE = "middle",
  156310. /**
  156311. * HandPart - Ring finger
  156312. */
  156313. RING = "ring",
  156314. /**
  156315. * HandPart - Little finger
  156316. */
  156317. LITTLE = "little"
  156318. }
  156319. /**
  156320. * Representing a single hand (with its corresponding native XRHand object)
  156321. */
  156322. export class WebXRHand implements IDisposable {
  156323. /** the controller to which the hand correlates */
  156324. readonly xrController: WebXRInputSource;
  156325. /** the meshes to be used to track the hand joints */
  156326. readonly trackedMeshes: AbstractMesh[];
  156327. /**
  156328. * Hand-parts definition (key is HandPart)
  156329. */
  156330. handPartsDefinition: {
  156331. [key: string]: number[];
  156332. };
  156333. /**
  156334. * Populate the HandPartsDefinition object.
  156335. * This is called as a side effect since certain browsers don't have XRHand defined.
  156336. */
  156337. private generateHandPartsDefinition;
  156338. /**
  156339. * Construct a new hand object
  156340. * @param xrController the controller to which the hand correlates
  156341. * @param trackedMeshes the meshes to be used to track the hand joints
  156342. */
  156343. constructor(
  156344. /** the controller to which the hand correlates */
  156345. xrController: WebXRInputSource,
  156346. /** the meshes to be used to track the hand joints */
  156347. trackedMeshes: AbstractMesh[]);
  156348. /**
  156349. * Update this hand from the latest xr frame
  156350. * @param xrFrame xrFrame to update from
  156351. * @param referenceSpace The current viewer reference space
  156352. * @param scaleFactor optional scale factor for the meshes
  156353. */
  156354. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  156355. /**
  156356. * Get meshes of part of the hand
  156357. * @param part the part of hand to get
  156358. * @returns An array of meshes that correlate to the hand part requested
  156359. */
  156360. getHandPartMeshes(part: HandPart): AbstractMesh[];
  156361. /**
  156362. * Dispose this Hand object
  156363. */
  156364. dispose(): void;
  156365. }
  156366. /**
  156367. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  156368. */
  156369. export class WebXRHandTracking extends WebXRAbstractFeature {
  156370. /**
  156371. * options to use when constructing this feature
  156372. */
  156373. readonly options: IWebXRHandTrackingOptions;
  156374. private static _idCounter;
  156375. /**
  156376. * The module's name
  156377. */
  156378. static readonly Name: string;
  156379. /**
  156380. * The (Babylon) version of this module.
  156381. * This is an integer representing the implementation version.
  156382. * This number does not correspond to the WebXR specs version
  156383. */
  156384. static readonly Version: number;
  156385. /**
  156386. * This observable will notify registered observers when a new hand object was added and initialized
  156387. */
  156388. onHandAddedObservable: Observable<WebXRHand>;
  156389. /**
  156390. * This observable will notify its observers right before the hand object is disposed
  156391. */
  156392. onHandRemovedObservable: Observable<WebXRHand>;
  156393. private _hands;
  156394. /**
  156395. * Creates a new instance of the hit test feature
  156396. * @param _xrSessionManager an instance of WebXRSessionManager
  156397. * @param options options to use when constructing this feature
  156398. */
  156399. constructor(_xrSessionManager: WebXRSessionManager,
  156400. /**
  156401. * options to use when constructing this feature
  156402. */
  156403. options: IWebXRHandTrackingOptions);
  156404. /**
  156405. * Check if the needed objects are defined.
  156406. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  156407. */
  156408. isCompatible(): boolean;
  156409. /**
  156410. * attach this feature
  156411. * Will usually be called by the features manager
  156412. *
  156413. * @returns true if successful.
  156414. */
  156415. attach(): boolean;
  156416. /**
  156417. * detach this feature.
  156418. * Will usually be called by the features manager
  156419. *
  156420. * @returns true if successful.
  156421. */
  156422. detach(): boolean;
  156423. /**
  156424. * Dispose this feature and all of the resources attached
  156425. */
  156426. dispose(): void;
  156427. /**
  156428. * Get the hand object according to the controller id
  156429. * @param controllerId the controller id to which we want to get the hand
  156430. * @returns null if not found or the WebXRHand object if found
  156431. */
  156432. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  156433. /**
  156434. * Get a hand object according to the requested handedness
  156435. * @param handedness the handedness to request
  156436. * @returns null if not found or the WebXRHand object if found
  156437. */
  156438. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  156439. protected _onXRFrame(_xrFrame: XRFrame): void;
  156440. private _attachHand;
  156441. private _detachHand;
  156442. }
  156443. }
  156444. declare module BABYLON {
  156445. /**
  156446. * The motion controller class for all microsoft mixed reality controllers
  156447. */
  156448. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156449. protected readonly _mapping: {
  156450. defaultButton: {
  156451. valueNodeName: string;
  156452. unpressedNodeName: string;
  156453. pressedNodeName: string;
  156454. };
  156455. defaultAxis: {
  156456. valueNodeName: string;
  156457. minNodeName: string;
  156458. maxNodeName: string;
  156459. };
  156460. buttons: {
  156461. "xr-standard-trigger": {
  156462. rootNodeName: string;
  156463. componentProperty: string;
  156464. states: string[];
  156465. };
  156466. "xr-standard-squeeze": {
  156467. rootNodeName: string;
  156468. componentProperty: string;
  156469. states: string[];
  156470. };
  156471. "xr-standard-touchpad": {
  156472. rootNodeName: string;
  156473. labelAnchorNodeName: string;
  156474. touchPointNodeName: string;
  156475. };
  156476. "xr-standard-thumbstick": {
  156477. rootNodeName: string;
  156478. componentProperty: string;
  156479. states: string[];
  156480. };
  156481. };
  156482. axes: {
  156483. "xr-standard-touchpad": {
  156484. "x-axis": {
  156485. rootNodeName: string;
  156486. };
  156487. "y-axis": {
  156488. rootNodeName: string;
  156489. };
  156490. };
  156491. "xr-standard-thumbstick": {
  156492. "x-axis": {
  156493. rootNodeName: string;
  156494. };
  156495. "y-axis": {
  156496. rootNodeName: string;
  156497. };
  156498. };
  156499. };
  156500. };
  156501. /**
  156502. * The base url used to load the left and right controller models
  156503. */
  156504. static MODEL_BASE_URL: string;
  156505. /**
  156506. * The name of the left controller model file
  156507. */
  156508. static MODEL_LEFT_FILENAME: string;
  156509. /**
  156510. * The name of the right controller model file
  156511. */
  156512. static MODEL_RIGHT_FILENAME: string;
  156513. profileId: string;
  156514. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156515. protected _getFilenameAndPath(): {
  156516. filename: string;
  156517. path: string;
  156518. };
  156519. protected _getModelLoadingConstraints(): boolean;
  156520. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156521. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156522. protected _updateModel(): void;
  156523. }
  156524. }
  156525. declare module BABYLON {
  156526. /**
  156527. * The motion controller class for oculus touch (quest, rift).
  156528. * This class supports legacy mapping as well the standard xr mapping
  156529. */
  156530. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156531. private _forceLegacyControllers;
  156532. private _modelRootNode;
  156533. /**
  156534. * The base url used to load the left and right controller models
  156535. */
  156536. static MODEL_BASE_URL: string;
  156537. /**
  156538. * The name of the left controller model file
  156539. */
  156540. static MODEL_LEFT_FILENAME: string;
  156541. /**
  156542. * The name of the right controller model file
  156543. */
  156544. static MODEL_RIGHT_FILENAME: string;
  156545. /**
  156546. * Base Url for the Quest controller model.
  156547. */
  156548. static QUEST_MODEL_BASE_URL: string;
  156549. profileId: string;
  156550. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156551. protected _getFilenameAndPath(): {
  156552. filename: string;
  156553. path: string;
  156554. };
  156555. protected _getModelLoadingConstraints(): boolean;
  156556. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156557. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156558. protected _updateModel(): void;
  156559. /**
  156560. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156561. * between the touch and touch 2.
  156562. */
  156563. private _isQuest;
  156564. }
  156565. }
  156566. declare module BABYLON {
  156567. /**
  156568. * The motion controller class for the standard HTC-Vive controllers
  156569. */
  156570. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156571. private _modelRootNode;
  156572. /**
  156573. * The base url used to load the left and right controller models
  156574. */
  156575. static MODEL_BASE_URL: string;
  156576. /**
  156577. * File name for the controller model.
  156578. */
  156579. static MODEL_FILENAME: string;
  156580. profileId: string;
  156581. /**
  156582. * Create a new Vive motion controller object
  156583. * @param scene the scene to use to create this controller
  156584. * @param gamepadObject the corresponding gamepad object
  156585. * @param handedness the handedness of the controller
  156586. */
  156587. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156588. protected _getFilenameAndPath(): {
  156589. filename: string;
  156590. path: string;
  156591. };
  156592. protected _getModelLoadingConstraints(): boolean;
  156593. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156594. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156595. protected _updateModel(): void;
  156596. }
  156597. }
  156598. declare module BABYLON {
  156599. /**
  156600. * A cursor which tracks a point on a path
  156601. */
  156602. export class PathCursor {
  156603. private path;
  156604. /**
  156605. * Stores path cursor callbacks for when an onchange event is triggered
  156606. */
  156607. private _onchange;
  156608. /**
  156609. * The value of the path cursor
  156610. */
  156611. value: number;
  156612. /**
  156613. * The animation array of the path cursor
  156614. */
  156615. animations: Animation[];
  156616. /**
  156617. * Initializes the path cursor
  156618. * @param path The path to track
  156619. */
  156620. constructor(path: Path2);
  156621. /**
  156622. * Gets the cursor point on the path
  156623. * @returns A point on the path cursor at the cursor location
  156624. */
  156625. getPoint(): Vector3;
  156626. /**
  156627. * Moves the cursor ahead by the step amount
  156628. * @param step The amount to move the cursor forward
  156629. * @returns This path cursor
  156630. */
  156631. moveAhead(step?: number): PathCursor;
  156632. /**
  156633. * Moves the cursor behind by the step amount
  156634. * @param step The amount to move the cursor back
  156635. * @returns This path cursor
  156636. */
  156637. moveBack(step?: number): PathCursor;
  156638. /**
  156639. * Moves the cursor by the step amount
  156640. * If the step amount is greater than one, an exception is thrown
  156641. * @param step The amount to move the cursor
  156642. * @returns This path cursor
  156643. */
  156644. move(step: number): PathCursor;
  156645. /**
  156646. * Ensures that the value is limited between zero and one
  156647. * @returns This path cursor
  156648. */
  156649. private ensureLimits;
  156650. /**
  156651. * Runs onchange callbacks on change (used by the animation engine)
  156652. * @returns This path cursor
  156653. */
  156654. private raiseOnChange;
  156655. /**
  156656. * Executes a function on change
  156657. * @param f A path cursor onchange callback
  156658. * @returns This path cursor
  156659. */
  156660. onchange(f: (cursor: PathCursor) => void): PathCursor;
  156661. }
  156662. }
  156663. declare module BABYLON {
  156664. /** @hidden */
  156665. export var blurPixelShader: {
  156666. name: string;
  156667. shader: string;
  156668. };
  156669. }
  156670. declare module BABYLON {
  156671. /** @hidden */
  156672. export var pointCloudVertexDeclaration: {
  156673. name: string;
  156674. shader: string;
  156675. };
  156676. }
  156677. // Mixins
  156678. interface Window {
  156679. mozIndexedDB: IDBFactory;
  156680. webkitIndexedDB: IDBFactory;
  156681. msIndexedDB: IDBFactory;
  156682. webkitURL: typeof URL;
  156683. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  156684. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  156685. WebGLRenderingContext: WebGLRenderingContext;
  156686. MSGesture: MSGesture;
  156687. CANNON: any;
  156688. AudioContext: AudioContext;
  156689. webkitAudioContext: AudioContext;
  156690. PointerEvent: any;
  156691. Math: Math;
  156692. Uint8Array: Uint8ArrayConstructor;
  156693. Float32Array: Float32ArrayConstructor;
  156694. mozURL: typeof URL;
  156695. msURL: typeof URL;
  156696. VRFrameData: any; // WebVR, from specs 1.1
  156697. DracoDecoderModule: any;
  156698. setImmediate(handler: (...args: any[]) => void): number;
  156699. }
  156700. interface HTMLCanvasElement {
  156701. requestPointerLock(): void;
  156702. msRequestPointerLock?(): void;
  156703. mozRequestPointerLock?(): void;
  156704. webkitRequestPointerLock?(): void;
  156705. /** Track wether a record is in progress */
  156706. isRecording: boolean;
  156707. /** Capture Stream method defined by some browsers */
  156708. captureStream(fps?: number): MediaStream;
  156709. }
  156710. interface CanvasRenderingContext2D {
  156711. msImageSmoothingEnabled: boolean;
  156712. }
  156713. interface MouseEvent {
  156714. mozMovementX: number;
  156715. mozMovementY: number;
  156716. webkitMovementX: number;
  156717. webkitMovementY: number;
  156718. msMovementX: number;
  156719. msMovementY: number;
  156720. }
  156721. interface Navigator {
  156722. mozGetVRDevices: (any: any) => any;
  156723. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156724. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156725. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156726. webkitGetGamepads(): Gamepad[];
  156727. msGetGamepads(): Gamepad[];
  156728. webkitGamepads(): Gamepad[];
  156729. }
  156730. interface HTMLVideoElement {
  156731. mozSrcObject: any;
  156732. }
  156733. interface Math {
  156734. fround(x: number): number;
  156735. imul(a: number, b: number): number;
  156736. }
  156737. interface WebGLRenderingContext {
  156738. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  156739. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  156740. vertexAttribDivisor(index: number, divisor: number): void;
  156741. createVertexArray(): any;
  156742. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  156743. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  156744. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  156745. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  156746. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  156747. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  156748. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  156749. // Queries
  156750. createQuery(): WebGLQuery;
  156751. deleteQuery(query: WebGLQuery): void;
  156752. beginQuery(target: number, query: WebGLQuery): void;
  156753. endQuery(target: number): void;
  156754. getQueryParameter(query: WebGLQuery, pname: number): any;
  156755. getQuery(target: number, pname: number): any;
  156756. MAX_SAMPLES: number;
  156757. RGBA8: number;
  156758. READ_FRAMEBUFFER: number;
  156759. DRAW_FRAMEBUFFER: number;
  156760. UNIFORM_BUFFER: number;
  156761. HALF_FLOAT_OES: number;
  156762. RGBA16F: number;
  156763. RGBA32F: number;
  156764. R32F: number;
  156765. RG32F: number;
  156766. RGB32F: number;
  156767. R16F: number;
  156768. RG16F: number;
  156769. RGB16F: number;
  156770. RED: number;
  156771. RG: number;
  156772. R8: number;
  156773. RG8: number;
  156774. UNSIGNED_INT_24_8: number;
  156775. DEPTH24_STENCIL8: number;
  156776. MIN: number;
  156777. MAX: number;
  156778. /* Multiple Render Targets */
  156779. drawBuffers(buffers: number[]): void;
  156780. readBuffer(src: number): void;
  156781. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  156782. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  156783. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  156784. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  156785. // Occlusion Query
  156786. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  156787. ANY_SAMPLES_PASSED: number;
  156788. QUERY_RESULT_AVAILABLE: number;
  156789. QUERY_RESULT: number;
  156790. }
  156791. interface WebGLProgram {
  156792. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  156793. }
  156794. interface EXT_disjoint_timer_query {
  156795. QUERY_COUNTER_BITS_EXT: number;
  156796. TIME_ELAPSED_EXT: number;
  156797. TIMESTAMP_EXT: number;
  156798. GPU_DISJOINT_EXT: number;
  156799. QUERY_RESULT_EXT: number;
  156800. QUERY_RESULT_AVAILABLE_EXT: number;
  156801. queryCounterEXT(query: WebGLQuery, target: number): void;
  156802. createQueryEXT(): WebGLQuery;
  156803. beginQueryEXT(target: number, query: WebGLQuery): void;
  156804. endQueryEXT(target: number): void;
  156805. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  156806. deleteQueryEXT(query: WebGLQuery): void;
  156807. }
  156808. interface WebGLUniformLocation {
  156809. _currentState: any;
  156810. }
  156811. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  156812. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  156813. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  156814. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156815. interface WebGLRenderingContext {
  156816. readonly RASTERIZER_DISCARD: number;
  156817. readonly DEPTH_COMPONENT24: number;
  156818. readonly TEXTURE_3D: number;
  156819. readonly TEXTURE_2D_ARRAY: number;
  156820. readonly TEXTURE_COMPARE_FUNC: number;
  156821. readonly TEXTURE_COMPARE_MODE: number;
  156822. readonly COMPARE_REF_TO_TEXTURE: number;
  156823. readonly TEXTURE_WRAP_R: number;
  156824. readonly HALF_FLOAT: number;
  156825. readonly RGB8: number;
  156826. readonly RED_INTEGER: number;
  156827. readonly RG_INTEGER: number;
  156828. readonly RGB_INTEGER: number;
  156829. readonly RGBA_INTEGER: number;
  156830. readonly R8_SNORM: number;
  156831. readonly RG8_SNORM: number;
  156832. readonly RGB8_SNORM: number;
  156833. readonly RGBA8_SNORM: number;
  156834. readonly R8I: number;
  156835. readonly RG8I: number;
  156836. readonly RGB8I: number;
  156837. readonly RGBA8I: number;
  156838. readonly R8UI: number;
  156839. readonly RG8UI: number;
  156840. readonly RGB8UI: number;
  156841. readonly RGBA8UI: number;
  156842. readonly R16I: number;
  156843. readonly RG16I: number;
  156844. readonly RGB16I: number;
  156845. readonly RGBA16I: number;
  156846. readonly R16UI: number;
  156847. readonly RG16UI: number;
  156848. readonly RGB16UI: number;
  156849. readonly RGBA16UI: number;
  156850. readonly R32I: number;
  156851. readonly RG32I: number;
  156852. readonly RGB32I: number;
  156853. readonly RGBA32I: number;
  156854. readonly R32UI: number;
  156855. readonly RG32UI: number;
  156856. readonly RGB32UI: number;
  156857. readonly RGBA32UI: number;
  156858. readonly RGB10_A2UI: number;
  156859. readonly R11F_G11F_B10F: number;
  156860. readonly RGB9_E5: number;
  156861. readonly RGB10_A2: number;
  156862. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  156863. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  156864. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  156865. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  156866. readonly DEPTH_COMPONENT32F: number;
  156867. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  156868. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  156869. 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;
  156870. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  156871. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  156872. readonly TRANSFORM_FEEDBACK: number;
  156873. readonly INTERLEAVED_ATTRIBS: number;
  156874. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  156875. createTransformFeedback(): WebGLTransformFeedback;
  156876. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  156877. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  156878. beginTransformFeedback(primitiveMode: number): void;
  156879. endTransformFeedback(): void;
  156880. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  156881. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156882. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156883. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156884. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  156885. }
  156886. interface ImageBitmap {
  156887. readonly width: number;
  156888. readonly height: number;
  156889. close(): void;
  156890. }
  156891. interface WebGLQuery extends WebGLObject {
  156892. }
  156893. declare var WebGLQuery: {
  156894. prototype: WebGLQuery;
  156895. new(): WebGLQuery;
  156896. };
  156897. interface WebGLSampler extends WebGLObject {
  156898. }
  156899. declare var WebGLSampler: {
  156900. prototype: WebGLSampler;
  156901. new(): WebGLSampler;
  156902. };
  156903. interface WebGLSync extends WebGLObject {
  156904. }
  156905. declare var WebGLSync: {
  156906. prototype: WebGLSync;
  156907. new(): WebGLSync;
  156908. };
  156909. interface WebGLTransformFeedback extends WebGLObject {
  156910. }
  156911. declare var WebGLTransformFeedback: {
  156912. prototype: WebGLTransformFeedback;
  156913. new(): WebGLTransformFeedback;
  156914. };
  156915. interface WebGLVertexArrayObject extends WebGLObject {
  156916. }
  156917. declare var WebGLVertexArrayObject: {
  156918. prototype: WebGLVertexArrayObject;
  156919. new(): WebGLVertexArrayObject;
  156920. };
  156921. // Type definitions for WebVR API
  156922. // Project: https://w3c.github.io/webvr/
  156923. // Definitions by: six a <https://github.com/lostfictions>
  156924. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156925. interface VRDisplay extends EventTarget {
  156926. /**
  156927. * Dictionary of capabilities describing the VRDisplay.
  156928. */
  156929. readonly capabilities: VRDisplayCapabilities;
  156930. /**
  156931. * z-depth defining the far plane of the eye view frustum
  156932. * enables mapping of values in the render target depth
  156933. * attachment to scene coordinates. Initially set to 10000.0.
  156934. */
  156935. depthFar: number;
  156936. /**
  156937. * z-depth defining the near plane of the eye view frustum
  156938. * enables mapping of values in the render target depth
  156939. * attachment to scene coordinates. Initially set to 0.01.
  156940. */
  156941. depthNear: number;
  156942. /**
  156943. * An identifier for this distinct VRDisplay. Used as an
  156944. * association point in the Gamepad API.
  156945. */
  156946. readonly displayId: number;
  156947. /**
  156948. * A display name, a user-readable name identifying it.
  156949. */
  156950. readonly displayName: string;
  156951. readonly isConnected: boolean;
  156952. readonly isPresenting: boolean;
  156953. /**
  156954. * If this VRDisplay supports room-scale experiences, the optional
  156955. * stage attribute contains details on the room-scale parameters.
  156956. */
  156957. readonly stageParameters: VRStageParameters | null;
  156958. /**
  156959. * Passing the value returned by `requestAnimationFrame` to
  156960. * `cancelAnimationFrame` will unregister the callback.
  156961. * @param handle Define the hanle of the request to cancel
  156962. */
  156963. cancelAnimationFrame(handle: number): void;
  156964. /**
  156965. * Stops presenting to the VRDisplay.
  156966. * @returns a promise to know when it stopped
  156967. */
  156968. exitPresent(): Promise<void>;
  156969. /**
  156970. * Return the current VREyeParameters for the given eye.
  156971. * @param whichEye Define the eye we want the parameter for
  156972. * @returns the eye parameters
  156973. */
  156974. getEyeParameters(whichEye: string): VREyeParameters;
  156975. /**
  156976. * Populates the passed VRFrameData with the information required to render
  156977. * the current frame.
  156978. * @param frameData Define the data structure to populate
  156979. * @returns true if ok otherwise false
  156980. */
  156981. getFrameData(frameData: VRFrameData): boolean;
  156982. /**
  156983. * Get the layers currently being presented.
  156984. * @returns the list of VR layers
  156985. */
  156986. getLayers(): VRLayer[];
  156987. /**
  156988. * Return a VRPose containing the future predicted pose of the VRDisplay
  156989. * when the current frame will be presented. The value returned will not
  156990. * change until JavaScript has returned control to the browser.
  156991. *
  156992. * The VRPose will contain the position, orientation, velocity,
  156993. * and acceleration of each of these properties.
  156994. * @returns the pose object
  156995. */
  156996. getPose(): VRPose;
  156997. /**
  156998. * Return the current instantaneous pose of the VRDisplay, with no
  156999. * prediction applied.
  157000. * @returns the current instantaneous pose
  157001. */
  157002. getImmediatePose(): VRPose;
  157003. /**
  157004. * The callback passed to `requestAnimationFrame` will be called
  157005. * any time a new frame should be rendered. When the VRDisplay is
  157006. * presenting the callback will be called at the native refresh
  157007. * rate of the HMD. When not presenting this function acts
  157008. * identically to how window.requestAnimationFrame acts. Content should
  157009. * make no assumptions of frame rate or vsync behavior as the HMD runs
  157010. * asynchronously from other displays and at differing refresh rates.
  157011. * @param callback Define the eaction to run next frame
  157012. * @returns the request handle it
  157013. */
  157014. requestAnimationFrame(callback: FrameRequestCallback): number;
  157015. /**
  157016. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  157017. * Repeat calls while already presenting will update the VRLayers being displayed.
  157018. * @param layers Define the list of layer to present
  157019. * @returns a promise to know when the request has been fulfilled
  157020. */
  157021. requestPresent(layers: VRLayer[]): Promise<void>;
  157022. /**
  157023. * Reset the pose for this display, treating its current position and
  157024. * orientation as the "origin/zero" values. VRPose.position,
  157025. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  157026. * updated when calling resetPose(). This should be called in only
  157027. * sitting-space experiences.
  157028. */
  157029. resetPose(): void;
  157030. /**
  157031. * The VRLayer provided to the VRDisplay will be captured and presented
  157032. * in the HMD. Calling this function has the same effect on the source
  157033. * canvas as any other operation that uses its source image, and canvases
  157034. * created without preserveDrawingBuffer set to true will be cleared.
  157035. * @param pose Define the pose to submit
  157036. */
  157037. submitFrame(pose?: VRPose): void;
  157038. }
  157039. declare var VRDisplay: {
  157040. prototype: VRDisplay;
  157041. new(): VRDisplay;
  157042. };
  157043. interface VRLayer {
  157044. leftBounds?: number[] | Float32Array | null;
  157045. rightBounds?: number[] | Float32Array | null;
  157046. source?: HTMLCanvasElement | null;
  157047. }
  157048. interface VRDisplayCapabilities {
  157049. readonly canPresent: boolean;
  157050. readonly hasExternalDisplay: boolean;
  157051. readonly hasOrientation: boolean;
  157052. readonly hasPosition: boolean;
  157053. readonly maxLayers: number;
  157054. }
  157055. interface VREyeParameters {
  157056. /** @deprecated */
  157057. readonly fieldOfView: VRFieldOfView;
  157058. readonly offset: Float32Array;
  157059. readonly renderHeight: number;
  157060. readonly renderWidth: number;
  157061. }
  157062. interface VRFieldOfView {
  157063. readonly downDegrees: number;
  157064. readonly leftDegrees: number;
  157065. readonly rightDegrees: number;
  157066. readonly upDegrees: number;
  157067. }
  157068. interface VRFrameData {
  157069. readonly leftProjectionMatrix: Float32Array;
  157070. readonly leftViewMatrix: Float32Array;
  157071. readonly pose: VRPose;
  157072. readonly rightProjectionMatrix: Float32Array;
  157073. readonly rightViewMatrix: Float32Array;
  157074. readonly timestamp: number;
  157075. }
  157076. interface VRPose {
  157077. readonly angularAcceleration: Float32Array | null;
  157078. readonly angularVelocity: Float32Array | null;
  157079. readonly linearAcceleration: Float32Array | null;
  157080. readonly linearVelocity: Float32Array | null;
  157081. readonly orientation: Float32Array | null;
  157082. readonly position: Float32Array | null;
  157083. readonly timestamp: number;
  157084. }
  157085. interface VRStageParameters {
  157086. sittingToStandingTransform?: Float32Array;
  157087. sizeX?: number;
  157088. sizeY?: number;
  157089. }
  157090. interface Navigator {
  157091. getVRDisplays(): Promise<VRDisplay[]>;
  157092. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  157093. }
  157094. interface Window {
  157095. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  157096. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  157097. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  157098. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157099. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157100. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  157101. }
  157102. interface Gamepad {
  157103. readonly displayId: number;
  157104. }
  157105. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  157106. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  157107. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  157108. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  157109. type XRHandedness = "none" | "left" | "right";
  157110. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  157111. type XREye = "none" | "left" | "right";
  157112. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  157113. interface XRSpace extends EventTarget {}
  157114. interface XRRenderState {
  157115. depthNear?: number;
  157116. depthFar?: number;
  157117. inlineVerticalFieldOfView?: number;
  157118. baseLayer?: XRWebGLLayer;
  157119. }
  157120. interface XRInputSource {
  157121. handedness: XRHandedness;
  157122. targetRayMode: XRTargetRayMode;
  157123. targetRaySpace: XRSpace;
  157124. gripSpace: XRSpace | undefined;
  157125. gamepad: Gamepad | undefined;
  157126. profiles: Array<string>;
  157127. hand: XRHand | undefined;
  157128. }
  157129. interface XRSessionInit {
  157130. optionalFeatures?: string[];
  157131. requiredFeatures?: string[];
  157132. }
  157133. interface XRSession {
  157134. addEventListener: Function;
  157135. removeEventListener: Function;
  157136. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  157137. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  157138. requestAnimationFrame: Function;
  157139. end(): Promise<void>;
  157140. renderState: XRRenderState;
  157141. inputSources: Array<XRInputSource>;
  157142. // hit test
  157143. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  157144. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  157145. // legacy AR hit test
  157146. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157147. // legacy plane detection
  157148. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  157149. }
  157150. interface XRReferenceSpace extends XRSpace {
  157151. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  157152. onreset: any;
  157153. }
  157154. type XRPlaneSet = Set<XRPlane>;
  157155. type XRAnchorSet = Set<XRAnchor>;
  157156. interface XRFrame {
  157157. session: XRSession;
  157158. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  157159. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  157160. // AR
  157161. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  157162. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  157163. // Anchors
  157164. trackedAnchors?: XRAnchorSet;
  157165. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  157166. // Planes
  157167. worldInformation: {
  157168. detectedPlanes?: XRPlaneSet;
  157169. };
  157170. // Hand tracking
  157171. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  157172. }
  157173. interface XRViewerPose extends XRPose {
  157174. views: Array<XRView>;
  157175. }
  157176. interface XRPose {
  157177. transform: XRRigidTransform;
  157178. emulatedPosition: boolean;
  157179. }
  157180. interface XRWebGLLayerOptions {
  157181. antialias?: boolean;
  157182. depth?: boolean;
  157183. stencil?: boolean;
  157184. alpha?: boolean;
  157185. multiview?: boolean;
  157186. framebufferScaleFactor?: number;
  157187. }
  157188. declare var XRWebGLLayer: {
  157189. prototype: XRWebGLLayer;
  157190. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  157191. };
  157192. interface XRWebGLLayer {
  157193. framebuffer: WebGLFramebuffer;
  157194. framebufferWidth: number;
  157195. framebufferHeight: number;
  157196. getViewport: Function;
  157197. }
  157198. declare class XRRigidTransform {
  157199. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  157200. position: DOMPointReadOnly;
  157201. orientation: DOMPointReadOnly;
  157202. matrix: Float32Array;
  157203. inverse: XRRigidTransform;
  157204. }
  157205. interface XRView {
  157206. eye: XREye;
  157207. projectionMatrix: Float32Array;
  157208. transform: XRRigidTransform;
  157209. }
  157210. interface XRInputSourceChangeEvent {
  157211. session: XRSession;
  157212. removed: Array<XRInputSource>;
  157213. added: Array<XRInputSource>;
  157214. }
  157215. interface XRInputSourceEvent extends Event {
  157216. readonly frame: XRFrame;
  157217. readonly inputSource: XRInputSource;
  157218. }
  157219. // Experimental(er) features
  157220. declare class XRRay {
  157221. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  157222. origin: DOMPointReadOnly;
  157223. direction: DOMPointReadOnly;
  157224. matrix: Float32Array;
  157225. }
  157226. declare enum XRHitTestTrackableType {
  157227. "point",
  157228. "plane",
  157229. "mesh",
  157230. }
  157231. interface XRHitResult {
  157232. hitMatrix: Float32Array;
  157233. }
  157234. interface XRTransientInputHitTestResult {
  157235. readonly inputSource: XRInputSource;
  157236. readonly results: Array<XRHitTestResult>;
  157237. }
  157238. interface XRHitTestResult {
  157239. getPose(baseSpace: XRSpace): XRPose | undefined;
  157240. // When anchor system is enabled
  157241. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  157242. }
  157243. interface XRHitTestSource {
  157244. cancel(): void;
  157245. }
  157246. interface XRTransientInputHitTestSource {
  157247. cancel(): void;
  157248. }
  157249. interface XRHitTestOptionsInit {
  157250. space: XRSpace;
  157251. entityTypes?: Array<XRHitTestTrackableType>;
  157252. offsetRay?: XRRay;
  157253. }
  157254. interface XRTransientInputHitTestOptionsInit {
  157255. profile: string;
  157256. entityTypes?: Array<XRHitTestTrackableType>;
  157257. offsetRay?: XRRay;
  157258. }
  157259. interface XRAnchor {
  157260. anchorSpace: XRSpace;
  157261. delete(): void;
  157262. }
  157263. interface XRPlane {
  157264. orientation: "Horizontal" | "Vertical";
  157265. planeSpace: XRSpace;
  157266. polygon: Array<DOMPointReadOnly>;
  157267. lastChangedTime: number;
  157268. }
  157269. interface XRJointSpace extends XRSpace {}
  157270. interface XRJointPose extends XRPose {
  157271. radius: number | undefined;
  157272. }
  157273. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  157274. readonly length: number;
  157275. [index: number]: XRJointSpace;
  157276. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  157277. readonly WRIST: number;
  157278. readonly THUMB_METACARPAL: number;
  157279. readonly THUMB_PHALANX_PROXIMAL: number;
  157280. readonly THUMB_PHALANX_DISTAL: number;
  157281. readonly THUMB_PHALANX_TIP: number;
  157282. readonly INDEX_METACARPAL: number;
  157283. readonly INDEX_PHALANX_PROXIMAL: number;
  157284. readonly INDEX_PHALANX_INTERMEDIATE: number;
  157285. readonly INDEX_PHALANX_DISTAL: number;
  157286. readonly INDEX_PHALANX_TIP: number;
  157287. readonly MIDDLE_METACARPAL: number;
  157288. readonly MIDDLE_PHALANX_PROXIMAL: number;
  157289. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  157290. readonly MIDDLE_PHALANX_DISTAL: number;
  157291. readonly MIDDLE_PHALANX_TIP: number;
  157292. readonly RING_METACARPAL: number;
  157293. readonly RING_PHALANX_PROXIMAL: number;
  157294. readonly RING_PHALANX_INTERMEDIATE: number;
  157295. readonly RING_PHALANX_DISTAL: number;
  157296. readonly RING_PHALANX_TIP: number;
  157297. readonly LITTLE_METACARPAL: number;
  157298. readonly LITTLE_PHALANX_PROXIMAL: number;
  157299. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  157300. readonly LITTLE_PHALANX_DISTAL: number;
  157301. readonly LITTLE_PHALANX_TIP: number;
  157302. }
  157303. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  157304. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  157305. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  157306. interface XRSession {
  157307. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  157308. }
  157309. interface XRFrame {
  157310. featurePointCloud? : Array<number>;
  157311. }